Geant4-11
Public Types | Public Member Functions | Private Attributes
G4SmartFilter< T > Class Template Referenceabstract

#include <G4SmartFilter.hh>

Inheritance diagram for G4SmartFilter< T >:
G4VFilter< T > G4AttributeFilterT< T >

Public Types

typedef T Type
 

Public Member Functions

G4bool Accept (const T &) const
 
virtual void Clear ()=0
 
virtual G4bool Evaluate (const T &) const =0
 
 G4SmartFilter (const G4String &name)
 
G4bool GetActive () const
 
G4bool GetInvert () const
 
G4String GetName () const
 
G4bool GetVerbose () const
 
G4String Name () const
 
virtual void Print (std::ostream &ostr) const =0
 
virtual void PrintAll (std::ostream &ostr) const
 
virtual void Reset ()
 
void SetActive (const G4bool &)
 
void SetInvert (const G4bool &)
 
void SetVerbose (const G4bool &)
 
virtual ~G4SmartFilter ()
 

Private Attributes

G4bool fActive
 
G4bool fInvert
 
G4String fName
 
size_t fNPassed
 
size_t fNProcessed
 
G4bool fVerbose
 

Detailed Description

template<typename T>
class G4SmartFilter< T >

Definition at line 38 of file G4SmartFilter.hh.

Member Typedef Documentation

◆ Type

template<typename T >
typedef T G4VFilter< T >::Type
inherited

Definition at line 43 of file G4VFilter.hh.

Constructor & Destructor Documentation

◆ G4SmartFilter()

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

Definition at line 90 of file G4SmartFilter.hh.

92 ,fActive(true)
93 ,fInvert(false)
94 ,fVerbose(false)
95 ,fNPassed(0)
96 ,fNProcessed(0)
97{}
size_t fNProcessed
const char * name(G4int ptype)

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

References G4cout, G4endl, and G4VFilter< T >::Name().

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

◆ GetName()

template<typename T >
G4String G4VFilter< T >::GetName
inherited

Definition at line 87 of file G4VFilter.hh.

88{
89 return Name();
90}

◆ GetVerbose()

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

Definition at line 200 of file G4SmartFilter.hh.

201{
202 return fVerbose;
203}

◆ Name()

template<typename T >
G4String G4VFilter< T >::Name
inherited

Definition at line 80 of file G4VFilter.hh.

81{
82 return fName;
83}
G4String fName
Definition: G4VFilter.hh:66

Referenced by G4SmartFilter< T >::Accept(), G4AttributeFilterT< T >::Print(), and G4SmartFilter< T >::PrintAll().

◆ 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

References G4endl, G4VFilter< T >::Name(), and pyG4Element::Print().

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

Field Documentation

◆ fActive

template<typename T >
G4bool G4SmartFilter< T >::fActive
private

Definition at line 81 of file G4SmartFilter.hh.

◆ fInvert

template<typename T >
G4bool G4SmartFilter< T >::fInvert
private

Definition at line 82 of file G4SmartFilter.hh.

◆ fName

template<typename T >
G4String G4VFilter< T >::fName
privateinherited

Definition at line 66 of file G4VFilter.hh.

◆ fNPassed

template<typename T >
size_t G4SmartFilter< T >::fNPassed
mutableprivate

Definition at line 84 of file G4SmartFilter.hh.

◆ fNProcessed

template<typename T >
size_t G4SmartFilter< T >::fNProcessed
mutableprivate

Definition at line 85 of file G4SmartFilter.hh.

◆ fVerbose

template<typename T >
G4bool G4SmartFilter< T >::fVerbose
private

Definition at line 83 of file G4SmartFilter.hh.


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