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.11 by paus, Thu Jul 3 09:47:49 2008 UTC vs.
Revision 1.37 by loizides, Wed Mar 18 15:10:31 2009 UTC

# Line 3 | Line 3
3   //
4   // Track
5   //
6 < // This will/must 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/SimParticle.h"
83 > #include "MitAna/DataTree/interface/MCParticle.h"
84 > #include "MitAna/DataTree/interface/SuperCluster.h"
85   #include "MitAna/DataTree/interface/Types.h"
86  
87   namespace mithep
# Line 20 | Line 89 | namespace mithep
89    class Track : public DataObject
90    {
91      public:
92 <      Track() {}
93 <      Track(Double_t phi, Double_t d0, Double_t pt, Double_t dz, Double_t theta) :
94 <        fPhi(phi), fD0(d0), fPt(pt), fDz(dz), fTheta(theta) {}
92 >      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 >        TID3S,
110 >        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 >        TEC3S,
124 >        TEC4,
125 >        TEC4S,
126 >        TEC5,
127 >        TEC5S,
128 >        TEC6,
129 >        TEC6S,
130 >        TEC7,
131 >        TEC7S,
132 >        TEC8,
133 >        TEC8S,
134 >        TEC9,
135 >        TEC9S
136 >      };
137 >
138 >      Track() : fQOverP(0), fQOverPErr(0), fLambda(0), fLambdaErr(0),
139 >                fPhi0(0), fPhi0Err(0), fDxy(0), fDxyErr(0), fDsz(0), fDszErr(0),
140 >                fChi2(0), fNdof(0), fEtaEcal(0), fPhiEcal(0) {}
141 >      Track(Double_t qOverP, Double_t lambda, Double_t phi0, Double_t dxy, Double_t dsz) :
142 >                fQOverP(qOverP), fQOverPErr(0), fLambda(lambda), fLambdaErr(0),
143 >                fPhi0(phi0), fPhi0Err(0), fDxy(dxy), fDxyErr(0), fDsz(dsz), fDszErr(0),
144 >                fChi2(0), fNdof(0), fEtaEcal(0), fPhiEcal(0) {}
145        ~Track() {}
146  
147 <      Int_t             Charge()       const { return fCharge; }      
148 <      Double_t          D0()           const { return fD0; }
149 <      Double_t          D0Err()        const { return fD0Err; }
150 <      Double_t          Dz()           const { return fDz; }
151 <      Double_t          DzErr()        const { return fDzErr; }
152 <      ThreeVector       Mom()          const { return ThreeVector(Px(),Py(),Pz()); }
153 <      Double_t          P2()           const { return Px()*Px()+Py()*Py()+Pz()*Pz(); }
154 <      Double_t          P()            const { return sqrt(P2()); }
155 <      Double_t          Px()           const { return cos(fPhi)*fabs(fPt); }      
156 <      Double_t          Py()           const { return sin(fPhi)*fabs(fPt); }
157 <      Double_t          Pz()           const { return fabs(fPt)/tan(fTheta); }
158 <      Double_t          Phi()          const { return fPhi; }
159 <      Double_t          PhiErr()       const { return fPhiErr; }
160 <      Double_t          Pt()           const { return fPt; }
161 <      Double_t          PtErr()        const { return fPtErr; }
162 <      Double_t          Theta()        const { return fTheta; }
163 <      Double_t          ThetaErr()     const { return fThetaErr; }
164 <      
165 <      FourVector        Mom4(double m) const { return FourVector(Px(),Py(),Pz(),E(m)); }
166 <      Double_t          E2(double m)   const { return P2()+m*m; }
167 <      Double_t          E(double m)    const { return sqrt(E2(m)); }
168 <
169 <      void              SetCharge(Int_t charge) { fCharge = charge; }
170 <      void              SetHelix (Double_t phi, Double_t d0, Double_t pt, Double_t dz, Double_t theta);
171 <      void              SetErrors(Double_t phiErr, Double_t d0Err, Double_t ptErr,
172 <                                  Double_t dzErr, Double_t thetaErr);
173 <      
174 <      SimParticle*      GetSimParticle() const         { return (SimParticle*)fSimParticleRef.GetObject(); }
175 <      void              SetSimParticle(SimParticle* p) { fSimParticleRef = p; }
176 <      
147 >      Int_t                Charge()         const { return (fQOverP>0) ? 1 : -1;  }
148 >      Double_t             Chi2()           const { return fChi2;                 }
149 >      void                 ClearHit(EHitLayer l)  { fHits.ClearBit(l);            }
150 >      Double_t             D0()             const { return -fDxy;                 }
151 >      Double_t             D0Corrected(const BaseVertex &iVertex) const;
152 >      Double_t             D0Err()          const { return fDxyErr;               }
153 >      Double_t             Dsz()            const { return fDsz;                  }
154 >      Double_t             DszErr()         const { return fDszErr;               }
155 >      Double_t             Dxy()            const { return fDxy;                  }
156 >      Double_t             DxyErr()         const { return fDxyErr;               }
157 >      Double_t             E(Double_t m)    const { return TMath::Sqrt(E2(m));    }
158 >      Double_t             E2(Double_t m)   const { return P2()+m*m;              }
159 >      Double_t             Eta()            const { return Mom().Eta();           }
160 >      Double_t             EtaEcal()        const { return fEtaEcal;              }
161 >      Bool_t               Hit(EHitLayer l) const { return fHits.TestBit(l);      }
162 >      const BitMask48     &Hits()           const { return fHits;                 }
163 >      Double_t             Lambda()         const { return fLambda;               }
164 >      Double_t             LambdaErr()      const { return fLambdaErr;            }
165 >      const MCParticle    *MCPart()         const { return fMCParticleRef.Obj();  }
166 >      const ThreeVectorC  &Mom()            const;
167 >      FourVectorM          Mom4(Double_t m) const { return FourVectorM(Pt(),Eta(),Phi(),E(m)); }
168 >      UInt_t               Ndof()           const { return fNdof;                              }
169 >      UInt_t               NHits()          const { return fHits.NBitsSet();                   }
170 >      UInt_t               NStereoHits()    const { return StereoHits().NBitsSet();            }
171 >      EObjType             ObjType()        const { return kTrack;                             }    
172 >      Double_t             P2()             const { return 1./fQOverP/fQOverP;                 }
173 >      Double_t             P()              const { return TMath::Abs(1./fQOverP);             }
174 >      Double_t             Phi()            const { return fPhi0;                              }
175 >      Double_t             Phi0()           const { return fPhi0;                              }
176 >      Double_t             Phi0Err()        const { return fPhi0Err;                           }
177 >      Double_t             PhiEcal()        const { return fPhiEcal;                           }
178 >      Double_t             Prob()           const { return TMath::Prob(fChi2,fNdof);           }
179 >      Double_t             Pt()             const { return Mom().Rho();                        }
180 >      Double_t             Px()             const { return Mom().X();                          }
181 >      Double_t             Py()             const { return Mom().Y();                          }
182 >      Double_t             Pz()             const { return Mom().Z();                          }
183 >      Double_t             QOverP()         const { return fQOverP;                            }
184 >      Double_t             QOverPErr()      const { return fQOverPErr;                         }
185 >      Double_t             RChi2()          const { return fChi2/(Double_t)fNdof; }
186 >      Double_t             Theta()          const { return (TMath::PiOver2() - fLambda);       }
187 >      const SuperCluster  *SCluster()       const { return fSuperClusterRef.Obj();             }
188 >      const BitMask48      StereoHits()     const { return (fHits & StereoLayers());           }
189 >      void                 SetChi2(Double_t chi2)              { fChi2 = chi2;                 }
190 >      void                 SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
191 >                                     Double_t dXyErr, Double_t dSzErr);
192 >      void                 SetEtaEcal(Double_t eta)            { fEtaEcal = eta;               }
193 >      void                 SetHelix (Double_t qOverP, Double_t lambda, Double_t phi0,
194 >                                     Double_t dXy, Double_t dSz);
195 >      void                 SetHit(EHitLayer l)                 { fHits.SetBit(l);              }
196 >      void                 SetHits(const BitMask48 &hits)      { fHits = hits;                 }
197 >      void                 SetNdof(UInt_t dof)                 { fNdof = dof;                  }
198 >      void                 SetMCPart(const MCParticle *p)      { fMCParticleRef = p;           }
199 >      void                 SetPhiEcal(Double_t phi)            { fPhiEcal = phi;               }
200 >      void                 SetSCluster(const SuperCluster* sc) { fSuperClusterRef = sc;        }
201 >      Double_t             Z0()             const { return fDsz/TMath::Cos(fLambda);           }
202 >
203 >      static
204 >      const BitMask48      StereoLayers();
205 >
206      protected:
207 <      Double_t          fPhi;            // azimuthal angle
208 <      Double_t          fD0;             // raw impact parameter
209 <      Double_t          fPt;             // transverse momentum
210 <      Double_t          fDz;             // z-displacement
211 <      Double_t          fTheta;          // polar angle
212 <      Double_t          fPhiErr;         // uncertainy on phi
213 <      Double_t          fD0Err;          // uncertainty on D0
214 <      Double_t          fPtErr;          // uncertainty on pt
215 <      Double_t          fDzErr;          // uncertainty on dz
216 <      Double_t          fThetaErr;       // uncertainty on theta
217 <      Int_t             fCharge;         // electric charge of reconstructed track
218 <      TRef              fSimParticleRef; //reference to sim particle (for monte carlo)
207 >      void                 ClearMom()    const { fCacheMomFlag.ClearCache(); }
208 >      void                 GetMom()      const;
209 >
210 >      BitMask48            fHits;                //storage for mostly hit information
211 >      Double32_t           fQOverP;              //signed inverse of momentum [1/GeV]
212 >      Double32_t           fQOverPErr;           //error of q/p
213 >      Double32_t           fLambda;              //pi/2 - polar angle at the reference point
214 >      Double32_t           fLambdaErr;           //error of lambda
215 >      Double32_t           fPhi0;                //azimuth angle at the given point
216 >      Double32_t           fPhi0Err;             //error of azimuthal angle
217 >      Double32_t           fDxy;                 //transverse distance to reference point [cm]
218 >      Double32_t           fDxyErr;              //error of transverse distance
219 >      Double32_t           fDsz;                 //longitudinal distance to reference point [cm]
220 >      Double32_t           fDszErr;              //error of longitudinal distance
221 >      Double32_t           fChi2;                //chi squared of track fit
222 >      UInt_t               fNdof;                //degree-of-freedom of track fit
223 >      Double32_t           fEtaEcal;             //eta of track at Ecal front face
224 >      Double32_t           fPhiEcal;             //phi of track at Ecal front face
225 >      Ref<SuperCluster>    fSuperClusterRef;     //superCluster crossed by track
226 >      Ref<MCParticle>      fMCParticleRef;       //reference to sim particle (for monte carlo)
227 >      mutable CacheFlag    fCacheMomFlag;        //||cache validity flag for momentum
228 >      mutable ThreeVectorC fCachedMom;           //!cached momentum vector
229                
230      ClassDef(Track, 1) // Track class
231    };
232   }
233  
234   //--------------------------------------------------------------------------------------------------
235 + inline void mithep::Track::GetMom() const
236 + {
237 +  // Compute three momentum.
238 +
239 +  Double_t pt = TMath::Abs(TMath::Cos(fLambda)/fQOverP);
240 +  Double_t eta = - TMath::Log(TMath::Tan(Theta()/2.));
241 +  fCachedMom.SetCoordinates(pt,eta,Phi());
242 + }
243 +
244 + //--------------------------------------------------------------------------------------------------
245 + inline const mithep::ThreeVectorC &mithep::Track::Mom() const
246 + {
247 +  // Return cached momentum value.
248 +
249 +  if (!fCacheMomFlag.IsValid()) {
250 +    GetMom();
251 +    fCacheMomFlag.SetValid();
252 +  }
253 +  return fCachedMom;
254 + }
255 +
256 + //--------------------------------------------------------------------------------------------------
257 + inline Double_t mithep::Track::D0Corrected(const BaseVertex &iVertex) const
258 + {
259 +  // Return corrected d0 with respect to primary vertex or beamspot.
260 +
261 +  Double_t lXM =  -TMath::Sin(Phi()) * D0();
262 +  Double_t lYM =   TMath::Cos(Phi()) * D0();
263 +  Double_t lDX = (lXM + iVertex.X());
264 +  Double_t lDY = (lYM + iVertex.Y());
265 +  Double_t d0Corr = (Px()*lDY - Py()*lDX)/Pt();
266 +  
267 +  return d0Corr;
268 + }
269 +
270 + //--------------------------------------------------------------------------------------------------
271   inline
272 < void mithep::Track::SetHelix(Double_t phi, Double_t d0, Double_t pt, Double_t dz, Double_t theta)
272 > void mithep::Track::SetHelix(Double_t qOverP, Double_t lambda, Double_t phi0,
273 >                                   Double_t dxy, Double_t dsz)
274   {
275 <  fPhi   = phi;
276 <  fD0    = d0;
277 <  fPt    = pt;
278 <  fDz    = dz;
279 <  fTheta = theta;
275 >  // Set helix parameters.
276 >
277 >  fQOverP = qOverP;
278 >  fLambda = lambda;
279 >  fPhi0   = phi0;
280 >  fDxy    = dxy;
281 >  fDsz    = dsz;
282 >  ClearMom();
283   }
284  
285   //--------------------------------------------------------------------------------------------------
286   inline
287 < void mithep::Track::SetErrors(Double_t phiErr, Double_t d0Err, Double_t ptErr, Double_t dzErr,
288 <                              Double_t thetaErr)
287 > void mithep::Track::SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
288 >                                   Double_t dxyErr, Double_t dszErr)
289   {
290 <  fPhiErr   = phiErr;
291 <  fD0Err    = d0Err;
292 <  fPtErr    = ptErr;
293 <  fDzErr    = dzErr;
294 <  fThetaErr = thetaErr;
290 >  // Set helix errors.
291 >
292 >  fQOverPErr = qOverPErr;
293 >  fLambdaErr = lambdaErr;
294 >  fPhi0Err   = phi0Err;
295 >  fDxyErr    = dxyErr;
296 >  fDszErr    = dszErr;
297 > }
298 >
299 > //--------------------------------------------------------------------------------------------------
300 > inline
301 > const mithep::BitMask48 mithep::Track::StereoLayers()
302 > {
303 >  // Build and return BitMask of stereo layers.
304 >
305 >  mithep::BitMask48 stereoLayers;
306 >  stereoLayers.SetBit(mithep::Track::TIB1S);
307 >  stereoLayers.SetBit(mithep::Track::TIB2S);
308 >  stereoLayers.SetBit(mithep::Track::TID1S);
309 >  stereoLayers.SetBit(mithep::Track::TID2S);
310 >  stereoLayers.SetBit(mithep::Track::TID3S);
311 >  stereoLayers.SetBit(mithep::Track::TOB1S);
312 >  stereoLayers.SetBit(mithep::Track::TOB2S);
313 >  stereoLayers.SetBit(mithep::Track::TEC1S);
314 >  stereoLayers.SetBit(mithep::Track::TEC2S);
315 >  stereoLayers.SetBit(mithep::Track::TEC3S);
316 >  stereoLayers.SetBit(mithep::Track::TEC4S);
317 >  stereoLayers.SetBit(mithep::Track::TEC5S);
318 >  stereoLayers.SetBit(mithep::Track::TEC6S);
319 >  stereoLayers.SetBit(mithep::Track::TEC7S);
320 >  stereoLayers.SetBit(mithep::Track::TEC8S);
321 >  stereoLayers.SetBit(mithep::Track::TEC9S);
322 >  return stereoLayers;
323   }
324   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines