G4SmartFilter< T > Class Template Reference

#include <G4SmartFilter.hh>

Inheritance diagram for G4SmartFilter< T >:

G4VFilter< T > G4AttributeFilterT< 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

Detailed Description

template<typename T>
class G4SmartFilter< T >

Definition at line 39 of file G4SmartFilter.hh.


Constructor & Destructor Documentation

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

Definition at line 91 of file G4SmartFilter.hh.

00092   :G4VFilter<T>(name)
00093   ,fActive(true)
00094   ,fInvert(false)
00095   ,fVerbose(false)
00096   ,fNPassed(0)
00097   ,fNProcessed(0)
00098 {}

template<typename T>
G4SmartFilter< T >::~G4SmartFilter (  )  [virtual]

Definition at line 101 of file G4SmartFilter.hh.

00101 {}


Member Function Documentation

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

Implements G4VFilter< T >.

Definition at line 105 of file G4SmartFilter.hh.

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

00106 {
00107   if (fVerbose) {
00108     G4cout<<"Begin verbose printout for filter "<<G4VFilter<T>::Name()<<G4endl;
00109     G4cout<<"Active ? :   "<<fActive<<G4endl;
00110   }
00111   
00112   fNProcessed++;
00113   
00114   // Pass everything if filter is not active
00115   if (!fActive) {
00116     fNPassed++;
00117     return true;
00118   }
00119   
00120   // Do filtering
00121   G4bool passed = Evaluate(object);
00122   
00123   // Apply inversion if applicable
00124   if (fInvert) passed = !passed;
00125   
00126   if (passed) fNPassed++;
00127   
00128   if (fVerbose) {
00129     G4cout<<"Inverted ? : "<<fInvert<<G4endl;
00130     G4cout<<"Passed ?   : "<<passed<<G4endl;
00131     G4cout<<"End verbose printout for filter "<<G4VFilter<T>::Name()<<G4endl;
00132   }
00133   
00134   return passed;
00135 }

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

Implemented in G4AttributeFilterT< T >, G4TrajectoryChargeFilter, G4TrajectoryOriginVolumeFilter, and G4TrajectoryParticleFilter.

Referenced by G4SmartFilter< T >::Reset().

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

Implemented in G4AttributeFilterT< T >, G4TrajectoryChargeFilter, G4TrajectoryOriginVolumeFilter, and G4TrajectoryParticleFilter.

Referenced by G4SmartFilter< T >::Accept().

template<typename T>
G4bool G4SmartFilter< T >::GetActive (  )  const

Definition at line 173 of file G4SmartFilter.hh.

00174 {
00175   return fActive;
00176 }

template<typename T>
G4bool G4SmartFilter< T >::GetInvert (  )  const

Definition at line 187 of file G4SmartFilter.hh.

00188 {
00189   return fInvert;
00190 }

template<typename T>
G4bool G4SmartFilter< T >::GetVerbose (  )  const

Definition at line 201 of file G4SmartFilter.hh.

00202 {
00203   return fVerbose;
00204 }

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

Implemented in G4AttributeFilterT< T >, G4TrajectoryChargeFilter, G4TrajectoryOriginVolumeFilter, and G4TrajectoryParticleFilter.

Referenced by G4SmartFilter< T >::PrintAll().

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

Implements G4VFilter< T >.

Definition at line 139 of file G4SmartFilter.hh.

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

00140 {
00141   ostr<<"Printing data for filter: "<<G4VFilter<T>::Name()<<G4endl;
00142 
00143   Print(ostr);
00144 
00145   ostr<<"Active ?   : " <<fActive<<G4endl;
00146   ostr<<"Inverted ? : " <<fInvert<<G4endl;
00147   ostr<<"#Processed : " <<fNProcessed<<G4endl;
00148   ostr<<"#Passed    : " <<fNPassed<<G4endl;
00149 }

template<typename T>
void G4SmartFilter< T >::Reset (  )  [virtual]

Implements G4VFilter< T >.

Definition at line 153 of file G4SmartFilter.hh.

References G4SmartFilter< T >::Clear().

00154 {
00155   fActive = true;
00156   fInvert = false;
00157   fNProcessed = 0;
00158   fNPassed = 0;
00159   
00160   // Clear subclass data
00161   Clear();
00162 }

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

Definition at line 166 of file G4SmartFilter.hh.

00167 {
00168   fActive = active;
00169 }

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

Definition at line 180 of file G4SmartFilter.hh.

00181 {
00182   fInvert = invert;
00183 }

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

Definition at line 194 of file G4SmartFilter.hh.

00195 {
00196   fVerbose = verbose;
00197 }


The documentation for this class was generated from the following file:
Generated on Mon May 27 17:53:23 2013 for Geant4 by  doxygen 1.4.7