Geant4-11
Public Types | Public Member Functions | Private Attributes
G4TrajectoryEncounteredVolumeFilter Class Reference

#include <G4TrajectoryEncounteredVolumeFilter.hh>

Inheritance diagram for G4TrajectoryEncounteredVolumeFilter:
G4SmartFilter< G4VTrajectory > G4VFilter< G4VTrajectory >

Public Types

typedef G4VTrajectory Type
 

Public Member Functions

G4bool Accept (const G4VTrajectory &) const
 
void Add (const G4String &volume)
 
virtual void Clear ()
 
virtual bool Evaluate (const G4VTrajectory &) const
 
 G4TrajectoryEncounteredVolumeFilter (const G4String &name="Unspecified")
 
G4bool GetActive () const
 
G4bool GetInvert () const
 
G4String GetName () const
 
G4bool GetVerbose () const
 
G4String Name () const
 
virtual void Print (std::ostream &ostr) const
 
virtual void PrintAll (std::ostream &ostr) const
 
virtual void Reset ()
 
void SetActive (const G4bool &)
 
void SetInvert (const G4bool &)
 
void SetVerbose (const G4bool &)
 
virtual ~G4TrajectoryEncounteredVolumeFilter ()
 

Private Attributes

G4bool fActive
 
G4bool fInvert
 
G4String fName
 
size_t fNPassed
 
size_t fNProcessed
 
G4bool fVerbose
 
std::vector< G4StringfVolumes
 

Detailed Description

Definition at line 39 of file G4TrajectoryEncounteredVolumeFilter.hh.

Member Typedef Documentation

◆ Type

Definition at line 43 of file G4VFilter.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

◆ Accept()

G4bool G4SmartFilter< G4VTrajectory >::Accept ( const G4VTrajectory object) const
virtualinherited

Implements G4VFilter< G4VTrajectory >.

Definition at line 57 of file G4SmartFilter.hh.

105{
106 if (fVerbose) {
107 G4cout<<"Begin verbose printout for filter "<<G4VFilter<T>::Name()<<G4endl;
108 G4cout<<"Active ? : "<<fActive<<G4endl;
109 }
110
111 fNProcessed++;
112
113 // Pass everything if filter is not active
114 if (!fActive) {
115 fNPassed++;
116 return true;
117 }
118
119 // Do filtering
120 G4bool passed = Evaluate(object);
121
122 // Apply inversion if applicable
123 if (fInvert) passed = !passed;
124
125 if (passed) fNPassed++;
126
127 if (fVerbose) {
128 G4cout<<"Inverted ? : "<<fInvert<<G4endl;
129 G4cout<<"Passed ? : "<<passed<<G4endl;
130 G4cout<<"End verbose printout for filter "<<G4VFilter<T>::Name()<<G4endl;
131 }
132
133 return passed;
134}
bool G4bool
Definition: G4Types.hh:86
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
virtual G4bool Evaluate(const G4VTrajectory &) const=0
G4String Name() const
Definition: G4VFilter.hh:80

◆ Add()

void G4TrajectoryEncounteredVolumeFilter::Add ( const G4String volume)

Definition at line 82 of file G4TrajectoryEncounteredVolumeFilter.cc.

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

References fVolumes.

◆ 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}

References fVolumes.

◆ 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 G4StrUtil::contains(iAtt->GetValue(),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
G4bool contains(const G4String &str, std::string_view ss)
Check if a string contains a given substring.

References G4StrUtil::contains(), G4VTrajectoryPoint::CreateAttValues(), fVolumes, G4Exception(), G4RichTrajectory::GetPoint(), G4RichTrajectory::GetPointEntries(), and JustWarning.

◆ GetActive()

G4bool G4SmartFilter< G4VTrajectory >::GetActive
inherited

Definition at line 67 of file G4SmartFilter.hh.

173{
174 return fActive;
175}

◆ GetInvert()

G4bool G4SmartFilter< G4VTrajectory >::GetInvert
inherited

Definition at line 71 of file G4SmartFilter.hh.

187{
188 return fInvert;
189}

◆ GetName()

G4String G4VFilter< G4VTrajectory >::GetName
inherited

Definition at line 61 of file G4VFilter.hh.

88{
89 return Name();
90}

◆ GetVerbose()

G4bool G4SmartFilter< G4VTrajectory >::GetVerbose
inherited

Definition at line 75 of file G4SmartFilter.hh.

201{
202 return fVerbose;
203}

◆ Name()

G4String G4VFilter< G4VTrajectory >::Name
inherited

Definition at line 60 of file G4VFilter.hh.

81{
82 return fName;
83}

◆ 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}

References fVolumes, and G4endl.

◆ PrintAll()

void G4SmartFilter< G4VTrajectory >::PrintAll ( std::ostream &  ostr) const
virtualinherited

Implements G4VFilter< G4VTrajectory >.

Definition at line 60 of file G4SmartFilter.hh.

139{
140 ostr<<"Printing data for filter: "<<G4VFilter<T>::Name()<<G4endl;
141
142 Print(ostr);
143
144 ostr<<"Active ? : " <<fActive<<G4endl;
145 ostr<<"Inverted ? : " <<fInvert<<G4endl;
146 ostr<<"#Processed : " <<fNProcessed<<G4endl;
147 ostr<<"#Passed : " <<fNPassed<<G4endl;
148}
virtual void Print(std::ostream &ostr) const=0

◆ Reset()

void G4SmartFilter< G4VTrajectory >::Reset
virtualinherited

Implements G4VFilter< G4VTrajectory >.

Definition at line 63 of file G4SmartFilter.hh.

153{
154 fActive = true;
155 fInvert = false;
156 fNProcessed = 0;
157 fNPassed = 0;
158
159 // Clear subclass data
160 Clear();
161}

◆ SetActive()

void G4SmartFilter< G4VTrajectory >::SetActive ( const G4bool active)
inherited

Definition at line 66 of file G4SmartFilter.hh.

166{
167 fActive = active;
168}

◆ SetInvert()

void G4SmartFilter< G4VTrajectory >::SetInvert ( const G4bool invert)
inherited

Definition at line 70 of file G4SmartFilter.hh.

180{
181 fInvert = invert;
182}

◆ SetVerbose()

void G4SmartFilter< G4VTrajectory >::SetVerbose ( const G4bool verbose)
inherited

Definition at line 74 of file G4SmartFilter.hh.

194{
195 fVerbose = verbose;
196}

Field Documentation

◆ fActive

G4bool G4SmartFilter< G4VTrajectory >::fActive
privateinherited

Definition at line 81 of file G4SmartFilter.hh.

◆ fInvert

G4bool G4SmartFilter< G4VTrajectory >::fInvert
privateinherited

Definition at line 82 of file G4SmartFilter.hh.

◆ fName

G4String G4VFilter< G4VTrajectory >::fName
privateinherited

Definition at line 66 of file G4VFilter.hh.

◆ fNPassed

size_t G4SmartFilter< G4VTrajectory >::fNPassed
mutableprivateinherited

Definition at line 84 of file G4SmartFilter.hh.

◆ fNProcessed

size_t G4SmartFilter< G4VTrajectory >::fNProcessed
mutableprivateinherited

Definition at line 85 of file G4SmartFilter.hh.

◆ fVerbose

G4bool G4SmartFilter< G4VTrajectory >::fVerbose
privateinherited

Definition at line 83 of file G4SmartFilter.hh.

◆ fVolumes

std::vector<G4String> G4TrajectoryEncounteredVolumeFilter::fVolumes
private

Definition at line 63 of file G4TrajectoryEncounteredVolumeFilter.hh.

Referenced by Add(), Clear(), Evaluate(), and Print().


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