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.46 by bendavid, Thu Jan 7 11:03:41 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/BaseVertex.h"
82   #include "MitAna/DataTree/interface/DataObject.h"
81 #include "MitAna/DataTree/interface/SuperCluster.h"
83   #include "MitAna/DataTree/interface/MCParticle.h"
84 < #include "MitAna/DataTree/interface/BitMask.h"
84 < #include "MitAna/DataTree/interface/BaseVertex.h"
85 < #include "MitAna/DataTree/interface/Types.h"
84 > #include "MitAna/DataTree/interface/SuperCluster.h"
85  
86   namespace mithep
87   {
# Line 135 | Line 134 | namespace mithep
134          TEC9S
135        };
136  
137 <      Track() : fQOverP(0), fQOverPErr(0), fLambda(0), fLambdaErr(0),
138 <                fPhi0(0), fPhi0Err(0), fDxy(0), fDxyErr(0), fDsz(0), fDszErr(0),
139 <                fChi2(0), fNdof(0), fEtaEcal(0), fPhiEcal(0) {}
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 <                fQOverP(qOverP), fQOverPErr(0), fLambda(lambda), fLambdaErr(0),
177 <                fPhi0(phi0), fPhi0Err(0), fDxy(dxy), fDxyErr(0), fDsz(dsz), fDszErr(0),
178 <                fChi2(0), fNdof(0), fEtaEcal(0), fPhiEcal(0) {}
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 <      Int_t               Charge()          const { return (fQOverP>0) ? 1 : -1; }
183 <      Double_t            Chi2()            const { return fChi2; }
184 <      Double_t            RChi2()           const { return fChi2/(Double_t)fNdof; }
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 <      Double_t            Lambda()          const { return fLambda; }
200 <      Double_t            LambdaErr()       const { return fLambdaErr; }
201 <      const MCParticle   *MCPart()          const;
202 <      ThreeVector         Mom()             const { return ThreeVector(Px(),Py(),Pz()); }
203 <      FourVector          Mom4(Double_t m)  const { return FourVector(Px(),Py(),Pz(),E(m)); }
204 <      UInt_t              Ndof()            const { return fNdof; }
205 <      UInt_t              NHits()           const { return fHits.NBitsSet(); }
206 <      UInt_t              NStereoHits()     const { return StereoHits().NBitsSet(); }
207 <      EObjType            ObjType()         const { return kTrack; }      
208 <      Double_t            P2()              const { return P()*P(); }
209 <      Double_t            P()               const { return TMath::Abs(1./fQOverP); }
210 <      Double_t            Phi()             const { return fPhi0; }
211 <      Double_t            Phi0()            const { return fPhi0; }
212 <      Double_t            Phi0Err()         const { return fPhi0Err; }
213 <      Double_t            PhiEcal()         const { return fPhiEcal; }
214 <      Double_t            Prob()            const { return TMath::Prob(fChi2,fNdof); }
215 <      Double_t            Pt()              const { return TMath::Abs(TMath::Cos(fLambda)/fQOverP); }
216 <      Double_t            Px()              const { return Pt()*TMath::Cos(fPhi0); }      
217 <      Double_t            Py()              const { return Pt()*TMath::Sin(fPhi0); }
218 <      Double_t            Pz()              const { return P()*TMath::Sin(fLambda); }
219 <      Double_t            QOverP()          const { return fQOverP; }
220 <      Double_t            QOverPErr()       const { return fQOverPErr; }
221 <      Double_t            Theta()           const { return (TMath::PiOver2() - fLambda); }
222 <      Double_t            Z0()              const { return fDsz/TMath::Cos(fLambda); }
223 <      const SuperCluster *SCluster()        const;
224 <      const BitMask48     StereoHits()      const { return (fHits & StereoLayers()); }
225 <      void                SetChi2(Double_t chi2)   { fChi2 = chi2; }
226 <      void                SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
227 <                                    Double_t dXyErr, Double_t dSzErr);
228 <      void                SetEtaEcal(Double_t eta) { fEtaEcal = eta; }
229 <      void                SetHelix (Double_t qOverP, Double_t lambda, Double_t phi0,
230 <                                    Double_t dXy, Double_t dSz);
231 <      void                SetHit(EHitLayer l)      { fHits.SetBit(l); }
232 <      void                SetHits(const BitMask48 &hits) { fHits = hits; }
233 <      void                SetNdof(UInt_t dof)      { fNdof = dof; }
234 <      void                SetMCPart(const MCParticle *p)
235 <                            { fMCParticleRef = const_cast<MCParticle*>(p); }
236 <      void                SetPhiEcal(Double_t phi) { fPhiEcal = phi; }
237 <      void                SetSCluster(const SuperCluster* sc)
238 <                            { fSuperClusterRef = const_cast<SuperCluster*>(sc); }
239 <
240 <      static
241 <      const BitMask48    StereoLayers();
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 >      UInt_t               NPixelHits()     const { return PixelHits().NBitsSet();             }
209 >      EObjType             ObjType()        const { return kTrack;                             }    
210 >      Double_t             P2()             const { return 1./fQOverP/fQOverP;                 }
211 >      Double_t             P()              const { return TMath::Abs(1./fQOverP);             }
212 >      Double_t             Phi()            const { return fPhi0;                              }
213 >      Double_t             Phi0()           const { return fPhi0;                              }
214 >      Double_t             Phi0Err()        const { return fPhi0Err;                           }
215 >      Double_t             PhiEcal()        const { return fPhiEcal;                           }
216 >      Double_t             Prob()           const { return TMath::Prob(fChi2,fNdof);           }
217 >      Double_t             Pt()             const { return Mom().Rho();                        }
218 >      Double_t             Px()             const { return Mom().X();                          }
219 >      Double_t             Py()             const { return Mom().Y();                          }
220 >      Double_t             Pz()             const { return Mom().Z();                          }
221 >      Double_t             QOverP()         const { return fQOverP;                            }
222 >      Double_t             QOverPErr()      const { return fQOverPErr;                         }
223 >      Double_t             RChi2()          const { return fChi2/(Double_t)fNdof; }
224 >      Double_t             Theta()          const { return (TMath::PiOver2() - fLambda);       }
225 >      const SuperCluster  *SCluster()       const { return fSuperClusterRef.Obj();             }
226 >      const BitMask48      PixelHits()      const { return (fHits & PixelLayers());            }
227 >      const BitMask48      StereoHits()     const { return (fHits & StereoLayers());           }
228 >      void                 SetAlgo(ETrackAlgorithm e)          { fAlgo = e;                    }
229 >      void                 SetChi2(Double_t chi2)              { fChi2 = chi2;                 }
230 >      void                 SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
231 >                                     Double_t dXyErr, Double_t dSzErr);
232 >      void                 SetEtaEcal(Double_t eta)            { fEtaEcal = eta;               }
233 >      void                 SetHelix (Double_t qOverP, Double_t lambda, Double_t phi0,
234 >                                     Double_t dXy, Double_t dSz);
235 >      void                 SetHit(EHitLayer l)                 { fHits.SetBit(l);              }
236 >      void                 SetHits(const BitMask48 &hits)      { fHits = hits;                 }
237 >      void                 SetIsGsf(Bool_t b)                  { fIsGsf = b;                   }
238 >      void                 SetNdof(UShort_t dof)               { fNdof = dof;                  }
239 >      void                 SetMCPart(const MCParticle *p)      { fMCParticleRef = p;           }
240 >      void                 SetPhiEcal(Double_t phi)            { fPhiEcal = phi;               }
241 >      void                 SetSCluster(const SuperCluster* sc) { fSuperClusterRef = sc;        }
242 >      Double_t             Z0()             const { return fDsz/TMath::Cos(fLambda);           }
243 >
244 >      
245 >      static const BitMask48      StereoLayers();
246 >      static const BitMask48      PixelLayers();
247  
248      protected:
249 <      BitMask48           fHits;                //storage for mostly hit information
250 <      Double_t            fQOverP;              //signed inverse of momentum [1/GeV]
251 <      Double_t            fQOverPErr;           //error of q/p
252 <      Double_t            fLambda;              //pi/2 - polar angle at the reference point
253 <      Double_t            fLambdaErr;           //error of lambda
254 <      Double_t            fPhi0;                //azimuth angle at the given point
255 <      Double_t            fPhi0Err;             //error of azimuthal angle
256 <      Double_t            fDxy;                 //transverse distance to reference point [cm]
257 <      Double_t            fDxyErr;              //error of transverse distance
258 <      Double_t            fDsz;                 //longitudinal distance to reference point [cm]
259 <      Double_t            fDszErr;              //error of longitudinal distance
260 <      Double_t            fChi2;                //chi squared of track fit
261 <      UInt_t              fNdof;                //degree-of-freedom of track fit
262 <      Double32_t          fEtaEcal;             //eta of track at Ecal front face
263 <      Double32_t          fPhiEcal;             //phi of track at Ecal front face
264 <      TRef                fSuperClusterRef;     //superCluster crossed by track
265 <      TRef                fMCParticleRef;       //reference to sim particle (for monte carlo)
249 >      void                 ClearMom()    const { fCacheMomFlag.ClearCache(); }
250 >      void                 GetMom()      const;
251 >
252 >      BitMask48            fHits;                //storage for mostly hit information
253 >      ETrackAlgorithm      fAlgo;                //track algorithm
254 >      Bool_t               fIsGsf;               //flag to identify gsf tracks
255 >      Double32_t           fQOverP;              //[0,0,14]signed inverse of momentum [1/GeV]
256 >      Double32_t           fQOverPErr;           //[0,0,14]error of q/p
257 >      Double32_t           fLambda;              //[0,0,14]pi/2 - polar angle at the reference point
258 >      Double32_t           fLambdaErr;           //[0,0,14]error of lambda
259 >      Double32_t           fPhi0;                //[0,0,14]azimuth angle at the given point
260 >      Double32_t           fPhi0Err;             //[0,0,14]error of azimuthal angle
261 >      Double32_t           fDxy;                 //[0,0,14]trans. distance to reference point [cm]
262 >      Double32_t           fDxyErr;              //[0,0,14]error of transverse distance
263 >      Double32_t           fDsz;                 //[0,0,14]long. distance to reference point [cm]
264 >      Double32_t           fDszErr;              //[0,0,14]error of longitudinal distance
265 >      Double32_t           fChi2;                //[0,0,12]chi squared of track fit
266 >      UShort_t             fNdof;                //degree-of-freedom of track fit
267 >      Double32_t           fEtaEcal;             //[0,0,12]eta of track at Ecal front face
268 >      Double32_t           fPhiEcal;             //[0,0,12]phi of track at Ecal front face
269 >      Ref<SuperCluster>    fSuperClusterRef;     //superCluster crossed by track
270 >      Ref<MCParticle>      fMCParticleRef;       //reference to sim particle (for monte carlo)
271 >      mutable CacheFlag    fCacheMomFlag;        //||cache validity flag for momentum
272 >      mutable ThreeVectorC fCachedMom;           //!cached momentum vector
273                
274      ClassDef(Track, 2) // Track class
275    };
276   }
277  
278   //--------------------------------------------------------------------------------------------------
279 < inline Double_t mithep::Track::D0Corrected(const BaseVertex *iVertex) const
279 > inline void mithep::Track::GetMom() const
280 > {
281 >  // Compute three momentum.
282 >
283 >  Double_t pt = TMath::Abs(TMath::Cos(fLambda)/fQOverP);
284 >  Double_t eta = - TMath::Log(TMath::Tan(Theta()/2.));
285 >  fCachedMom.SetCoordinates(pt,eta,Phi());
286 > }
287 >
288 > //--------------------------------------------------------------------------------------------------
289 > inline const mithep::ThreeVectorC &mithep::Track::Mom() const
290 > {
291 >  // Return cached momentum value.
292 >
293 >  if (!fCacheMomFlag.IsValid()) {
294 >    GetMom();
295 >    fCacheMomFlag.SetValid();
296 >  }
297 >  return fCachedMom;
298 > }
299 >
300 > //--------------------------------------------------------------------------------------------------
301 > inline Double_t mithep::Track::D0Corrected(const BaseVertex &iVertex) const
302   {
303    // Return corrected d0 with respect to primary vertex or beamspot.
304  
305    Double_t lXM =  -TMath::Sin(Phi()) * D0();
306    Double_t lYM =   TMath::Cos(Phi()) * D0();
307 <  Double_t lDX = (lXM + iVertex->X());
308 <  Double_t lDY = (lYM + iVertex->Y());
307 >  Double_t lDX = (lXM + iVertex.X());
308 >  Double_t lDY = (lYM + iVertex.Y());
309    Double_t d0Corr = (Px()*lDY - Py()*lDX)/Pt();
310    
311    return d0Corr;
312   }
313  
314   //--------------------------------------------------------------------------------------------------
315 < inline
316 < void mithep::Track::SetHelix(Double_t qOverP, Double_t lambda, Double_t phi0,
248 <                                   Double_t dxy, Double_t dsz)
315 > inline void mithep::Track::SetHelix(Double_t qOverP, Double_t lambda, Double_t phi0,
316 >                                    Double_t dxy, Double_t dsz)
317   {
318    // Set helix parameters.
319  
# Line 254 | Line 322 | void mithep::Track::SetHelix(Double_t qO
322    fPhi0   = phi0;
323    fDxy    = dxy;
324    fDsz    = dsz;
325 +  ClearMom();
326   }
327  
328   //--------------------------------------------------------------------------------------------------
329 < inline
330 < void mithep::Track::SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
262 <                                   Double_t dxyErr, Double_t dszErr)
329 > inline void mithep::Track::SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
330 >                                     Double_t dxyErr, Double_t dszErr)
331   {
332    // Set helix errors.
333  
# Line 271 | Line 339 | void mithep::Track::SetErrors(Double_t q
339   }
340  
341   //--------------------------------------------------------------------------------------------------
342 < inline
275 < const mithep::MCParticle *mithep::Track::MCPart() const
342 > inline const mithep::BitMask48 mithep::Track::StereoLayers()
343   {
344 <  // 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
344 >  // Build and return BitMask of stereo layers.
345  
346    mithep::BitMask48 stereoLayers;
347    stereoLayers.SetBit(mithep::Track::TIB1S);
# Line 312 | Line 362 | const mithep::BitMask48 mithep::Track::S
362    stereoLayers.SetBit(mithep::Track::TEC9S);
363    return stereoLayers;
364   }
365 +
366 + //--------------------------------------------------------------------------------------------------
367 + inline const mithep::BitMask48 mithep::Track::PixelLayers()
368 + {
369 +  // Build and return BitMask of stereo layers.
370 +
371 +  mithep::BitMask48 pixelLayers;
372 +  pixelLayers.SetBit(mithep::Track::PXB1);
373 +  pixelLayers.SetBit(mithep::Track::PXB2);
374 +  pixelLayers.SetBit(mithep::Track::PXB3);
375 +  pixelLayers.SetBit(mithep::Track::PXF1);
376 +  pixelLayers.SetBit(mithep::Track::PXF2);
377 +  return pixelLayers;
378 + }
379   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines