3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
8 ////////////////////////////////////////////////////////////////////////////
10 // The TRD track seed //
12 ////////////////////////////////////////////////////////////////////////////
22 #ifndef ALITRDGEOMETRY_H
23 #include "AliTRDgeometry.h"
31 #include "AliRieman.h"
34 class TTreeSRedirector;
38 class AliTRDtrackingChamber;
41 class AliTRDReconstructor;
42 class AliTRDseedV1 : public TObject //TODO we should inherit
43 { // AliTRDtrackletBase
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
51 // bits from 0-13 are reserved by ROOT (see TObject.h)
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
58 AliTRDseedV1(Int_t det = -1);
60 AliTRDseedV1(const AliTRDseedV1 &ref);
61 AliTRDseedV1& operator=(const AliTRDseedV1 &ref);
63 Bool_t AttachClustersIter(
64 AliTRDtrackingChamber *chamber, Float_t quality,
65 Bool_t kZcorr = kFALSE, AliTRDcluster *c=0x0);
66 Bool_t AttachClusters(
67 AliTRDtrackingChamber *chamber, Bool_t tilt = kFALSE);
68 void Bootstrap(const AliTRDReconstructor *rec);
70 void CookdEdx(Int_t nslices);
72 Bool_t Fit(Bool_t tilt=kTRUE, Int_t errors = 2);
74 Bool_t Init(AliTRDtrackV1 *track);
75 inline void Init(const AliRieman *fit);
76 Bool_t IsEqual(const TObject *inTracklet) const;
77 Bool_t IsCalibrated() const { return TestBit(kCalib);}
78 Bool_t IsOwner() const { return TestBit(kOwner);}
79 Bool_t IsOK() const { return fN2 > 4;}
80 Bool_t IsRowCross() const { return TestBit(kRowCross);}
81 Bool_t IsUsable(Int_t i) const { return TESTBIT(fUsable, i);}
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;
87 static void GetClusterXY(const AliTRDcluster *c, Double_t &x, Double_t &y);
88 void GetCovAt(Double_t x, Double_t *cov) const;
89 void GetCovXY(Double_t *cov) const { memcpy(cov, &fCov[0], 3*sizeof(Double_t));}
90 void GetCovRef(Double_t *cov) const { memcpy(cov, &fRefCov[0], 3*sizeof(Double_t));}
91 Float_t GetdX() const { return fdX;}
92 Float_t* GetdEdx() { return &fdEdx[0];}
93 Float_t GetdQdl(Int_t ic) const;
94 Int_t GetDetector() const { return fDet;}
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];}
100 Double_t GetMomentum() const { return fMom;}
101 Int_t GetN() const { return fN2;}
102 Int_t GetN2() const { return fN2;}
103 Int_t GetNUsed() const { return fNUsed;}
104 Float_t GetQuality(Bool_t kZcorr) const;
105 Float_t GetPadLength() const { return fPadLength;}
106 Int_t GetPlane() const { return AliTRDgeometry::GetLayer(fDet); }
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;}
117 Float_t GetY() const { return fYfit[0] - fYfit[1] * fX;}
118 Double_t GetYat(Double_t x) const { return fYfit[0] - fYfit[1] * (fX0-x);}
119 Float_t GetYfit(Int_t id) const { return fYfit[id];}
120 Float_t GetYref(Int_t id) const { return fYref[id];}
121 Float_t GetZ() const { return fZfit[0] - fZfit[1] * fX;}
122 Double_t GetZat(Double_t x) const { return fZfit[0] - fZfit[1] * (fX0-x);}
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; }
127 inline AliTRDcluster* NextCluster();
128 inline AliTRDcluster* PrevCluster();
129 void Print(Option_t *o = "") const;
130 inline void ResetClusterIter(Bool_t forward = kTRUE);
133 void SetC(Float_t c) { fC = c;}
134 void SetChi2(Float_t chi2) { fChi2 = chi2;}
135 void SetCovRef(const Double_t *cov) { memcpy(&fRefCov[0], cov, 3*sizeof(Double_t));}
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)); }
138 void SetMomentum(Double_t mom){ fMom = mom;}
140 void SetTilt(Float_t tilt) { fTilt = tilt; }
141 void SetPadLength(Float_t len){ fPadLength = len;}
142 void SetDetector(Int_t d) { fDet = d; }
143 void SetDX(Float_t inDX) { fdX = inDX;}
144 void SetReconstructor(const AliTRDReconstructor *rec) {fReconstructor = rec;}
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; }
149 void UpDate(const AliTRDtrackV1* trk);
154 void Copy(TObject &ref) const;
157 const AliTRDReconstructor *fReconstructor;//! local reconstructor
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
166 Char_t fClusterIdx; //! clusters iterator
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]
179 Float_t fdX; // length of time bin
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
191 Double_t fRefCov[3]; // covariance matrix of the track in the yz plane
192 Double_t fCov[3]; // covariance matrix of the tracklet in the xy plane
194 ClassDef(AliTRDseedV1, 5) // The offline TRD tracklet
197 //____________________________________________________________
198 inline Float_t AliTRDseedV1::GetChi2Z() const
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.;
206 //____________________________________________________________
207 inline Float_t AliTRDseedV1::GetChi2Y() const
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.;
215 //____________________________________________________________
216 inline void AliTRDseedV1::Init(const AliRieman *rieman)
218 fZref[0] = rieman->GetZat(fX0);
219 fZref[1] = rieman->GetDZat(fX0);
220 fYref[0] = rieman->GetYat(fX0);
221 fYref[1] = rieman->GetDYat(fX0);
223 fChi2 = rieman->GetChi2();
226 //____________________________________________________________
227 inline AliTRDcluster* AliTRDseedV1::NextCluster()
229 // Mimic the usage of STL iterators.
232 fClusterIdx++; fClusterIter++;
233 while(fClusterIdx < kNTimeBins){
234 if(!(*fClusterIter)){
239 return *fClusterIter;
244 //____________________________________________________________
245 inline AliTRDcluster* AliTRDseedV1::PrevCluster()
247 // Mimic the usage of STL iterators.
250 fClusterIdx--; fClusterIter--;
251 while(fClusterIdx >= 0){
252 if(!(*fClusterIter)){
257 return *fClusterIter;
262 //____________________________________________________________
263 inline void AliTRDseedV1::ResetClusterIter(Bool_t forward)
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)
270 fClusterIter = &fClusters[0]; fClusterIter--;
273 fClusterIter = &fClusters[kNTimeBins-1]; fClusterIter++;
274 fClusterIdx=kNTimeBins;