ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/DecayParticle.h
Revision: 1.28
Committed: Tue Dec 15 23:27:18 2009 UTC (15 years, 4 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_013c, Mit_013b, Mit_013a, Mit_013, Mit_013pre1, Mit_012i, Mit_012h, Mit_012g
Changes since 1.27: +8 -2 lines
Log Message:
Add shared layer mask

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: DecayParticle.h,v 1.27 2009/07/13 11:00:28 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 Bool_t SharedLayer(Track::EHitLayer l) const { return fSharedLayers.TestBit(l); }
66 const BitMask48 &SharedLayers() const { return fSharedLayers; }
67 UInt_t NSharedHits() const { return fSharedLayers.NBitsSet(); }
68 void SetAbsPdgId(UInt_t apid) { fAbsPdgId=apid; }
69 void SetChi2(Double_t chi2) { fChi2 = chi2; }
70 void SetDxy(Double_t dxy) { fDxy = dxy; ClearPos(); }
71 void SetDxyError(Double_t dxyError) { fDxyError = dxyError; }
72 void SetLxy(Double_t lxy) { fLxy = lxy; ClearPos(); }
73 void SetLxyError(Double_t lxyError) { fLxyError = lxyError; }
74 void SetLz(Double_t lz) { fLz = lz; ClearPos(); }
75 void SetLzError(Double_t lzError) { fLzError = lzError; }
76 void SetMassError(Double_t massError) { fMassError = massError; }
77 void SetMom(Double_t px, Double_t py, Double_t pz, Double_t e);
78 void SetMom(const FourVector &p)
79 { fMomentum = p; ClearMom(); ClearPos(); }
80 void SetNdof(UShort_t ndof) { fNdof = ndof; }
81 void SetPriVertex(const Vertex *v) { fPriVtx = v; ClearPos(); }
82 void SetSharedLayer(Track::EHitLayer l) { fSharedLayers.SetBit(l); }
83 void SetSharedLayers(const BitMask48 &layers) { fSharedLayers = layers; }
84 using TObject::Error;
85
86 protected:
87 void ClearPos() const { fCachePosFlag.ClearCache(); }
88 Double_t GetCharge() const;
89 void GetMom() const;
90 void GetPos() const;
91
92 UInt_t fAbsPdgId; //absolute value of pid code
93 Double32_t fChi2; //[0,0,12]chi-squared of fit
94 UShort_t fNdof; //degrees of freedom for fit
95 Double32_t fMassError; //[0,0,14]fitted mass error
96 Double32_t fLxy; //[0,0,14]fitted lxy (decay length)
97 Double32_t fLxyError; //[0,0,14]fitted lxy error
98 Double32_t fDxy; //[0,0,14]fitted impact parameter
99 Double32_t fDxyError; //[0,0,14]fitted impact parameter error
100 Double32_t fLz; //[0,0,14]fitted lz (decay length)
101 Double32_t fLzError; //[0,0,14]fitted lz error
102 Vect4M fMomentum; //momentum fourvector
103 RefArray<DaughterData> fDaughterData; //momentum of daughters at vertex
104 Ref<Vertex> fPriVtx; //reference to primary vertex
105 BitMask48 fSharedLayers; //layer mask for shared hits from daughter particles
106 mutable CacheFlag fCachePosFlag; //||cache validity flag for position
107 mutable ThreeVector fCachedPos; //!cached momentum vector (filled by derived classes)
108
109 ClassDef(DecayParticle, 2) // Decay particle class
110 };
111 }
112
113 //--------------------------------------------------------------------------------------------------
114 inline Double_t mithep::DecayParticle::GetCharge() const
115 {
116 // Return sum of charge of daughter particles.
117
118 Double_t charge = 0;
119 for (UInt_t i=0; i<NDaughters(); ++i)
120 charge += DaughterDat(i)->Charge();
121
122 return charge;
123 }
124
125 //--------------------------------------------------------------------------------------------------
126 inline void mithep::DecayParticle::GetMom() const
127 {
128 // Get momentum values from stored values.
129
130 fCachedMom.SetCoordinates(fMomentum.Pt(), fMomentum.Eta(), fMomentum.Phi(), fMomentum.M());
131 }
132
133 //--------------------------------------------------------------------------------------------------
134 inline TParticlePDG *mithep::DecayParticle::ParticlePdgEntry() const
135 {
136 // Return entry to pdg database for the particle.
137
138 return TDatabasePDG::Instance()->GetParticle(fAbsPdgId);
139 }
140
141 //--------------------------------------------------------------------------------------------------
142 inline void mithep::DecayParticle::SetMom(Double_t px, Double_t py, Double_t pz, Double_t e)
143 {
144 // Set four vector.
145
146 fMomentum.SetXYZT(px,py,pz,e);
147 ClearMom();
148 ClearPos();
149 }
150
151 //--------------------------------------------------------------------------------------------------
152 inline const mithep::ThreeVector &mithep::DecayParticle::Position() const
153 {
154 // Return cached momentum value.
155
156 if (!fCachePosFlag.IsValid()) {
157 GetPos();
158 fCachePosFlag.SetValid();
159 }
160
161 return fCachedPos;
162 }
163
164 //--------------------------------------------------------------------------------------------------
165 inline void mithep::DecayParticle::GetPos() const
166 {
167 // Return absolute position of decay.
168
169 const mithep::Vertex *pv = PriVertex();
170
171 if (pv)
172 fCachedPos = pv->Position() + RelativePosition();
173 else
174 fCachedPos = RelativePosition();
175 }
176
177 //--------------------------------------------------------------------------------------------------
178 inline const mithep::ThreeVector mithep::DecayParticle::RelativePosition() const
179 {
180 // Compute the position vector of the decay vertex relative to the primary vertex.
181
182 mithep::ThreeVector dz(0,0,fLz*TMath::Abs(Pz())/Pz());
183 mithep::ThreeVector momPerp(Px(),Py(),0);
184 mithep::ThreeVector zHat(0,0,1.0);
185 mithep::ThreeVector dxy = -momPerp.Cross(zHat)*fDxy/momPerp.R();
186 mithep::ThreeVector dlxy = momPerp*fLxy/momPerp.R();
187 return (dxy+dlxy+dz);
188 }
189 #endif