ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/DecayParticle.h
Revision: 1.24
Committed: Thu Feb 26 17:06:24 2009 UTC (16 years, 2 months ago) by bendavid
Content type: text/plain
Branch: MAIN
Changes since 1.23: +34 -14 lines
Log Message:
Incorporate updated RefArray (no size template argument anymore) and add necessary caches and cache clear calls

File Contents

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