ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/MCParticle.h
Revision: 1.5
Committed: Mon Oct 6 15:55:17 2008 UTC (16 years, 7 months ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_005
Changes since 1.4: +2 -1 lines
Log Message:
Adding SetPdgId option

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: MCParticle.h,v 1.4 2008/09/22 10:40:07 bendavid Exp $
3 //
4 // MCParticle
5 //
6 // Stores MC information for both gen and sim level
7 //
8 // Authors: C.Loizides, J.Bendavid...
9 //--------------------------------------------------------------------------------------------------
10
11 #ifndef MITANA_DATATREE_MCPARTICLE_H
12 #define MITANA_DATATREE_MCPARTICLE_H
13
14 #include <TRef.h>
15 #include <TDatabasePDG.h>
16 #include <TParticlePDG.h>
17 #include "MitAna/DataTree/interface/CompositeParticle.h"
18
19 namespace mithep
20 {
21 class MCParticle : public CompositeParticle
22 {
23 public:
24 MCParticle() : fIsGenerated(kFALSE), fIsSimulated(kFALSE) {}
25 MCParticle(Double_t px, Double_t py, Double_t pz, Double_t e, Int_t id, Int_t s) :
26 fPdgId(id), fStatus(s),
27 fFourVector(px,py,pz,e), fDecayVertex(0,0,0),
28 fIsGenerated(kFALSE), fIsSimulated(kFALSE) {}
29 ~MCParticle() {}
30
31 Int_t AbsPdgId() const { return (fPdgId<0 ? -fPdgId:fPdgId); }
32 void AddDaughter(MCParticle *p) { fDaughters.Add(p); }
33 Double_t Charge() const;
34 const ThreeVector &DecayVertex() const { return fDecayVertex; }
35 const MCParticle *Daughter(UInt_t i) const;
36 const MCParticle *DistinctMother() const;
37 Bool_t HasMother() const { return fMother.IsValid(); }
38 Bool_t IsGenerated() const { return fIsGenerated; }
39 Bool_t IsSimulated() const { return fIsSimulated; }
40 Bool_t IsNeutrino() const;
41 const MCParticle *Mother() const;
42 FourVector Mom() const { return fFourVector; }
43 void SetIsGenerated(Bool_t t=kTRUE) { fIsGenerated = t; }
44 void SetIsSimulated(Bool_t t=kTRUE) { fIsSimulated = t; }
45 TParticlePDG *PdgEntry() const;
46 Int_t PdgId() const { return fPdgId; }
47 void SetMom(Double_t px, Double_t py, Double_t pz, Double_t e);
48 void SetMother(MCParticle *p) { fMother = p; }
49 void SetStatus(Int_t s) { fStatus = s; }
50 void SetVertex(Double_t x, Double_t y, Double_t z);
51 void SetPdgId(Int_t s) { fPdgId = s; }
52 Int_t Status() const { return fStatus; }
53 void Print(Option_t *opt="") const;
54
55 enum EPartType {
56 kUnknown=0,
57 kEl=11, kMu=13, kTau=15,
58 kElNu=12, kMuNu=14, kTauNu=16,
59 kGlu=21, kGamma=22
60 };
61
62 protected:
63 Int_t fPdgId; //pdg identifier
64 Int_t fStatus; //status flag of generator or simulation
65 FourVector fFourVector; //four momentum vector
66 ThreeVector fDecayVertex; //gen decay vertex
67 TRef fMother; //reference to mother
68 Bool_t fIsGenerated; //=true if generated particle
69 Bool_t fIsSimulated; //=true if simulated particle
70
71 ClassDef(MCParticle,2) // Generated particle class
72 };
73 }
74
75 //--------------------------------------------------------------------------------------------------
76 inline const mithep::MCParticle *mithep::MCParticle::Daughter(UInt_t i) const
77 {
78 // Return daughter corresponding to given index.
79
80 return static_cast<const MCParticle*>(fDaughters.At(i));
81 }
82
83 //--------------------------------------------------------------------------------------------------
84 inline const mithep::MCParticle *mithep::MCParticle::DistinctMother() const
85 {
86 // Return mother, walking up the tree until a particle with a different pdg from this one
87 // is found.
88
89 const mithep::MCParticle *mother = Mother();
90
91 if (!mother) return 0;
92
93 while (mother->PdgId()==fPdgId)
94 mother = mother->Mother();
95
96 return mother;
97 }
98
99 //--------------------------------------------------------------------------------------------------
100 inline const mithep::MCParticle *mithep::MCParticle::Mother() const
101 {
102 // Return mother.
103
104 return static_cast<const MCParticle*>(fMother.GetObject());
105 }
106
107 //--------------------------------------------------------------------------------------------------
108 inline Bool_t mithep::MCParticle::IsNeutrino() const
109 {
110 // Return true if particle is neutrino.
111
112 Int_t ap = AbsPdgId();
113 if ((ap==kElNu) ||
114 (ap==kMuNu) ||
115 (ap==kTauNu))
116 return kTRUE;
117
118 return kFALSE;
119 }
120
121 //--------------------------------------------------------------------------------------------------
122 inline TParticlePDG *mithep::MCParticle::PdgEntry() const
123 {
124 // Return entry to pdg database.
125
126 return TDatabasePDG::Instance()->GetParticle(fPdgId);
127 }
128
129 //--------------------------------------------------------------------------------------------------
130 inline void mithep::MCParticle::SetMom(Double_t px, Double_t py, Double_t pz, Double_t e)
131 {
132 // Set four vector.
133
134 fFourVector.SetXYZT(px, py, pz, e);
135 }
136
137 //--------------------------------------------------------------------------------------------------
138 inline void mithep::MCParticle::SetVertex(Double_t x, Double_t y, Double_t z)
139 {
140 // Set decay vertex.
141
142 fDecayVertex.SetXYZ(x,y,z);
143 }
144 #endif