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