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.32 by loizides, Thu Jan 22 14:21:32 2009 UTC vs.
Revision 1.37 by loizides, Wed Mar 18 15:10:31 2009 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"
84 > #include "MitAna/DataTree/interface/SuperCluster.h"
85   #include "MitAna/DataTree/interface/Types.h"
86  
87   namespace mithep
# Line 144 | Line 144 | namespace mithep
144                  fChi2(0), fNdof(0), fEtaEcal(0), fPhiEcal(0) {}
145        ~Track() {}
146  
147 <      Int_t               Charge()         const { return (fQOverP>0) ? 1 : -1; }
148 <      Double_t            Chi2()           const { return fChi2; }
149 <      Double_t            RChi2()          const { return fChi2/(Double_t)fNdof; }
150 <      void                ClearHit(EHitLayer l)  { fHits.ClearBit(l); }
151 <      Double_t            D0()             const { return -fDxy; }
152 <      Double_t            D0Corrected(const BaseVertex *iVertex) const;
153 <      Double_t            D0Err()          const { return fDxyErr; }
154 <      Double_t            Dsz()            const { return fDsz; }
155 <      Double_t            DszErr()         const { return fDszErr; }
156 <      Double_t            Dxy()            const { return fDxy; }
157 <      Double_t            DxyErr()         const { return fDxyErr; }
158 <      Double_t            E(Double_t m)    const { return TMath::Sqrt(E2(m)); }
159 <      Double_t            E2(Double_t m)   const { return P2()+m*m; }
160 <      Double_t            Eta()            const { return Mom().Eta(); }
161 <      Double_t            EtaEcal()        const { return fEtaEcal; }
162 <      Bool_t              Hit(EHitLayer l) const { return fHits.TestBit(l); }
163 <      const BitMask48    &Hits()           const { return fHits; }
164 <      Double_t            Lambda()         const { return fLambda; }
165 <      Double_t            LambdaErr()      const { return fLambdaErr; }
166 <      const MCParticle   *MCPart()         const;
167 <      ThreeVector         Mom()            const { return ThreeVector(Px(),Py(),Pz()); }
168 <      FourVector          Mom4(Double_t m) const { return FourVector(Px(),Py(),Pz(),E(m)); }
169 <      UInt_t              Ndof()           const { return fNdof; }
170 <      UInt_t              NHits()          const { return fHits.NBitsSet(); }
171 <      UInt_t              NStereoHits()    const { return StereoHits().NBitsSet(); }
172 <      EObjType            ObjType()        const { return kTrack; }      
173 <      Double_t            P2()             const { return P()*P(); }
174 <      Double_t            P()              const { return TMath::Abs(1./fQOverP); }
175 <      Double_t            Phi()            const { return fPhi0; }
176 <      Double_t            Phi0()           const { return fPhi0; }
177 <      Double_t            Phi0Err()        const { return fPhi0Err; }
178 <      Double_t            PhiEcal()        const { return fPhiEcal; }
179 <      Double_t            Prob()           const { return TMath::Prob(fChi2,fNdof); }
180 <      Double_t            Pt()             const { return TMath::Abs(TMath::Cos(fLambda)/fQOverP); }
181 <      Double_t            Px()             const { return Pt()*TMath::Cos(fPhi0); }      
182 <      Double_t            Py()             const { return Pt()*TMath::Sin(fPhi0); }
183 <      Double_t            Pz()             const { return P()*TMath::Sin(fLambda); }
184 <      Double_t            QOverP()         const { return fQOverP; }
185 <      Double_t            QOverPErr()      const { return fQOverPErr; }
186 <      Double_t            Theta()          const { return (TMath::PiOver2() - fLambda); }
187 <      Double_t            Z0()             const { return fDsz/TMath::Cos(fLambda); }
188 <      const SuperCluster *SCluster()       const;
189 <      const BitMask48     StereoHits()     const { return (fHits & StereoLayers()); }
190 <      void                SetChi2(Double_t chi2)   { fChi2 = chi2; }
191 <      void                SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
192 <                                    Double_t dXyErr, Double_t dSzErr);
193 <      void                SetEtaEcal(Double_t eta) { fEtaEcal = eta; }
194 <      void                SetHelix (Double_t qOverP, Double_t lambda, Double_t phi0,
195 <                                    Double_t dXy, Double_t dSz);
196 <      void                SetHit(EHitLayer l)      { fHits.SetBit(l); }
197 <      void                SetHits(const BitMask48 &hits) { fHits = hits; }
198 <      void                SetNdof(UInt_t dof)      { fNdof = dof; }
199 <      void                SetMCPart(const MCParticle *p)
200 <                            { fMCParticleRef = const_cast<MCParticle*>(p); }
201 <      void                SetPhiEcal(Double_t phi) { fPhiEcal = phi; }
202 <      void                SetSCluster(const SuperCluster* sc)
203 <                            { fSuperClusterRef = const_cast<SuperCluster*>(sc); }
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();
204 >      const BitMask48      StereoLayers();
205  
206      protected:
207 <      BitMask48           fHits;                //storage for mostly hit information
208 <      Double_t            fQOverP;              //signed inverse of momentum [1/GeV]
209 <      Double_t            fQOverPErr;           //error of q/p
210 <      Double_t            fLambda;              //pi/2 - polar angle at the reference point
211 <      Double_t            fLambdaErr;           //error of lambda
212 <      Double_t            fPhi0;                //azimuth angle at the given point
213 <      Double_t            fPhi0Err;             //error of azimuthal angle
214 <      Double_t            fDxy;                 //transverse distance to reference point [cm]
215 <      Double_t            fDxyErr;              //error of transverse distance
216 <      Double_t            fDsz;                 //longitudinal distance to reference point [cm]
217 <      Double_t            fDszErr;              //error of longitudinal distance
218 <      Double_t            fChi2;                //chi squared of track fit
219 <      UInt_t              fNdof;                //degree-of-freedom of track fit
220 <      Double32_t          fEtaEcal;             //eta of track at Ecal front face
221 <      Double32_t          fPhiEcal;             //phi of track at Ecal front face
222 <      TRef                fSuperClusterRef;     //superCluster crossed by track
223 <      TRef                fMCParticleRef;       //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, 2) // Track class
230 >    ClassDef(Track, 1) // Track class
231    };
232   }
233  
234   //--------------------------------------------------------------------------------------------------
235 < inline Double_t mithep::Track::D0Corrected(const BaseVertex *iVertex) const
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());
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;
# Line 254 | Line 279 | void mithep::Track::SetHelix(Double_t qO
279    fPhi0   = phi0;
280    fDxy    = dxy;
281    fDsz    = dsz;
282 +  ClearMom();
283   }
284  
285   //--------------------------------------------------------------------------------------------------
# Line 272 | Line 298 | void mithep::Track::SetErrors(Double_t q
298  
299   //--------------------------------------------------------------------------------------------------
300   inline
275 const mithep::MCParticle *mithep::Track::MCPart() const
276 {
277  // 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
301   const mithep::BitMask48 mithep::Track::StereoLayers()
302   {
303 <  // Build and return BitMask of stereo layers
303 >  // Build and return BitMask of stereo layers.
304  
305    mithep::BitMask48 stereoLayers;
306    stereoLayers.SetBit(mithep::Track::TIB1S);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines