ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/Track.h
(Generate patch)

Comparing UserCode/MitAna/DataTree/interface/Track.h (file contents):
Revision 1.7 by loizides, Wed Jun 18 19:08:14 2008 UTC vs.
Revision 1.44 by loizides, Mon Jul 20 04:57:27 2009 UTC

# Line 3 | Line 3
3   //
4   // Track
5   //
6 < // This will be re-written :-)
6 > // 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 > // (See http://cmslxr.fnal.gov/lxr/source/DataFormats/TrackReco/interface/TrackBase.h)
16 > //
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 > // (TIB L1,L2, TID L1,L2,L3, TOB L1,L2, TEC L1,L2,L3,L4,L5,L6,L7,L8,L9).
23 > //
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 > // but muon chamber information will likely be added as well.
28 > //
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 > // Bit 11: TID L1 r-phi
42 > // Bit 12: TID L1 stereo
43 > // Bit 13: TID L2 r-phi
44 > // Bit 14: TID L2 stereo
45 > // Bit 15: TID L3 r-phi
46 > // 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   //
74   // Authors: C.Loizides, J.Bendavid, C.Paus
75   //--------------------------------------------------------------------------------------------------
76  
77 < #ifndef DATATREE_TRACK_H
78 < #define DATATREE_TRACK_H
77 > #ifndef MITANA_DATATREE_TRACK_H
78 > #define MITANA_DATATREE_TRACK_H
79  
80 + #include "MitAna/DataCont/interface/BitMask.h"
81 + #include "MitAna/DataTree/interface/BaseVertex.h"
82   #include "MitAna/DataTree/interface/DataObject.h"
83 + #include "MitAna/DataTree/interface/MCParticle.h"
84 + #include "MitAna/DataTree/interface/SuperCluster.h"
85  
86   namespace mithep
87   {
88    class Track : public DataObject
89    {
90      public:
91 <      Track() {}
92 <      Track(Double_t phi, Double_t d0, Double_t pt, Double_t dz, Double_t theta) :
93 <        fPhi(phi), fD0(d0), fPt(pt), fDz(dz), fTheta(theta) {}
91 >      enum EHitLayer {
92 >        PXB1,
93 >        PXB2,
94 >        PXB3,
95 >        PXF1,
96 >        PXF2,
97 >        TIB1,
98 >        TIB1S,
99 >        TIB2,
100 >        TIB2S,
101 >        TIB3,
102 >        TIB4,
103 >        TID1,
104 >        TID1S,
105 >        TID2,
106 >        TID2S,
107 >        TID3,
108 >        TID3S,
109 >        TOB1,
110 >        TOB1S,
111 >        TOB2,
112 >        TOB2S,
113 >        TOB3,
114 >        TOB4,
115 >        TOB5,
116 >        TOB6,
117 >        TEC1,
118 >        TEC1S,
119 >        TEC2,
120 >        TEC2S,
121 >        TEC3,
122 >        TEC3S,
123 >        TEC4,
124 >        TEC4S,
125 >        TEC5,
126 >        TEC5S,
127 >        TEC6,
128 >        TEC6S,
129 >        TEC7,
130 >        TEC7S,
131 >        TEC8,
132 >        TEC8S,
133 >        TEC9,
134 >        TEC9S
135 >      };
136 >
137 >      enum ETrackAlgorithm { //taken from DataFormats/TrackReco/interface/TrackBase.h
138 >        undefAlgorithm=0,
139 >        ctf=1,
140 >        rs=2,
141 >        cosmics=3,
142 >        iter0=4,
143 >        iter1=5,
144 >        iter2=6,
145 >        iter3=7,
146 >        iter4=8,
147 >        iter5=9,
148 >        iter6=10,
149 >        iter7=11,
150 >        iter8=12,
151 >        iter9=13,
152 >        iter10=14,
153 >        outInEcalSeededConv=15,
154 >        inOutEcalSeededConv=16,
155 >        nuclInter=17,
156 >        standAloneMuon=18,
157 >        globalMuon=19,
158 >        cosmicStandAloneMuon=20,
159 >        cosmicGlobalMuon=21,
160 >        iter1LargeD0=22,
161 >        iter2LargeD0=23,
162 >        iter3LargeD0=24,
163 >        iter4LargeD0=25,
164 >        iter5LargeD0=26,
165 >        bTagGhostTracks=27,
166 >        beamhalo=28,
167 >        algoSize=29
168 >      };
169 >
170 >
171 >      Track() : fAlgo(undefAlgorithm), fIsGsf(0), fQOverP(0), fQOverPErr(0),
172 >                fLambda(0), fLambdaErr(0), fPhi0(0), fPhi0Err(0),
173 >                fDxy(0), fDxyErr(0), fDsz(0), fDszErr(0), fChi2(0),
174 >                fNdof(0), fEtaEcal(0), fPhiEcal(0) {}
175 >      Track(Double_t qOverP, Double_t lambda, Double_t phi0, Double_t dxy, Double_t dsz) :
176 >                fAlgo(undefAlgorithm), fIsGsf(0), fQOverP(qOverP), fQOverPErr(0),
177 >                fLambda(lambda), fLambdaErr(0), fPhi0(phi0), fPhi0Err(0),
178 >                fDxy(dxy), fDxyErr(0), fDsz(dsz), fDszErr(0), fChi2(0),
179 >                fNdof(0), fEtaEcal(0), fPhiEcal(0) {}
180        ~Track() {}
181  
182 <      void      SetHelix (Double_t phi, Double_t d0, Double_t pt, Double_t dz, Double_t theta);
183 <      void      SetErrors(Double_t phiErr, Double_t d0Err, Double_t ptErr, Double_t dzErr,
184 <                          Double_t thetaErr);
185 <      
186 <      Double_t  Phi()      const { return fPhi; }
187 <      Double_t  D0()       const { return fD0; }
188 <      Double_t  Pt()       const { return fPt; }
189 <      Double_t  Dz()       const { return fDz; }
190 <      Double_t  Theta()    const { return fTheta; }
191 <      
192 <      Double_t  PhiErr()   const { return fPhiErr; }
193 <      Double_t  D0Err()    const { return fD0Err; }
194 <      Double_t  PtErr()    const { return fPtErr; }
195 <      Double_t  DzErr()    const { return fDzErr; }
196 <      Double_t  ThetaErr() const { return fThetaErr; }
197 <      
198 <      Int_t     Charge()   const { return fCharge; }
199 <      
200 <      void      SetCharge(Int_t charge) { fCharge = charge; }
201 <      
182 >      ETrackAlgorithm      Algo()           const { return fAlgo;                 }
183 >      Int_t                Charge()         const { return (fQOverP>0) ? 1 : -1;  }
184 >      Double_t             Chi2()           const { return fChi2;                 }
185 >      void                 ClearHit(EHitLayer l)  { fHits.ClearBit(l);            }
186 >      Double_t             D0()             const { return -fDxy;                 }
187 >      Double_t             D0Corrected(const BaseVertex &iVertex) const;
188 >      Double_t             D0Err()          const { return fDxyErr;               }
189 >      Double_t             Dsz()            const { return fDsz;                  }
190 >      Double_t             DszErr()         const { return fDszErr;               }
191 >      Double_t             Dxy()            const { return fDxy;                  }
192 >      Double_t             DxyErr()         const { return fDxyErr;               }
193 >      Double_t             E(Double_t m)    const { return TMath::Sqrt(E2(m));    }
194 >      Double_t             E2(Double_t m)   const { return P2()+m*m;              }
195 >      Double_t             Eta()            const { return Mom().Eta();           }
196 >      Double_t             EtaEcal()        const { return fEtaEcal;              }
197 >      Bool_t               Hit(EHitLayer l) const { return fHits.TestBit(l);      }
198 >      const BitMask48     &Hits()           const { return fHits;                 }
199 >      Bool_t               IsGsf()          const { return fIsGsf;                }
200 >      Double_t             Lambda()         const { return fLambda;               }
201 >      Double_t             LambdaErr()      const { return fLambdaErr;            }
202 >      const MCParticle    *MCPart()         const { return fMCParticleRef.Obj();  }
203 >      const ThreeVectorC  &Mom()            const;
204 >      FourVectorM          Mom4(Double_t m) const { return FourVectorM(Pt(),Eta(),Phi(),m); }
205 >      UShort_t             Ndof()           const { return fNdof;                              }
206 >      UInt_t               NHits()          const { return fHits.NBitsSet();                   }
207 >      UInt_t               NStereoHits()    const { return StereoHits().NBitsSet();            }
208 >      EObjType             ObjType()        const { return kTrack;                             }    
209 >      Double_t             P2()             const { return 1./fQOverP/fQOverP;                 }
210 >      Double_t             P()              const { return TMath::Abs(1./fQOverP);             }
211 >      Double_t             Phi()            const { return fPhi0;                              }
212 >      Double_t             Phi0()           const { return fPhi0;                              }
213 >      Double_t             Phi0Err()        const { return fPhi0Err;                           }
214 >      Double_t             PhiEcal()        const { return fPhiEcal;                           }
215 >      Double_t             Prob()           const { return TMath::Prob(fChi2,fNdof);           }
216 >      Double_t             Pt()             const { return Mom().Rho();                        }
217 >      Double_t             Px()             const { return Mom().X();                          }
218 >      Double_t             Py()             const { return Mom().Y();                          }
219 >      Double_t             Pz()             const { return Mom().Z();                          }
220 >      Double_t             QOverP()         const { return fQOverP;                            }
221 >      Double_t             QOverPErr()      const { return fQOverPErr;                         }
222 >      Double_t             RChi2()          const { return fChi2/(Double_t)fNdof; }
223 >      Double_t             Theta()          const { return (TMath::PiOver2() - fLambda);       }
224 >      const SuperCluster  *SCluster()       const { return fSuperClusterRef.Obj();             }
225 >      const BitMask48      StereoHits()     const { return (fHits & StereoLayers());           }
226 >      void                 SetAlgo(ETrackAlgorithm e)          { fAlgo = e;                    }
227 >      void                 SetChi2(Double_t chi2)              { fChi2 = chi2;                 }
228 >      void                 SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
229 >                                     Double_t dXyErr, Double_t dSzErr);
230 >      void                 SetEtaEcal(Double_t eta)            { fEtaEcal = eta;               }
231 >      void                 SetHelix (Double_t qOverP, Double_t lambda, Double_t phi0,
232 >                                     Double_t dXy, Double_t dSz);
233 >      void                 SetHit(EHitLayer l)                 { fHits.SetBit(l);              }
234 >      void                 SetHits(const BitMask48 &hits)      { fHits = hits;                 }
235 >      void                 SetIsGsf(Bool_t b)                  { fIsGsf = b;                   }
236 >      void                 SetNdof(UShort_t dof)               { fNdof = dof;                  }
237 >      void                 SetMCPart(const MCParticle *p)      { fMCParticleRef = p;           }
238 >      void                 SetPhiEcal(Double_t phi)            { fPhiEcal = phi;               }
239 >      void                 SetSCluster(const SuperCluster* sc) { fSuperClusterRef = sc;        }
240 >      Double_t             Z0()             const { return fDsz/TMath::Cos(fLambda);           }
241 >
242 >      static
243 >      const BitMask48      StereoLayers();
244 >
245      protected:
246 <      Double_t fPhi;      // azimuthal angle
247 <      Double_t fD0;       // raw impact parameter
248 <      Double_t fPt;       // transverse momentum
249 <      Double_t fDz;       // z-displacement
250 <      Double_t fTheta;    // polar angle
251 <      Double_t fPhiErr;   // uncertainy on phi
252 <      Double_t fD0Err;    // uncertainty on D0
253 <      Double_t fPtErr;    // uncertainty on pt
254 <      Double_t fDzErr;    // uncertainty on dz
255 <      Double_t fThetaErr; // uncertainty on theta
256 <      Int_t    fCharge;   // electric charge of reconstructed track
246 >      void                 ClearMom()    const { fCacheMomFlag.ClearCache(); }
247 >      void                 GetMom()      const;
248 >
249 >      BitMask48            fHits;                //storage for mostly hit information
250 >      ETrackAlgorithm      fAlgo;                //track algorithm
251 >      Bool_t               fIsGsf;               //flag to identify gsf tracks
252 >      Double32_t           fQOverP;              //[0,0,14]signed inverse of momentum [1/GeV]
253 >      Double32_t           fQOverPErr;           //[0,0,14]error of q/p
254 >      Double32_t           fLambda;              //[0,0,14]pi/2 - polar angle at the reference point
255 >      Double32_t           fLambdaErr;           //[0,0,14]error of lambda
256 >      Double32_t           fPhi0;                //[0,0,14]azimuth angle at the given point
257 >      Double32_t           fPhi0Err;             //[0,0,14]error of azimuthal angle
258 >      Double32_t           fDxy;                 //[0,0,14]trans. distance to reference point [cm]
259 >      Double32_t           fDxyErr;              //[0,0,14]error of transverse distance
260 >      Double32_t           fDsz;                 //[0,0,14]long. distance to reference point [cm]
261 >      Double32_t           fDszErr;              //[0,0,14]error of longitudinal distance
262 >      Double32_t           fChi2;                //[0,0,12]chi squared of track fit
263 >      UShort_t             fNdof;                //degree-of-freedom of track fit
264 >      Double32_t           fEtaEcal;             //[0,0,12]eta of track at Ecal front face
265 >      Double32_t           fPhiEcal;             //[0,0,12]phi of track at Ecal front face
266 >      Ref<SuperCluster>    fSuperClusterRef;     //superCluster crossed by track
267 >      Ref<MCParticle>      fMCParticleRef;       //reference to sim particle (for monte carlo)
268 >      mutable CacheFlag    fCacheMomFlag;        //||cache validity flag for momentum
269 >      mutable ThreeVectorC fCachedMom;           //!cached momentum vector
270                
271 <      ClassDef(Track, 1) // Track class
271 >    ClassDef(Track, 2) // Track class
272    };
273   }
274  
275   //--------------------------------------------------------------------------------------------------
276 < inline
277 < void mithep::Track::SetHelix(Double_t phi, Double_t d0, Double_t pt, Double_t dz, Double_t theta)
276 > inline void mithep::Track::GetMom() const
277 > {
278 >  // Compute three momentum.
279 >
280 >  Double_t pt = TMath::Abs(TMath::Cos(fLambda)/fQOverP);
281 >  Double_t eta = - TMath::Log(TMath::Tan(Theta()/2.));
282 >  fCachedMom.SetCoordinates(pt,eta,Phi());
283 > }
284 >
285 > //--------------------------------------------------------------------------------------------------
286 > inline const mithep::ThreeVectorC &mithep::Track::Mom() const
287   {
288 <  fPhi   = phi;
289 <  fD0    = d0;
290 <  fPt    = pt;
291 <  fDz    = dz;
292 <  fTheta = theta;
288 >  // Return cached momentum value.
289 >
290 >  if (!fCacheMomFlag.IsValid()) {
291 >    GetMom();
292 >    fCacheMomFlag.SetValid();
293 >  }
294 >  return fCachedMom;
295   }
296  
297   //--------------------------------------------------------------------------------------------------
298 < inline
299 < void mithep::Track::SetErrors(Double_t phiErr, Double_t d0Err, Double_t ptErr, Double_t dzErr,
300 <                              Double_t thetaErr)
301 < {
302 <  fPhiErr   = phiErr;
303 <  fD0Err    = d0Err;
304 <  fPtErr    = ptErr;
305 <  fDzErr    = dzErr;
306 <  fThetaErr = thetaErr;
298 > inline Double_t mithep::Track::D0Corrected(const BaseVertex &iVertex) const
299 > {
300 >  // Return corrected d0 with respect to primary vertex or beamspot.
301 >
302 >  Double_t lXM =  -TMath::Sin(Phi()) * D0();
303 >  Double_t lYM =   TMath::Cos(Phi()) * D0();
304 >  Double_t lDX = (lXM + iVertex.X());
305 >  Double_t lDY = (lYM + iVertex.Y());
306 >  Double_t d0Corr = (Px()*lDY - Py()*lDX)/Pt();
307 >  
308 >  return d0Corr;
309 > }
310 >
311 > //--------------------------------------------------------------------------------------------------
312 > inline void mithep::Track::SetHelix(Double_t qOverP, Double_t lambda, Double_t phi0,
313 >                                    Double_t dxy, Double_t dsz)
314 > {
315 >  // Set helix parameters.
316 >
317 >  fQOverP = qOverP;
318 >  fLambda = lambda;
319 >  fPhi0   = phi0;
320 >  fDxy    = dxy;
321 >  fDsz    = dsz;
322 >  ClearMom();
323 > }
324 >
325 > //--------------------------------------------------------------------------------------------------
326 > inline void mithep::Track::SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
327 >                                     Double_t dxyErr, Double_t dszErr)
328 > {
329 >  // Set helix errors.
330 >
331 >  fQOverPErr = qOverPErr;
332 >  fLambdaErr = lambdaErr;
333 >  fPhi0Err   = phi0Err;
334 >  fDxyErr    = dxyErr;
335 >  fDszErr    = dszErr;
336 > }
337 >
338 > //--------------------------------------------------------------------------------------------------
339 > inline const mithep::BitMask48 mithep::Track::StereoLayers()
340 > {
341 >  // Build and return BitMask of stereo layers.
342 >
343 >  mithep::BitMask48 stereoLayers;
344 >  stereoLayers.SetBit(mithep::Track::TIB1S);
345 >  stereoLayers.SetBit(mithep::Track::TIB2S);
346 >  stereoLayers.SetBit(mithep::Track::TID1S);
347 >  stereoLayers.SetBit(mithep::Track::TID2S);
348 >  stereoLayers.SetBit(mithep::Track::TID3S);
349 >  stereoLayers.SetBit(mithep::Track::TOB1S);
350 >  stereoLayers.SetBit(mithep::Track::TOB2S);
351 >  stereoLayers.SetBit(mithep::Track::TEC1S);
352 >  stereoLayers.SetBit(mithep::Track::TEC2S);
353 >  stereoLayers.SetBit(mithep::Track::TEC3S);
354 >  stereoLayers.SetBit(mithep::Track::TEC4S);
355 >  stereoLayers.SetBit(mithep::Track::TEC5S);
356 >  stereoLayers.SetBit(mithep::Track::TEC6S);
357 >  stereoLayers.SetBit(mithep::Track::TEC7S);
358 >  stereoLayers.SetBit(mithep::Track::TEC8S);
359 >  stereoLayers.SetBit(mithep::Track::TEC9S);
360 >  return stereoLayers;
361   }
362   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines