FairRoot/PandaRoot
FairEvtFilter.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- FairEvtFilter source file -----
3 // -------------------------------------------------------------------------
4 
5 
6 #include "FairEvtFilter.h"
7 
9 
10 // ----- Default constructor -------------------------------------------
12 : TNamed(), fParticleList(NULL), fVerbose(0), fTestMode(0), fAcceptedEventNumbers(), fEvtNrsToAccept(), fEventNr(0)
13 {
14  fAcceptedEventNumbers.clear();
15  fdbPdg = TDatabasePDG::Instance();
16 }
17 // -------------------------------------------------------------------------
18 
19 
20 
21 // ----- Constructor with name and title -------------------------------
22 FairEvtFilter::FairEvtFilter(const char* name, const char* title)
23 : TNamed(name, title), fParticleList(NULL), fVerbose(0), fTestMode(0), fAcceptedEventNumbers(), fEvtNrsToAccept(), fEventNr(0)
24 {
25  fAcceptedEventNumbers.clear();
26  fParticleList = 0;
27  fdbPdg = TDatabasePDG::Instance();
28 }
29 // -------------------------------------------------------------------------
30 
31 
32 
33 // ----- Destructor ----------------------------------------------------
35 // -------------------------------------------------------------------------
36 
37 
38 std::ostream& operator <<(std::ostream& os, const std::set<Int_t> & set)
39 {
40  std::set<Int_t>::iterator iter;
41  os << "{";
42  for(iter=set.begin(); iter!=set.end(); ++iter){
43  os << *iter;
44  if(iter!=--set.end()){os << ",";}
45  }
46  os << "}\n";
47 
48  return os;
49 }
50 
51 
53  // sanity checks
54  if (0==fParticleList){ return; }
55  for (Int_t iPart=0; iPart<fParticleList->GetEntries(); ++iPart) {
56  TParticle *particle = (TParticle*)fParticleList->At(iPart);
57  particle->Print();
58  }
59 }
60 
61 
62 Bool_t FairEvtFilter::GetCharge ( Int_t inPdgCode, Double_t *pdgCodeCharge )
63 {
64  // Try to find the pdg code
65  TParticlePDG *ptrToPdg = fdbPdg->GetParticle(inPdgCode);
66  if ( 0 == ptrToPdg) {
67  // ignore particles with unknown charges
68  std::cout << "WARNING from FairEvtFilter::GetCharge Charge of pdgCode " << inPdgCode << " is unknown and will be ignored!\n";
69  *pdgCodeCharge = kNoChargeSpecified;
70  return kFALSE;
71  }
72  *pdgCodeCharge = ptrToPdg->Charge()/3.; // TParticlePDG contains charge in units of |e|/3
73  if ( fVerbose > 1 ) std::cout << "Found pdgCodeCharge = " << *pdgCodeCharge << " for inPdgCode " << inPdgCode << '\n';
74  return kTRUE;
75 }
76 
void PrintAllTParticleInEvent()
int fVerbose
Definition: poormantracks.C:24
Bool_t GetCharge(Int_t inPdgCode, Double_t *pdgCodeCharge)
const int particle
Double_t
std::set< Int_t > fAcceptedEventNumbers
virtual ~FairEvtFilter()
TClonesArray * fParticleList
static const Double_t kNoChargeSpecified
TString name
ClassImp(PndAnaContFact)
TDatabasePDG * fdbPdg