]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDseedV1.h
correct also z coordinate calculation (GetZ())
[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// //
10// The TRD track seed //
11// //
12////////////////////////////////////////////////////////////////////////////
13
e3cf3d02 14#ifndef ROOT_TObject
15#include "TObject.h"
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
34class TTreeSRedirector;
35
36class AliRieman;
37
eb38ed55 38class AliTRDtrackingChamber;
e4f2f73d 39class AliTRDcluster;
f3d3af1b 40class AliTRDtrackV1;
3a039a31 41class AliTRDReconstructor;
e3cf3d02 42class AliTRDseedV1 : public TObject //TODO we should inherit
43{ // AliTRDtrackletBase
44public:
45 enum ETRDtrackletBuffers {
46 kNtb = 32 // max clusters/pad row
47 ,kNTimeBins = 2*kNtb // max number of clusters/tracklet
48 ,kNSlices = 10 // max dEdx slices
e44586fb 49 };
e3cf3d02 50
2e2915e7 51 // bits from 0-13 are reserved by ROOT (see TObject.h)
e3cf3d02 52 enum ETRDtrackletStatus {
53 kOwner = BIT(14) // owner of its clusters
54 ,kRowCross = BIT(15) // pad row cross tracklet
55 ,kCalib = BIT(16) // calibrated tracklet
e44586fb 56 };
57
ae4e8b84 58 AliTRDseedV1(Int_t det = -1);
e44586fb 59 ~AliTRDseedV1();
60 AliTRDseedV1(const AliTRDseedV1 &ref);
61 AliTRDseedV1& operator=(const AliTRDseedV1 &ref);
62
203967fc 63 Bool_t AttachClustersIter(
64 AliTRDtrackingChamber *chamber, Float_t quality,
65 Bool_t kZcorr = kFALSE, AliTRDcluster *c=0x0);
66 Bool_t AttachClusters(
b1957d3c 67 AliTRDtrackingChamber *chamber, Bool_t tilt = kFALSE);
203967fc 68 void Bootstrap(const AliTRDReconstructor *rec);
e3cf3d02 69 void Calibrate();
203967fc 70 void CookdEdx(Int_t nslices);
e3cf3d02 71 void CookLabels();
d937ad7a 72 Bool_t Fit(Bool_t tilt=kTRUE, Int_t errors = 2);
e3cf3d02 73 void FitMI();
203967fc 74 Bool_t Init(AliTRDtrackV1 *track);
e44586fb 75 inline void Init(const AliRieman *fit);
203967fc 76 Bool_t IsEqual(const TObject *inTracklet) const;
e3cf3d02 77 Bool_t IsCalibrated() const { return TestBit(kCalib);}
e44586fb 78 Bool_t IsOwner() const { return TestBit(kOwner);}
e3cf3d02 79 Bool_t IsOK() const { return fN2 > 4;}
e44586fb 80 Bool_t IsRowCross() const { return TestBit(kRowCross);}
e3cf3d02 81 Bool_t IsUsable(Int_t i) const { return TESTBIT(fUsable, i);}
e44586fb 82
e3cf3d02 83 Float_t GetC() const { return fC; }
84 Float_t GetChi2() const { return fChi2; }
85 inline Float_t GetChi2Z() const;
86 inline Float_t GetChi2Y() const;
d937ad7a 87 static void GetClusterXY(const AliTRDcluster *c, Double_t &x, Double_t &y);
e44586fb 88 void GetCovAt(Double_t x, Double_t *cov) const;
d937ad7a 89 void GetCovXY(Double_t *cov) const { memcpy(cov, &fCov[0], 3*sizeof(Double_t));}
ac6764f5 90 void GetCovRef(Double_t *cov) const { memcpy(cov, &fRefCov[0], 3*sizeof(Double_t));}
203967fc 91 Float_t GetdX() const { return fdX;}
92 Float_t* GetdEdx() { return &fdEdx[0];}
e44586fb 93 Float_t GetdQdl(Int_t ic) const;
203967fc 94 Int_t GetDetector() const { return fDet;}
e3cf3d02 95 void GetCalibParam(Float_t &exb, Float_t &vd, Float_t &t0, Float_t &s2, Float_t &dl, Float_t &dt) const {
96 exb = fExB; vd = fVD; t0 = fT0; s2 = fS2PRF; dl = fDiffL; dt = fDiffT;}
97 AliTRDcluster* GetClusters(Int_t i) const { return i<0 || i>=kNTimeBins ? 0x0 : fClusters[i];}
98 Int_t GetIndexes(Int_t i) const{ return i<0 || i>=kNTimeBins ? -1 : fIndexes[i];}
99 Int_t GetLabels(Int_t i) const { return fLabels[i];}
203967fc 100 Double_t GetMomentum() const { return fMom;}
101 Int_t GetN() const { return fN2;}
e3cf3d02 102 Int_t GetN2() const { return fN2;}
103 Int_t GetNUsed() const { return fNUsed;}
e44586fb 104 Float_t GetQuality(Bool_t kZcorr) const;
e3cf3d02 105 Float_t GetPadLength() const { return fPadLength;}
ae4e8b84 106 Int_t GetPlane() const { return AliTRDgeometry::GetLayer(fDet); }
107
e3cf3d02 108 Float_t* GetProbability();
109 Float_t GetS2Y() const { return fS2Y;}
110 Float_t GetS2Z() const { return fS2Z;}
111 Float_t GetSigmaY() const { return fS2Y > 0. ? TMath::Sqrt(fS2Y) : 0.2;}
112 Float_t GetSnp() const { return fYref[1]/TMath::Sqrt(1+fYref[1]*fYref[1]);}
113 Float_t GetTgl() const { return fZref[1];}
114 Float_t GetTilt() const { return fTilt;}
115 Float_t GetX0() const { return fX0;}
116 Float_t GetX() const { return fX0 - fX;}
5a7a515d 117 Float_t GetY() const { return fYfit[0] - fYfit[1] * fX;}
b1957d3c 118 Double_t GetYat(Double_t x) const { return fYfit[0] - fYfit[1] * (fX0-x);}
e3cf3d02 119 Float_t GetYfit(Int_t id) const { return fYfit[id];}
120 Float_t GetYref(Int_t id) const { return fYref[id];}
3658afdc 121 Float_t GetZ() const { return fZfit[0] - fZfit[1] * fX;}
b1957d3c 122 Double_t GetZat(Double_t x) const { return fZfit[0] - fZfit[1] * (fX0-x);}
e3cf3d02 123 Float_t GetZfit(Int_t id) const { return fZfit[id];}
124 Float_t GetZref(Int_t id) const { return fZref[id];}
125 Long_t GetUsabilityMap() const { return fUsable; }
126
ae4e8b84 127 inline AliTRDcluster* NextCluster();
71ea19a3 128 inline AliTRDcluster* PrevCluster();
e44586fb 129 void Print(Option_t *o = "") const;
71ea19a3 130 inline void ResetClusterIter(Bool_t forward = kTRUE);
e3cf3d02 131 void Reset();
ae4e8b84 132
e3cf3d02 133 void SetC(Float_t c) { fC = c;}
134 void SetChi2(Float_t chi2) { fChi2 = chi2;}
0849f128 135 void SetCovRef(const Double_t *cov) { memcpy(&fRefCov[0], cov, 3*sizeof(Double_t));}
e3cf3d02 136 void SetIndexes(Int_t i, Int_t idx) { fIndexes[i] = idx; }
137 void SetLabels(Int_t *lbls) { memcpy(fLabels, lbls, 3*sizeof(Int_t)); }
203967fc 138 void SetMomentum(Double_t mom){ fMom = mom;}
29b87567 139 void SetOwner();
e3cf3d02 140 void SetTilt(Float_t tilt) { fTilt = tilt; }
141 void SetPadLength(Float_t len){ fPadLength = len;}
203967fc 142 void SetDetector(Int_t d) { fDet = d; }
bee2b41e 143 void SetDX(Float_t inDX) { fdX = inDX;}
3a039a31 144 void SetReconstructor(const AliTRDReconstructor *rec) {fReconstructor = rec;}
e3cf3d02 145 void SetX0(Float_t x0) { fX0 = x0; }
146 void SetYref(Int_t i, Float_t y) { fYref[i] = y;}
147 void SetZref(Int_t i, Float_t z) { fZref[i] = z;}
148 void SetUsabilityMap(Long_t um) { fUsable = um; }
b1957d3c 149 void UpDate(const AliTRDtrackV1* trk);
e3cf3d02 150 void UpdateUsed();
151 void UseClusters();
e4f2f73d 152
d937ad7a 153protected:
e44586fb 154 void Copy(TObject &ref) const;
e4f2f73d 155
e44586fb 156private:
0ae89c5d 157 const AliTRDReconstructor *fReconstructor;//! local reconstructor
e3cf3d02 158 AliTRDcluster **fClusterIter; //! clusters iterator
159 Int_t fIndexes[kNTimeBins]; //! Indexes
160 Float_t fExB; //! tg(a_L) @ tracklet location
161 Float_t fVD; //! drift velocity @ tracklet location
162 Float_t fT0; //! time 0 @ tracklet location
163 Float_t fS2PRF; //! sigma^2 PRF for xd->0 and phi=a_L
164 Float_t fDiffL; //! longitudinal diffusion coefficient
165 Float_t fDiffT; //! transversal diffusion coefficient
71ea19a3 166 Char_t fClusterIdx; //! clusters iterator
e3cf3d02 167 Long_t fUsable; //! bit map of usable clusters
168 UChar_t fN2; // number of clusters attached
169 UChar_t fNUsed; // number of used usable clusters
170 Short_t fDet; // TRD detector
171 Float_t fTilt; // local tg of the tilt angle
172 Float_t fPadLength; // local pad length
173 AliTRDcluster *fClusters[kNTimeBins]; // Clusters
174 Float_t fYref[2]; // Reference y
175 Float_t fZref[2]; // Reference z
176 Float_t fYfit[2]; // Y fit position +derivation
177 Float_t fZfit[2]; // Z fit position
178 Float_t fMom; // Momentum estimate @ tracklet [GeV/c]
e44586fb 179 Float_t fdX; // length of time bin
e3cf3d02 180 Float_t fX0; // anode wire position
181 Float_t fX; // radial position of the tracklet
182 Float_t fY; // r-phi position of the tracklet
183 Float_t fZ; // z position of the tracklet
184 Float_t fS2Y; // estimated resolution in the r-phi direction
185 Float_t fS2Z; // estimated resolution in the z direction
186 Float_t fC; // Curvature
187 Float_t fChi2; // Global chi2
188 Float_t fdEdx[kNSlices]; // dE/dx measurements for tracklet
189 Float_t fProb[AliPID::kSPECIES]; // PID probabilities
190 Int_t fLabels[3]; // most frequent MC labels and total number of different labels
6e4d4425 191 Double_t fRefCov[3]; // covariance matrix of the track in the yz plane
d937ad7a 192 Double_t fCov[3]; // covariance matrix of the tracklet in the xy plane
e4f2f73d 193
e3cf3d02 194 ClassDef(AliTRDseedV1, 5) // The offline TRD tracklet
e4f2f73d 195};
196
197//____________________________________________________________
e3cf3d02 198inline Float_t AliTRDseedV1::GetChi2Z() const
e4f2f73d 199{
e3cf3d02 200 Double_t dz = fZref[0]-fZfit[0]; dz*=dz;
201 Double_t cov[3]; GetCovAt(fX, cov);
202 Double_t s2 = fRefCov[2]+cov[2];
203 return s2 > 0. ? dz/s2 : 0.;
e4f2f73d 204}
205
206//____________________________________________________________
e3cf3d02 207inline Float_t AliTRDseedV1::GetChi2Y() const
e4f2f73d 208{
e3cf3d02 209 Double_t dy = fYref[0]-fYfit[0]; dy*=dy;
210 Double_t cov[3]; GetCovAt(fX, cov);
211 Double_t s2 = fRefCov[0]+cov[0];
212 return s2 > 0. ? dy/s2 : 0.;
e4f2f73d 213}
214
215//____________________________________________________________
0906e73e 216inline void AliTRDseedV1::Init(const AliRieman *rieman)
e4f2f73d 217{
e44586fb 218 fZref[0] = rieman->GetZat(fX0);
219 fZref[1] = rieman->GetDZat(fX0);
220 fYref[0] = rieman->GetYat(fX0);
221 fYref[1] = rieman->GetDYat(fX0);
55ef6967 222 fC = rieman->GetC();
223 fChi2 = rieman->GetChi2();
e4f2f73d 224}
225
ae4e8b84 226//____________________________________________________________
227inline AliTRDcluster* AliTRDseedV1::NextCluster()
228{
71ea19a3 229// Mimic the usage of STL iterators.
230// Forward iterator
231
ae4e8b84 232 fClusterIdx++; fClusterIter++;
e3cf3d02 233 while(fClusterIdx < kNTimeBins){
71ea19a3 234 if(!(*fClusterIter)){
235 fClusterIdx++;
236 fClusterIter++;
237 continue;
238 }
239 return *fClusterIter;
240 }
241 return 0x0;
242}
243
244//____________________________________________________________
245inline AliTRDcluster* AliTRDseedV1::PrevCluster()
246{
247// Mimic the usage of STL iterators.
248// Backward iterator
249
250 fClusterIdx--; fClusterIter--;
251 while(fClusterIdx >= 0){
252 if(!(*fClusterIter)){
253 fClusterIdx--;
254 fClusterIter--;
255 continue;
256 }
257 return *fClusterIter;
258 }
259 return 0x0;
260}
261
262//____________________________________________________________
263inline void AliTRDseedV1::ResetClusterIter(Bool_t forward)
264{
265// Mimic the usage of STL iterators.
266// Facilitate the usage of NextCluster for forward like
267// iterator (kTRUE) and PrevCluster for backward like iterator (kFALSE)
268
269 if(forward){
270 fClusterIter = &fClusters[0]; fClusterIter--;
271 fClusterIdx=-1;
272 } else {
e3cf3d02 273 fClusterIter = &fClusters[kNTimeBins-1]; fClusterIter++;
274 fClusterIdx=kNTimeBins;
71ea19a3 275 }
ae4e8b84 276}
277
e4f2f73d 278#endif
279
47d5d320 280
6e49cfdb 281