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