FairRoot/PandaRoot
PndEvtFilter.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndEvtFilter source file -----
3 // -------------------------------------------------------------------------
4 
5 
6 #include "PndEvtFilter.h"
7 
8 
9 // ----- Default constructor -------------------------------------------
11 }
12 // -------------------------------------------------------------------------
13 
14 
15 
16 // ----- Constructor with name and title -------------------------------
17 PndEvtFilter::PndEvtFilter(const char* name, const char* title)
18 : FairEvtFilter(name, title){
19 }
20 // -------------------------------------------------------------------------
21 
22 
23 
24 // ----- Destructor ----------------------------------------------------
26 // -------------------------------------------------------------------------
27 
28 
29 
30 
31 Bool_t PndEvtFilter::FillList ( RhoCandList& rhoOutList, Int_t inPdgCode, Double_t pdgCodeCharge )
32 {
33  rhoOutList.Cleanup();
34 
35 
36  // Get charge corresponding to pdgCode if it has not been passed as an argument by the user
37  if ( kNoChargeSpecified == pdgCodeCharge ){
38  if ( kFALSE == GetCharge( inPdgCode, &pdgCodeCharge ) ) {
39  return kFALSE;
40  }
41  }
42 
43 
44 
45  // find all TParticle on stack with a charge(particle) == charge(pdgCode)
46  for (Int_t iPart=0; iPart<fParticleList->GetEntries(); ++iPart) {
47  TParticle *particle = (TParticle*)fParticleList->At(iPart);
48 
49  // get charge for particle
50  TParticlePDG* pdt = particle->GetPDG();
51  if (0==pdt) continue; // unknown particle type (KG, 10/2015)
52 
53  Double_t pCharge = pdt->Charge()/3.; // TParticlePDG contains charge in units of |e|/3
54 
55  if ( pdgCodeCharge != pCharge ){ continue; } // skip all particles with different charge
56 
57 
58  // // mark stable particles
59  // Bool_t isStable = kFALSE;
60  // switch(abs(particle->GetPdgCode())) {
61  // case 22: isStable = true; break;
62  // case 11: isStable = true; break;
63  // case 13: isStable = true; break;
64  // case 211: isStable = true; break;
65  // case 321: isStable = true; break;
66  // case 2212: isStable = true; break;
67  // }
68  //
69  // if (kFALSE == isStable) { continue; } // skip all particles which are not considered stable
70 
71 
72  // store TParticle as RhoCandidate in output TCA and modify 4 momentum to match particle hypothesis
73  TVector3 pVertex(particle->Vx(),particle->Vy(),particle->Vz());
74  TLorentzVector p4(particle->Px(),particle->Py(),particle->Pz(),particle->Energy());
75  // assign mass hypothesis according to pdgCode
76  p4.SetVectM(p4.Vect(),fdbPdg->GetParticle(inPdgCode)->Mass());
77  // construct RhoCandidate
78  RhoCandidate rhoCand(p4,pCharge);
79  rhoCand.SetMcTruth(&rhoCand);
80  rhoCand.SetPos(pVertex);
81  rhoCand.SetType(inPdgCode);
82  // save to output
83  rhoOutList.Add(&rhoCand);
84  }//trackloop
85 
86 
87  return kTRUE;
88 }
89 
void Add(const RhoCandidate *c)
Definition: RhoCandList.h:49
void Cleanup()
Definition: RhoCandList.cxx:62
void SetPos(const TVector3 &pos)
Definition: RhoCandidate.h:235
Bool_t FillList(RhoCandList &rhoOutList, Int_t inPdgCode, Double_t pdgCodeCharge=kNoChargeSpecified)
Bool_t GetCharge(Int_t inPdgCode, Double_t *pdgCodeCharge)
const int particle
void SetType(const TParticlePDG *pdt)
Double_t
TClonesArray * fParticleList
static const Double_t kNoChargeSpecified
TString name
void SetMcTruth(RhoCandidate *mct)
Definition: RhoCandidate.h:436
ClassImp(PndAnaContFact)
virtual ~PndEvtFilter()
TDatabasePDG * fdbPdg