Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TrajectoryChargeFilter Class Reference

#include <G4TrajectoryChargeFilter.hh>

+ Inheritance diagram for G4TrajectoryChargeFilter:

Public Member Functions

 G4TrajectoryChargeFilter (const G4String &name="Unspecified")
 
virtual ~G4TrajectoryChargeFilter ()
 
virtual bool Evaluate (const G4VTrajectory &) const
 
virtual void Print (std::ostream &ostr) const
 
virtual void Clear ()
 
void Add (const G4String &particle)
 
- Public Member Functions inherited from G4SmartFilter< G4VTrajectory >
 G4SmartFilter (const G4String &name)
 
virtual ~G4SmartFilter ()
 
virtual G4bool Evaluate (const G4VTrajectory &) const=0
 
virtual void Print (std::ostream &ostr) const=0
 
virtual void Clear ()=0
 
G4bool Accept (const G4VTrajectory &) const
 
virtual void PrintAll (std::ostream &ostr) const
 
virtual void Reset ()
 
void SetActive (const G4bool &)
 
G4bool GetActive () const
 
void SetInvert (const G4bool &)
 
G4bool GetInvert () const
 
void SetVerbose (const G4bool &)
 
G4bool GetVerbose () const
 
- Public Member Functions inherited from G4VFilter< T >
 G4VFilter (const G4String &name)
 
virtual ~G4VFilter ()
 
virtual G4bool Accept (const T &) const =0
 
virtual void PrintAll (std::ostream &ostr) const =0
 
virtual void Reset ()=0
 
G4String Name () const
 
G4String GetName () const
 

Additional Inherited Members

- Public Types inherited from G4VFilter< T >
typedef T Type
 

Detailed Description

Definition at line 39 of file G4TrajectoryChargeFilter.hh.

Constructor & Destructor Documentation

◆ G4TrajectoryChargeFilter()

G4TrajectoryChargeFilter::G4TrajectoryChargeFilter ( const G4String name = "Unspecified")

Definition at line 35 of file G4TrajectoryChargeFilter.cc.

◆ ~G4TrajectoryChargeFilter()

G4TrajectoryChargeFilter::~G4TrajectoryChargeFilter ( )
virtual

Definition at line 39 of file G4TrajectoryChargeFilter.cc.

39{}

Member Function Documentation

◆ Add()

void G4TrajectoryChargeFilter::Add ( const G4String particle)

Definition at line 63 of file G4TrajectoryChargeFilter.cc.

64{
65 MyCharge myCharge;
66
67 if (!ConvertToCharge(charge, myCharge)) {
69 ed << "Invalid charge "<<charge;
71 ("G4TrajectoryChargeFilter::Add(const G4String& charge)",
72 "modeling0115", JustWarning, ed);
73 return;
74 }
75
76 return Add(myCharge);
77}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
void Add(const G4String &particle)

Referenced by Add().

◆ Clear()

void G4TrajectoryChargeFilter::Clear ( )
virtual

Implements G4SmartFilter< G4VTrajectory >.

Definition at line 98 of file G4TrajectoryChargeFilter.cc.

99{
100 // Clear registered charge vector
101 fCharges.clear();
102}

◆ Evaluate()

bool G4TrajectoryChargeFilter::Evaluate ( const G4VTrajectory traj) const
virtual

Implements G4SmartFilter< G4VTrajectory >.

Definition at line 42 of file G4TrajectoryChargeFilter.cc.

43{
44 G4double charge = traj.GetCharge();
45
46 if (GetVerbose()) G4cout<<"G4TrajectoryChargeFilter processing trajectory with charge: "<<charge<<G4endl;
47
48 MyCharge myCharge;
49
50 if(charge>0.) myCharge = Positive;
51 else if(charge<0.) myCharge = Negative;
52 else myCharge = Neutral;
53
54 std::vector<MyCharge>::const_iterator iter = std::find(fCharges.begin(), fCharges.end(), myCharge);
55
56 // Fail if charge not registered
57 if (iter == fCharges.end()) return false;
58
59 return true;
60}
double G4double
Definition: G4Types.hh:83
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
virtual G4double GetCharge() const =0

◆ Print()

void G4TrajectoryChargeFilter::Print ( std::ostream &  ostr) const
virtual

Implements G4SmartFilter< G4VTrajectory >.

Definition at line 86 of file G4TrajectoryChargeFilter.cc.

87{
88 ostr<<"Charges registered: "<<G4endl;
89 std::vector<MyCharge>::const_iterator iter = fCharges.begin();
90
91 while (iter != fCharges.end()) {
92 ostr<<*iter<<G4endl;
93 iter++;
94 }
95}

The documentation for this class was generated from the following files: