Geant4 11.3.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 ()
 
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< G4VTrajectory >
 G4VFilter (const G4String &name)
 
virtual ~G4VFilter ()
 
G4String Name () const
 
G4String GetName () const
 

Additional Inherited Members

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

Detailed Description

Definition at line 39 of file G4TrajectoryEncounteredVolumeFilter.hh.

Constructor & Destructor Documentation

◆ G4TrajectoryEncounteredVolumeFilter()

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

Definition at line 38 of file G4TrajectoryEncounteredVolumeFilter.cc.

40{}
G4SmartFilter(const G4String &name)

◆ ~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 85 of file G4TrajectoryEncounteredVolumeFilter.cc.

86{
87 fVolumes.push_back(volume);
88}

◆ Clear()

void G4TrajectoryEncounteredVolumeFilter::Clear ( )
virtual

Implements G4SmartFilter< G4VTrajectory >.

Definition at line 103 of file G4TrajectoryEncounteredVolumeFilter.cc.

104{
105 // Clear volume vector
106 fVolumes.clear();
107}

◆ Evaluate()

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

Implements G4SmartFilter< G4VTrajectory >.

Definition at line 45 of file G4TrajectoryEncounteredVolumeFilter.cc.

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

◆ Print()

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

Implements G4SmartFilter< G4VTrajectory >.

Definition at line 91 of file G4TrajectoryEncounteredVolumeFilter.cc.

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

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