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.31 by loizides, Tue Dec 9 17:47:00 2008 UTC vs.
Revision 1.50 by bendavid, Mon May 10 15:13:09 2010 UTC

# Line 77 | Line 77
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/TrackQuality.h"
82 + #include "MitAna/DataTree/interface/BaseVertex.h"
83   #include "MitAna/DataTree/interface/DataObject.h"
81 #include "MitAna/DataTree/interface/SuperCluster.h"
84   #include "MitAna/DataTree/interface/MCParticle.h"
85 < #include "MitAna/DataTree/interface/BitMask.h"
84 < #include "MitAna/DataTree/interface/BaseVertex.h"
85 < #include "MitAna/DataTree/interface/Types.h"
85 > #include "MitAna/DataTree/interface/SuperCluster.h"
86  
87   namespace mithep
88   {
# Line 135 | Line 135 | namespace mithep
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) {}
138 >      enum ETrackAlgorithm { //taken from DataFormats/TrackReco/interface/TrackBase.h
139 >        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 >      Track() : fAlgo(undefAlgorithm), fIsGsf(0), fPtErr(0), fQOverP(0), fQOverPErr(0),
173 >                fLambda(0), fLambdaErr(0), fPhi0(0), fPhi0Err(0),
174 >                fDxy(0), fDxyErr(0), fDsz(0), fDszErr(0), fChi2(0),
175 >                fNdof(0), fEtaEcal(0), fPhiEcal(0) {}
176        Track(Double_t qOverP, Double_t lambda, Double_t phi0, Double_t dxy, Double_t dsz) :
177 <                fQOverP(qOverP), fQOverPErr(0), fLambda(lambda), fLambdaErr(0),
178 <                fPhi0(phi0), fPhi0Err(0), fDxy(dxy), fDxyErr(0), fDsz(dsz), fDszErr(0),
179 <                fChi2(0), fNdof(0), fEtaEcal(0), fPhiEcal(0) {}
177 >                fAlgo(undefAlgorithm), fIsGsf(0), fPtErr(0), fQOverP(qOverP), fQOverPErr(0),
178 >                fLambda(lambda), fLambdaErr(0), fPhi0(phi0), fPhi0Err(0),
179 >                fDxy(dxy), fDxyErr(0), fDsz(dsz), fDszErr(0), fChi2(0),
180 >                fNdof(0), fEtaEcal(0), fPhiEcal(0) {}
181        ~Track() {}
182  
183 <      Int_t               Charge()          const { return (fQOverP>0) ? 1 : -1; }
184 <      Double_t            Chi2()            const { return fChi2; }
185 <      Double_t            RChi2()           const { return fChi2/(Double_t)fNdof; }
186 <      void                ClearHit(EHitLayer l)  { fHits.ClearBit(l); }
187 <      Double_t            D0()              const { return -fDxy; }
188 <      Double_t            D0Corrected(const BaseVertex *iVertex) const;
189 <      Double_t            D0Err()           const { return fDxyErr; }
190 <      Double_t            Dsz()             const { return fDsz; }
191 <      Double_t            DszErr()          const { return fDszErr; }
192 <      Double_t            Dxy()             const { return fDxy; }
193 <      Double_t            DxyErr()          const { return fDxyErr; }
194 <      Double_t            E(Double_t m)     const { return TMath::Sqrt(E2(m)); }
195 <      Double_t            E2(Double_t m)    const { return P2()+m*m; }
196 <      Double_t            Eta()             const { return Mom().Eta(); }
197 <      Double_t            EtaEcal()         const { return fEtaEcal; }
198 <      Bool_t              Hit(EHitLayer l)  const { return fHits.TestBit(l); }
199 <      const BitMask48    &Hits()            const { return fHits; }
200 <      Double_t            Lambda()          const { return fLambda; }
201 <      Double_t            LambdaErr()       const { return fLambdaErr; }
202 <      const MCParticle   *MCPart()          const;
203 <      ThreeVector         Mom()             const { return ThreeVector(Px(),Py(),Pz()); }
204 <      FourVector          Mom4(Double_t m)  const { return FourVector(Px(),Py(),Pz(),E(m)); }
205 <      UInt_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 P()*P(); }
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 TMath::Abs(TMath::Cos(fLambda)/fQOverP); }
217 <      Double_t            Px()              const { return Pt()*TMath::Cos(fPhi0); }      
218 <      Double_t            Py()              const { return Pt()*TMath::Sin(fPhi0); }
219 <      Double_t            Pz()              const { return P()*TMath::Sin(fLambda); }
220 <      Double_t            QOverP()          const { return fQOverP; }
221 <      Double_t            QOverPErr()       const { return fQOverPErr; }
222 <      Double_t            Theta()           const { return (TMath::PiOver2() - fLambda); }
223 <      Double_t            Z0()              const { return fDsz/TMath::Cos(fLambda); }
224 <      const SuperCluster *SCluster()        const;
225 <      const BitMask48     StereoHits()      const { return (fHits & StereoLayers()); }
226 <      void                SetChi2(Double_t chi2)   { fChi2 = chi2; }
227 <      void                SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
228 <                                    Double_t dXyErr, Double_t dSzErr);
229 <      void                SetEtaEcal(Double_t eta) { fEtaEcal = eta; }
230 <      void                SetHelix (Double_t qOverP, Double_t lambda, Double_t phi0,
231 <                                    Double_t dXy, Double_t dSz);
232 <      void                SetHit(EHitLayer l)      { fHits.SetBit(l); }
233 <      void                SetHits(const BitMask48 &hits) { fHits = hits; }
234 <      void                SetNdof(UInt_t dof)      { fNdof = dof; }
235 <      void                SetMCPart(const MCParticle *p)
236 <                            { fMCParticleRef = const_cast<MCParticle*>(p); }
237 <      void                SetPhiEcal(Double_t phi) { fPhiEcal = phi; }
238 <      void                SetSCluster(const SuperCluster* sc)
239 <                            { fSuperClusterRef = const_cast<SuperCluster*>(sc); }
240 <
241 <      static
242 <      const BitMask48    StereoLayers();
183 >      ETrackAlgorithm      Algo()           const { return fAlgo;                 }
184 >      Int_t                Charge()         const { return (fQOverP>0) ? 1 : -1;  }
185 >      Double_t             Chi2()           const { return fChi2;                 }
186 >      void                 ClearHit(EHitLayer l)  { fHits.ClearBit(l);            }
187 >      Double_t             D0()             const { return -fDxy;                 }
188 >      Double_t             D0Corrected(const BaseVertex &iVertex) const;
189 >      Double_t             DzCorrected(const BaseVertex &iVertex) const;
190 >      Double_t             D0Err()          const { return fDxyErr;               }
191 >      Double_t             Dsz()            const { return fDsz;                  }
192 >      Double_t             DszErr()         const { return fDszErr;               }
193 >      Double_t             Dxy()            const { return fDxy;                  }
194 >      Double_t             DxyErr()         const { return fDxyErr;               }
195 >      Double_t             E(Double_t m)    const { return TMath::Sqrt(E2(m));    }
196 >      Double_t             E2(Double_t m)   const { return P2()+m*m;              }
197 >      Double_t             Eta()            const { return Mom().Eta();           }
198 >      Double_t             EtaEcal()        const { return fEtaEcal;              }
199 >      Bool_t               Hit(EHitLayer l) const { return fHits.TestBit(l);      }
200 >      const BitMask48     &Hits()           const { return fHits;                 }
201 >      const BitMask48     &MissingHits()    const { return fMissingHits;          }
202 >      const BitMask48     &ExpectedHitsInner() const { return fExpectedHitsInner; }
203 >      const BitMask48     &ExpectedHitsOuter() const { return fExpectedHitsOuter; }
204 >      Bool_t               IsGsf()          const { return fIsGsf;                }
205 >      Double_t             Lambda()         const { return fLambda;               }
206 >      Double_t             LambdaErr()      const { return fLambdaErr;            }
207 >      const MCParticle    *MCPart()         const { return fMCParticleRef.Obj();  }
208 >      const ThreeVectorC  &Mom()            const;
209 >      FourVectorM          Mom4(Double_t m) const { return FourVectorM(Pt(),Eta(),Phi(),m); }
210 >      UShort_t             Ndof()           const { return fNdof;                              }
211 >      UInt_t               NHits()          const { return fHits.NBitsSet();                   }
212 >      UInt_t               NMissingHits()   const { return fMissingHits.NBitsSet();            }
213 >      UInt_t               NExpectedHitsInner() const { return fExpectedHitsInner.NBitsSet();  }
214 >      UInt_t               NExpectedHitsOuter() const { return fExpectedHitsOuter.NBitsSet();  }
215 >      UInt_t               NStereoHits()    const { return StereoHits().NBitsSet();            }
216 >      UInt_t               NPixelHits()     const { return PixelHits().NBitsSet();             }
217 >      EObjType             ObjType()        const { return kTrack;                             }    
218 >      Double_t             P2()             const { return 1./fQOverP/fQOverP;                 }
219 >      Double_t             P()              const { return TMath::Abs(1./fQOverP);             }
220 >      Double_t             Phi()            const { return fPhi0;                              }
221 >      Double_t             Phi0()           const { return fPhi0;                              }
222 >      Double_t             Phi0Err()        const { return fPhi0Err;                           }
223 >      Double_t             PhiEcal()        const { return fPhiEcal;                           }
224 >      Double_t             Prob()           const { return TMath::Prob(fChi2,fNdof);           }
225 >      Double_t             Pt()             const { return Mom().Rho();                        }
226 >      Double_t             PtErr()          const { return fPtErr;                             }
227 >      Double_t             Px()             const { return Mom().X();                          }
228 >      Double_t             Py()             const { return Mom().Y();                          }
229 >      Double_t             Pz()             const { return Mom().Z();                          }
230 >      Double_t             QOverP()         const { return fQOverP;                            }
231 >      Double_t             QOverPErr()      const { return fQOverPErr;                         }
232 >      Double_t             RChi2()          const { return fChi2/(Double_t)fNdof; }
233 >      Double_t             Theta()          const { return (TMath::PiOver2() - fLambda);       }
234 >      const SuperCluster  *SCluster()       const { return fSuperClusterRef.Obj();             }
235 >      const BitMask48      PixelHits()      const { return (fHits & PixelLayers());            }
236 >      const TrackQuality  &Quality()        const { return fQuality;                           }
237 >      TrackQuality        &Quality()              { return fQuality;                           }
238 >      const BitMask48      StereoHits()     const { return (fHits & StereoLayers());           }
239 >      void                 SetAlgo(ETrackAlgorithm e)          { fAlgo = e;                    }
240 >      void                 SetChi2(Double_t chi2)              { fChi2 = chi2;                 }
241 >      void                 SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
242 >                                     Double_t dXyErr, Double_t dSzErr);
243 >      void                 SetEtaEcal(Double_t eta)            { fEtaEcal = eta;               }
244 >      void                 SetHelix (Double_t qOverP, Double_t lambda, Double_t phi0,
245 >                                     Double_t dXy, Double_t dSz);
246 >      void                 SetPtErr(Double_t ptErr)            { fPtErr = ptErr;               }
247 >      void                 SetHit(EHitLayer l)                 { fHits.SetBit(l);              }
248 >      void                 SetHits(const BitMask48 &hits)      { fHits = hits;                 }
249 >      void                 SetMissingHits(const BitMask48 &h)  { fMissingHits = h;             }
250 >      void                 SetExpectedHitsInner(const BitMask48 &h) { fExpectedHitsInner = h;  }
251 >      void                 SetExpectedHitsOuter(const BitMask48 &h) { fExpectedHitsInner = h;  }
252 >      void                 SetIsGsf(Bool_t b)                  { fIsGsf = b;                   }
253 >      void                 SetNdof(UShort_t dof)               { fNdof = dof;                  }
254 >      void                 SetMCPart(const MCParticle *p)      { fMCParticleRef = p;           }
255 >      void                 SetPhiEcal(Double_t phi)            { fPhiEcal = phi;               }
256 >      void                 SetSCluster(const SuperCluster* sc) { fSuperClusterRef = sc;        }
257 >      Double_t             X0()             const { return  D0()*TMath::Sin(Phi());            }
258 >      Double_t             Y0()             const { return -D0()*TMath::Cos(Phi());            }
259 >      Double_t             Z0()             const { return fDsz/TMath::Cos(fLambda);           }
260 >
261 >      
262 >      static const BitMask48      StereoLayers();
263 >      static const BitMask48      PixelLayers();
264  
265      protected:
266 <      BitMask48           fHits;                //storage for mostly hit information
267 <      Double_t            fQOverP;              //signed inverse of momentum [1/GeV]
268 <      Double_t            fQOverPErr;           //error of q/p
269 <      Double_t            fLambda;              //pi/2 - polar angle at the reference point
270 <      Double_t            fLambdaErr;           //error of lambda
271 <      Double_t            fPhi0;                //azimuth angle at the given point
272 <      Double_t            fPhi0Err;             //error of azimuthal angle
273 <      Double_t            fDxy;                 //transverse distance to reference point [cm]
274 <      Double_t            fDxyErr;              //error of transverse distance
275 <      Double_t            fDsz;                 //longitudinal distance to reference point [cm]
276 <      Double_t            fDszErr;              //error of longitudinal distance
277 <      Double_t            fChi2;                //chi squared of track fit
278 <      UInt_t              fNdof;                //degree-of-freedom of track fit
279 <      Double32_t          fEtaEcal;             //eta of track at Ecal front face
280 <      Double32_t          fPhiEcal;             //phi of track at Ecal front face
281 <      TRef                fSuperClusterRef;     //superCluster crossed by track
282 <      TRef                fMCParticleRef;       //reference to sim particle (for monte carlo)
266 >      void                 ClearMom()    const { fCacheMomFlag.ClearCache(); }
267 >      void                 GetMom()      const;
268 >
269 >      BitMask48            fHits;                //storage for mostly hit information
270 >      BitMask48            fMissingHits;         //missing hits in crossed good modules
271 >      BitMask48            fExpectedHitsInner;   //expected hits before first hit
272 >      BitMask48            fExpectedHitsOuter;   //expected hits after last hit
273 >      ETrackAlgorithm      fAlgo;                //track algorithm
274 >      TrackQuality         fQuality;             //track quality
275 >      Bool_t               fIsGsf;               //flag to identify gsf tracks
276 >      Double32_t           fPtErr;               //[0,0,12]pt uncertainty
277 >      Double32_t           fQOverP;              //[0,0,14]signed inverse of momentum [1/GeV]
278 >      Double32_t           fQOverPErr;           //[0,0,14]error of q/p
279 >      Double32_t           fLambda;              //[0,0,14]pi/2 - polar angle at the reference point
280 >      Double32_t           fLambdaErr;           //[0,0,14]error of lambda
281 >      Double32_t           fPhi0;                //[0,0,14]azimuth angle at the given point
282 >      Double32_t           fPhi0Err;             //[0,0,14]error of azimuthal angle
283 >      Double32_t           fDxy;                 //[0,0,14]trans. distance to reference point [cm]
284 >      Double32_t           fDxyErr;              //[0,0,14]error of transverse distance
285 >      Double32_t           fDsz;                 //[0,0,14]long. distance to reference point [cm]
286 >      Double32_t           fDszErr;              //[0,0,14]error of longitudinal distance
287 >      Double32_t           fChi2;                //[0,0,12]chi squared of track fit
288 >      UShort_t             fNdof;                //degree-of-freedom of track fit
289 >      Double32_t           fEtaEcal;             //[0,0,12]eta of track at Ecal front face
290 >      Double32_t           fPhiEcal;             //[0,0,12]phi of track at Ecal front face
291 >      Ref<SuperCluster>    fSuperClusterRef;     //superCluster crossed by track
292 >      Ref<MCParticle>      fMCParticleRef;       //reference to sim particle (for monte carlo)
293 >      mutable CacheFlag    fCacheMomFlag;        //||cache validity flag for momentum
294 >      mutable ThreeVectorC fCachedMom;           //!cached momentum vector
295                
296 <    ClassDef(Track, 2) // Track class
296 >    ClassDef(Track, 5) // Track class
297    };
298   }
299  
300   //--------------------------------------------------------------------------------------------------
301 < inline Double_t mithep::Track::D0Corrected(const BaseVertex *iVertex) const
301 > inline void mithep::Track::GetMom() const
302 > {
303 >  // Compute three momentum.
304 >
305 >  Double_t pt = TMath::Abs(TMath::Cos(fLambda)/fQOverP);
306 >  Double_t eta = - TMath::Log(TMath::Tan(Theta()/2.));
307 >  fCachedMom.SetCoordinates(pt,eta,Phi());
308 > }
309 >
310 > //--------------------------------------------------------------------------------------------------
311 > inline const mithep::ThreeVectorC &mithep::Track::Mom() const
312 > {
313 >  // Return cached momentum value.
314 >
315 >  if (!fCacheMomFlag.IsValid()) {
316 >    GetMom();
317 >    fCacheMomFlag.SetValid();
318 >  }
319 >  return fCachedMom;
320 > }
321 >
322 > //--------------------------------------------------------------------------------------------------
323 > inline Double_t mithep::Track::D0Corrected(const BaseVertex &iVertex) const
324   {
325    // Return corrected d0 with respect to primary vertex or beamspot.
326  
327    Double_t lXM =  -TMath::Sin(Phi()) * D0();
328    Double_t lYM =   TMath::Cos(Phi()) * D0();
329 <  Double_t lDX = (lXM + iVertex->X());
330 <  Double_t lDY = (lYM + iVertex->Y());
329 >  Double_t lDX = (lXM + iVertex.X());
330 >  Double_t lDY = (lYM + iVertex.Y());
331    Double_t d0Corr = (Px()*lDY - Py()*lDX)/Pt();
332    
333    return d0Corr;
334   }
335  
336   //--------------------------------------------------------------------------------------------------
337 < inline
338 < void mithep::Track::SetHelix(Double_t qOverP, Double_t lambda, Double_t phi0,
339 <                                   Double_t dxy, Double_t dsz)
337 > inline Double_t mithep::Track::DzCorrected(const mithep::BaseVertex &iVertex) const
338 > {
339 >  // Compute Dxy with respect to a given position
340 >  mithep::ThreeVector momPerp(Px(),Py(),0);
341 >  mithep::ThreeVector posPerp(X0()-iVertex.X(),Y0()-iVertex.Y(),0);
342 >  return Z0() - iVertex.Z() - posPerp.Dot(momPerp)/Pt() * (Pz()/Pt());
343 >  
344 > }
345 >
346 > //--------------------------------------------------------------------------------------------------
347 > inline void mithep::Track::SetHelix(Double_t qOverP, Double_t lambda, Double_t phi0,
348 >                                    Double_t dxy, Double_t dsz)
349   {
350    // Set helix parameters.
351  
# Line 254 | Line 354 | void mithep::Track::SetHelix(Double_t qO
354    fPhi0   = phi0;
355    fDxy    = dxy;
356    fDsz    = dsz;
357 +  ClearMom();
358   }
359  
360   //--------------------------------------------------------------------------------------------------
361 < inline
362 < void mithep::Track::SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
262 <                                   Double_t dxyErr, Double_t dszErr)
361 > inline void mithep::Track::SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
362 >                                     Double_t dxyErr, Double_t dszErr)
363   {
364    // Set helix errors.
365  
# Line 271 | Line 371 | void mithep::Track::SetErrors(Double_t q
371   }
372  
373   //--------------------------------------------------------------------------------------------------
374 < inline
275 < const mithep::MCParticle *mithep::Track::MCPart() const
374 > inline const mithep::BitMask48 mithep::Track::StereoLayers()
375   {
376 <  // Get reference to simulated particle.
278 <
279 <  return static_cast<const MCParticle*>(fMCParticleRef.GetObject());
280 < }
281 <
282 < //--------------------------------------------------------------------------------------------------
283 < inline const mithep::SuperCluster *mithep::Track::SCluster() const
284 < {
285 <  // Return Super cluster
286 <
287 <  return static_cast<const SuperCluster*>(fSuperClusterRef.GetObject());
288 < }
289 <
290 < //--------------------------------------------------------------------------------------------------
291 < inline
292 < const mithep::BitMask48 mithep::Track::StereoLayers()
293 < {
294 <  // Build and return BitMask of stereo layers
376 >  // Build and return BitMask of stereo layers.
377  
378    mithep::BitMask48 stereoLayers;
379    stereoLayers.SetBit(mithep::Track::TIB1S);
# Line 312 | Line 394 | const mithep::BitMask48 mithep::Track::S
394    stereoLayers.SetBit(mithep::Track::TEC9S);
395    return stereoLayers;
396   }
397 +
398 + //--------------------------------------------------------------------------------------------------
399 + inline const mithep::BitMask48 mithep::Track::PixelLayers()
400 + {
401 +  // Build and return BitMask of stereo layers.
402 +
403 +  mithep::BitMask48 pixelLayers;
404 +  pixelLayers.SetBit(mithep::Track::PXB1);
405 +  pixelLayers.SetBit(mithep::Track::PXB2);
406 +  pixelLayers.SetBit(mithep::Track::PXB3);
407 +  pixelLayers.SetBit(mithep::Track::PXF1);
408 +  pixelLayers.SetBit(mithep::Track::PXF2);
409 +  return pixelLayers;
410 + }
411   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines