Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4SmartFilter< T > Class Template Referenceabstract

#include <G4SmartFilter.hh>

+ Inheritance diagram for G4SmartFilter< T >:

Public Member Functions

 G4SmartFilter (const G4String &name)
 
virtual ~G4SmartFilter ()
 
virtual G4bool Evaluate (const T &) const =0
 
virtual void Print (std::ostream &ostr) const =0
 
virtual void Clear ()=0
 
G4bool Accept (const T &) 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

template<typename T>
class G4SmartFilter< T >

Definition at line 38 of file G4SmartFilter.hh.

Constructor & Destructor Documentation

◆ G4SmartFilter()

template<typename T >
G4SmartFilter< T >::G4SmartFilter ( const G4String name)

Definition at line 90 of file G4SmartFilter.hh.

91 :G4VFilter<T>(name)
92 ,fActive(true)
93 ,fInvert(false)
94 ,fVerbose(false)
95 ,fNPassed(0)
96 ,fNProcessed(0)
97{}

◆ ~G4SmartFilter()

template<typename T >
G4SmartFilter< T >::~G4SmartFilter
virtual

Definition at line 100 of file G4SmartFilter.hh.

100{}

Member Function Documentation

◆ Accept()

template<typename T >
G4bool G4SmartFilter< T >::Accept ( const T &  object) const
virtual

Implements G4VFilter< T >.

Definition at line 104 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 T &) const =0
G4String Name() const
Definition: G4VFilter.hh:80

◆ Clear()

◆ Evaluate()

template<typename T >
virtual G4bool G4SmartFilter< T >::Evaluate ( const T &  ) const
pure virtual

◆ GetActive()

template<typename T >
G4bool G4SmartFilter< T >::GetActive

Definition at line 172 of file G4SmartFilter.hh.

173{
174 return fActive;
175}

◆ GetInvert()

template<typename T >
G4bool G4SmartFilter< T >::GetInvert

Definition at line 186 of file G4SmartFilter.hh.

187{
188 return fInvert;
189}

◆ GetVerbose()

template<typename T >
G4bool G4SmartFilter< T >::GetVerbose

Definition at line 200 of file G4SmartFilter.hh.

201{
202 return fVerbose;
203}

◆ Print()

template<typename T >
virtual void G4SmartFilter< T >::Print ( std::ostream &  ostr) const
pure virtual

◆ PrintAll()

template<typename T >
void G4SmartFilter< T >::PrintAll ( std::ostream &  ostr) const
virtual

Implements G4VFilter< T >.

Definition at line 138 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()

template<typename T >
void G4SmartFilter< T >::Reset
virtual

Implements G4VFilter< T >.

Definition at line 152 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}
virtual void Clear()=0

◆ SetActive()

template<typename T >
void G4SmartFilter< T >::SetActive ( const G4bool active)

Definition at line 165 of file G4SmartFilter.hh.

166{
167 fActive = active;
168}

◆ SetInvert()

template<typename T >
void G4SmartFilter< T >::SetInvert ( const G4bool invert)

Definition at line 179 of file G4SmartFilter.hh.

180{
181 fInvert = invert;
182}

◆ SetVerbose()

template<typename T >
void G4SmartFilter< T >::SetVerbose ( const G4bool verbose)

Definition at line 193 of file G4SmartFilter.hh.

194{
195 fVerbose = verbose;
196}

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