ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/DecayParticle.h
Revision: 1.35
Committed: Fri Apr 8 00:01:29 2011 UTC (14 years, 1 month ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_025c_branch2, Mit_025c_branch1, Mit_025c_branch0, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b
Branch point for: Mit_025c_branch
Changes since 1.34: +3 -3 lines
Log Message:
use momentum direction rather than vertex phi

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: DecayParticle.h,v 1.34 2011/04/07 11:30:45 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), fDzBeamlineError(0),
34 fDzBeamlineEcal(0), fDzBeamlineEcalError(0), fNSharedHits(0) {}
35 DecayParticle(Int_t absPdgId) :
36 fAbsPdgId(absPdgId), fChi2(0), fNdof(0), fMassError(0),
37 fLxy(0), fLxyError(0), fDxy(0), fDxyError(0), fLz(0), fLzError(0), fDzBeamlineError(0),
38 fDzBeamlineEcal(0), fDzBeamlineEcalError(0), fNSharedHits(0) {}
39
40 void AddDaughterData(const DaughterData *dd)
41 { fDaughterData.Add(dd); ClearCharge(); }
42 UInt_t AbsPdgId() const { return fAbsPdgId; }
43 Double_t Chi2() const { return fChi2; }
44 const Particle *Daughter(UInt_t i) const { return DaughterDat(i)->Original(); }
45 const DaughterData *DaughterDat(UInt_t i) const { return fDaughterData.At(i); }
46 Double_t Dxy() const { return fDxy; }
47 Double_t DxyCorrected(const ThreeVector &v) const;
48 Double_t DxyCorrected(const BaseVertex *v) const;
49 Double_t DxyError() const { return fDxyError; }
50 Double_t DzBeamlineError() const { return fDzBeamlineError; }
51 Double_t DzBeamlineEcal() const { return fDzBeamlineEcal; }
52 Double_t DzBeamlineEcalError() const { return fDzBeamlineEcalError; }
53 Double_t DzCorrected(const ThreeVector &v) const;
54 Double_t DzCorrected(const BaseVertex *v) const;
55 Double_t Z0EcalVtx(const ThreeVector &bspos, const ThreeVector &ecalpos) const;
56 Bool_t HasDaughter(const Particle *p) const;
57 Bool_t HasCommonDaughter(const DecayParticle *p) const;
58 Bool_t HasPriVertex() const { return fPriVtx.IsValid(); }
59 Bool_t HasPriVertex(const Vertex *v)
60 const { return fPriVtx.RefsObject(v); }
61 Bool_t HasSameDaughters(const DecayParticle *p) const;
62 Double_t Lxy() const { return fLxy; }
63 Double_t LxyError() const { return fLxyError; }
64 Double_t LxyCorrected(const BaseVertex *v) const;
65 Double_t Lz() const { return fLz; }
66 Double_t LzError() const { return fLzError; }
67 Double_t MassError() const { return fMassError; }
68 UShort_t Ndof() const { return fNdof; }
69 UInt_t NDaughters() const { return fDaughterData.Entries(); }
70 EObjType ObjType() const { return kDecayParticle; }
71 TParticlePDG *ParticlePdgEntry() const;
72 Double_t PdgMass() const;
73 const Vertex *PriVertex() const { return fPriVtx.Obj(); }
74 Double_t Prob() const { return TMath::Prob(fChi2,fNdof); }
75 const ThreeVector &Position() const;
76 const ConversionQuality &Quality() const { return fQuality; }
77 ConversionQuality &Quality() { return fQuality; }
78 const ThreeVector RelativePosition() const;
79 Bool_t SharedLayer(Track::EHitLayer l) const { return fSharedLayers.TestBit(l); }
80 const BitMask48 &SharedLayers() const { return fSharedLayers; }
81 UInt_t NSharedLayers() const { return fSharedLayers.NBitsSet(); }
82 UInt_t NSharedHits() const { return TMath::Max(UInt_t(fNSharedHits),NSharedLayers()); }
83 void SetAbsPdgId(UInt_t apid) { fAbsPdgId=apid; }
84 void SetChi2(Double_t chi2) { fChi2 = chi2; }
85 void SetDxy(Double_t dxy) { fDxy = dxy; ClearPos(); }
86 void SetDxyError(Double_t dxyError) { fDxyError = dxyError; }
87 void SetDzBeamlineError(Double_t dzError) { fDzBeamlineError = dzError; }
88 void SetDzBeamlineEcal(Double_t dz) { fDzBeamlineEcal = dz; }
89 void SetDzBeamlineEcalError(Double_t dzError) { fDzBeamlineEcalError = dzError; }
90 void SetLxy(Double_t lxy) { fLxy = lxy; ClearPos(); }
91 void SetLxyError(Double_t lxyError) { fLxyError = lxyError; }
92 void SetLz(Double_t lz) { fLz = lz; ClearPos(); }
93 void SetLzError(Double_t lzError) { fLzError = lzError; }
94 void SetMassError(Double_t massError) { fMassError = massError; }
95 void SetMom(Double_t px, Double_t py, Double_t pz, Double_t e);
96 void SetMom(const FourVector &p)
97 { fMomentum = p; ClearMom(); ClearPos(); }
98 void SetNdof(UShort_t ndof) { fNdof = ndof; }
99 void SetNSharedHits(UShort_t nhits) { fNSharedHits = nhits; }
100 void SetPriVertex(const Vertex *v) { fPriVtx = v; ClearPos(); }
101 void SetSharedLayer(Track::EHitLayer l) { fSharedLayers.SetBit(l); }
102 void SetSharedLayers(const BitMask48 &layers) { fSharedLayers = layers; }
103 using TObject::Error;
104
105 protected:
106 void ClearPos() const { fCachePosFlag.ClearCache(); }
107 Double_t GetCharge() const;
108 void GetMom() const;
109 void GetPos() const;
110
111 UInt_t fAbsPdgId; //absolute value of pid code
112 Double32_t fChi2; //[0,0,12]chi-squared of fit
113 UShort_t fNdof; //degrees of freedom for fit
114 Double32_t fMassError; //[0,0,14]fitted mass error
115 Double32_t fLxy; //[0,0,14]fitted lxy (decay length)
116 Double32_t fLxyError; //[0,0,14]fitted lxy error
117 Double32_t fDxy; //[0,0,14]fitted impact parameter
118 Double32_t fDxyError; //[0,0,14]fitted impact parameter error
119 Double32_t fLz; //[0,0,14]fitted lz (decay length)
120 Double32_t fLzError; //[0,0,14]fitted lz error
121 Double32_t fDzBeamlineError; //[0,0,14]fitted deltaz error at beamline
122 Double32_t fDzBeamlineEcal; //[0,0,14]fitted deltaz at beamline (with ecal constraint)
123 Double32_t fDzBeamlineEcalError; //[0,0,14]fitted deltaz error at beamline (with ecal constraint)
124 Vect4M fMomentum; //momentum fourvector
125 RefArray<DaughterData> fDaughterData; //momentum of daughters at vertex
126 Ref<Vertex> fPriVtx; //reference to primary vertex
127 BitMask48 fSharedLayers; //layer mask for shared hits from daughter particles
128 UShort_t fNSharedHits; //number of shared hits
129 ConversionQuality fQuality; //conversion quality flags
130 mutable CacheFlag fCachePosFlag; //||cache validity flag for position
131 mutable ThreeVector fCachedPos; //!cached momentum vector (filled by derived classes)
132
133 ClassDef(DecayParticle, 5) // Decay particle class
134 };
135 }
136
137 //--------------------------------------------------------------------------------------------------
138 inline Double_t mithep::DecayParticle::GetCharge() const
139 {
140 // Return sum of charge of daughter particles.
141
142 Double_t charge = 0;
143 for (UInt_t i=0; i<NDaughters(); ++i)
144 charge += DaughterDat(i)->Charge();
145
146 return charge;
147 }
148
149 //--------------------------------------------------------------------------------------------------
150 inline void mithep::DecayParticle::GetMom() const
151 {
152 // Get momentum values from stored values.
153
154 fCachedMom.SetCoordinates(fMomentum.Pt(), fMomentum.Eta(), fMomentum.Phi(), fMomentum.M());
155 }
156
157 //--------------------------------------------------------------------------------------------------
158 inline TParticlePDG *mithep::DecayParticle::ParticlePdgEntry() const
159 {
160 // Return entry to pdg database for the particle.
161
162 return TDatabasePDG::Instance()->GetParticle(fAbsPdgId);
163 }
164
165 //--------------------------------------------------------------------------------------------------
166 inline void mithep::DecayParticle::SetMom(Double_t px, Double_t py, Double_t pz, Double_t e)
167 {
168 // Set four vector.
169
170 fMomentum.SetXYZT(px,py,pz,e);
171 ClearMom();
172 ClearPos();
173 }
174
175 //--------------------------------------------------------------------------------------------------
176 inline const mithep::ThreeVector &mithep::DecayParticle::Position() const
177 {
178 // Return cached momentum value.
179
180 if (!fCachePosFlag.IsValid()) {
181 GetPos();
182 fCachePosFlag.SetValid();
183 }
184
185 return fCachedPos;
186 }
187
188 //--------------------------------------------------------------------------------------------------
189 inline void mithep::DecayParticle::GetPos() const
190 {
191 // Return absolute position of decay.
192
193 const mithep::Vertex *pv = PriVertex();
194
195 if (pv)
196 fCachedPos = pv->Position() + RelativePosition();
197 else
198 fCachedPos = RelativePosition();
199 }
200
201 //--------------------------------------------------------------------------------------------------
202 inline const mithep::ThreeVector mithep::DecayParticle::RelativePosition() const
203 {
204 // Compute the position vector of the decay vertex relative to the primary vertex.
205
206 mithep::ThreeVector dz(0,0,fLz*TMath::Abs(Pz())/Pz());
207 mithep::ThreeVector momPerp(Px(),Py(),0);
208 mithep::ThreeVector zHat(0,0,1.0);
209 mithep::ThreeVector dxy = -momPerp.Cross(zHat)*fDxy/momPerp.R();
210 mithep::ThreeVector dlxy = momPerp*fLxy/momPerp.R();
211 return (dxy+dlxy+dz);
212 }
213
214 //--------------------------------------------------------------------------------------------------
215 inline Double_t mithep::DecayParticle::DxyCorrected(const mithep::ThreeVector &v) const
216 {
217 // Compute Dxy with respect to a given position
218 mithep::ThreeVector momPerp(Px(),Py(),0);
219 return momPerp.Cross(Position() - v).Z()/Pt();
220
221 }
222
223 //--------------------------------------------------------------------------------------------------
224 inline Double_t mithep::DecayParticle::DxyCorrected(const mithep::BaseVertex *v) const
225 {
226 // Compute Dxy with respect to a given beamspot/vertex
227 return DxyCorrected(v->Position());
228
229 }
230
231 //--------------------------------------------------------------------------------------------------
232 inline Double_t mithep::DecayParticle::DzCorrected(const mithep::ThreeVector &v) const
233 {
234 // Compute Dxy with respect to a given position
235 mithep::ThreeVector momPerp(Px(),Py(),0);
236 mithep::ThreeVector posPerp(Position().X()-v.X(),Position().Y()-v.Y(),0);
237 return Position().Z() - v.Z() - posPerp.Dot(momPerp)/Pt() * (Pz()/Pt());
238
239 }
240
241 //--------------------------------------------------------------------------------------------------
242 inline Double_t mithep::DecayParticle::DzCorrected(const mithep::BaseVertex *v) const
243 {
244 // Compute Dxy with respect to a given beamspot/vertex
245 return DzCorrected(v->Position());
246
247 }
248
249
250 //--------------------------------------------------------------------------------------------------
251 inline Double_t mithep::DecayParticle::Z0EcalVtx(const ThreeVector &bspos, const ThreeVector &ecalpos) const
252 {
253 // Compute z position at beamline with vector joining conversion vertex to ecal position
254 mithep::ThreeVector dirscvtx = ecalpos - Position();
255
256 mithep::ThreeVector momPerp(Px(),Py(),0);
257 mithep::ThreeVector posPerp(Position().X()-bspos.X(),Position().Y()-bspos.Y(),0);
258 return Position().Z() - posPerp.Dot(momPerp)/Pt() * (dirscvtx.Z()/dirscvtx.Rho());
259
260 }
261
262 inline Double_t mithep::DecayParticle::LxyCorrected(const mithep::BaseVertex *v) const
263 {
264 // Compute Dxy with respect to a given beamspot/vertex
265 Double_t dx = Position().X() - v->X();
266 Double_t dy = Position().Y() - v->Y();
267 Double_t lxy = (dx*Px() + dy*Py())/Pt();
268 return lxy;
269
270 }
271
272 #endif