3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
8 ////////////////////////////////////////////////////////////////////////////
10 // The TRD offline tracklet //
12 ////////////////////////////////////////////////////////////////////////////
14 #ifndef ALITRDTRACKLETBASE_H
15 #include "AliTRDtrackletBase.h"
22 #ifndef ALITRDGEOMETRY_H
23 #include "AliTRDgeometry.h"
31 #include "AliRieman.h"
34 #ifndef ALITRDCLUSTER_H
35 #include "AliTRDcluster.h"
38 #include "AliTRDReconstructor.h"
40 class TTreeSRedirector;
45 class AliTRDtrackingChamber;
48 class AliTRDseedV1 : public AliTRDtrackletBase
51 enum ETRDtrackletBuffers {
52 kNtb = 31 // max clusters/pad row
53 ,kNclusters = 2*kNtb // max number of clusters/tracklet
54 ,kNslices = 10 // max dEdx slices
57 // bits from 0-13 are reserved by ROOT (see TObject.h)
58 enum ETRDtrackletStatus {
59 kOwner = BIT(14) // owner of its clusters
60 ,kRowCross = BIT(15) // pad row cross tracklet
61 ,kPID = BIT(16) // PID contributor
62 ,kCalib = BIT(17) // calibrated tracklet
63 ,kKink = BIT(18) // kink prolongation tracklet
64 ,kStandAlone = BIT(19) // tracklet build during stand alone track finding
67 AliTRDseedV1(Int_t det = -1);
69 AliTRDseedV1(const AliTRDseedV1 &ref);
70 AliTRDseedV1& operator=(const AliTRDseedV1 &ref);
72 Bool_t AttachClusters(AliTRDtrackingChamber *const chamber, Bool_t tilt = kFALSE);
73 void Bootstrap(const AliTRDReconstructor *rec);
75 void CookdEdx(Int_t nslices);
78 Bool_t Fit(Bool_t tilt=kFALSE, Bool_t zcorr=kFALSE);
79 Bool_t Init(AliTRDtrackV1 *track);
80 inline void Init(const AliRieman *fit);
81 Bool_t IsEqual(const TObject *inTracklet) const;
82 Bool_t IsCalibrated() const { return TestBit(kCalib);}
83 Bool_t IsOwner() const { return TestBit(kOwner);}
84 Bool_t IsKink() const { return TestBit(kKink);}
85 Bool_t HasPID() const { return TestBit(kPID);}
86 Bool_t IsOK() const { return GetN() > 4 && GetNUsed() < 4;}
87 Bool_t IsRowCross() const { return TestBit(kRowCross);}
88 Bool_t IsUsable(Int_t i) const { return fClusters[i] && !fClusters[i]->IsUsed();}
89 Bool_t IsStandAlone() const { return TestBit(kStandAlone);}
91 Float_t GetC() const { return fC; }
92 Float_t GetChi2() const { return fChi2; }
93 inline Float_t GetChi2Z() const;
94 inline Float_t GetChi2Y() const;
95 inline Float_t GetChi2Phi() const;
96 void GetCovAt(Double_t x, Double_t *cov) const;
97 void GetCovXY(Double_t *cov) const { memcpy(cov, &fCov[0], 3*sizeof(Double_t));}
98 void GetCovRef(Double_t *cov) const { memcpy(cov, &fRefCov, 7*sizeof(Double_t));}
99 static Double_t GetCovSqrt(const Double_t * const c, Double_t *d);
100 static Double_t GetCovInv(const Double_t * const c, Double_t *d);
101 Float_t GetdX() const { return fdX;}
102 const Float_t* GetdEdx() const { return &fdEdx[0];}
103 Float_t GetdQdl(Int_t ic, Float_t *dx=NULL) const;
104 Float_t GetdYdX() const { return fYfit[1]; }
105 Float_t GetdZdX() const { return fZref[1]; }
106 Int_t GetdY() const { return Int_t(GetY()/0.014);}
107 Int_t GetDetector() const { return fDet;}
108 void GetCalibParam(Float_t &exb, Float_t &vd, Float_t &t0, Float_t &s2, Float_t &dl, Float_t &dt) const {
109 exb = fExB; vd = fVD; t0 = fT0; s2 = fS2PRF; dl = fDiffL; dt = fDiffT;}
110 AliTRDcluster* GetClusters(Int_t i) const { return i<0 || i>=kNclusters ? NULL: fClusters[i];}
111 static TLinearFitter* GetFitterY();
112 static TLinearFitter* GetFitterZ();
113 Int_t GetIndexes(Int_t i) const{ return i<0 || i>=kNclusters ? -1 : fIndexes[i];}
114 Int_t GetLabels(Int_t i) const { return fLabels[i];}
115 Float_t GetMomentum(Float_t *err = NULL) const;
116 Int_t GetN() const { return (Int_t)fN&0x1f;}
117 Int_t GetN2() const { return GetN();}
118 Int_t GetNUsed() const { return Int_t((fN>>5)&0x1f);}
119 Int_t GetNShared() const { return Int_t((fN>>10)&0x1f);}
120 Float_t GetQuality(Bool_t kZcorr) const;
121 Float_t GetPadLength() const { return fPad[0];}
122 Float_t GetPadWidth() const { return fPad[1];}
123 Int_t GetPlane() const { return AliTRDgeometry::GetLayer(fDet); }
125 Float_t* GetProbability(Bool_t force=kFALSE);
126 Float_t GetPt() const { return fPt; }
127 inline Double_t GetPID(Int_t is=-1) const;
128 Float_t GetS2Y() const { return fS2Y;}
129 Float_t GetS2Z() const { return fS2Z;}
130 Float_t GetSigmaY() const { return fS2Y > 0. ? TMath::Sqrt(fS2Y) : 0.2;}
131 Float_t GetSnp() const { return fYref[1]/TMath::Sqrt(1+fYref[1]*fYref[1]);}
132 Float_t GetTgl() const { return fZref[1]/TMath::Sqrt(1+fYref[1]*fYref[1]);}
133 Float_t GetTilt() const { return fPad[2];}
134 UInt_t GetTrackletWord() const { return 0;}
135 UShort_t GetVolumeId() const;
136 Float_t GetX0() const { return fX0;}
137 Float_t GetX() const { return fX0 - fX;}
138 Float_t GetY() const { return fYfit[0] - fYfit[1] * fX;}
139 Double_t GetYat(Double_t x) const { return fYfit[0] - fYfit[1] * (fX0-x);}
140 Float_t GetYfit(Int_t id) const { return fYfit[id];}
141 Float_t GetYref(Int_t id) const { return fYref[id];}
142 Float_t GetZ() const { return fZfit[0] - fZfit[1] * fX;}
143 Double_t GetZat(Double_t x) const { return fZfit[0] - fZfit[1] * (fX0-x);}
144 Float_t GetZfit(Int_t id) const { return fZfit[id];}
145 Float_t GetZref(Int_t id) const { return fZref[id];}
146 Int_t GetYbin() const { return Int_t(GetY()/0.016);}
147 Int_t GetZbin() const { return Int_t(GetZ()/fPad[0]);}
149 inline AliTRDcluster* NextCluster();
150 inline AliTRDcluster* PrevCluster();
151 void Print(Option_t *o = "") const;
152 inline void ResetClusterIter(Bool_t forward = kTRUE);
155 void SetC(Float_t c) { fC = c;}
156 void SetChi2(Float_t chi2) { fChi2 = chi2;}
157 inline void SetCovRef(const Double_t *cov);
158 void SetIndexes(Int_t i, Int_t idx) { fIndexes[i] = idx; }
159 void SetLabels(Int_t *lbls) { memcpy(fLabels, lbls, 3*sizeof(Int_t)); }
160 void SetKink(Bool_t k = kTRUE){ SetBit(kKink, k);}
161 void SetPID(Bool_t k = kTRUE) { SetBit(kPID, k);}
162 void SetStandAlone(Bool_t st) { SetBit(kStandAlone, st); }
163 void SetPt(Double_t pt) { fPt = pt;}
165 void SetPadPlane(AliTRDpadPlane *p);
166 void SetPadLength(Float_t l) { fPad[0] = l;}
167 void SetPadWidth(Float_t w) { fPad[1] = w;}
168 void SetTilt(Float_t tilt) { fPad[2] = tilt; }
169 void SetDetector(Int_t d) { fDet = d; }
170 void SetDX(Float_t inDX) { fdX = inDX;}
171 void SetReconstructor(const AliTRDReconstructor *rec) {fkReconstructor = rec;}
172 void SetX0(Float_t x0) { fX0 = x0; }
173 void SetYref(Int_t i, Float_t y) { fYref[i] = y;}
174 void SetZref(Int_t i, Float_t z) { fZref[i] = z;}
175 // void SetUsabilityMap(Long_t um) { fUsable = um; }
176 void Update(const AliTRDtrackV1* trk);
181 void Copy(TObject &ref) const;
184 inline void SetN(Int_t n);
185 inline void SetNUsed(Int_t n);
186 inline void SetNShared(Int_t n);
188 const AliTRDReconstructor *fkReconstructor;//! local reconstructor
189 AliTRDcluster **fClusterIter; //! clusters iterator
190 Int_t fIndexes[kNclusters]; //! Indexes
191 Float_t fExB; //! tg(a_L) @ tracklet location
192 Float_t fVD; //! drift velocity @ tracklet location
193 Float_t fT0; //! time 0 @ tracklet location
194 Float_t fS2PRF; //! sigma^2 PRF for xd->0 and phi=a_L
195 Float_t fDiffL; //! longitudinal diffusion coefficient
196 Float_t fDiffT; //! transversal diffusion coefficient
197 Char_t fClusterIdx; //! clusters iterator
198 UShort_t fN; // number of clusters attached/used/shared
199 Short_t fDet; // TRD detector
200 AliTRDcluster *fClusters[kNclusters]; // Clusters
201 Float_t fPad[3]; // local pad definition : length/width/tilt
202 Float_t fYref[2]; // Reference y, dydx
203 Float_t fZref[2]; // Reference z, dz/dx
204 Float_t fYfit[2]; // Fit y, dy/dx
205 Float_t fZfit[2]; // Fit z
206 Float_t fPt; // Pt estimate @ tracklet [GeV/c]
207 Float_t fdX; // length of time bin
208 Float_t fX0; // anode wire position
209 Float_t fX; // radial position of the tracklet
210 Float_t fY; // r-phi position of the tracklet
211 Float_t fZ; // z position of the tracklet
212 Float_t fS2Y; // estimated resolution in the r-phi direction
213 Float_t fS2Z; // estimated resolution in the z direction
214 Float_t fC; // Curvature
215 Float_t fChi2; // Global chi2
216 Float_t fdEdx[kNslices]; // dE/dx measurements for tracklet
217 Float_t fProb[AliPID::kSPECIES]; // PID probabilities
218 Int_t fLabels[3]; // most frequent MC labels and total number of different labels
219 Double_t fRefCov[7]; // covariance matrix of the track in the yz plane + the rest of the diagonal elements
220 Double_t fCov[3]; // covariance matrix of the tracklet in the xy plane
221 static TLinearFitter *fgFitterY; // Linear Fitter for tracklet fit in xy-plane
222 static TLinearFitter *fgFitterZ; // Linear Fitter for tracklet fit in xz-plane
224 ClassDef(AliTRDseedV1, 7) // The offline TRD tracklet
227 //____________________________________________________________
228 inline Float_t AliTRDseedV1::GetChi2Z() const
230 Double_t dz = fZref[0]-fZfit[0]; dz*=dz;
231 Double_t cov[3]; GetCovAt(fX, cov);
232 Double_t s2 = fRefCov[2]+cov[2];
233 return s2 > 0. ? dz/s2 : 0.;
236 //____________________________________________________________
237 inline Float_t AliTRDseedV1::GetChi2Y() const
239 Double_t dy = fYref[0]-fYfit[0]; dy*=dy;
240 Double_t cov[3]; GetCovAt(fX, cov);
241 Double_t s2 = fRefCov[0]+cov[0];
242 return s2 > 0. ? dy/s2 : 0.;
245 //____________________________________________________________
246 inline Float_t AliTRDseedV1::GetChi2Phi() const
248 Double_t dphi = fYref[1]-fYfit[1]; dphi*=dphi;
249 Double_t cov[3]; GetCovAt(fX, cov);
250 Double_t s2 = fRefCov[2]+cov[2];
251 return s2 > 0. ? dphi/s2 : 0.;
256 //____________________________________________________________
257 inline Double_t AliTRDseedV1::GetPID(Int_t is) const
259 if(is<0) return fProb[AliPID::kElectron];
260 if(is<AliPID::kSPECIES) return fProb[is];
264 //____________________________________________________________
265 inline void AliTRDseedV1::Init(const AliRieman *rieman)
267 fZref[0] = rieman->GetZat(fX0);
268 fZref[1] = rieman->GetDZat(fX0);
269 fYref[0] = rieman->GetYat(fX0);
270 fYref[1] = rieman->GetDYat(fX0);
271 if(fkReconstructor && fkReconstructor->IsHLT()){
275 fRefCov[0] = rieman->GetErrY(fX0);
276 fRefCov[2] = rieman->GetErrZ(fX0);
279 fChi2 = rieman->GetChi2();
282 //____________________________________________________________
283 inline AliTRDcluster* AliTRDseedV1::NextCluster()
285 // Mimic the usage of STL iterators.
288 fClusterIdx++; fClusterIter++;
289 while(fClusterIdx < kNclusters){
290 if(!(*fClusterIter)){
295 return *fClusterIter;
300 //____________________________________________________________
301 inline AliTRDcluster* AliTRDseedV1::PrevCluster()
303 // Mimic the usage of STL iterators.
306 fClusterIdx--; fClusterIter--;
307 while(fClusterIdx >= 0){
308 if(!(*fClusterIter)){
313 return *fClusterIter;
318 //____________________________________________________________
319 inline void AliTRDseedV1::ResetClusterIter(Bool_t forward)
321 // Mimic the usage of STL iterators.
322 // Facilitate the usage of NextCluster for forward like
323 // iterator (kTRUE) and PrevCluster for backward like iterator (kFALSE)
326 fClusterIter = &fClusters[0]; fClusterIter--;
329 fClusterIter = &fClusters[kNclusters-1]; fClusterIter++;
330 fClusterIdx=kNclusters;
334 //____________________________________________________________
335 inline void AliTRDseedV1::SetCovRef(const Double_t *cov)
337 // Copy some "important" covariance matrix elements
342 // cov(tgl, 1/pt) var(1/pt)
344 memcpy(&fRefCov[0], cov, 3*sizeof(Double_t)); // yz full covariance
345 fRefCov[3] = cov[ 5]; // snp variance
346 fRefCov[4] = cov[ 9]; // tgl variance
347 fRefCov[5] = cov[13]; // cov(tgl, 1/pt)
348 fRefCov[6] = cov[14]; // 1/pt variance
352 //____________________________________________________________
353 inline void AliTRDseedV1::SetN(Int_t n)
355 if(n<0 || n>= (1<<5)) return;
360 //____________________________________________________________
361 inline void AliTRDseedV1::SetNUsed(Int_t n)
363 if(n<0 || n>= (1<<5)) return;
368 //____________________________________________________________
369 inline void AliTRDseedV1::SetNShared(Int_t n)
371 if(n<0 || n>= (1<<5)) return;