]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDseedV1.h
Avoiding warnings
[u/mrichter/AliRoot.git] / TRD / AliTRDseedV1.h
CommitLineData
e4f2f73d 1#ifndef ALITRDSEEDV1_H
2#define ALITRDSEEDV1_H
3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
e44586fb 4* See cxx source for full Copyright notice */
e4f2f73d 5
6/* $Id$ */
7
8////////////////////////////////////////////////////////////////////////////
9// //
3e778975 10// The TRD offline tracklet //
e4f2f73d 11// //
12////////////////////////////////////////////////////////////////////////////
13
3e778975 14#ifndef ALITRDTRACKLETBASE_H
15#include "AliTRDtrackletBase.h"
e3cf3d02 16#endif
17
18#ifndef ROOT_TMath
19#include "TMath.h"
e4f2f73d 20#endif
21
ae4e8b84 22#ifndef ALITRDGEOMETRY_H
23#include "AliTRDgeometry.h"
24#endif
25
0906e73e 26#ifndef ALIPID_H
27#include "AliPID.h"
28#endif
29
e4f2f73d 30#ifndef ALIRIEMAN_H
31#include "AliRieman.h"
32#endif
33
f29f13a6 34#ifndef ALITRDCLUSTER_H
35#include "AliTRDcluster.h"
36#endif
37
d07eec70 38#include "AliTRDReconstructor.h"
39
e4f2f73d 40class TTreeSRedirector;
f301a656 41class TLinearFitter;
e4f2f73d 42
43class AliRieman;
44
eb38ed55 45class AliTRDtrackingChamber;
f3d3af1b 46class AliTRDtrackV1;
eb2b4f91 47class AliTRDpadPlane;
3e778975 48class AliTRDseedV1 : public AliTRDtrackletBase
49{
3044dfe5 50 friend class AliHLTTRDTracklet;
51
e3cf3d02 52public:
53 enum ETRDtrackletBuffers {
8d2bec9e 54 kNtb = 31 // max clusters/pad row
55 ,kNclusters = 2*kNtb // max number of clusters/tracklet
56 ,kNslices = 10 // max dEdx slices
e44586fb 57 };
e3cf3d02 58
2e2915e7 59 // bits from 0-13 are reserved by ROOT (see TObject.h)
e3cf3d02 60 enum ETRDtrackletStatus {
f29f13a6 61 kOwner = BIT(14) // owner of its clusters
62 ,kRowCross = BIT(15) // pad row cross tracklet
e20bef2b 63 ,kPID = BIT(16) // PID contributor
64 ,kCalib = BIT(17) // calibrated tracklet
65 ,kKink = BIT(18) // kink prolongation tracklet
1fd9389f 66 ,kStandAlone = BIT(19) // tracklet build during stand alone track finding
e44586fb 67 };
68
ae4e8b84 69 AliTRDseedV1(Int_t det = -1);
e44586fb 70 ~AliTRDseedV1();
71 AliTRDseedV1(const AliTRDseedV1 &ref);
72 AliTRDseedV1& operator=(const AliTRDseedV1 &ref);
73
4d6aee34 74 Bool_t AttachClusters(AliTRDtrackingChamber *const chamber, Bool_t tilt = kFALSE);
203967fc 75 void Bootstrap(const AliTRDReconstructor *rec);
e3cf3d02 76 void Calibrate();
203967fc 77 void CookdEdx(Int_t nslices);
e3cf3d02 78 void CookLabels();
3e778975 79 Bool_t CookPID();
b72f4eaf 80 Bool_t Fit(Bool_t tilt=kFALSE, Bool_t zcorr=kFALSE);
203967fc 81 Bool_t Init(AliTRDtrackV1 *track);
e44586fb 82 inline void Init(const AliRieman *fit);
203967fc 83 Bool_t IsEqual(const TObject *inTracklet) const;
e3cf3d02 84 Bool_t IsCalibrated() const { return TestBit(kCalib);}
e44586fb 85 Bool_t IsOwner() const { return TestBit(kOwner);}
f29f13a6 86 Bool_t IsKink() const { return TestBit(kKink);}
e20bef2b 87 Bool_t HasPID() const { return TestBit(kPID);}
3e778975 88 Bool_t IsOK() const { return GetN() > 4 && GetNUsed() < 4;}
e44586fb 89 Bool_t IsRowCross() const { return TestBit(kRowCross);}
f29f13a6 90 Bool_t IsUsable(Int_t i) const { return fClusters[i] && !fClusters[i]->IsUsed();}
91 Bool_t IsStandAlone() const { return TestBit(kStandAlone);}
e44586fb 92
e3cf3d02 93 Float_t GetC() const { return fC; }
94 Float_t GetChi2() const { return fChi2; }
95 inline Float_t GetChi2Z() const;
96 inline Float_t GetChi2Y() const;
f29f13a6 97 inline Float_t GetChi2Phi() const;
e44586fb 98 void GetCovAt(Double_t x, Double_t *cov) const;
d937ad7a 99 void GetCovXY(Double_t *cov) const { memcpy(cov, &fCov[0], 3*sizeof(Double_t));}
16cca13f 100 void GetCovRef(Double_t *cov) const { memcpy(cov, &fRefCov, 7*sizeof(Double_t));}
4d6aee34 101 static Double_t GetCovSqrt(const Double_t * const c, Double_t *d);
102 static Double_t GetCovInv(const Double_t * const c, Double_t *d);
203967fc 103 Float_t GetdX() const { return fdX;}
4d6aee34 104 const Float_t* GetdEdx() const { return &fdEdx[0];}
105 Float_t GetdQdl(Int_t ic, Float_t *dx=NULL) const;
3e778975 106 Float_t GetdYdX() const { return fYfit[1]; }
107 Float_t GetdZdX() const { return fZref[1]; }
108 Int_t GetdY() const { return Int_t(GetY()/0.014);}
203967fc 109 Int_t GetDetector() const { return fDet;}
e3cf3d02 110 void GetCalibParam(Float_t &exb, Float_t &vd, Float_t &t0, Float_t &s2, Float_t &dl, Float_t &dt) const {
111 exb = fExB; vd = fVD; t0 = fT0; s2 = fS2PRF; dl = fDiffL; dt = fDiffT;}
4d6aee34 112 AliTRDcluster* GetClusters(Int_t i) const { return i<0 || i>=kNclusters ? NULL: fClusters[i];}
f301a656 113 static TLinearFitter* GetFitterY();
114 static TLinearFitter* GetFitterZ();
8d2bec9e 115 Int_t GetIndexes(Int_t i) const{ return i<0 || i>=kNclusters ? -1 : fIndexes[i];}
e3cf3d02 116 Int_t GetLabels(Int_t i) const { return fLabels[i];}
4d6aee34 117 Float_t GetMomentum(Float_t *err = NULL) const;
3e778975 118 Int_t GetN() const { return (Int_t)fN&0x1f;}
119 Int_t GetN2() const { return GetN();}
120 Int_t GetNUsed() const { return Int_t((fN>>5)&0x1f);}
121 Int_t GetNShared() const { return Int_t((fN>>10)&0x1f);}
e44586fb 122 Float_t GetQuality(Bool_t kZcorr) const;
dd8059a8 123 Float_t GetPadLength() const { return fPad[0];}
124 Float_t GetPadWidth() const { return fPad[1];}
ae4e8b84 125 Int_t GetPlane() const { return AliTRDgeometry::GetLayer(fDet); }
126
3e778975 127 Float_t* GetProbability(Bool_t force=kFALSE);
b25a5e9e 128 Float_t GetPt() const { return fPt; }
3e778975 129 inline Double_t GetPID(Int_t is=-1) const;
e3cf3d02 130 Float_t GetS2Y() const { return fS2Y;}
131 Float_t GetS2Z() const { return fS2Z;}
132 Float_t GetSigmaY() const { return fS2Y > 0. ? TMath::Sqrt(fS2Y) : 0.2;}
133 Float_t GetSnp() const { return fYref[1]/TMath::Sqrt(1+fYref[1]*fYref[1]);}
1fd9389f 134 Float_t GetTgl() const { return fZref[1]/TMath::Sqrt(1+fYref[1]*fYref[1]);}
dd8059a8 135 Float_t GetTilt() const { return fPad[2];}
3e778975 136 UInt_t GetTrackletWord() const { return 0;}
b72f4eaf 137 UShort_t GetVolumeId() const;
e3cf3d02 138 Float_t GetX0() const { return fX0;}
139 Float_t GetX() const { return fX0 - fX;}
5a7a515d 140 Float_t GetY() const { return fYfit[0] - fYfit[1] * fX;}
b1957d3c 141 Double_t GetYat(Double_t x) const { return fYfit[0] - fYfit[1] * (fX0-x);}
1fd9389f 142 Float_t GetYfit(Int_t id) const { return fYfit[id];}
143 Float_t GetYref(Int_t id) const { return fYref[id];}
144 Float_t GetZ() const { return fZfit[0] - fZfit[1] * fX;}
b1957d3c 145 Double_t GetZat(Double_t x) const { return fZfit[0] - fZfit[1] * (fX0-x);}
1fd9389f 146 Float_t GetZfit(Int_t id) const { return fZfit[id];}
147 Float_t GetZref(Int_t id) const { return fZref[id];}
148 Int_t GetYbin() const { return Int_t(GetY()/0.016);}
149 Int_t GetZbin() const { return Int_t(GetZ()/fPad[0]);}
e3cf3d02 150
ae4e8b84 151 inline AliTRDcluster* NextCluster();
71ea19a3 152 inline AliTRDcluster* PrevCluster();
e44586fb 153 void Print(Option_t *o = "") const;
71ea19a3 154 inline void ResetClusterIter(Bool_t forward = kTRUE);
e3cf3d02 155 void Reset();
ae4e8b84 156
1fd9389f 157 void SetC(Float_t c) { fC = c;}
158 void SetChi2(Float_t chi2) { fChi2 = chi2;}
16cca13f 159 inline void SetCovRef(const Double_t *cov);
e3cf3d02 160 void SetIndexes(Int_t i, Int_t idx) { fIndexes[i] = idx; }
161 void SetLabels(Int_t *lbls) { memcpy(fLabels, lbls, 3*sizeof(Int_t)); }
e20bef2b 162 void SetKink(Bool_t k = kTRUE){ SetBit(kKink, k);}
163 void SetPID(Bool_t k = kTRUE) { SetBit(kPID, k);}
f29f13a6 164 void SetStandAlone(Bool_t st) { SetBit(kStandAlone, st); }
b25a5e9e 165 void SetPt(Double_t pt) { fPt = pt;}
29b87567 166 void SetOwner();
eb2b4f91 167 void SetPadPlane(AliTRDpadPlane *p);
dd8059a8 168 void SetPadLength(Float_t l) { fPad[0] = l;}
169 void SetPadWidth(Float_t w) { fPad[1] = w;}
cbe97468 170 void SetTilt(Float_t tilt) { fPad[2] = tilt; }
203967fc 171 void SetDetector(Int_t d) { fDet = d; }
bee2b41e 172 void SetDX(Float_t inDX) { fdX = inDX;}
4d6aee34 173 void SetReconstructor(const AliTRDReconstructor *rec) {fkReconstructor = rec;}
e3cf3d02 174 void SetX0(Float_t x0) { fX0 = x0; }
175 void SetYref(Int_t i, Float_t y) { fYref[i] = y;}
176 void SetZref(Int_t i, Float_t z) { fZref[i] = z;}
f29f13a6 177// void SetUsabilityMap(Long_t um) { fUsable = um; }
16cca13f 178 void Update(const AliTRDtrackV1* trk);
e3cf3d02 179 void UpdateUsed();
180 void UseClusters();
e4f2f73d 181
d937ad7a 182protected:
3e778975 183 void Copy(TObject &ref) const;
e4f2f73d 184
e44586fb 185private:
3e778975 186 inline void SetN(Int_t n);
187 inline void SetNUsed(Int_t n);
188 inline void SetNShared(Int_t n);
189
4d6aee34 190 const AliTRDReconstructor *fkReconstructor;//! local reconstructor
e3cf3d02 191 AliTRDcluster **fClusterIter; //! clusters iterator
8d2bec9e 192 Int_t fIndexes[kNclusters]; //! Indexes
e3cf3d02 193 Float_t fExB; //! tg(a_L) @ tracklet location
194 Float_t fVD; //! drift velocity @ tracklet location
195 Float_t fT0; //! time 0 @ tracklet location
196 Float_t fS2PRF; //! sigma^2 PRF for xd->0 and phi=a_L
197 Float_t fDiffL; //! longitudinal diffusion coefficient
198 Float_t fDiffT; //! transversal diffusion coefficient
71ea19a3 199 Char_t fClusterIdx; //! clusters iterator
dd8059a8 200 UShort_t fN; // number of clusters attached/used/shared
e3cf3d02 201 Short_t fDet; // TRD detector
8d2bec9e 202 AliTRDcluster *fClusters[kNclusters]; // Clusters
dd8059a8 203 Float_t fPad[3]; // local pad definition : length/width/tilt
1fd9389f 204 Float_t fYref[2]; // Reference y, dydx
205 Float_t fZref[2]; // Reference z, dz/dx
206 Float_t fYfit[2]; // Fit y, dy/dx
207 Float_t fZfit[2]; // Fit z
16cca13f 208 Float_t fPt; // Pt estimate @ tracklet [GeV/c]
e44586fb 209 Float_t fdX; // length of time bin
e3cf3d02 210 Float_t fX0; // anode wire position
211 Float_t fX; // radial position of the tracklet
212 Float_t fY; // r-phi position of the tracklet
213 Float_t fZ; // z position of the tracklet
214 Float_t fS2Y; // estimated resolution in the r-phi direction
215 Float_t fS2Z; // estimated resolution in the z direction
216 Float_t fC; // Curvature
217 Float_t fChi2; // Global chi2
8d2bec9e 218 Float_t fdEdx[kNslices]; // dE/dx measurements for tracklet
1fd9389f 219 Float_t fProb[AliPID::kSPECIES]; // PID probabilities
e3cf3d02 220 Int_t fLabels[3]; // most frequent MC labels and total number of different labels
16cca13f 221 Double_t fRefCov[7]; // covariance matrix of the track in the yz plane + the rest of the diagonal elements
d937ad7a 222 Double_t fCov[3]; // covariance matrix of the tracklet in the xy plane
4d6aee34 223 static TLinearFitter *fgFitterY; // Linear Fitter for tracklet fit in xy-plane
224 static TLinearFitter *fgFitterZ; // Linear Fitter for tracklet fit in xz-plane
e4f2f73d 225
16cca13f 226 ClassDef(AliTRDseedV1, 7) // The offline TRD tracklet
e4f2f73d 227};
228
229//____________________________________________________________
e3cf3d02 230inline Float_t AliTRDseedV1::GetChi2Z() const
e4f2f73d 231{
e3cf3d02 232 Double_t dz = fZref[0]-fZfit[0]; dz*=dz;
233 Double_t cov[3]; GetCovAt(fX, cov);
234 Double_t s2 = fRefCov[2]+cov[2];
235 return s2 > 0. ? dz/s2 : 0.;
e4f2f73d 236}
237
238//____________________________________________________________
e3cf3d02 239inline Float_t AliTRDseedV1::GetChi2Y() const
e4f2f73d 240{
e3cf3d02 241 Double_t dy = fYref[0]-fYfit[0]; dy*=dy;
242 Double_t cov[3]; GetCovAt(fX, cov);
243 Double_t s2 = fRefCov[0]+cov[0];
244 return s2 > 0. ? dy/s2 : 0.;
e4f2f73d 245}
246
f29f13a6 247//____________________________________________________________
248inline Float_t AliTRDseedV1::GetChi2Phi() const
249{
250 Double_t dphi = fYref[1]-fYfit[1]; dphi*=dphi;
251 Double_t cov[3]; GetCovAt(fX, cov);
252 Double_t s2 = fRefCov[2]+cov[2];
253 return s2 > 0. ? dphi/s2 : 0.;
254}
255
16cca13f 256
257
3e778975 258//____________________________________________________________
259inline Double_t AliTRDseedV1::GetPID(Int_t is) const
260{
261 if(is<0) return fProb[AliPID::kElectron];
262 if(is<AliPID::kSPECIES) return fProb[is];
263 return 0.;
264}
265
e4f2f73d 266//____________________________________________________________
0906e73e 267inline void AliTRDseedV1::Init(const AliRieman *rieman)
e4f2f73d 268{
e44586fb 269 fZref[0] = rieman->GetZat(fX0);
270 fZref[1] = rieman->GetDZat(fX0);
271 fYref[0] = rieman->GetYat(fX0);
272 fYref[1] = rieman->GetDYat(fX0);
4d6aee34 273 if(fkReconstructor && fkReconstructor->IsHLT()){
d07eec70 274 fRefCov[0] = 1;
275 fRefCov[2] = 10;
276 }else{
277 fRefCov[0] = rieman->GetErrY(fX0);
278 fRefCov[2] = rieman->GetErrZ(fX0);
279 }
55ef6967 280 fC = rieman->GetC();
281 fChi2 = rieman->GetChi2();
e4f2f73d 282}
283
ae4e8b84 284//____________________________________________________________
285inline AliTRDcluster* AliTRDseedV1::NextCluster()
286{
71ea19a3 287// Mimic the usage of STL iterators.
288// Forward iterator
289
ae4e8b84 290 fClusterIdx++; fClusterIter++;
8d2bec9e 291 while(fClusterIdx < kNclusters){
71ea19a3 292 if(!(*fClusterIter)){
293 fClusterIdx++;
294 fClusterIter++;
295 continue;
296 }
297 return *fClusterIter;
298 }
4d6aee34 299 return NULL;
71ea19a3 300}
301
302//____________________________________________________________
303inline AliTRDcluster* AliTRDseedV1::PrevCluster()
304{
305// Mimic the usage of STL iterators.
306// Backward iterator
307
308 fClusterIdx--; fClusterIter--;
309 while(fClusterIdx >= 0){
310 if(!(*fClusterIter)){
311 fClusterIdx--;
312 fClusterIter--;
313 continue;
314 }
315 return *fClusterIter;
316 }
4d6aee34 317 return NULL;
71ea19a3 318}
319
320//____________________________________________________________
321inline void AliTRDseedV1::ResetClusterIter(Bool_t forward)
322{
323// Mimic the usage of STL iterators.
324// Facilitate the usage of NextCluster for forward like
325// iterator (kTRUE) and PrevCluster for backward like iterator (kFALSE)
326
327 if(forward){
328 fClusterIter = &fClusters[0]; fClusterIter--;
329 fClusterIdx=-1;
330 } else {
8d2bec9e 331 fClusterIter = &fClusters[kNclusters-1]; fClusterIter++;
332 fClusterIdx=kNclusters;
71ea19a3 333 }
ae4e8b84 334}
335
16cca13f 336//____________________________________________________________
337inline void AliTRDseedV1::SetCovRef(const Double_t *cov)
338{
339// Copy some "important" covariance matrix elements
340// var(y)
341// cov(y,z) var(z)
342// var(snp)
343// var(tgl)
344// cov(tgl, 1/pt) var(1/pt)
345
346 memcpy(&fRefCov[0], cov, 3*sizeof(Double_t)); // yz full covariance
347 fRefCov[3] = cov[ 5]; // snp variance
348 fRefCov[4] = cov[ 9]; // tgl variance
349 fRefCov[5] = cov[13]; // cov(tgl, 1/pt)
350 fRefCov[6] = cov[14]; // 1/pt variance
351}
352
353
3e778975 354//____________________________________________________________
355inline void AliTRDseedV1::SetN(Int_t n)
356{
357 if(n<0 || n>= (1<<5)) return;
358 fN &= ~0x1f;
359 fN |= n;
360}
361
362//____________________________________________________________
363inline void AliTRDseedV1::SetNUsed(Int_t n)
364{
365 if(n<0 || n>= (1<<5)) return;
366 fN &= ~(0x1f<<5);
367 n <<= 5; fN |= n;
368}
369
370//____________________________________________________________
371inline void AliTRDseedV1::SetNShared(Int_t n)
372{
373 if(n<0 || n>= (1<<5)) return;
374 fN &= ~(0x1f<<10);
375 n <<= 10; fN |= n;
376}
377
378
e4f2f73d 379#endif
380
47d5d320 381
6e49cfdb 382