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.17 by loizides, Wed Sep 10 03:33:27 2008 UTC vs.
Revision 1.42 by loizides, Mon Jul 13 11:00:32 2009 UTC

# Line 12 | Line 12
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, TOB L1,L2, TEC L1,L2,L5).
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   //
# Line 42 | Line 43
43   // Bit 13: TID L2 r-phi
44   // Bit 14: TID L2 stereo
45   // Bit 15: TID L3 r-phi
46 < // Bit 16: TOB L1 r-phi
47 < // Bit 17: TOB L1 stereo
48 < // Bit 18: TOB L2 r-phi
49 < // Bit 19: TOB L2 stereo
50 < // Bit 20: TOB L3 r-phi
51 < // Bit 21: TOB L4 r-phi
52 < // Bit 22: TOB L5 r-phi
53 < // Bit 23: TOB L6 r-phi
54 < // Bit 24: TEC L1 r-phi
55 < // Bit 25: TEC L1 stereo
56 < // Bit 26: TEC L2 r-phi
57 < // Bit 27: TEC L2 stereo
58 < // Bit 28: TEC L3 r-phi
59 < // Bit 29: TEC L4 r-phi
60 < // Bit 30: TEC L5 r-phi
61 < // Bit 31: TEC L5 stereo
62 < // Bit 32: TEC L6 r-phi
63 < // Bit 33: TEC L7 r-phi
64 < // Bit 34: TEC L8 r-phi
65 < // Bit 35: TEC L9 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   //--------------------------------------------------------------------------------------------------
# Line 69 | 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"
83   #include "MitAna/DataTree/interface/MCParticle.h"
84 < #include "MitAna/DataTree/interface/BitMask32.h"
75 < #include "MitAna/DataTree/interface/BitMask64.h"
76 < #include "MitAna/DataTree/interface/Types.h"
84 > #include "MitAna/DataTree/interface/SuperCluster.h"
85  
86   namespace mithep
87   {
88    class Track : public DataObject
89    {
90      public:
91 <      enum HitLayer { PXB1,
92 <                      PXB2,
93 <                      PXB3,
94 <                      PXF1,
95 <                      PXF2,
96 <                      TIB1,
97 <                      TIB1S,
98 <                      TIB2,
99 <                      TIB2S,
100 <                      TIB3,
101 <                      TIB4,
102 <                      TID1,
103 <                      TID1S,
104 <                      TID2,
105 <                      TID2S,
106 <                      TID3,
107 <                      TOB1,
108 <                      TOB1S,
109 <                      TOB2,
110 <                      TOB2S,
111 <                      TOB3,
112 <                      TOB4,
113 <                      TOB5,
114 <                      TOB6,
115 <                      TEC1,
116 <                      TEC1S,
117 <                      TEC2,
118 <                      TEC2S,
119 <                      TEC3,
120 <                      TEC4,
121 <                      TEC5,
122 <                      TEC5S,
123 <                      TEC6,
124 <                      TEC7,
125 <                      TEC8,
126 <                      TEC9 };
127 <    
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        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) {}
139 >                fChi2(0), fNdof(0), fEtaEcal(0), fPhiEcal(0) {}
140        Track(Double_t qOverP, Double_t lambda, Double_t phi0, Double_t dxy, Double_t dsz) :
141                  fQOverP(qOverP), fQOverPErr(0), fLambda(lambda), fLambdaErr(0),
142                  fPhi0(phi0), fPhi0Err(0), fDxy(dxy), fDxyErr(0), fDsz(dsz), fDszErr(0),
143 <                fChi2(0), fNdof(0) {}
143 >                fChi2(0), fNdof(0), fEtaEcal(0), fPhiEcal(0) {}
144        ~Track() {}
145  
146 <      Double_t           QOverP()        const { return fQOverP; }
147 <      Double_t           QOverPErr()     const { return fQOverPErr; }
148 <      Double_t           Lambda()        const { return fLambda; }
149 <      Double_t           LambdaErr()     const { return fLambdaErr; }
150 <      Double_t           Phi0()          const { return fPhi0; }
151 <      Double_t           Phi0Err()       const { return fPhi0Err; }
152 <      Double_t           Dxy()           const { return fDxy; }
153 <      Double_t           DxyErr()        const { return fDxyErr; }
154 <      Double_t           Dsz()           const { return fDsz; }
155 <      Double_t           DszErr()        const { return fDszErr; }
156 <      Int_t              Charge()        const { return (fQOverP>0) ? 1 : -1; }
157 <      Double_t           Chi2()          const { return fChi2; }
158 <      void               ClearHit(HitLayer l)  { fHits.ClearBit(l); }
159 <      Double_t           D0()            const { return -fDxy; }
160 <      Double_t           D0Err()         const { return fDxyErr; }
161 <      Bool_t             Hit(HitLayer l) const { return fHits.TestBit(l); }
162 <      BitMask64         &Hits()                { return fHits; }
163 <      const BitMask64   &Hits()          const { return fHits; }
164 <      ULong64_t          HitMask()       const { return fHits.Bits(); }
165 <      ThreeVector        Mom()           const { return ThreeVector(Px(),Py(),Pz()); }
166 <      UInt_t             Ndof()          const { return fNdof; }
167 <      Double_t           P2()            const { return P()*P(); }
168 <      Double_t           P()             const { return TMath::Abs(1./fQOverP); }
169 <      Double_t           Px()            const { return Pt()*TMath::Cos(fPhi0); }      
170 <      Double_t           Py()            const { return Pt()*TMath::Sin(fPhi0); }
171 <      Double_t           Pz()            const { return P()*TMath::Sin(fLambda); }
172 <      Double_t           Phi()           const { return fPhi0; }
173 <      Double_t           Pt()            const { return TMath::Abs(TMath::Cos(fLambda)/fQOverP); }
174 <      void               SetChi2(Double_t chi2)     { fChi2 = chi2; }
175 <      void               SetHit(HitLayer l)         { fHits.SetBit(l); }
176 <      void               SetHits(BitMask64 hits)    { fHits = hits; }
177 <      void               SetHits(ULong64_t hitMask) { fHits.SetBits(hitMask); }
178 <      void               SetNdof(UInt_t dof)        { fNdof = dof; }
179 <      void               SetStat(BitMask32 stat)    { fStat = stat; }
180 <      void               SetStat(UInt_t statBits)   { fStat.SetBits(statBits); }
181 <      BitMask32         &Stat()                     { return fStat; }
182 <      const BitMask32   &Stat()               const { return fStat; }
183 <      UInt_t             StatBits()           const { return fStat.Bits(); }
184 <      Double_t           Theta()              const { return (TMath::PiOver2() - fLambda); }
185 <      Double_t           Z0()                 const { return fDsz/TMath::Cos(fLambda); }
186 <      FourVector         Mom4(Double_t m)     const { return FourVector(Px(),Py(),Pz(),E(m)); }
187 <      Double_t           E2(Double_t m)       const { return P2()+m*m; }
188 <      Double_t           E(Double_t m)        const { return TMath::Sqrt(E2(m)); }
189 <      UInt_t             NHits()              const { return fHits.NBitsSet(); }
190 <
191 <      void               SetHelix (Double_t qOverP, Double_t lambda, Double_t phi0,
192 <                                   Double_t dXy, Double_t dSz);
193 <      void               SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
194 <                                   Double_t dXyErr, Double_t dSzErr);
195 <      
196 <      const MCParticle  *MCPart()             const;
197 <      void               SetMCPart(MCParticle *p)   { fMCParticleRef = p; }
198 <      
146 >      Int_t                Charge()         const { return (fQOverP>0) ? 1 : -1;  }
147 >      Double_t             Chi2()           const { return fChi2;                 }
148 >      void                 ClearHit(EHitLayer l)  { fHits.ClearBit(l);            }
149 >      Double_t             D0()             const { return -fDxy;                 }
150 >      Double_t             D0Corrected(const BaseVertex &iVertex) const;
151 >      Double_t             D0Err()          const { return fDxyErr;               }
152 >      Double_t             Dsz()            const { return fDsz;                  }
153 >      Double_t             DszErr()         const { return fDszErr;               }
154 >      Double_t             Dxy()            const { return fDxy;                  }
155 >      Double_t             DxyErr()         const { return fDxyErr;               }
156 >      Double_t             E(Double_t m)    const { return TMath::Sqrt(E2(m));    }
157 >      Double_t             E2(Double_t m)   const { return P2()+m*m;              }
158 >      Double_t             Eta()            const { return Mom().Eta();           }
159 >      Double_t             EtaEcal()        const { return fEtaEcal;              }
160 >      Bool_t               Hit(EHitLayer l) const { return fHits.TestBit(l);      }
161 >      const BitMask48     &Hits()           const { return fHits;                 }
162 >      Double_t             Lambda()         const { return fLambda;               }
163 >      Double_t             LambdaErr()      const { return fLambdaErr;            }
164 >      const MCParticle    *MCPart()         const { return fMCParticleRef.Obj();  }
165 >      const ThreeVectorC  &Mom()            const;
166 >      FourVectorM          Mom4(Double_t m) const { return FourVectorM(Pt(),Eta(),Phi(),m); }
167 >      UShort_t             Ndof()           const { return fNdof;                              }
168 >      UInt_t               NHits()          const { return fHits.NBitsSet();                   }
169 >      UInt_t               NStereoHits()    const { return StereoHits().NBitsSet();            }
170 >      EObjType             ObjType()        const { return kTrack;                             }    
171 >      Double_t             P2()             const { return 1./fQOverP/fQOverP;                 }
172 >      Double_t             P()              const { return TMath::Abs(1./fQOverP);             }
173 >      Double_t             Phi()            const { return fPhi0;                              }
174 >      Double_t             Phi0()           const { return fPhi0;                              }
175 >      Double_t             Phi0Err()        const { return fPhi0Err;                           }
176 >      Double_t             PhiEcal()        const { return fPhiEcal;                           }
177 >      Double_t             Prob()           const { return TMath::Prob(fChi2,fNdof);           }
178 >      Double_t             Pt()             const { return Mom().Rho();                        }
179 >      Double_t             Px()             const { return Mom().X();                          }
180 >      Double_t             Py()             const { return Mom().Y();                          }
181 >      Double_t             Pz()             const { return Mom().Z();                          }
182 >      Double_t             QOverP()         const { return fQOverP;                            }
183 >      Double_t             QOverPErr()      const { return fQOverPErr;                         }
184 >      Double_t             RChi2()          const { return fChi2/(Double_t)fNdof; }
185 >      Double_t             Theta()          const { return (TMath::PiOver2() - fLambda);       }
186 >      const SuperCluster  *SCluster()       const { return fSuperClusterRef.Obj();             }
187 >      const BitMask48      StereoHits()     const { return (fHits & StereoLayers());           }
188 >      void                 SetChi2(Double_t chi2)              { fChi2 = chi2;                 }
189 >      void                 SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
190 >                                     Double_t dXyErr, Double_t dSzErr);
191 >      void                 SetEtaEcal(Double_t eta)            { fEtaEcal = eta;               }
192 >      void                 SetHelix (Double_t qOverP, Double_t lambda, Double_t phi0,
193 >                                     Double_t dXy, Double_t dSz);
194 >      void                 SetHit(EHitLayer l)                 { fHits.SetBit(l);              }
195 >      void                 SetHits(const BitMask48 &hits)      { fHits = hits;                 }
196 >      void                 SetNdof(UShort_t dof)               { fNdof = dof;                  }
197 >      void                 SetMCPart(const MCParticle *p)      { fMCParticleRef = p;           }
198 >      void                 SetPhiEcal(Double_t phi)            { fPhiEcal = phi;               }
199 >      void                 SetSCluster(const SuperCluster* sc) { fSuperClusterRef = sc;        }
200 >      Double_t             Z0()             const { return fDsz/TMath::Cos(fLambda);           }
201 >
202 >      static
203 >      const BitMask48      StereoLayers();
204 >
205      protected:
206 <      BitMask64          fHits;                //storage for mostly hit information
207 <      BitMask32          fStat;                //storage for various interesting things
208 <      Double_t           fQOverP;              //track parameters/uncertainties
209 <      Double_t           fQOverPErr;           //
210 <      Double_t           fLambda;              //
211 <      Double_t           fLambdaErr;           //
212 <      Double_t           fPhi0;                //
213 <      Double_t           fPhi0Err;             //
214 <      Double_t           fDxy;                 //
215 <      Double_t           fDxyErr;              //
216 <      Double_t           fDsz;                 //
217 <      Double_t           fDszErr;              //
218 <      Double_t           fChi2;                //chi squared of track fit
219 <      UInt_t             fNdof;                //number of dof of track fit
220 <      TRef               fMCParticleRef;       //reference to sim particle (for monte carlo)
206 >      void                 ClearMom()    const { fCacheMomFlag.ClearCache(); }
207 >      void                 GetMom()      const;
208 >
209 >      BitMask48            fHits;                //storage for mostly hit information
210 >      Double32_t           fQOverP;              //[0,0,14]signed inverse of momentum [1/GeV]
211 >      Double32_t           fQOverPErr;           //[0,0,14]error of q/p
212 >      Double32_t           fLambda;              //[0,0,14]pi/2 - polar angle at the reference point
213 >      Double32_t           fLambdaErr;           //[0,0,14]error of lambda
214 >      Double32_t           fPhi0;                //[0,0,14]azimuth angle at the given point
215 >      Double32_t           fPhi0Err;             //[0,0,14]error of azimuthal angle
216 >      Double32_t           fDxy;                 //[0,0,14]trans. distance to reference point [cm]
217 >      Double32_t           fDxyErr;              //[0,0,14]error of transverse distance
218 >      Double32_t           fDsz;                 //[0,0,14]long. distance to reference point [cm]
219 >      Double32_t           fDszErr;              //[0,0,14]error of longitudinal distance
220 >      Double32_t           fChi2;                //[0,0,12]chi squared of track fit
221 >      UShort_t             fNdof;                //degree-of-freedom of track fit
222 >      Double32_t           fEtaEcal;             //[0,0,12]eta of track at Ecal front face
223 >      Double32_t           fPhiEcal;             //[0,0,12]phi of track at Ecal front face
224 >      Ref<SuperCluster>    fSuperClusterRef;     //superCluster crossed by track
225 >      Ref<MCParticle>      fMCParticleRef;       //reference to sim particle (for monte carlo)
226 >      mutable CacheFlag    fCacheMomFlag;        //||cache validity flag for momentum
227 >      mutable ThreeVectorC fCachedMom;           //!cached momentum vector
228                
229      ClassDef(Track, 1) // Track class
230    };
231   }
232  
233   //--------------------------------------------------------------------------------------------------
234 + inline void mithep::Track::GetMom() const
235 + {
236 +  // Compute three momentum.
237 +
238 +  Double_t pt = TMath::Abs(TMath::Cos(fLambda)/fQOverP);
239 +  Double_t eta = - TMath::Log(TMath::Tan(Theta()/2.));
240 +  fCachedMom.SetCoordinates(pt,eta,Phi());
241 + }
242 +
243 + //--------------------------------------------------------------------------------------------------
244 + inline const mithep::ThreeVectorC &mithep::Track::Mom() const
245 + {
246 +  // Return cached momentum value.
247 +
248 +  if (!fCacheMomFlag.IsValid()) {
249 +    GetMom();
250 +    fCacheMomFlag.SetValid();
251 +  }
252 +  return fCachedMom;
253 + }
254 +
255 + //--------------------------------------------------------------------------------------------------
256 + inline Double_t mithep::Track::D0Corrected(const BaseVertex &iVertex) const
257 + {
258 +  // Return corrected d0 with respect to primary vertex or beamspot.
259 +
260 +  Double_t lXM =  -TMath::Sin(Phi()) * D0();
261 +  Double_t lYM =   TMath::Cos(Phi()) * D0();
262 +  Double_t lDX = (lXM + iVertex.X());
263 +  Double_t lDY = (lYM + iVertex.Y());
264 +  Double_t d0Corr = (Px()*lDY - Py()*lDX)/Pt();
265 +  
266 +  return d0Corr;
267 + }
268 +
269 + //--------------------------------------------------------------------------------------------------
270   inline
271   void mithep::Track::SetHelix(Double_t qOverP, Double_t lambda, Double_t phi0,
272 <                                   Double_t dxy, Double_t dsz)
272 >                             Double_t dxy, Double_t dsz)
273   {
274    // Set helix parameters.
275  
# Line 212 | Line 278 | void mithep::Track::SetHelix(Double_t qO
278    fPhi0   = phi0;
279    fDxy    = dxy;
280    fDsz    = dsz;
281 +  ClearMom();
282   }
283  
284   //--------------------------------------------------------------------------------------------------
285   inline
286   void mithep::Track::SetErrors(Double_t qOverPErr, Double_t lambdaErr, Double_t phi0Err,
287 <                                   Double_t dxyErr, Double_t dszErr)
287 >                              Double_t dxyErr, Double_t dszErr)
288   {
289    // Set helix errors.
290  
# Line 230 | Line 297 | void mithep::Track::SetErrors(Double_t q
297  
298   //--------------------------------------------------------------------------------------------------
299   inline
300 < const mithep::MCParticle *mithep::Track::MCPart() const
300 > const mithep::BitMask48 mithep::Track::StereoLayers()
301   {
302 <  // Get reference to simulated particle.
302 >  // Build and return BitMask of stereo layers.
303  
304 <  return static_cast<const MCParticle*>(fMCParticleRef.GetObject());
304 >  mithep::BitMask48 stereoLayers;
305 >  stereoLayers.SetBit(mithep::Track::TIB1S);
306 >  stereoLayers.SetBit(mithep::Track::TIB2S);
307 >  stereoLayers.SetBit(mithep::Track::TID1S);
308 >  stereoLayers.SetBit(mithep::Track::TID2S);
309 >  stereoLayers.SetBit(mithep::Track::TID3S);
310 >  stereoLayers.SetBit(mithep::Track::TOB1S);
311 >  stereoLayers.SetBit(mithep::Track::TOB2S);
312 >  stereoLayers.SetBit(mithep::Track::TEC1S);
313 >  stereoLayers.SetBit(mithep::Track::TEC2S);
314 >  stereoLayers.SetBit(mithep::Track::TEC3S);
315 >  stereoLayers.SetBit(mithep::Track::TEC4S);
316 >  stereoLayers.SetBit(mithep::Track::TEC5S);
317 >  stereoLayers.SetBit(mithep::Track::TEC6S);
318 >  stereoLayers.SetBit(mithep::Track::TEC7S);
319 >  stereoLayers.SetBit(mithep::Track::TEC8S);
320 >  stereoLayers.SetBit(mithep::Track::TEC9S);
321 >  return stereoLayers;
322   }
323   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines