3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
8 ////////////////////////////////////////////////////////////////////////////
10 // \class AliTRDseedV1
11 // \brief The TRD offline tracklet
12 // \author Alexandru Bercuci
14 ////////////////////////////////////////////////////////////////////////////
16 #ifndef ALITRDTRACKLETBASE_H
17 #include "AliTRDtrackletBase.h"
24 #ifndef ALITRDGEOMETRY_H
25 #include "AliTRDgeometry.h"
33 #include "AliRieman.h"
36 #ifndef ALITRDCLUSTER_H
37 #include "AliTRDcluster.h"
40 #include "AliTRDReconstructor.h"
42 class TTreeSRedirector;
47 class AliTRDtrackingChamber;
50 class AliTRDseedV1 : public AliTRDtrackletBase
52 friend class AliHLTTRDTracklet;
55 enum ETRDtrackletBuffers {
56 kNtb = 31 // max clusters/pad row
57 ,kNclusters = 2*kNtb // max number of clusters/tracklet
58 ,kNslices = 10 // max dEdx slices
61 // bits from 0-13 are reserved by ROOT (see TObject.h)
62 enum ETRDtrackletStatus {
63 kOwner = BIT(14) // owner of its clusters
64 ,kRowCross = BIT(15) // pad row cross tracklet
65 ,kPID = BIT(16) // PID contributor
66 ,kCalib = BIT(17) // calibrated tracklet
67 ,kKink = BIT(18) // kink prolongation tracklet
68 ,kStandAlone = BIT(19) // tracklet build during stand alone track finding
71 AliTRDseedV1(Int_t det = -1);
73 AliTRDseedV1(const AliTRDseedV1 &ref);
74 AliTRDseedV1& operator=(const AliTRDseedV1 &ref);
76 Bool_t AttachClusters(AliTRDtrackingChamber *const chamber, Bool_t tilt = kFALSE);
77 void Bootstrap(const AliTRDReconstructor *rec);
79 void CookdEdx(Int_t nslices);
82 Bool_t Fit(Bool_t tilt=kFALSE, Bool_t zcorr=kFALSE);
83 Bool_t Init(AliTRDtrackV1 *track);
84 inline void Init(const AliRieman *fit);
85 Bool_t IsEqual(const TObject *inTracklet) const;
86 Bool_t IsCalibrated() const { return TestBit(kCalib);}
87 Bool_t IsOwner() const { return TestBit(kOwner);}
88 Bool_t IsKink() const { return TestBit(kKink);}
89 Bool_t HasPID() const { return TestBit(kPID);}
90 Bool_t IsOK() const { return GetN() > 4 && GetNUsed() < 4;}
91 Bool_t IsRowCross() const { return TestBit(kRowCross);}
92 Bool_t IsUsable(Int_t i) const { return fClusters[i] && !fClusters[i]->IsUsed();}
93 Bool_t IsStandAlone() const { return TestBit(kStandAlone);}
95 Float_t GetC() const { return fC; }
96 Float_t GetChi2() const { return fChi2; }
97 inline Float_t GetChi2Z() const;
98 inline Float_t GetChi2Y() const;
99 inline Float_t GetChi2Phi() const;
100 void GetCovAt(Double_t x, Double_t *cov) const;
101 void GetCovXY(Double_t *cov) const { memcpy(cov, &fCov[0], 3*sizeof(Double_t));}
102 void GetCovRef(Double_t *cov) const { memcpy(cov, &fRefCov, 7*sizeof(Double_t));}
103 static Double_t GetCovSqrt(const Double_t * const c, Double_t *d);
104 static Double_t GetCovInv(const Double_t * const c, Double_t *d);
105 Float_t GetdX() const { return fdX;}
106 const Float_t* GetdEdx() const { return &fdEdx[0];}
107 Float_t GetdQdl(Int_t ic, Float_t *dx=NULL) const;
108 Float_t GetdYdX() const { return fYfit[1]; }
109 Float_t GetdZdX() const { return fZref[1]; }
110 Int_t GetdY() const { return Int_t(GetY()/0.014);}
111 Int_t GetDetector() const { return fDet;}
112 void GetCalibParam(Float_t &exb, Float_t &vd, Float_t &t0, Float_t &s2, Float_t &dl, Float_t &dt) const {
113 exb = fExB; vd = fVD; t0 = fT0; s2 = fS2PRF; dl = fDiffL; dt = fDiffT;}
114 AliTRDcluster* GetClusters(Int_t i) const { return i<0 || i>=kNclusters ? NULL: fClusters[i];}
115 static TLinearFitter* GetFitterY();
116 static TLinearFitter* GetFitterZ();
117 Int_t GetIndexes(Int_t i) const{ return i<0 || i>=kNclusters ? -1 : fIndexes[i];}
118 Int_t GetLabels(Int_t i) const { return fLabels[i];}
119 Float_t GetMomentum(Float_t *err = NULL) const;
120 Int_t GetN() const { return (Int_t)fN&0x1f;}
121 Int_t GetN2() const { return GetN();}
122 Int_t GetNUsed() const { return Int_t((fN>>5)&0x1f);}
123 Int_t GetNShared() const { return Int_t((fN>>10)&0x1f);}
124 Float_t GetQuality(Bool_t kZcorr) const;
125 Float_t GetPadLength() const { return fPad[0];}
126 Float_t GetPadWidth() const { return fPad[1];}
127 Int_t GetPlane() const { return AliTRDgeometry::GetLayer(fDet); }
129 Float_t* GetProbability(Bool_t force=kFALSE);
130 Float_t GetPt() const { return fPt; }
131 inline Double_t GetPID(Int_t is=-1) const;
132 Float_t GetS2Y() const { return fS2Y;}
133 Float_t GetS2Z() const { return fS2Z;}
134 Float_t GetSigmaY() const { return fS2Y > 0. ? TMath::Sqrt(fS2Y) : 0.2;}
135 Float_t GetSnp() const { return fYref[1]/TMath::Sqrt(1+fYref[1]*fYref[1]);}
136 Float_t GetTgl() const { return fZref[1]/TMath::Sqrt(1+fYref[1]*fYref[1]);}
137 Float_t GetTilt() const { return fPad[2];}
138 UInt_t GetTrackletWord() const { return 0;}
139 UShort_t GetVolumeId() const;
140 Float_t GetX0() const { return fX0;}
141 Float_t GetX() const { return fX0 - fX;}
142 Float_t GetY() const { return fYfit[0] - fYfit[1] * fX;}
143 Double_t GetYat(Double_t x) const { return fYfit[0] - fYfit[1] * (fX0-x);}
144 Float_t GetYfit(Int_t id) const { return fYfit[id];}
145 Float_t GetYref(Int_t id) const { return fYref[id];}
146 Float_t GetZ() const { return fZfit[0] - fZfit[1] * fX;}
147 Double_t GetZat(Double_t x) const { return fZfit[0] - fZfit[1] * (fX0-x);}
148 Float_t GetZfit(Int_t id) const { return fZfit[id];}
149 Float_t GetZref(Int_t id) const { return fZref[id];}
150 Int_t GetYbin() const { return Int_t(GetY()/0.016);}
151 Int_t GetZbin() const { return Int_t(GetZ()/fPad[0]);}
153 inline AliTRDcluster* NextCluster();
154 inline AliTRDcluster* PrevCluster();
155 void Print(Option_t *o = "") const;
156 inline void ResetClusterIter(Bool_t forward = kTRUE);
159 void SetC(Float_t c) { fC = c;}
160 void SetChi2(Float_t chi2) { fChi2 = chi2;}
161 inline void SetCovRef(const Double_t *cov);
162 void SetIndexes(Int_t i, Int_t idx) { fIndexes[i] = idx; }
163 void SetLabels(Int_t *lbls) { memcpy(fLabels, lbls, 3*sizeof(Int_t)); }
164 void SetKink(Bool_t k = kTRUE){ SetBit(kKink, k);}
165 void SetPID(Bool_t k = kTRUE) { SetBit(kPID, k);}
166 void SetStandAlone(Bool_t st) { SetBit(kStandAlone, st); }
167 void SetPt(Double_t pt) { fPt = pt;}
169 void SetPadPlane(AliTRDpadPlane *p);
170 void SetPadLength(Float_t l) { fPad[0] = l;}
171 void SetPadWidth(Float_t w) { fPad[1] = w;}
172 void SetTilt(Float_t tilt) { fPad[2] = tilt; }
173 void SetDetector(Int_t d) { fDet = d; }
174 void SetDX(Float_t inDX) { fdX = inDX;}
175 void SetReconstructor(const AliTRDReconstructor *rec) {fkReconstructor = rec;}
176 void SetX0(Float_t x0) { fX0 = x0; }
177 void SetYref(Int_t i, Float_t y) { fYref[i] = y;}
178 void SetZref(Int_t i, Float_t z) { fZref[i] = z;}
179 // void SetUsabilityMap(Long_t um) { fUsable = um; }
180 void Update(const AliTRDtrackV1* trk);
185 void Copy(TObject &ref) const;
188 inline void SetN(Int_t n);
189 inline void SetNUsed(Int_t n);
190 inline void SetNShared(Int_t n);
192 const AliTRDReconstructor *fkReconstructor;//! local reconstructor
193 AliTRDcluster **fClusterIter; //! clusters iterator
194 Int_t fIndexes[kNclusters]; //! Indexes
195 Float_t fExB; //! tg(a_L) @ tracklet location
196 Float_t fVD; //! drift velocity @ tracklet location
197 Float_t fT0; //! time 0 @ tracklet location
198 Float_t fS2PRF; //! sigma^2 PRF for xd->0 and phi=a_L
199 Float_t fDiffL; //! longitudinal diffusion coefficient
200 Float_t fDiffT; //! transversal diffusion coefficient
201 Char_t fClusterIdx; //! clusters iterator
202 UShort_t fN; // number of clusters attached/used/shared
203 Short_t fDet; // TRD detector
204 AliTRDcluster *fClusters[kNclusters]; // Clusters
205 Float_t fPad[3]; // local pad definition : length/width/tilt
206 Float_t fYref[2]; // Reference y, dydx
207 Float_t fZref[2]; // Reference z, dz/dx
208 Float_t fYfit[2]; // Fit y, dy/dx
209 Float_t fZfit[2]; // Fit z
210 Float_t fPt; // Pt estimate @ tracklet [GeV/c]
211 Float_t fdX; // length of time bin
212 Float_t fX0; // anode wire position
213 Float_t fX; // radial position of the tracklet
214 Float_t fY; // r-phi position of the tracklet
215 Float_t fZ; // z position of the tracklet
216 Float_t fS2Y; // estimated resolution in the r-phi direction
217 Float_t fS2Z; // estimated resolution in the z direction
218 Float_t fC; // Curvature
219 Float_t fChi2; // Global chi2
220 Float_t fdEdx[kNslices]; // dE/dx measurements for tracklet
221 Float_t fProb[AliPID::kSPECIES]; // PID probabilities
222 Int_t fLabels[3]; // most frequent MC labels and total number of different labels
223 Double_t fRefCov[7]; // covariance matrix of the track in the yz plane + the rest of the diagonal elements
224 Double_t fCov[3]; // covariance matrix of the tracklet in the xy plane
225 static TLinearFitter *fgFitterY; // Linear Fitter for tracklet fit in xy-plane
226 static TLinearFitter *fgFitterZ; // Linear Fitter for tracklet fit in xz-plane
228 ClassDef(AliTRDseedV1, 7) // The offline TRD tracklet
231 //____________________________________________________________
232 inline Float_t AliTRDseedV1::GetChi2Z() const
234 Double_t dz = fZref[0]-fZfit[0]; dz*=dz;
235 Double_t cov[3]; GetCovAt(fX, cov);
236 Double_t s2 = fRefCov[2]+cov[2];
237 return s2 > 0. ? dz/s2 : 0.;
240 //____________________________________________________________
241 inline Float_t AliTRDseedV1::GetChi2Y() const
243 Double_t dy = fYref[0]-fYfit[0]; dy*=dy;
244 Double_t cov[3]; GetCovAt(fX, cov);
245 Double_t s2 = fRefCov[0]+cov[0];
246 return s2 > 0. ? dy/s2 : 0.;
249 //____________________________________________________________
250 inline Float_t AliTRDseedV1::GetChi2Phi() const
252 Double_t dphi = fYref[1]-fYfit[1]; dphi*=dphi;
253 Double_t cov[3]; GetCovAt(fX, cov);
254 Double_t s2 = fRefCov[2]+cov[2];
255 return s2 > 0. ? dphi/s2 : 0.;
260 //____________________________________________________________
261 inline Double_t AliTRDseedV1::GetPID(Int_t is) const
263 if(is<0) return fProb[AliPID::kElectron];
264 if(is<AliPID::kSPECIES) return fProb[is];
268 //____________________________________________________________
269 inline void AliTRDseedV1::Init(const AliRieman *rieman)
271 fZref[0] = rieman->GetZat(fX0);
272 fZref[1] = rieman->GetDZat(fX0);
273 fYref[0] = rieman->GetYat(fX0);
274 fYref[1] = rieman->GetDYat(fX0);
275 if(fkReconstructor && fkReconstructor->IsHLT()){
279 fRefCov[0] = rieman->GetErrY(fX0);
280 fRefCov[2] = rieman->GetErrZ(fX0);
283 fChi2 = rieman->GetChi2();
286 //____________________________________________________________
287 inline AliTRDcluster* AliTRDseedV1::NextCluster()
289 // Mimic the usage of STL iterators.
292 fClusterIdx++; fClusterIter++;
293 while(fClusterIdx < kNclusters){
294 if(!(*fClusterIter)){
299 return *fClusterIter;
304 //____________________________________________________________
305 inline AliTRDcluster* AliTRDseedV1::PrevCluster()
307 // Mimic the usage of STL iterators.
310 fClusterIdx--; fClusterIter--;
311 while(fClusterIdx >= 0){
312 if(!(*fClusterIter)){
317 return *fClusterIter;
322 //____________________________________________________________
323 inline void AliTRDseedV1::ResetClusterIter(Bool_t forward)
325 // Mimic the usage of STL iterators.
326 // Facilitate the usage of NextCluster for forward like
327 // iterator (kTRUE) and PrevCluster for backward like iterator (kFALSE)
330 fClusterIter = &fClusters[0]; fClusterIter--;
333 fClusterIter = &fClusters[kNclusters-1]; fClusterIter++;
334 fClusterIdx=kNclusters;
338 //____________________________________________________________
339 inline void AliTRDseedV1::SetCovRef(const Double_t *cov)
341 // Copy some "important" covariance matrix elements
346 // cov(tgl, 1/pt) var(1/pt)
348 memcpy(&fRefCov[0], cov, 3*sizeof(Double_t)); // yz full covariance
349 fRefCov[3] = cov[ 5]; // snp variance
350 fRefCov[4] = cov[ 9]; // tgl variance
351 fRefCov[5] = cov[13]; // cov(tgl, 1/pt)
352 fRefCov[6] = cov[14]; // 1/pt variance
356 //____________________________________________________________
357 inline void AliTRDseedV1::SetN(Int_t n)
359 if(n<0 || n>= (1<<5)) return;
364 //____________________________________________________________
365 inline void AliTRDseedV1::SetNUsed(Int_t n)
367 if(n<0 || n>= (1<<5)) return;
372 //____________________________________________________________
373 inline void AliTRDseedV1::SetNShared(Int_t n)
375 if(n<0 || n>= (1<<5)) return;