]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDseedV1.h
store pt in the tracklet instead of momentum
[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
e4f2f73d 38class TTreeSRedirector;
39
40class AliRieman;
41
eb38ed55 42class AliTRDtrackingChamber;
f3d3af1b 43class AliTRDtrackV1;
3a039a31 44class AliTRDReconstructor;
eb2b4f91 45class AliTRDpadPlane;
3e778975 46class AliTRDseedV1 : public AliTRDtrackletBase
47{
e3cf3d02 48public:
49 enum ETRDtrackletBuffers {
8d2bec9e 50 kNtb = 31 // max clusters/pad row
51 ,kNclusters = 2*kNtb // max number of clusters/tracklet
52 ,kNslices = 10 // max dEdx slices
e44586fb 53 };
e3cf3d02 54
2e2915e7 55 // bits from 0-13 are reserved by ROOT (see TObject.h)
e3cf3d02 56 enum ETRDtrackletStatus {
f29f13a6 57 kOwner = BIT(14) // owner of its clusters
58 ,kRowCross = BIT(15) // pad row cross tracklet
59 ,kCalib = BIT(16) // calibrated tracklet
60 ,kKink = BIT(17) // kink prolongation tracklet
61 ,kStandAlone = BIT(18)
e44586fb 62 };
63
ae4e8b84 64 AliTRDseedV1(Int_t det = -1);
e44586fb 65 ~AliTRDseedV1();
66 AliTRDseedV1(const AliTRDseedV1 &ref);
67 AliTRDseedV1& operator=(const AliTRDseedV1 &ref);
68
f29f13a6 69/* Bool_t AttachClustersIter(
203967fc 70 AliTRDtrackingChamber *chamber, Float_t quality,
f29f13a6 71 Bool_t kZcorr = kFALSE, AliTRDcluster *c=0x0);*/
203967fc 72 Bool_t AttachClusters(
b1957d3c 73 AliTRDtrackingChamber *chamber, Bool_t tilt = kFALSE);
203967fc 74 void Bootstrap(const AliTRDReconstructor *rec);
e3cf3d02 75 void Calibrate();
203967fc 76 void CookdEdx(Int_t nslices);
e3cf3d02 77 void CookLabels();
3e778975 78 Bool_t CookPID();
d937ad7a 79 Bool_t Fit(Bool_t tilt=kTRUE, Int_t errors = 2);
f29f13a6 80// void FitMI();
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);}
3e778975 87 Bool_t IsOK() const { return GetN() > 4 && GetNUsed() < 4;}
e44586fb 88 Bool_t IsRowCross() const { return TestBit(kRowCross);}
f29f13a6 89 Bool_t IsUsable(Int_t i) const { return fClusters[i] && !fClusters[i]->IsUsed();}
90 Bool_t IsStandAlone() const { return TestBit(kStandAlone);}
e44586fb 91
e3cf3d02 92 Float_t GetC() const { return fC; }
93 Float_t GetChi2() const { return fChi2; }
94 inline Float_t GetChi2Z() const;
95 inline Float_t GetChi2Y() const;
f29f13a6 96 inline Float_t GetChi2Phi() const;
d937ad7a 97 static void GetClusterXY(const AliTRDcluster *c, Double_t &x, Double_t &y);
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));}
bb2db46c 100 void GetCovRef(Double_t *cov) const { memcpy(cov, &fRefCov, 3*sizeof(Double_t));}
101 static Double_t GetCovSqrt(Double_t *c, Double_t *d);
102 static Double_t GetCovInv(Double_t *c, Double_t *d);
203967fc 103 Float_t GetdX() const { return fdX;}
104 Float_t* GetdEdx() { return &fdEdx[0];}
e44586fb 105 Float_t GetdQdl(Int_t ic) 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;}
8d2bec9e 112 AliTRDcluster* GetClusters(Int_t i) const { return i<0 || i>=kNclusters ? 0x0 : fClusters[i];}
113 Int_t GetIndexes(Int_t i) const{ return i<0 || i>=kNclusters ? -1 : fIndexes[i];}
e3cf3d02 114 Int_t GetLabels(Int_t i) const { return fLabels[i];}
b25a5e9e 115 Float_t GetMomentum() const { return fPt*TMath::Sqrt(1.+fZref[1]*fZref[1]);}
3e778975 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);}
e44586fb 120 Float_t GetQuality(Bool_t kZcorr) const;
dd8059a8 121 Float_t GetPadLength() const { return fPad[0];}
122 Float_t GetPadWidth() const { return fPad[1];}
ae4e8b84 123 Int_t GetPlane() const { return AliTRDgeometry::GetLayer(fDet); }
124
3e778975 125 Float_t* GetProbability(Bool_t force=kFALSE);
b25a5e9e 126 Float_t GetPt() const { return fPt; }
3e778975 127 inline Double_t GetPID(Int_t is=-1) const;
e3cf3d02 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];}
dd8059a8 133 Float_t GetTilt() const { return fPad[2];}
3e778975 134 UInt_t GetTrackletWord() const { return 0;}
e3cf3d02 135 Float_t GetX0() const { return fX0;}
136 Float_t GetX() const { return fX0 - fX;}
5a7a515d 137 Float_t GetY() const { return fYfit[0] - fYfit[1] * fX;}
b1957d3c 138 Double_t GetYat(Double_t x) const { return fYfit[0] - fYfit[1] * (fX0-x);}
e3cf3d02 139 Float_t GetYfit(Int_t id) const { return fYfit[id];}
140 Float_t GetYref(Int_t id) const { return fYref[id];}
3658afdc 141 Float_t GetZ() const { return fZfit[0] - fZfit[1] * fX;}
b1957d3c 142 Double_t GetZat(Double_t x) const { return fZfit[0] - fZfit[1] * (fX0-x);}
e3cf3d02 143 Float_t GetZfit(Int_t id) const { return fZfit[id];}
144 Float_t GetZref(Int_t id) const { return fZref[id];}
3e778975 145 Int_t GetYbin() const { return Int_t(GetY()/0.016);}
dd8059a8 146 Int_t GetZbin() const { return Int_t(GetZ()/fPad[0]);}
e3cf3d02 147
ae4e8b84 148 inline AliTRDcluster* NextCluster();
71ea19a3 149 inline AliTRDcluster* PrevCluster();
e44586fb 150 void Print(Option_t *o = "") const;
71ea19a3 151 inline void ResetClusterIter(Bool_t forward = kTRUE);
e3cf3d02 152 void Reset();
ae4e8b84 153
e3cf3d02 154 void SetC(Float_t c) { fC = c;}
155 void SetChi2(Float_t chi2) { fChi2 = chi2;}
0849f128 156 void SetCovRef(const Double_t *cov) { memcpy(&fRefCov[0], cov, 3*sizeof(Double_t));}
e3cf3d02 157 void SetIndexes(Int_t i, Int_t idx) { fIndexes[i] = idx; }
158 void SetLabels(Int_t *lbls) { memcpy(fLabels, lbls, 3*sizeof(Int_t)); }
f29f13a6 159 void SetKink(Bool_t k) { SetBit(kKink, k);}
160 void SetStandAlone(Bool_t st) { SetBit(kStandAlone, st); }
b25a5e9e 161 void SetPt(Double_t pt) { fPt = pt;}
29b87567 162 void SetOwner();
eb2b4f91 163 void SetPadPlane(AliTRDpadPlane *p);
dd8059a8 164 void SetPadLength(Float_t l) { fPad[0] = l;}
165 void SetPadWidth(Float_t w) { fPad[1] = w;}
cbe97468 166 void SetTilt(Float_t tilt) { fPad[2] = tilt; }
203967fc 167 void SetDetector(Int_t d) { fDet = d; }
bee2b41e 168 void SetDX(Float_t inDX) { fdX = inDX;}
3a039a31 169 void SetReconstructor(const AliTRDReconstructor *rec) {fReconstructor = rec;}
e3cf3d02 170 void SetX0(Float_t x0) { fX0 = x0; }
171 void SetYref(Int_t i, Float_t y) { fYref[i] = y;}
172 void SetZref(Int_t i, Float_t z) { fZref[i] = z;}
f29f13a6 173// void SetUsabilityMap(Long_t um) { fUsable = um; }
b1957d3c 174 void UpDate(const AliTRDtrackV1* trk);
e3cf3d02 175 void UpdateUsed();
176 void UseClusters();
e4f2f73d 177
d937ad7a 178protected:
3e778975 179 void Copy(TObject &ref) const;
e4f2f73d 180
e44586fb 181private:
3e778975 182 inline void SetN(Int_t n);
183 inline void SetNUsed(Int_t n);
184 inline void SetNShared(Int_t n);
185
0ae89c5d 186 const AliTRDReconstructor *fReconstructor;//! local reconstructor
e3cf3d02 187 AliTRDcluster **fClusterIter; //! clusters iterator
8d2bec9e 188 Int_t fIndexes[kNclusters]; //! Indexes
e3cf3d02 189 Float_t fExB; //! tg(a_L) @ tracklet location
190 Float_t fVD; //! drift velocity @ tracklet location
191 Float_t fT0; //! time 0 @ tracklet location
192 Float_t fS2PRF; //! sigma^2 PRF for xd->0 and phi=a_L
193 Float_t fDiffL; //! longitudinal diffusion coefficient
194 Float_t fDiffT; //! transversal diffusion coefficient
71ea19a3 195 Char_t fClusterIdx; //! clusters iterator
dd8059a8 196 UShort_t fN; // number of clusters attached/used/shared
e3cf3d02 197 Short_t fDet; // TRD detector
8d2bec9e 198 AliTRDcluster *fClusters[kNclusters]; // Clusters
dd8059a8 199 Float_t fPad[3]; // local pad definition : length/width/tilt
e3cf3d02 200 Float_t fYref[2]; // Reference y
201 Float_t fZref[2]; // Reference z
202 Float_t fYfit[2]; // Y fit position +derivation
203 Float_t fZfit[2]; // Z fit position
b25a5e9e 204 Float_t fPt; // Momentum estimate @ tracklet [GeV/c]
e44586fb 205 Float_t fdX; // length of time bin
e3cf3d02 206 Float_t fX0; // anode wire position
207 Float_t fX; // radial position of the tracklet
208 Float_t fY; // r-phi position of the tracklet
209 Float_t fZ; // z position of the tracklet
210 Float_t fS2Y; // estimated resolution in the r-phi direction
211 Float_t fS2Z; // estimated resolution in the z direction
212 Float_t fC; // Curvature
213 Float_t fChi2; // Global chi2
8d2bec9e 214 Float_t fdEdx[kNslices]; // dE/dx measurements for tracklet
e3cf3d02 215 Float_t fProb[AliPID::kSPECIES]; // PID probabilities
216 Int_t fLabels[3]; // most frequent MC labels and total number of different labels
6e4d4425 217 Double_t fRefCov[3]; // covariance matrix of the track in the yz plane
d937ad7a 218 Double_t fCov[3]; // covariance matrix of the tracklet in the xy plane
e4f2f73d 219
3e778975 220 ClassDef(AliTRDseedV1, 6) // The offline TRD tracklet
e4f2f73d 221};
222
223//____________________________________________________________
e3cf3d02 224inline Float_t AliTRDseedV1::GetChi2Z() const
e4f2f73d 225{
e3cf3d02 226 Double_t dz = fZref[0]-fZfit[0]; dz*=dz;
227 Double_t cov[3]; GetCovAt(fX, cov);
228 Double_t s2 = fRefCov[2]+cov[2];
229 return s2 > 0. ? dz/s2 : 0.;
e4f2f73d 230}
231
232//____________________________________________________________
e3cf3d02 233inline Float_t AliTRDseedV1::GetChi2Y() const
e4f2f73d 234{
e3cf3d02 235 Double_t dy = fYref[0]-fYfit[0]; dy*=dy;
236 Double_t cov[3]; GetCovAt(fX, cov);
237 Double_t s2 = fRefCov[0]+cov[0];
238 return s2 > 0. ? dy/s2 : 0.;
e4f2f73d 239}
240
f29f13a6 241//____________________________________________________________
242inline Float_t AliTRDseedV1::GetChi2Phi() const
243{
244 Double_t dphi = fYref[1]-fYfit[1]; dphi*=dphi;
245 Double_t cov[3]; GetCovAt(fX, cov);
246 Double_t s2 = fRefCov[2]+cov[2];
247 return s2 > 0. ? dphi/s2 : 0.;
248}
249
3e778975 250//____________________________________________________________
251inline Double_t AliTRDseedV1::GetPID(Int_t is) const
252{
253 if(is<0) return fProb[AliPID::kElectron];
254 if(is<AliPID::kSPECIES) return fProb[is];
255 return 0.;
256}
257
e4f2f73d 258//____________________________________________________________
0906e73e 259inline void AliTRDseedV1::Init(const AliRieman *rieman)
e4f2f73d 260{
e44586fb 261 fZref[0] = rieman->GetZat(fX0);
262 fZref[1] = rieman->GetDZat(fX0);
263 fYref[0] = rieman->GetYat(fX0);
264 fYref[1] = rieman->GetDYat(fX0);
55ef6967 265 fC = rieman->GetC();
266 fChi2 = rieman->GetChi2();
e4f2f73d 267}
268
ae4e8b84 269//____________________________________________________________
270inline AliTRDcluster* AliTRDseedV1::NextCluster()
271{
71ea19a3 272// Mimic the usage of STL iterators.
273// Forward iterator
274
ae4e8b84 275 fClusterIdx++; fClusterIter++;
8d2bec9e 276 while(fClusterIdx < kNclusters){
71ea19a3 277 if(!(*fClusterIter)){
278 fClusterIdx++;
279 fClusterIter++;
280 continue;
281 }
282 return *fClusterIter;
283 }
284 return 0x0;
285}
286
287//____________________________________________________________
288inline AliTRDcluster* AliTRDseedV1::PrevCluster()
289{
290// Mimic the usage of STL iterators.
291// Backward iterator
292
293 fClusterIdx--; fClusterIter--;
294 while(fClusterIdx >= 0){
295 if(!(*fClusterIter)){
296 fClusterIdx--;
297 fClusterIter--;
298 continue;
299 }
300 return *fClusterIter;
301 }
302 return 0x0;
303}
304
305//____________________________________________________________
306inline void AliTRDseedV1::ResetClusterIter(Bool_t forward)
307{
308// Mimic the usage of STL iterators.
309// Facilitate the usage of NextCluster for forward like
310// iterator (kTRUE) and PrevCluster for backward like iterator (kFALSE)
311
312 if(forward){
313 fClusterIter = &fClusters[0]; fClusterIter--;
314 fClusterIdx=-1;
315 } else {
8d2bec9e 316 fClusterIter = &fClusters[kNclusters-1]; fClusterIter++;
317 fClusterIdx=kNclusters;
71ea19a3 318 }
ae4e8b84 319}
320
3e778975 321//____________________________________________________________
322inline void AliTRDseedV1::SetN(Int_t n)
323{
324 if(n<0 || n>= (1<<5)) return;
325 fN &= ~0x1f;
326 fN |= n;
327}
328
329//____________________________________________________________
330inline void AliTRDseedV1::SetNUsed(Int_t n)
331{
332 if(n<0 || n>= (1<<5)) return;
333 fN &= ~(0x1f<<5);
334 n <<= 5; fN |= n;
335}
336
337//____________________________________________________________
338inline void AliTRDseedV1::SetNShared(Int_t n)
339{
340 if(n<0 || n>= (1<<5)) return;
341 fN &= ~(0x1f<<10);
342 n <<= 10; fN |= n;
343}
344
345
e4f2f73d 346#endif
347
47d5d320 348
6e49cfdb 349