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

#include <G4TrajectoryEncounteredVolumeFilter.hh>

+ Inheritance diagram for G4TrajectoryEncounteredVolumeFilter:

Public Member Functions

 G4TrajectoryEncounteredVolumeFilter (const G4String &name="Unspecified")
 
virtual ~G4TrajectoryEncounteredVolumeFilter ()
 
virtual bool Evaluate (const G4VTrajectory &) const
 
virtual void Print (std::ostream &ostr) const
 
virtual void Clear ()
 
void Add (const G4String &volume)
 
- 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 G4TrajectoryEncounteredVolumeFilter.hh.

Constructor & Destructor Documentation

◆ G4TrajectoryEncounteredVolumeFilter()

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

◆ ~G4TrajectoryEncounteredVolumeFilter()

G4TrajectoryEncounteredVolumeFilter::~G4TrajectoryEncounteredVolumeFilter ( )
virtual

Definition at line 42 of file G4TrajectoryEncounteredVolumeFilter.cc.

42{}

Member Function Documentation

◆ Add()

void G4TrajectoryEncounteredVolumeFilter::Add ( const G4String volume)

Definition at line 82 of file G4TrajectoryEncounteredVolumeFilter.cc.

83{
84 fVolumes.push_back(volume);
85}

◆ Clear()

void G4TrajectoryEncounteredVolumeFilter::Clear ( )
virtual

Implements G4SmartFilter< G4VTrajectory >.

Definition at line 100 of file G4TrajectoryEncounteredVolumeFilter.cc.

101{
102 // Clear volume vector
103 fVolumes.clear();
104}

◆ Evaluate()

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

Implements G4SmartFilter< G4VTrajectory >.

Definition at line 45 of file G4TrajectoryEncounteredVolumeFilter.cc.

46{
47 try
48 {
49 const G4RichTrajectory& richTrajectory = dynamic_cast<const G4RichTrajectory&>(traj);
50
51 for (const auto& pvname: fVolumes) {
52 for (G4int iPoint = 0; iPoint < richTrajectory.GetPointEntries(); iPoint++) {
53 G4VTrajectoryPoint* point = richTrajectory.GetPoint(iPoint);
54 if (!point) continue;
55 std::vector<G4AttValue>* attValues = point->CreateAttValues();
56 std::vector<G4AttValue>::const_iterator iAtt;
57 for (iAtt = attValues->begin(); iAtt != attValues->end(); ++iAtt) {
58 if (iAtt->GetName() == "PostVPath" &&
59 iAtt->GetValue().contains(pvname)) break;
60 }
61 if (iAtt != attValues->end()) { // Required value found
62 return true; // First found pvname determines selection.
63 }
64 }
65 }
66 return false;
67 }
68
69 catch (const std::bad_cast&)
70 {
72 ed << "Requires G4RichTrajectory - \"/vis/scene/add/trajectories rich\"";
74 ("G4TrajectoryEncounteredVolumeFilter::Evaluate(const G4VTrajectory& traj)",
75 "modeling0126",
76 JustWarning, ed);
77 return false;
78 }
79}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
int G4int
Definition: G4Types.hh:85
G4VTrajectoryPoint * GetPoint(G4int i) const
G4int GetPointEntries() const
virtual std::vector< G4AttValue > * CreateAttValues() const

◆ Print()

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

Implements G4SmartFilter< G4VTrajectory >.

Definition at line 88 of file G4TrajectoryEncounteredVolumeFilter.cc.

89{
90 ostr<<"Volume names registered: "<<G4endl;
91 std::vector<G4String>::const_iterator iter = fVolumes.begin();
92
93 while (iter != fVolumes.end()) {
94 ostr<<*iter<<G4endl;
95 iter++;
96 }
97}
#define G4endl
Definition: G4ios.hh:57

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