FairRoot/PandaRoot
FairEvtFilter.h
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- FairEvtFilter header file -----
3 // -------------------------------------------------------------------------
4 
5 
18 #ifndef FAIREVTFILTER_H
19 #define FAIREVTFILTER_H
20 
21 #include "TNamed.h" // for TNamed
22 #include "Rtypes.h" // for Bool_t, etc
23 #include "TClonesArray.h"
24 #include "TParticle.h"
25 #include <iostream>
26 #include <set>
27 #include "TDatabasePDG.h"
28 
29 
30 std::ostream& operator <<(std::ostream& os, const std::set<Int_t> & set);
31 
32 
33 
34 class FairEvtFilter : public TNamed
35 {
36 
37 public:
38 
43 
45  FairEvtFilter();
46 
47 
49  FairEvtFilter(const char* name, const char* title="FairEvtFilter");
50 
51 
53  virtual ~FairEvtFilter();
54 
55 
56  //contains the list of particles that should be checked in the EventMatches method
57  Bool_t SetListOfParticles(TClonesArray* ParticleList){fParticleList=ParticleList; return kTRUE;};
58 
59  // prints all TParticle in event
61 
62 
63  //Initialize the filter if needed
64  Bool_t Init() { return kTRUE;}
65 
66 
67  void SetVerbose(Int_t verbose=12){
68  if ( verbose >= 0 ){
69  fVerbose = verbose;
70  std::cout << "FairEvtFilter: fVerbose is now set to " << verbose << "\n";
71  } else {
72  std::cout << "\n\n\n -WARNING from FairEvtFilter: verbose must be a positive number! Check your SetVerbose call!\n\n\n";
73  }
74  }
75 
76 
78  // for QA
79  // shows fAcceptedEventNumbers that is filled after running a simulation
80  std::cout << "\n fAcceptedEventNumbers" << " = " << fAcceptedEventNumbers;
81  }
82 
83 
85  // for QA
86  //shows fEvtNrsToAccept that has to be set if you want to run your simulation in test mode
87  std::cout << "\n fEvtNrsToAccept" << " = " << fEvtNrsToAccept;
88  }
89 
90 
91  void SetTestMode(Int_t* arrayPtr, Int_t nEntries){
92  //turns on the test mode with the declared fEvtNrsToAccept
93  fTestMode=kTRUE;
94  std::set<Int_t> evtNrsToAccept (arrayPtr,arrayPtr+nEntries);
95  fEvtNrsToAccept=evtNrsToAccept;
96  }
97 
98 
100  if(kFALSE==fTestMode){
101  std::cout << "\n\n\n WARNING from FairEvtFilter: Test mode not set.\n\n\n";
102  return kFALSE;
103  }
105  //std::cout << "\n\n\n FairEvtFilter: Test passed.\n\n\n";
106  return kTRUE;
107  }else{
108  //std::cout << "\n\n\n FairEvtFilter: Test failed. Check your SetTestMode calls. \n\n\n";
109  return kFALSE;
110  }
111  }
112 
113 
114  // returning kTRUE indicates that the event satisfies the filter conditions,
115  // kFALSE otherwise.
116  virtual Bool_t EventMatches(Int_t evtNr)=0;
117 
118  virtual Bool_t FilterActive()=0;
119 
120  // returns kTRUE if successful
121  // pdgCodeCharge will contain the charge of the particle with pdg code inPdgCode
122  Bool_t GetCharge ( Int_t inPdgCode, Double_t *pdgCodeCharge );
123 
124 
125 protected:
126  TDatabasePDG* fdbPdg;
127  // constant holding a double number which is not a valid charge
128  // this serves to indicate that the value has not been specified by the user
130 
131  TClonesArray* fParticleList; // list of particles in the event which was generated
132  Int_t fVerbose; // level of commenting output for your filter, between 0 and 12
133  Bool_t fTestMode; // is kTRUE if the filter should run in QA test mode
134  std::set<Int_t> fAcceptedEventNumbers; // set of event numbers which were accepted by the filter
135  std::set<Int_t> fEvtNrsToAccept; // event numbers that SHOULD be accepted by the filter (QA test mode)
136  Int_t fEventNr; // current event number
137 
138 private:
139  FairEvtFilter(const FairEvtFilter& G);
140  FairEvtFilter& operator= (const FairEvtFilter&) {return *this;}
141 
142 
143 
145 };
146 
147 #endif
148 
149 
void PrintAllTParticleInEvent()
Bool_t GetCharge(Int_t inPdgCode, Double_t *pdgCodeCharge)
#define verbose
FairEvtFilter & operator=(const FairEvtFilter &)
void SetVerbose(Int_t verbose=12)
Definition: FairEvtFilter.h:67
Bool_t Init()
Definition: FairEvtFilter.h:64
virtual Bool_t EventMatches(Int_t evtNr)=0
Double_t
std::set< Int_t > fAcceptedEventNumbers
virtual ~FairEvtFilter()
TClonesArray * fParticleList
void ShowEvtNrsToAccept()
Definition: FairEvtFilter.h:84
static const Double_t kNoChargeSpecified
TString name
void SetTestMode(Int_t *arrayPtr, Int_t nEntries)
Definition: FairEvtFilter.h:91
Bool_t TestPassed()
Definition: FairEvtFilter.h:99
std::set< Int_t > fEvtNrsToAccept
Bool_t SetListOfParticles(TClonesArray *ParticleList)
Definition: FairEvtFilter.h:57
virtual Bool_t FilterActive()=0
ClassDef(FairEvtFilter, 1)
void ShowAcceptedEventNumbers()
Definition: FairEvtFilter.h:77
TDatabasePDG * fdbPdg