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