Geant4 9.6.0
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 39 of file G4SmartFilter.hh.

Constructor & Destructor Documentation

◆ G4SmartFilter()

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

Definition at line 91 of file G4SmartFilter.hh.

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

◆ ~G4SmartFilter()

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

Definition at line 101 of file G4SmartFilter.hh.

101{}

Member Function Documentation

◆ Accept()

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

Implements G4VFilter< T >.

Definition at line 105 of file G4SmartFilter.hh.

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

◆ Clear()

template<typename T >
virtual void G4SmartFilter< T >::Clear ( )
pure virtual

◆ 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 173 of file G4SmartFilter.hh.

174{
175 return fActive;
176}

◆ GetInvert()

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

Definition at line 187 of file G4SmartFilter.hh.

188{
189 return fInvert;
190}

◆ GetVerbose()

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

Definition at line 201 of file G4SmartFilter.hh.

202{
203 return fVerbose;
204}

◆ 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 139 of file G4SmartFilter.hh.

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

◆ Reset()

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

Implements G4VFilter< T >.

Definition at line 153 of file G4SmartFilter.hh.

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

◆ SetActive()

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

Definition at line 166 of file G4SmartFilter.hh.

167{
168 fActive = active;
169}

◆ SetInvert()

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

Definition at line 180 of file G4SmartFilter.hh.

181{
182 fInvert = invert;
183}

◆ SetVerbose()

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

Definition at line 194 of file G4SmartFilter.hh.

195{
196 fVerbose = verbose;
197}

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