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