Geant4 9.6.0
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 40 of file G4TrajectoryChargeFilter.hh.

Constructor & Destructor Documentation

◆ G4TrajectoryChargeFilter()

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

Definition at line 36 of file G4TrajectoryChargeFilter.cc.

◆ ~G4TrajectoryChargeFilter()

G4TrajectoryChargeFilter::~G4TrajectoryChargeFilter ( )
virtual

Definition at line 40 of file G4TrajectoryChargeFilter.cc.

40{}

Member Function Documentation

◆ Add()

void G4TrajectoryChargeFilter::Add ( const G4String particle)

Definition at line 64 of file G4TrajectoryChargeFilter.cc.

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

Referenced by Add().

◆ Clear()

void G4TrajectoryChargeFilter::Clear ( )
virtual

Implements G4SmartFilter< G4VTrajectory >.

Definition at line 99 of file G4TrajectoryChargeFilter.cc.

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

◆ Evaluate()

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

Implements G4SmartFilter< G4VTrajectory >.

Definition at line 43 of file G4TrajectoryChargeFilter.cc.

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

◆ Print()

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

Implements G4SmartFilter< G4VTrajectory >.

Definition at line 87 of file G4TrajectoryChargeFilter.cc.

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

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