1 |
bendavid |
1.1 |
//--------------------------------------------------------------------------------------------------
|
2 |
loizides |
1.23 |
// $Id: MCParticle.h,v 1.22 2009/06/02 11:12:10 bendavid Exp $
|
3 |
bendavid |
1.1 |
//
|
4 |
|
|
// MCParticle
|
5 |
|
|
//
|
6 |
loizides |
1.12 |
// Stores MC information for both generated and simulated particles.
|
7 |
bendavid |
1.1 |
//
|
8 |
loizides |
1.12 |
// Authors: C.Loizides, J.Bendavid
|
9 |
bendavid |
1.1 |
//--------------------------------------------------------------------------------------------------
|
10 |
|
|
|
11 |
loizides |
1.3 |
#ifndef MITANA_DATATREE_MCPARTICLE_H
|
12 |
|
|
#define MITANA_DATATREE_MCPARTICLE_H
|
13 |
bendavid |
1.1 |
|
14 |
|
|
#include <TDatabasePDG.h>
|
15 |
|
|
#include <TParticlePDG.h>
|
16 |
loizides |
1.17 |
#include "MitCommon/DataFormats/interface/Vect3.h"
|
17 |
|
|
#include "MitCommon/DataFormats/interface/Vect4M.h"
|
18 |
bendavid |
1.13 |
#include "MitAna/DataCont/interface/Ref.h"
|
19 |
bendavid |
1.1 |
#include "MitAna/DataTree/interface/CompositeParticle.h"
|
20 |
|
|
|
21 |
|
|
namespace mithep
|
22 |
|
|
{
|
23 |
|
|
class MCParticle : public CompositeParticle
|
24 |
|
|
{
|
25 |
|
|
public:
|
26 |
loizides |
1.23 |
enum EPartType {
|
27 |
|
|
kUnknown=0,
|
28 |
|
|
kUp=1, kDown=2, kStrange=3, kCharm=4, kBottom=5, kTop=6,
|
29 |
|
|
kEl=11, kMu=13, kTau=15,
|
30 |
|
|
kElNu=12, kMuNu=14, kTauNu=16,
|
31 |
|
|
kGlu=21, kGamma=22, kZ=23, kW=24, kH=25,
|
32 |
|
|
kZp=32, kZpp=33, kWp=34, kH0=35, kA0=36, kHp=37,
|
33 |
|
|
kPi0=111, kEta=221, kKLong=130, kKShort=310, kK0=311,
|
34 |
|
|
kD0=413, kB0=511, kB0Bar=513, kJPsi=443, kUpsilon=553,
|
35 |
|
|
kProton=2122, kNeutron=2122, kDeltaPlusPlus = 2224,
|
36 |
|
|
kDeltaPlus = 2214, kDelta0 = 2114, kDeltaMinus=1114
|
37 |
|
|
};
|
38 |
|
|
|
39 |
loizides |
1.16 |
MCParticle() : fPdgId(0), fStatus(0), fIsGenerated(kFALSE), fIsSimulated(kFALSE) {}
|
40 |
bendavid |
1.1 |
MCParticle(Double_t px, Double_t py, Double_t pz, Double_t e, Int_t id, Int_t s) :
|
41 |
loizides |
1.18 |
fPdgId(id), fStatus(s), fMom(FourVector(px,py,pz,e)),
|
42 |
bendavid |
1.1 |
fIsGenerated(kFALSE), fIsSimulated(kFALSE) {}
|
43 |
|
|
|
44 |
loizides |
1.16 |
Int_t AbsPdgId() const { return (fPdgId<0 ? -fPdgId:fPdgId); }
|
45 |
|
|
void AddDaughter(const MCParticle *p) { fDaughters.Add(p); }
|
46 |
|
|
const ThreeVector DecayVertex() const { return fDecayVertex.V(); }
|
47 |
loizides |
1.3 |
const MCParticle *Daughter(UInt_t i) const;
|
48 |
bendavid |
1.4 |
const MCParticle *DistinctMother() const;
|
49 |
loizides |
1.7 |
using CompositeParticle::HasDaughter;
|
50 |
loizides |
1.8 |
const MCParticle *FindDaughter(Int_t pid,
|
51 |
|
|
Bool_t checkCharge=kFALSE, const MCParticle *start=0) const;
|
52 |
loizides |
1.16 |
const MCParticle *FindMother(Int_t pid, Bool_t checkCharge=kFALSE) const;
|
53 |
loizides |
1.7 |
Bool_t HasDaughter(Int_t pid, Bool_t checkCharge=kFALSE) const;
|
54 |
loizides |
1.3 |
Bool_t HasMother() const { return fMother.IsValid(); }
|
55 |
loizides |
1.9 |
Bool_t HasMother(const MCParticle *m) const;
|
56 |
loizides |
1.8 |
Bool_t HasMother(Int_t pid, Bool_t checkCharge=kFALSE) const;
|
57 |
loizides |
1.7 |
Bool_t Is(Int_t pid, Bool_t checkCharge=kFALSE) const;
|
58 |
loizides |
1.21 |
Bool_t IsCharged() const { return !IsNeutral(); }
|
59 |
loizides |
1.16 |
Bool_t IsGenerated() const { return fIsGenerated; }
|
60 |
|
|
Bool_t IsGluon() const { return fPdgId == kGlu; }
|
61 |
loizides |
1.19 |
Bool_t IsLepton() const;
|
62 |
phedex |
1.20 |
Bool_t IsNeutral() const;
|
63 |
loizides |
1.7 |
Bool_t IsNeutrino() const;
|
64 |
loizides |
1.21 |
Bool_t IsNot(Int_t pid, Bool_t checkCharge=kFALSE) const;
|
65 |
loizides |
1.16 |
Bool_t IsParton() const { return (IsGluon() || IsQuark()); }
|
66 |
loizides |
1.7 |
Bool_t IsQuark() const { return (AbsPdgId()>0 && AbsPdgId()<7); }
|
67 |
loizides |
1.16 |
Bool_t IsSimulated() const { return fIsSimulated; }
|
68 |
bendavid |
1.13 |
const MCParticle *Mother() const { return fMother.Obj(); }
|
69 |
loizides |
1.16 |
EObjType ObjType() const { return kMCParticle; }
|
70 |
|
|
void SetIsGenerated(Bool_t t=kTRUE) { fIsGenerated = t; }
|
71 |
|
|
void SetIsSimulated(Bool_t t=kTRUE) { fIsSimulated = t; }
|
72 |
loizides |
1.3 |
TParticlePDG *PdgEntry() const;
|
73 |
loizides |
1.16 |
Int_t PdgId() const { return fPdgId; }
|
74 |
loizides |
1.18 |
Double_t PdgMass() const;
|
75 |
bendavid |
1.1 |
void SetMom(Double_t px, Double_t py, Double_t pz, Double_t e);
|
76 |
loizides |
1.16 |
void SetMother(const MCParticle *p) { fMother = p; }
|
77 |
|
|
void SetStatus(Int_t s) { fStatus = s; }
|
78 |
bendavid |
1.2 |
void SetVertex(Double_t x, Double_t y, Double_t z);
|
79 |
loizides |
1.16 |
void SetPdgId(Int_t s) { fPdgId = s; }
|
80 |
loizides |
1.3 |
Int_t Status() const { return fStatus; }
|
81 |
|
|
void Print(Option_t *opt="") const;
|
82 |
bendavid |
1.1 |
|
83 |
|
|
protected:
|
84 |
loizides |
1.14 |
Double_t GetCharge() const;
|
85 |
|
|
void GetMom() const;
|
86 |
|
|
|
87 |
bendavid |
1.1 |
Int_t fPdgId; //pdg identifier
|
88 |
loizides |
1.16 |
Short_t fStatus; //status flag of generator or simulation
|
89 |
|
|
Vect4M fMom; //four momentum vector
|
90 |
|
|
Vect3 fDecayVertex; //gen decay vertex
|
91 |
bendavid |
1.13 |
Ref<MCParticle> fMother; //reference to mother
|
92 |
loizides |
1.3 |
Bool_t fIsGenerated; //=true if generated particle
|
93 |
|
|
Bool_t fIsSimulated; //=true if simulated particle
|
94 |
bendavid |
1.1 |
|
95 |
loizides |
1.14 |
ClassDef(MCParticle,1) // Generated particle class
|
96 |
bendavid |
1.1 |
};
|
97 |
|
|
}
|
98 |
|
|
|
99 |
|
|
//--------------------------------------------------------------------------------------------------
|
100 |
loizides |
1.8 |
inline const mithep::MCParticle *mithep::MCParticle::Daughter(UInt_t i) const
|
101 |
|
|
{
|
102 |
|
|
// Return daughter corresponding to given index.
|
103 |
|
|
|
104 |
|
|
return static_cast<const MCParticle*>(fDaughters.At(i));
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
//--------------------------------------------------------------------------------------------------
|
108 |
|
|
inline const mithep::MCParticle *mithep::MCParticle::DistinctMother() const
|
109 |
|
|
{
|
110 |
|
|
// Return mother, walking up the tree until a particle with a different pdg from this one
|
111 |
|
|
// is found.
|
112 |
|
|
|
113 |
|
|
const mithep::MCParticle *mother = Mother();
|
114 |
|
|
|
115 |
|
|
if (!mother)
|
116 |
|
|
return 0;
|
117 |
|
|
|
118 |
bendavid |
1.22 |
while (mother && mother->PdgId()==fPdgId)
|
119 |
loizides |
1.8 |
mother = mother->Mother();
|
120 |
|
|
|
121 |
|
|
return mother;
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
//--------------------------------------------------------------------------------------------------
|
125 |
loizides |
1.14 |
inline Double_t mithep::MCParticle::GetCharge() const
|
126 |
|
|
{
|
127 |
|
|
// Get charge from pdg lookup.
|
128 |
|
|
|
129 |
|
|
TParticlePDG *pdgEntry = PdgEntry();
|
130 |
|
|
if (pdgEntry)
|
131 |
|
|
return pdgEntry->Charge()/3.0;
|
132 |
|
|
else {
|
133 |
|
|
Error("Charge", "Pdg code for %i not found in table, returning charge=-99.0", fPdgId);
|
134 |
|
|
return -99.0;
|
135 |
|
|
}
|
136 |
|
|
}
|
137 |
|
|
|
138 |
|
|
//--------------------------------------------------------------------------------------------------
|
139 |
|
|
inline void mithep::MCParticle::GetMom() const
|
140 |
|
|
{
|
141 |
|
|
// Get momentum values from stored values.
|
142 |
|
|
|
143 |
loizides |
1.16 |
fCachedMom.SetCoordinates(fMom.Pt(), fMom.Eta(), fMom.Phi(), fMom.M());
|
144 |
loizides |
1.14 |
}
|
145 |
|
|
|
146 |
|
|
//--------------------------------------------------------------------------------------------------
|
147 |
loizides |
1.7 |
inline Bool_t mithep::MCParticle::HasDaughter(Int_t pid, Bool_t checkCharge) const
|
148 |
|
|
{
|
149 |
|
|
// Return true if a particle with given pdg code is found amoung daughters.
|
150 |
|
|
// If checkCharge is false then just the type of particle is checked
|
151 |
|
|
// (ie particle and anti-particle).
|
152 |
|
|
|
153 |
|
|
if (checkCharge) {
|
154 |
|
|
for (UInt_t i=0; i<NDaughters(); ++i)
|
155 |
|
|
if (Daughter(i)->PdgId()==pid)
|
156 |
|
|
return kTRUE;
|
157 |
|
|
} else {
|
158 |
|
|
Int_t apid = pid>0?pid:-pid;
|
159 |
|
|
for (UInt_t i=0; i<NDaughters(); ++i)
|
160 |
|
|
if (Daughter(i)->AbsPdgId()==apid)
|
161 |
|
|
return kTRUE;
|
162 |
|
|
}
|
163 |
|
|
return kFALSE;
|
164 |
|
|
}
|
165 |
|
|
|
166 |
|
|
//--------------------------------------------------------------------------------------------------
|
167 |
loizides |
1.9 |
inline Bool_t mithep::MCParticle::HasMother(const MCParticle *m) const
|
168 |
|
|
{
|
169 |
|
|
// Return true if the given particle is among mothers. (Note the comparison
|
170 |
|
|
// is made on pointers and therefore will fail if you work on copies.)
|
171 |
|
|
|
172 |
|
|
if (!m)
|
173 |
|
|
return kFALSE;
|
174 |
|
|
|
175 |
|
|
const mithep::MCParticle *mother = Mother();
|
176 |
|
|
while (mother && mother!=m)
|
177 |
|
|
mother = mother->Mother();
|
178 |
|
|
|
179 |
|
|
if (mother)
|
180 |
|
|
return kTRUE;
|
181 |
|
|
return kFALSE;
|
182 |
|
|
}
|
183 |
|
|
|
184 |
|
|
//--------------------------------------------------------------------------------------------------
|
185 |
loizides |
1.8 |
inline Bool_t mithep::MCParticle::HasMother(Int_t pid, Bool_t checkCharge) const
|
186 |
|
|
{
|
187 |
|
|
// Return true if a particle with given pdg code is found amoung mothers.
|
188 |
|
|
// If checkCharge is false then just the type of particle is checked
|
189 |
|
|
// (ie particle and anti-particle).
|
190 |
bendavid |
1.4 |
|
191 |
|
|
const mithep::MCParticle *mother = Mother();
|
192 |
|
|
|
193 |
loizides |
1.8 |
if (checkCharge) {
|
194 |
loizides |
1.9 |
while (mother && mother->PdgId()!=pid)
|
195 |
loizides |
1.8 |
mother = mother->Mother();
|
196 |
|
|
} else {
|
197 |
|
|
Int_t apid = pid>0?pid:-pid;
|
198 |
loizides |
1.9 |
while (mother && mother->AbsPdgId()!=apid)
|
199 |
loizides |
1.8 |
mother = mother->Mother();
|
200 |
|
|
}
|
201 |
bendavid |
1.4 |
|
202 |
loizides |
1.8 |
if (mother)
|
203 |
|
|
return kTRUE;
|
204 |
|
|
return kFALSE;
|
205 |
bendavid |
1.1 |
}
|
206 |
|
|
|
207 |
|
|
//--------------------------------------------------------------------------------------------------
|
208 |
loizides |
1.7 |
inline Bool_t mithep::MCParticle::Is(Int_t pid, Bool_t checkCharge) const
|
209 |
|
|
{
|
210 |
|
|
// Return true if particle is of given type. If checkCharge is false then just the type of
|
211 |
|
|
// particle is checked (ie particle and anti-particle).
|
212 |
|
|
|
213 |
|
|
if (checkCharge)
|
214 |
|
|
return (PdgId() == pid);
|
215 |
|
|
|
216 |
|
|
Int_t apid = pid>0?pid:-pid;
|
217 |
|
|
return (AbsPdgId() == apid);
|
218 |
|
|
}
|
219 |
|
|
|
220 |
|
|
//--------------------------------------------------------------------------------------------------
|
221 |
loizides |
1.11 |
inline Bool_t mithep::MCParticle::IsNot(Int_t pid, Bool_t checkCharge) const
|
222 |
|
|
{
|
223 |
|
|
// Return true if particle is not of given type. If checkCharge is false then just the type of
|
224 |
|
|
// particle is checked (ie particle and anti-particle).
|
225 |
|
|
|
226 |
|
|
return !Is(pid, checkCharge);
|
227 |
|
|
}
|
228 |
|
|
|
229 |
|
|
//--------------------------------------------------------------------------------------------------
|
230 |
loizides |
1.19 |
inline Bool_t mithep::MCParticle::IsLepton() const
|
231 |
|
|
{
|
232 |
|
|
// Return true if particle is a lepton.
|
233 |
|
|
|
234 |
|
|
Int_t ap = AbsPdgId();
|
235 |
|
|
if ((ap==kEl) ||
|
236 |
|
|
(ap==kMu) ||
|
237 |
|
|
(ap==kTau))
|
238 |
|
|
return kTRUE;
|
239 |
|
|
|
240 |
|
|
return kFALSE;
|
241 |
|
|
}
|
242 |
|
|
|
243 |
|
|
//--------------------------------------------------------------------------------------------------
|
244 |
phedex |
1.20 |
inline Bool_t mithep::MCParticle::IsNeutral() const
|
245 |
|
|
{
|
246 |
|
|
// Return true if particle is a neutral.
|
247 |
|
|
|
248 |
loizides |
1.21 |
return (Charge()!=0);
|
249 |
phedex |
1.20 |
}
|
250 |
|
|
|
251 |
|
|
//--------------------------------------------------------------------------------------------------
|
252 |
bendavid |
1.1 |
inline Bool_t mithep::MCParticle::IsNeutrino() const
|
253 |
|
|
{
|
254 |
loizides |
1.19 |
// Return true if particle is a neutrino.
|
255 |
bendavid |
1.1 |
|
256 |
|
|
Int_t ap = AbsPdgId();
|
257 |
|
|
if ((ap==kElNu) ||
|
258 |
|
|
(ap==kMuNu) ||
|
259 |
|
|
(ap==kTauNu))
|
260 |
|
|
return kTRUE;
|
261 |
|
|
|
262 |
|
|
return kFALSE;
|
263 |
|
|
}
|
264 |
|
|
|
265 |
|
|
//--------------------------------------------------------------------------------------------------
|
266 |
|
|
inline TParticlePDG *mithep::MCParticle::PdgEntry() const
|
267 |
|
|
{
|
268 |
|
|
// Return entry to pdg database.
|
269 |
|
|
|
270 |
|
|
return TDatabasePDG::Instance()->GetParticle(fPdgId);
|
271 |
|
|
}
|
272 |
|
|
|
273 |
|
|
//--------------------------------------------------------------------------------------------------
|
274 |
loizides |
1.18 |
inline Double_t mithep::MCParticle::PdgMass() const
|
275 |
|
|
{
|
276 |
|
|
// Return mass obtained from pdg database.
|
277 |
|
|
|
278 |
|
|
TParticlePDG *pdg = PdgEntry();
|
279 |
|
|
if (pdg)
|
280 |
|
|
return pdg->Mass();
|
281 |
|
|
return 0;
|
282 |
|
|
}
|
283 |
|
|
|
284 |
|
|
//--------------------------------------------------------------------------------------------------
|
285 |
bendavid |
1.1 |
inline void mithep::MCParticle::SetMom(Double_t px, Double_t py, Double_t pz, Double_t e)
|
286 |
|
|
{
|
287 |
|
|
// Set four vector.
|
288 |
|
|
|
289 |
loizides |
1.16 |
fMom.SetXYZT(px, py, pz, e);
|
290 |
bendavid |
1.15 |
ClearMom();
|
291 |
bendavid |
1.1 |
}
|
292 |
|
|
|
293 |
|
|
//--------------------------------------------------------------------------------------------------
|
294 |
|
|
inline void mithep::MCParticle::SetVertex(Double_t x, Double_t y, Double_t z)
|
295 |
|
|
{
|
296 |
|
|
// Set decay vertex.
|
297 |
|
|
|
298 |
|
|
fDecayVertex.SetXYZ(x,y,z);
|
299 |
|
|
}
|
300 |
|
|
#endif
|