ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/DecayParticle.h
Revision: 1.29
Committed: Wed Mar 31 12:04:06 2010 UTC (15 years, 1 month ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, Mit_014a, Mit_014, Mit_014pre3, Mit_014pre2, Mit_014pre1, Mit_013d
Changes since 1.28: +41 -1 lines
Log Message:
Add corrected dxy and dz functions for DecayParticle

File Contents

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