ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/DecayParticle.h
Revision: 1.27
Committed: Mon Jul 13 11:00:28 2009 UTC (15 years, 9 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_012f, Mit_012e, Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012, Mit_011a, Mit_011, Mit_010a, Mit_010
Changes since 1.26: +1 -3 lines
Log Message:
Include files checked.

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: DecayParticle.h,v 1.26 2009/03/18 15:44:32 loizides 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/DataCont/interface/RefArray.h"
24
25 namespace mithep
26 {
27 class DecayParticle : public Particle
28 {
29 public:
30 DecayParticle() :
31 fAbsPdgId(0), fChi2(0), fNdof(0), fMassError(0),
32 fLxy(0), fLxyError(0), fDxy(0), fDxyError(0), fLz(0), fLzError(0) {}
33 DecayParticle(Int_t absPdgId) :
34 fAbsPdgId(absPdgId), fChi2(0), fNdof(0), fMassError(0),
35 fLxy(0), fLxyError(0), fDxy(0), fDxyError(0), fLz(0), fLzError(0) {}
36
37 void AddDaughterData(const DaughterData *dd)
38 { fDaughterData.Add(dd); ClearCharge(); }
39 UInt_t AbsPdgId() const { return fAbsPdgId; }
40 Double_t Chi2() const { return fChi2; }
41 const Particle *Daughter(UInt_t i) const { return DaughterDat(i)->Original(); }
42 const DaughterData *DaughterDat(UInt_t i) const { return fDaughterData.At(i); }
43 Double_t Dxy() const { return fDxy; }
44 Double_t DxyError() const { return fDxyError; }
45 Bool_t HasDaughter(const Particle *p) const;
46 Bool_t HasCommonDaughter(const DecayParticle *p) const;
47 Bool_t HasPriVertex() const { return fPriVtx.IsValid(); }
48 Bool_t HasPriVertex(const Vertex *v)
49 const { return fPriVtx.RefsObject(v); }
50 Bool_t HasSameDaughters(const DecayParticle *p) const;
51 Double_t Lxy() const { return fLxy; }
52 Double_t LxyError() const { return fLxyError; }
53 Double_t Lz() const { return fLz; }
54 Double_t LzError() const { return fLzError; }
55 Double_t MassError() const { return fMassError; }
56 UShort_t Ndof() const { return fNdof; }
57 UInt_t NDaughters() const { return fDaughterData.Entries(); }
58 EObjType ObjType() const { return kDecayParticle; }
59 TParticlePDG *ParticlePdgEntry() const;
60 Double_t PdgMass() const;
61 const Vertex *PriVertex() const { return fPriVtx.Obj(); }
62 Double_t Prob() const { return TMath::Prob(fChi2,fNdof); }
63 const ThreeVector &Position() const;
64 const ThreeVector RelativePosition() const;
65 void SetAbsPdgId(UInt_t apid) { fAbsPdgId=apid; }
66 void SetChi2(Double_t chi2) { fChi2 = chi2; }
67 void SetDxy(Double_t dxy) { fDxy = dxy; ClearPos(); }
68 void SetDxyError(Double_t dxyError) { fDxyError = dxyError; }
69 void SetLxy(Double_t lxy) { fLxy = lxy; ClearPos(); }
70 void SetLxyError(Double_t lxyError) { fLxyError = lxyError; }
71 void SetLz(Double_t lz) { fLz = lz; ClearPos(); }
72 void SetLzError(Double_t lzError) { fLzError = lzError; }
73 void SetMassError(Double_t massError) { fMassError = massError; }
74 void SetMom(Double_t px, Double_t py, Double_t pz, Double_t e);
75 void SetMom(const FourVector &p)
76 { fMomentum = p; ClearMom(); ClearPos(); }
77 void SetNdof(UShort_t ndof) { fNdof = ndof; }
78 void SetPriVertex(const Vertex *v) { fPriVtx = v; ClearPos(); }
79 using TObject::Error;
80
81 protected:
82 void ClearPos() const { fCachePosFlag.ClearCache(); }
83 Double_t GetCharge() const;
84 void GetMom() const;
85 void GetPos() const;
86
87 UInt_t fAbsPdgId; //absolute value of pid code
88 Double32_t fChi2; //[0,0,12]chi-squared of fit
89 UShort_t fNdof; //degrees of freedom for fit
90 Double32_t fMassError; //[0,0,14]fitted mass error
91 Double32_t fLxy; //[0,0,14]fitted lxy (decay length)
92 Double32_t fLxyError; //[0,0,14]fitted lxy error
93 Double32_t fDxy; //[0,0,14]fitted impact parameter
94 Double32_t fDxyError; //[0,0,14]fitted impact parameter error
95 Double32_t fLz; //[0,0,14]fitted lz (decay length)
96 Double32_t fLzError; //[0,0,14]fitted lz error
97 Vect4M fMomentum; //momentum fourvector
98 RefArray<DaughterData> fDaughterData; //momentum of daughters at vertex
99 Ref<Vertex> fPriVtx; //reference to primary vertex
100 mutable CacheFlag fCachePosFlag; //||cache validity flag for position
101 mutable ThreeVector fCachedPos; //!cached momentum vector (filled by derived classes)
102
103 ClassDef(DecayParticle, 1) // Decay particle class
104 };
105 }
106
107 //--------------------------------------------------------------------------------------------------
108 inline Double_t mithep::DecayParticle::GetCharge() const
109 {
110 // Return sum of charge of daughter particles.
111
112 Double_t charge = 0;
113 for (UInt_t i=0; i<NDaughters(); ++i)
114 charge += DaughterDat(i)->Charge();
115
116 return charge;
117 }
118
119 //--------------------------------------------------------------------------------------------------
120 inline void mithep::DecayParticle::GetMom() const
121 {
122 // Get momentum values from stored values.
123
124 fCachedMom.SetCoordinates(fMomentum.Pt(), fMomentum.Eta(), fMomentum.Phi(), fMomentum.M());
125 }
126
127 //--------------------------------------------------------------------------------------------------
128 inline TParticlePDG *mithep::DecayParticle::ParticlePdgEntry() const
129 {
130 // Return entry to pdg database for the particle.
131
132 return TDatabasePDG::Instance()->GetParticle(fAbsPdgId);
133 }
134
135 //--------------------------------------------------------------------------------------------------
136 inline void mithep::DecayParticle::SetMom(Double_t px, Double_t py, Double_t pz, Double_t e)
137 {
138 // Set four vector.
139
140 fMomentum.SetXYZT(px,py,pz,e);
141 ClearMom();
142 ClearPos();
143 }
144
145 //--------------------------------------------------------------------------------------------------
146 inline const mithep::ThreeVector &mithep::DecayParticle::Position() const
147 {
148 // Return cached momentum value.
149
150 if (!fCachePosFlag.IsValid()) {
151 GetPos();
152 fCachePosFlag.SetValid();
153 }
154
155 return fCachedPos;
156 }
157
158 //--------------------------------------------------------------------------------------------------
159 inline void mithep::DecayParticle::GetPos() const
160 {
161 // Return absolute position of decay.
162
163 const mithep::Vertex *pv = PriVertex();
164
165 if (pv)
166 fCachedPos = pv->Position() + RelativePosition();
167 else
168 fCachedPos = RelativePosition();
169 }
170
171 //--------------------------------------------------------------------------------------------------
172 inline const mithep::ThreeVector mithep::DecayParticle::RelativePosition() const
173 {
174 // Compute the position vector of the decay vertex relative to the primary vertex.
175
176 mithep::ThreeVector dz(0,0,fLz*TMath::Abs(Pz())/Pz());
177 mithep::ThreeVector momPerp(Px(),Py(),0);
178 mithep::ThreeVector zHat(0,0,1.0);
179 mithep::ThreeVector dxy = -momPerp.Cross(zHat)*fDxy/momPerp.R();
180 mithep::ThreeVector dlxy = momPerp*fLxy/momPerp.R();
181 return (dxy+dlxy+dz);
182 }
183 #endif