ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/Track.h
Revision: 1.53
Committed: Thu Jul 1 15:05:15 2010 UTC (14 years, 10 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_025c_branch2, Mit_025c_branch1, Mit_025c_branch0, Mit_025d, 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, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c
Branch point for: Mit_025c_branch
Changes since 1.52: +5 -5 lines
Log Message:
Fix bug in Track constructor

File Contents

# User Rev Content
1 loizides 1.1 //--------------------------------------------------------------------------------------------------
2 bendavid 1.53 // $Id: Track.h,v 1.52 2010/06/25 15:11:34 bendavid Exp $
3 loizides 1.1 //
4     // Track
5     //
6 bendavid 1.15 // We store the CMSSW track parameterization
7     // Parameters associated to the 5D curvilinear covariance matrix:
8     // (qoverp, lambda, phi, dxy, dsz)
9     // defined as:
10     // qoverp = q / abs(p) = signed inverse of momentum [1/GeV]
11     // lambda = pi/2 - polar angle at the given point
12     // phi = azimuth angle at the given point
13     // dxy = -vx*sin(phi) + vy*cos(phi) [cm]
14     // dsz = vz*cos(lambda) - (vx*cos(phi)+vy*sin(phi))*sin(lambda) [cm]
15 loizides 1.18 // (See http://cmslxr.fnal.gov/lxr/source/DataFormats/TrackReco/interface/TrackBase.h)
16 bendavid 1.15 //
17     // Format for fHits: (We do not use anything resembling reco::HitPattern from CMSSW because that
18     // data format requires 800 bits per track!)
19     // There is a one to one mapping between bits and tracker layers, where layers are enumerated
20     // seperately in the PXB, PXF, TIB, TID, TOB, TEC and r-phi and stereo modules are treated as
21     // seperate layers in those detectors which have them
22 bendavid 1.25 // (TIB L1,L2, TID L1,L2,L3, TOB L1,L2, TEC L1,L2,L3,L4,L5,L6,L7,L8,L9).
23 bendavid 1.15 //
24     // A bit value of 1 indicates a hit in the corresponding layer, and 0 indicates no hit.
25     //
26     // Note that currently this only stores information about hits in the Tracker,
27 loizides 1.16 // but muon chamber information will likely be added as well.
28 bendavid 1.15 //
29     // Bit-Layer assignments (starting from bit 0):
30     // Bit 0: PXB L1
31     // Bit 1: PXB L2
32     // Bit 2: PXB L3
33     // Bit 3: PXF L1
34     // Bit 4: PXF L2
35     // Bit 5: TIB L1 r-phi
36     // Bit 6: TIB L1 stereo
37     // Bit 7: TIB L2 r-phi
38     // Bit 8: TIB L2 stereo
39     // Bit 9: TIB L3 r-phi
40     // Bit 10: TIB L4 r-phi
41 loizides 1.16 // Bit 11: TID L1 r-phi
42 bendavid 1.15 // Bit 12: TID L1 stereo
43 loizides 1.16 // Bit 13: TID L2 r-phi
44 bendavid 1.15 // Bit 14: TID L2 stereo
45 loizides 1.16 // Bit 15: TID L3 r-phi
46 bendavid 1.23 // Bit 16: TID L3 stereo
47     // Bit 17: TOB L1 r-phi
48     // Bit 18: TOB L1 stereo
49     // Bit 19: TOB L2 r-phi
50     // Bit 20: TOB L2 stereo
51     // Bit 21: TOB L3 r-phi
52     // Bit 22: TOB L4 r-phi
53     // Bit 23: TOB L5 r-phi
54     // Bit 24: TOB L6 r-phi
55     // Bit 25: TEC L1 r-phi
56     // Bit 26: TEC L1 stereo
57     // Bit 27: TEC L2 r-phi
58     // Bit 28: TEC L2 stereo
59     // Bit 29: TEC L3 r-phi
60     // Bit 30: TEC L3 stereo
61     // Bit 31: TEC L4 r-phi
62     // Bit 32: TEC L4 stereo
63     // Bit 33: TEC L5 r-phi
64     // Bit 34: TEC L5 stereo
65     // Bit 35: TEC L6 r-phi
66     // Bit 36: TEC L6 stereo
67     // Bit 37: TEC L7 r-phi
68     // Bit 38: TEC L7 stereo
69     // Bit 39: TEC L8 r-phi
70     // Bit 40: TEC L8 stereo
71     // Bit 41: TEC L9 r-phi
72     // Bit 42: TEC L9 stereo
73 loizides 1.1 //
74 loizides 1.5 // Authors: C.Loizides, J.Bendavid, C.Paus
75 loizides 1.1 //--------------------------------------------------------------------------------------------------
76 loizides 1.7
77 loizides 1.17 #ifndef MITANA_DATATREE_TRACK_H
78     #define MITANA_DATATREE_TRACK_H
79 paus 1.6
80 loizides 1.36 #include "MitAna/DataCont/interface/BitMask.h"
81 bendavid 1.47 #include "MitAna/DataTree/interface/TrackQuality.h"
82 loizides 1.35 #include "MitAna/DataTree/interface/BaseVertex.h"
83 paus 1.6 #include "MitAna/DataTree/interface/DataObject.h"
84 loizides 1.35 #include "MitAna/DataTree/interface/MCParticle.h"
85 bendavid 1.27 #include "MitAna/DataTree/interface/SuperCluster.h"
86 loizides 1.1
87     namespace mithep
88     {
89     class Track : public DataObject
90     {
91     public:
92 loizides 1.18 enum EHitLayer {
93     PXB1,
94     PXB2,
95     PXB3,
96     PXF1,
97     PXF2,
98     TIB1,
99     TIB1S,
100     TIB2,
101     TIB2S,
102     TIB3,
103     TIB4,
104     TID1,
105     TID1S,
106     TID2,
107     TID2S,
108     TID3,
109 bendavid 1.23 TID3S,
110 loizides 1.18 TOB1,
111     TOB1S,
112     TOB2,
113     TOB2S,
114     TOB3,
115     TOB4,
116     TOB5,
117     TOB6,
118     TEC1,
119     TEC1S,
120     TEC2,
121     TEC2S,
122     TEC3,
123 bendavid 1.23 TEC3S,
124 loizides 1.18 TEC4,
125 bendavid 1.23 TEC4S,
126 loizides 1.18 TEC5,
127     TEC5S,
128     TEC6,
129 bendavid 1.23 TEC6S,
130 loizides 1.18 TEC7,
131 bendavid 1.23 TEC7S,
132 loizides 1.18 TEC8,
133 bendavid 1.23 TEC8S,
134     TEC9,
135     TEC9S
136 loizides 1.18 };
137    
138 loizides 1.44 enum ETrackAlgorithm { //taken from DataFormats/TrackReco/interface/TrackBase.h
139 bendavid 1.43 undefAlgorithm=0,
140     ctf=1,
141     rs=2,
142     cosmics=3,
143     iter0=4,
144     iter1=5,
145     iter2=6,
146     iter3=7,
147     iter4=8,
148     iter5=9,
149     iter6=10,
150     iter7=11,
151     iter8=12,
152     iter9=13,
153     iter10=14,
154     outInEcalSeededConv=15,
155     inOutEcalSeededConv=16,
156     nuclInter=17,
157     standAloneMuon=18,
158     globalMuon=19,
159     cosmicStandAloneMuon=20,
160     cosmicGlobalMuon=21,
161     iter1LargeD0=22,
162     iter2LargeD0=23,
163     iter3LargeD0=24,
164     iter4LargeD0=25,
165     iter5LargeD0=26,
166     bTagGhostTracks=27,
167     beamhalo=28,
168     algoSize=29
169     };
170    
171    
172 bendavid 1.52 Track() : fNHits(0), fNPixelHits(0), fNMissingHits(0), fNExpectedHitsInner(0), fNExpectedHitsOuter(0),
173     fAlgo(undefAlgorithm), fIsGsf(0), fPtErr(0), fQOverP(0), fQOverPErr(0),
174 bendavid 1.43 fLambda(0), fLambdaErr(0), fPhi0(0), fPhi0Err(0),
175     fDxy(0), fDxyErr(0), fDsz(0), fDszErr(0), fChi2(0),
176     fNdof(0), fEtaEcal(0), fPhiEcal(0) {}
177 bendavid 1.15 Track(Double_t qOverP, Double_t lambda, Double_t phi0, Double_t dxy, Double_t dsz) :
178 bendavid 1.53 fNHits(0), fNPixelHits(0), fNMissingHits(0), fNExpectedHitsInner(0), fNExpectedHitsOuter(0),
179     fAlgo(undefAlgorithm), fIsGsf(0), fPtErr(0), fQOverP(qOverP), fQOverPErr(0),
180     fLambda(lambda), fLambdaErr(0), fPhi0(phi0), fPhi0Err(0),
181     fDxy(dxy), fDxyErr(0), fDsz(dsz), fDszErr(0), fChi2(0),
182 bendavid 1.43 fNdof(0), fEtaEcal(0), fPhiEcal(0) {}
183 loizides 1.1 ~Track() {}
184    
185 bendavid 1.43 ETrackAlgorithm Algo() const { return fAlgo; }
186 loizides 1.34 Int_t Charge() const { return (fQOverP>0) ? 1 : -1; }
187     Double_t Chi2() const { return fChi2; }
188     void ClearHit(EHitLayer l) { fHits.ClearBit(l); }
189     Double_t D0() const { return -fDxy; }
190     Double_t D0Corrected(const BaseVertex &iVertex) const;
191 bendavid 1.49 Double_t DzCorrected(const BaseVertex &iVertex) const;
192 loizides 1.34 Double_t D0Err() const { return fDxyErr; }
193     Double_t Dsz() const { return fDsz; }
194     Double_t DszErr() const { return fDszErr; }
195     Double_t Dxy() const { return fDxy; }
196     Double_t DxyErr() const { return fDxyErr; }
197     Double_t E(Double_t m) const { return TMath::Sqrt(E2(m)); }
198     Double_t E2(Double_t m) const { return P2()+m*m; }
199     Double_t Eta() const { return Mom().Eta(); }
200     Double_t EtaEcal() const { return fEtaEcal; }
201     Bool_t Hit(EHitLayer l) const { return fHits.TestBit(l); }
202     const BitMask48 &Hits() const { return fHits; }
203 bendavid 1.48 const BitMask48 &MissingHits() const { return fMissingHits; }
204     const BitMask48 &ExpectedHitsInner() const { return fExpectedHitsInner; }
205     const BitMask48 &ExpectedHitsOuter() const { return fExpectedHitsOuter; }
206 bendavid 1.43 Bool_t IsGsf() const { return fIsGsf; }
207 loizides 1.34 Double_t Lambda() const { return fLambda; }
208     Double_t LambdaErr() const { return fLambdaErr; }
209     const MCParticle *MCPart() const { return fMCParticleRef.Obj(); }
210     const ThreeVectorC &Mom() const;
211 pharris 1.41 FourVectorM Mom4(Double_t m) const { return FourVectorM(Pt(),Eta(),Phi(),m); }
212 loizides 1.38 UShort_t Ndof() const { return fNdof; }
213 bendavid 1.52 UInt_t NHits() const { if (fNHits) return fNHits; else return fHits.NBitsSet(); }
214     UInt_t NMissingHits() const { if (fNMissingHits) return fNMissingHits; else return fMissingHits.NBitsSet(); }
215     UInt_t NExpectedHitsInner() const { if (fNExpectedHitsInner) return fNExpectedHitsInner; else return fExpectedHitsInner.NBitsSet(); }
216     UInt_t NExpectedHitsOuter() const { if (fNExpectedHitsOuter) return fNExpectedHitsOuter; else return fExpectedHitsOuter.NBitsSet(); }
217 loizides 1.34 UInt_t NStereoHits() const { return StereoHits().NBitsSet(); }
218 bendavid 1.52 UInt_t NPixelHits() const { if (fNPixelHits) return fNPixelHits; else return PixelHits().NBitsSet(); }
219 loizides 1.34 EObjType ObjType() const { return kTrack; }
220     Double_t P2() const { return 1./fQOverP/fQOverP; }
221     Double_t P() const { return TMath::Abs(1./fQOverP); }
222     Double_t Phi() const { return fPhi0; }
223     Double_t Phi0() const { return fPhi0; }
224     Double_t Phi0Err() const { return fPhi0Err; }
225     Double_t PhiEcal() const { return fPhiEcal; }
226     Double_t Prob() const { return TMath::Prob(fChi2,fNdof); }
227     Double_t Pt() const { return Mom().Rho(); }
228 bendavid 1.50 Double_t PtErr() const { return fPtErr; }
229 loizides 1.34 Double_t Px() const { return Mom().X(); }
230     Double_t Py() const { return Mom().Y(); }
231     Double_t Pz() const { return Mom().Z(); }
232     Double_t QOverP() const { return fQOverP; }
233     Double_t QOverPErr() const { return fQOverPErr; }
234 loizides 1.37 Double_t RChi2() const { return fChi2/(Double_t)fNdof; }
235 loizides 1.34 Double_t Theta() const { return (TMath::PiOver2() - fLambda); }
236     const SuperCluster *SCluster() const { return fSuperClusterRef.Obj(); }
237 bendavid 1.45 const BitMask48 PixelHits() const { return (fHits & PixelLayers()); }
238 bendavid 1.47 const TrackQuality &Quality() const { return fQuality; }
239     TrackQuality &Quality() { return fQuality; }
240 loizides 1.34 const BitMask48 StereoHits() const { return (fHits & StereoLayers()); }
241 bendavid 1.43 void SetAlgo(ETrackAlgorithm e) { fAlgo = e; }
242 loizides 1.34 void SetChi2(Double_t chi2) { fChi2 = chi2; }
243     void SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
244     Double_t dXyErr, Double_t dSzErr);
245     void SetEtaEcal(Double_t eta) { fEtaEcal = eta; }
246     void SetHelix (Double_t qOverP, Double_t lambda, Double_t phi0,
247     Double_t dXy, Double_t dSz);
248 bendavid 1.50 void SetPtErr(Double_t ptErr) { fPtErr = ptErr; }
249 loizides 1.34 void SetHit(EHitLayer l) { fHits.SetBit(l); }
250     void SetHits(const BitMask48 &hits) { fHits = hits; }
251 bendavid 1.48 void SetMissingHits(const BitMask48 &h) { fMissingHits = h; }
252     void SetExpectedHitsInner(const BitMask48 &h) { fExpectedHitsInner = h; }
253 bendavid 1.51 void SetExpectedHitsOuter(const BitMask48 &h) { fExpectedHitsOuter = h; }
254 bendavid 1.43 void SetIsGsf(Bool_t b) { fIsGsf = b; }
255 bendavid 1.52 void SetNHits(Byte_t n) { fNHits = n; }
256     void SetNPixelHits(Byte_t n) { fNPixelHits = n; }
257     void SetNMissingHits(Byte_t n) { fNMissingHits = n; }
258     void SetNExpectedHitsInner(Byte_t n) { fNExpectedHitsInner = n; }
259     void SetNExpectedHitsOuter(Byte_t n) { fNExpectedHitsOuter = n; }
260 loizides 1.38 void SetNdof(UShort_t dof) { fNdof = dof; }
261 loizides 1.34 void SetMCPart(const MCParticle *p) { fMCParticleRef = p; }
262     void SetPhiEcal(Double_t phi) { fPhiEcal = phi; }
263     void SetSCluster(const SuperCluster* sc) { fSuperClusterRef = sc; }
264 bendavid 1.49 Double_t X0() const { return D0()*TMath::Sin(Phi()); }
265     Double_t Y0() const { return -D0()*TMath::Cos(Phi()); }
266 loizides 1.37 Double_t Z0() const { return fDsz/TMath::Cos(fLambda); }
267 loizides 1.30
268 bendavid 1.45
269     static const BitMask48 StereoLayers();
270     static const BitMask48 PixelLayers();
271 loizides 1.18
272 paus 1.4 protected:
273 loizides 1.34 void ClearMom() const { fCacheMomFlag.ClearCache(); }
274     void GetMom() const;
275    
276     BitMask48 fHits; //storage for mostly hit information
277 bendavid 1.48 BitMask48 fMissingHits; //missing hits in crossed good modules
278     BitMask48 fExpectedHitsInner; //expected hits before first hit
279     BitMask48 fExpectedHitsOuter; //expected hits after last hit
280 bendavid 1.52 Byte_t fNHits; //number of valid hits
281     Byte_t fNPixelHits; //number of valid pixel hits
282     Byte_t fNMissingHits; //number of missing hits
283     Byte_t fNExpectedHitsInner; //number of expected inner hits
284     Byte_t fNExpectedHitsOuter; //number of expected outer hits
285 bendavid 1.43 ETrackAlgorithm fAlgo; //track algorithm
286 bendavid 1.47 TrackQuality fQuality; //track quality
287 bendavid 1.43 Bool_t fIsGsf; //flag to identify gsf tracks
288 bendavid 1.50 Double32_t fPtErr; //[0,0,12]pt uncertainty
289 loizides 1.38 Double32_t fQOverP; //[0,0,14]signed inverse of momentum [1/GeV]
290     Double32_t fQOverPErr; //[0,0,14]error of q/p
291     Double32_t fLambda; //[0,0,14]pi/2 - polar angle at the reference point
292     Double32_t fLambdaErr; //[0,0,14]error of lambda
293     Double32_t fPhi0; //[0,0,14]azimuth angle at the given point
294     Double32_t fPhi0Err; //[0,0,14]error of azimuthal angle
295     Double32_t fDxy; //[0,0,14]trans. distance to reference point [cm]
296     Double32_t fDxyErr; //[0,0,14]error of transverse distance
297     Double32_t fDsz; //[0,0,14]long. distance to reference point [cm]
298     Double32_t fDszErr; //[0,0,14]error of longitudinal distance
299     Double32_t fChi2; //[0,0,12]chi squared of track fit
300     UShort_t fNdof; //degree-of-freedom of track fit
301 loizides 1.40 Double32_t fEtaEcal; //[0,0,12]eta of track at Ecal front face
302     Double32_t fPhiEcal; //[0,0,12]phi of track at Ecal front face
303 loizides 1.34 Ref<SuperCluster> fSuperClusterRef; //superCluster crossed by track
304     Ref<MCParticle> fMCParticleRef; //reference to sim particle (for monte carlo)
305     mutable CacheFlag fCacheMomFlag; //||cache validity flag for momentum
306     mutable ThreeVectorC fCachedMom; //!cached momentum vector
307 loizides 1.5
308 bendavid 1.52 ClassDef(Track, 6) // Track class
309 loizides 1.1 };
310 loizides 1.5 }
311 loizides 1.1
312 loizides 1.5 //--------------------------------------------------------------------------------------------------
313 loizides 1.34 inline void mithep::Track::GetMom() const
314     {
315     // Compute three momentum.
316    
317     Double_t pt = TMath::Abs(TMath::Cos(fLambda)/fQOverP);
318     Double_t eta = - TMath::Log(TMath::Tan(Theta()/2.));
319     fCachedMom.SetCoordinates(pt,eta,Phi());
320     }
321    
322     //--------------------------------------------------------------------------------------------------
323     inline const mithep::ThreeVectorC &mithep::Track::Mom() const
324     {
325     // Return cached momentum value.
326    
327     if (!fCacheMomFlag.IsValid()) {
328     GetMom();
329     fCacheMomFlag.SetValid();
330     }
331     return fCachedMom;
332     }
333    
334     //--------------------------------------------------------------------------------------------------
335     inline Double_t mithep::Track::D0Corrected(const BaseVertex &iVertex) const
336 bendavid 1.28 {
337 loizides 1.30 // Return corrected d0 with respect to primary vertex or beamspot.
338 bendavid 1.28
339     Double_t lXM = -TMath::Sin(Phi()) * D0();
340     Double_t lYM = TMath::Cos(Phi()) * D0();
341 loizides 1.34 Double_t lDX = (lXM + iVertex.X());
342     Double_t lDY = (lYM + iVertex.Y());
343 bendavid 1.28 Double_t d0Corr = (Px()*lDY - Py()*lDX)/Pt();
344    
345     return d0Corr;
346     }
347    
348     //--------------------------------------------------------------------------------------------------
349 bendavid 1.49 inline Double_t mithep::Track::DzCorrected(const mithep::BaseVertex &iVertex) const
350     {
351     // Compute Dxy with respect to a given position
352     mithep::ThreeVector momPerp(Px(),Py(),0);
353     mithep::ThreeVector posPerp(X0()-iVertex.X(),Y0()-iVertex.Y(),0);
354     return Z0() - iVertex.Z() - posPerp.Dot(momPerp)/Pt() * (Pz()/Pt());
355    
356     }
357    
358     //--------------------------------------------------------------------------------------------------
359 loizides 1.44 inline void mithep::Track::SetHelix(Double_t qOverP, Double_t lambda, Double_t phi0,
360     Double_t dxy, Double_t dsz)
361 loizides 1.5 {
362 loizides 1.13 // Set helix parameters.
363    
364 bendavid 1.15 fQOverP = qOverP;
365     fLambda = lambda;
366     fPhi0 = phi0;
367     fDxy = dxy;
368     fDsz = dsz;
369 loizides 1.34 ClearMom();
370 paus 1.4 }
371    
372 loizides 1.5 //--------------------------------------------------------------------------------------------------
373 loizides 1.44 inline void mithep::Track::SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
374     Double_t dxyErr, Double_t dszErr)
375 loizides 1.5 {
376 loizides 1.13 // Set helix errors.
377    
378 bendavid 1.15 fQOverPErr = qOverPErr;
379     fLambdaErr = lambdaErr;
380     fPhi0Err = phi0Err;
381     fDxyErr = dxyErr;
382     fDszErr = dszErr;
383 paus 1.4 }
384 loizides 1.13
385     //--------------------------------------------------------------------------------------------------
386 loizides 1.44 inline const mithep::BitMask48 mithep::Track::StereoLayers()
387 bendavid 1.26 {
388 loizides 1.35 // Build and return BitMask of stereo layers.
389 bendavid 1.26
390     mithep::BitMask48 stereoLayers;
391     stereoLayers.SetBit(mithep::Track::TIB1S);
392     stereoLayers.SetBit(mithep::Track::TIB2S);
393     stereoLayers.SetBit(mithep::Track::TID1S);
394     stereoLayers.SetBit(mithep::Track::TID2S);
395     stereoLayers.SetBit(mithep::Track::TID3S);
396     stereoLayers.SetBit(mithep::Track::TOB1S);
397     stereoLayers.SetBit(mithep::Track::TOB2S);
398     stereoLayers.SetBit(mithep::Track::TEC1S);
399     stereoLayers.SetBit(mithep::Track::TEC2S);
400     stereoLayers.SetBit(mithep::Track::TEC3S);
401     stereoLayers.SetBit(mithep::Track::TEC4S);
402     stereoLayers.SetBit(mithep::Track::TEC5S);
403     stereoLayers.SetBit(mithep::Track::TEC6S);
404     stereoLayers.SetBit(mithep::Track::TEC7S);
405     stereoLayers.SetBit(mithep::Track::TEC8S);
406     stereoLayers.SetBit(mithep::Track::TEC9S);
407     return stereoLayers;
408     }
409 bendavid 1.45
410     //--------------------------------------------------------------------------------------------------
411     inline const mithep::BitMask48 mithep::Track::PixelLayers()
412     {
413     // Build and return BitMask of stereo layers.
414    
415     mithep::BitMask48 pixelLayers;
416     pixelLayers.SetBit(mithep::Track::PXB1);
417     pixelLayers.SetBit(mithep::Track::PXB2);
418     pixelLayers.SetBit(mithep::Track::PXB3);
419     pixelLayers.SetBit(mithep::Track::PXF1);
420     pixelLayers.SetBit(mithep::Track::PXF2);
421     return pixelLayers;
422     }
423 loizides 1.5 #endif