1 |
//--------------------------------------------------------------------------------------------------
|
2 |
// $Id: DecayParticle.h,v 1.29 2010/03/31 12:04:06 bendavid Exp $
|
3 |
//
|
4 |
// DecayParticle
|
5 |
//
|
6 |
// The decay particle class is for use in vertexing based analyses. It
|
7 |
// stores vertex fit information (including four momentum) and links to daughters.
|
8 |
//
|
9 |
// Note that Charge() is still computed as a recursive loop over daughters, as inherited from
|
10 |
// CompositeParticle, but momentum is returned from the internally stored four vector.
|
11 |
//
|
12 |
// Authors: C.Paus, J.Bendavid
|
13 |
//--------------------------------------------------------------------------------------------------
|
14 |
|
15 |
#ifndef MITANA_DATATREE_DECAYPARTICLE_H
|
16 |
#define MITANA_DATATREE_DECAYPARTICLE_H
|
17 |
|
18 |
#include <TDatabasePDG.h>
|
19 |
#include <TParticlePDG.h>
|
20 |
#include "MitCommon/DataFormats/interface/Vect4M.h"
|
21 |
#include "MitAna/DataTree/interface/DaughterData.h"
|
22 |
#include "MitAna/DataTree/interface/Vertex.h"
|
23 |
#include "MitAna/DataTree/interface/ConversionQuality.h"
|
24 |
#include "MitAna/DataCont/interface/RefArray.h"
|
25 |
|
26 |
namespace mithep
|
27 |
{
|
28 |
class DecayParticle : public Particle
|
29 |
{
|
30 |
public:
|
31 |
DecayParticle() :
|
32 |
fAbsPdgId(0), fChi2(0), fNdof(0), fMassError(0),
|
33 |
fLxy(0), fLxyError(0), fDxy(0), fDxyError(0), fLz(0), fLzError(0), fNSharedHits(0) {}
|
34 |
DecayParticle(Int_t absPdgId) :
|
35 |
fAbsPdgId(absPdgId), fChi2(0), fNdof(0), fMassError(0),
|
36 |
fLxy(0), fLxyError(0), fDxy(0), fDxyError(0), fLz(0), fLzError(0), fNSharedHits(0) {}
|
37 |
|
38 |
void AddDaughterData(const DaughterData *dd)
|
39 |
{ fDaughterData.Add(dd); ClearCharge(); }
|
40 |
UInt_t AbsPdgId() const { return fAbsPdgId; }
|
41 |
Double_t Chi2() const { return fChi2; }
|
42 |
const Particle *Daughter(UInt_t i) const { return DaughterDat(i)->Original(); }
|
43 |
const DaughterData *DaughterDat(UInt_t i) const { return fDaughterData.At(i); }
|
44 |
Double_t Dxy() const { return fDxy; }
|
45 |
Double_t DxyCorrected(const ThreeVector &v) const;
|
46 |
Double_t DxyCorrected(const BaseVertex *v) const;
|
47 |
Double_t DxyError() const { return fDxyError; }
|
48 |
Double_t DzCorrected(const ThreeVector &v) const;
|
49 |
Double_t DzCorrected(const BaseVertex *v) const;
|
50 |
Bool_t HasDaughter(const Particle *p) const;
|
51 |
Bool_t HasCommonDaughter(const DecayParticle *p) const;
|
52 |
Bool_t HasPriVertex() const { return fPriVtx.IsValid(); }
|
53 |
Bool_t HasPriVertex(const Vertex *v)
|
54 |
const { return fPriVtx.RefsObject(v); }
|
55 |
Bool_t HasSameDaughters(const DecayParticle *p) const;
|
56 |
Double_t Lxy() const { return fLxy; }
|
57 |
Double_t LxyError() const { return fLxyError; }
|
58 |
Double_t Lz() const { return fLz; }
|
59 |
Double_t LzError() const { return fLzError; }
|
60 |
Double_t MassError() const { return fMassError; }
|
61 |
UShort_t Ndof() const { return fNdof; }
|
62 |
UInt_t NDaughters() const { return fDaughterData.Entries(); }
|
63 |
EObjType ObjType() const { return kDecayParticle; }
|
64 |
TParticlePDG *ParticlePdgEntry() const;
|
65 |
Double_t PdgMass() const;
|
66 |
const Vertex *PriVertex() const { return fPriVtx.Obj(); }
|
67 |
Double_t Prob() const { return TMath::Prob(fChi2,fNdof); }
|
68 |
const ThreeVector &Position() const;
|
69 |
const ConversionQuality &Quality() const { return fQuality; }
|
70 |
ConversionQuality &Quality() { return fQuality; }
|
71 |
const ThreeVector RelativePosition() const;
|
72 |
Bool_t SharedLayer(Track::EHitLayer l) const { return fSharedLayers.TestBit(l); }
|
73 |
const BitMask48 &SharedLayers() const { return fSharedLayers; }
|
74 |
UInt_t NSharedLayers() const { return fSharedLayers.NBitsSet(); }
|
75 |
UInt_t NSharedHits() const { return TMath::Max(UInt_t(fNSharedHits),NSharedLayers()); }
|
76 |
void SetAbsPdgId(UInt_t apid) { fAbsPdgId=apid; }
|
77 |
void SetChi2(Double_t chi2) { fChi2 = chi2; }
|
78 |
void SetDxy(Double_t dxy) { fDxy = dxy; ClearPos(); }
|
79 |
void SetDxyError(Double_t dxyError) { fDxyError = dxyError; }
|
80 |
void SetLxy(Double_t lxy) { fLxy = lxy; ClearPos(); }
|
81 |
void SetLxyError(Double_t lxyError) { fLxyError = lxyError; }
|
82 |
void SetLz(Double_t lz) { fLz = lz; ClearPos(); }
|
83 |
void SetLzError(Double_t lzError) { fLzError = lzError; }
|
84 |
void SetMassError(Double_t massError) { fMassError = massError; }
|
85 |
void SetMom(Double_t px, Double_t py, Double_t pz, Double_t e);
|
86 |
void SetMom(const FourVector &p)
|
87 |
{ fMomentum = p; ClearMom(); ClearPos(); }
|
88 |
void SetNdof(UShort_t ndof) { fNdof = ndof; }
|
89 |
void SetNSharedHits(UShort_t nhits) { fNSharedHits = nhits; }
|
90 |
void SetPriVertex(const Vertex *v) { fPriVtx = v; ClearPos(); }
|
91 |
void SetSharedLayer(Track::EHitLayer l) { fSharedLayers.SetBit(l); }
|
92 |
void SetSharedLayers(const BitMask48 &layers) { fSharedLayers = layers; }
|
93 |
using TObject::Error;
|
94 |
|
95 |
protected:
|
96 |
void ClearPos() const { fCachePosFlag.ClearCache(); }
|
97 |
Double_t GetCharge() const;
|
98 |
void GetMom() const;
|
99 |
void GetPos() const;
|
100 |
|
101 |
UInt_t fAbsPdgId; //absolute value of pid code
|
102 |
Double32_t fChi2; //[0,0,12]chi-squared of fit
|
103 |
UShort_t fNdof; //degrees of freedom for fit
|
104 |
Double32_t fMassError; //[0,0,14]fitted mass error
|
105 |
Double32_t fLxy; //[0,0,14]fitted lxy (decay length)
|
106 |
Double32_t fLxyError; //[0,0,14]fitted lxy error
|
107 |
Double32_t fDxy; //[0,0,14]fitted impact parameter
|
108 |
Double32_t fDxyError; //[0,0,14]fitted impact parameter error
|
109 |
Double32_t fLz; //[0,0,14]fitted lz (decay length)
|
110 |
Double32_t fLzError; //[0,0,14]fitted lz error
|
111 |
Vect4M fMomentum; //momentum fourvector
|
112 |
RefArray<DaughterData> fDaughterData; //momentum of daughters at vertex
|
113 |
Ref<Vertex> fPriVtx; //reference to primary vertex
|
114 |
BitMask48 fSharedLayers; //layer mask for shared hits from daughter particles
|
115 |
UShort_t fNSharedHits; //number of shared hits
|
116 |
ConversionQuality fQuality; //conversion quality flags
|
117 |
mutable CacheFlag fCachePosFlag; //||cache validity flag for position
|
118 |
mutable ThreeVector fCachedPos; //!cached momentum vector (filled by derived classes)
|
119 |
|
120 |
ClassDef(DecayParticle, 3) // Decay particle class
|
121 |
};
|
122 |
}
|
123 |
|
124 |
//--------------------------------------------------------------------------------------------------
|
125 |
inline Double_t mithep::DecayParticle::GetCharge() const
|
126 |
{
|
127 |
// Return sum of charge of daughter particles.
|
128 |
|
129 |
Double_t charge = 0;
|
130 |
for (UInt_t i=0; i<NDaughters(); ++i)
|
131 |
charge += DaughterDat(i)->Charge();
|
132 |
|
133 |
return charge;
|
134 |
}
|
135 |
|
136 |
//--------------------------------------------------------------------------------------------------
|
137 |
inline void mithep::DecayParticle::GetMom() const
|
138 |
{
|
139 |
// Get momentum values from stored values.
|
140 |
|
141 |
fCachedMom.SetCoordinates(fMomentum.Pt(), fMomentum.Eta(), fMomentum.Phi(), fMomentum.M());
|
142 |
}
|
143 |
|
144 |
//--------------------------------------------------------------------------------------------------
|
145 |
inline TParticlePDG *mithep::DecayParticle::ParticlePdgEntry() const
|
146 |
{
|
147 |
// Return entry to pdg database for the particle.
|
148 |
|
149 |
return TDatabasePDG::Instance()->GetParticle(fAbsPdgId);
|
150 |
}
|
151 |
|
152 |
//--------------------------------------------------------------------------------------------------
|
153 |
inline void mithep::DecayParticle::SetMom(Double_t px, Double_t py, Double_t pz, Double_t e)
|
154 |
{
|
155 |
// Set four vector.
|
156 |
|
157 |
fMomentum.SetXYZT(px,py,pz,e);
|
158 |
ClearMom();
|
159 |
ClearPos();
|
160 |
}
|
161 |
|
162 |
//--------------------------------------------------------------------------------------------------
|
163 |
inline const mithep::ThreeVector &mithep::DecayParticle::Position() const
|
164 |
{
|
165 |
// Return cached momentum value.
|
166 |
|
167 |
if (!fCachePosFlag.IsValid()) {
|
168 |
GetPos();
|
169 |
fCachePosFlag.SetValid();
|
170 |
}
|
171 |
|
172 |
return fCachedPos;
|
173 |
}
|
174 |
|
175 |
//--------------------------------------------------------------------------------------------------
|
176 |
inline void mithep::DecayParticle::GetPos() const
|
177 |
{
|
178 |
// Return absolute position of decay.
|
179 |
|
180 |
const mithep::Vertex *pv = PriVertex();
|
181 |
|
182 |
if (pv)
|
183 |
fCachedPos = pv->Position() + RelativePosition();
|
184 |
else
|
185 |
fCachedPos = RelativePosition();
|
186 |
}
|
187 |
|
188 |
//--------------------------------------------------------------------------------------------------
|
189 |
inline const mithep::ThreeVector mithep::DecayParticle::RelativePosition() const
|
190 |
{
|
191 |
// Compute the position vector of the decay vertex relative to the primary vertex.
|
192 |
|
193 |
mithep::ThreeVector dz(0,0,fLz*TMath::Abs(Pz())/Pz());
|
194 |
mithep::ThreeVector momPerp(Px(),Py(),0);
|
195 |
mithep::ThreeVector zHat(0,0,1.0);
|
196 |
mithep::ThreeVector dxy = -momPerp.Cross(zHat)*fDxy/momPerp.R();
|
197 |
mithep::ThreeVector dlxy = momPerp*fLxy/momPerp.R();
|
198 |
return (dxy+dlxy+dz);
|
199 |
}
|
200 |
|
201 |
//--------------------------------------------------------------------------------------------------
|
202 |
inline Double_t mithep::DecayParticle::DxyCorrected(const mithep::ThreeVector &v) const
|
203 |
{
|
204 |
// Compute Dxy with respect to a given position
|
205 |
mithep::ThreeVector momPerp(Px(),Py(),0);
|
206 |
return momPerp.Cross(Position() - v).Z()/Pt();
|
207 |
|
208 |
}
|
209 |
|
210 |
//--------------------------------------------------------------------------------------------------
|
211 |
inline Double_t mithep::DecayParticle::DxyCorrected(const mithep::BaseVertex *v) const
|
212 |
{
|
213 |
// Compute Dxy with respect to a given beamspot/vertex
|
214 |
return DxyCorrected(v->Position());
|
215 |
|
216 |
}
|
217 |
|
218 |
//--------------------------------------------------------------------------------------------------
|
219 |
inline Double_t mithep::DecayParticle::DzCorrected(const mithep::ThreeVector &v) const
|
220 |
{
|
221 |
// Compute Dxy with respect to a given position
|
222 |
mithep::ThreeVector momPerp(Px(),Py(),0);
|
223 |
mithep::ThreeVector posPerp(Position().X()-v.X(),Position().Y()-v.Y(),0);
|
224 |
return Position().Z() - v.Z() - posPerp.Dot(momPerp)/Pt() * (Pz()/Pt());
|
225 |
|
226 |
}
|
227 |
|
228 |
//--------------------------------------------------------------------------------------------------
|
229 |
inline Double_t mithep::DecayParticle::DzCorrected(const mithep::BaseVertex *v) const
|
230 |
{
|
231 |
// Compute Dxy with respect to a given beamspot/vertex
|
232 |
return DzCorrected(v->Position());
|
233 |
|
234 |
}
|
235 |
|
236 |
#endif
|