]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDseedV1.h
fix info in debug stream
[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 offline tracklet                                              //
11 //                                                                        //
12 ////////////////////////////////////////////////////////////////////////////
13
14 #ifndef ALITRDTRACKLETBASE_H
15 #include "AliTRDtrackletBase.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 AliTRDtrackletBase
46 {
47 public:
48   enum ETRDtrackletBuffers {    
49     kNtb       = 31     // max clusters/pad row
50    ,kNclusters = 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    CookPID();
78   Bool_t    Fit(Bool_t tilt=kTRUE, Int_t errors = 2);
79 //   void      FitMI();
80   Bool_t    Init(AliTRDtrackV1 *track);
81   inline void      Init(const AliRieman *fit);
82   Bool_t    IsEqual(const TObject *inTracklet) const;
83   Bool_t    IsCalibrated() const     { return TestBit(kCalib);}
84   Bool_t    IsOwner() const          { return TestBit(kOwner);}
85   Bool_t    IsKink() const           { return TestBit(kKink);}
86   Bool_t    IsOK() const             { return GetN() > 4 && GetNUsed() < 4;}
87   Bool_t    IsRowCross() const       { return TestBit(kRowCross);}
88   Bool_t    IsUsable(Int_t i) const  { return fClusters[i] && !fClusters[i]->IsUsed();}
89   Bool_t    IsStandAlone() const     { return TestBit(kStandAlone);}
90
91   Float_t   GetC() const             { return fC; }
92   Float_t   GetChi2() const          { return fChi2; }
93   inline Float_t   GetChi2Z() const;
94   inline Float_t   GetChi2Y() const;
95   inline Float_t   GetChi2Phi() const;
96   static void      GetClusterXY(const AliTRDcluster *c, Double_t &x, Double_t &y);
97   void      GetCovAt(Double_t x, Double_t *cov) const;
98   void      GetCovXY(Double_t *cov) const { memcpy(cov, &fCov[0], 3*sizeof(Double_t));}
99   void      GetCovRef(Double_t *cov) const { memcpy(cov, &fRefCov[0], 3*sizeof(Double_t));}
100   Float_t   GetdX() const            { return fdX;}
101   Float_t*  GetdEdx()                { return &fdEdx[0];}
102   Float_t   GetdQdl(Int_t ic) const;
103   Float_t   GetdYdX() const          { return fYfit[1]; } 
104   Float_t   GetdZdX() const          { return fZref[1]; }
105   Int_t     GetdY() const            { return Int_t(GetY()/0.014);}
106   Int_t     GetDetector() const      { return fDet;}
107   void      GetCalibParam(Float_t &exb, Float_t &vd, Float_t &t0, Float_t &s2, Float_t &dl, Float_t &dt) const    { 
108               exb = fExB; vd = fVD; t0 = fT0; s2 = fS2PRF; dl = fDiffL; dt = fDiffT;}
109   AliTRDcluster*  GetClusters(Int_t i) const               { return i<0 || i>=kNclusters ? 0x0 : fClusters[i];}
110   Int_t     GetIndexes(Int_t i) const{ return i<0 || i>=kNclusters ? -1 : fIndexes[i];}
111   Int_t     GetLabels(Int_t i) const { return fLabels[i];}  
112   Double_t  GetMomentum() const      { return fMom;}
113   Int_t     GetN() const             { return (Int_t)fN&0x1f;}
114   Int_t     GetN2() const            { return GetN();}
115   Int_t     GetNUsed() const         { return Int_t((fN>>5)&0x1f);}
116   Int_t     GetNShared() const       { return Int_t((fN>>10)&0x1f);}
117   Float_t   GetQuality(Bool_t kZcorr) const;
118   Float_t   GetPadLength() const     { return fPadLength;}
119   Int_t     GetPlane() const         { return AliTRDgeometry::GetLayer(fDet);    }
120
121   Float_t*  GetProbability(Bool_t force=kFALSE);
122   inline Double_t  GetPID(Int_t is=-1) const;
123   Float_t   GetS2Y() const           { return fS2Y;}
124   Float_t   GetS2Z() const           { return fS2Z;}
125   Float_t   GetSigmaY() const        { return fS2Y > 0. ? TMath::Sqrt(fS2Y) : 0.2;}
126   Float_t   GetSnp() const           { return fYref[1]/TMath::Sqrt(1+fYref[1]*fYref[1]);}
127   Float_t   GetTgl() const           { return fZref[1];}
128   Float_t   GetTilt() const          { return fTilt;}
129   UInt_t    GetTrackletWord() const  { return 0;}
130   Float_t   GetX0() const            { return fX0;}
131   Float_t   GetX() const             { return fX0 - fX;}
132   Float_t   GetY() const             { return fYfit[0] - fYfit[1] * fX;}
133   Double_t  GetYat(Double_t x) const { return fYfit[0] - fYfit[1] * (fX0-x);}
134   Float_t   GetYfit(Int_t id) const { return fYfit[id];}
135   Float_t   GetYref(Int_t id) const { return fYref[id];}
136   Float_t   GetZ() const            { return fZfit[0] - fZfit[1] * fX;}
137   Double_t  GetZat(Double_t x) const { return fZfit[0] - fZfit[1] * (fX0-x);}
138   Float_t   GetZfit(Int_t id) const { return fZfit[id];}
139   Float_t   GetZref(Int_t id) const { return fZref[id];}
140   Int_t     GetYbin() const         { return Int_t(GetY()/0.016);}
141   Int_t     GetZbin() const         { return Int_t(GetZ()/fPadLength);}
142
143   inline AliTRDcluster* NextCluster();
144   inline AliTRDcluster* PrevCluster();
145   void      Print(Option_t *o = "") const;
146   inline void ResetClusterIter(Bool_t forward = kTRUE);
147   void      Reset();
148
149   void      SetC(Float_t c)         { fC = c;}
150   void      SetChi2(Float_t chi2)   { fChi2 = chi2;}
151   void      SetCovRef(const Double_t *cov) { memcpy(&fRefCov[0], cov, 3*sizeof(Double_t));}
152   void      SetIndexes(Int_t i, Int_t idx) { fIndexes[i]  = idx; }
153   void      SetLabels(Int_t *lbls)   { memcpy(fLabels, lbls, 3*sizeof(Int_t)); }
154   void      SetKink(Bool_t k)        { SetBit(kKink, k);}
155   void      SetStandAlone(Bool_t st) { SetBit(kStandAlone, st); }
156   void      SetMomentum(Double_t mom){ fMom = mom;}
157   void      SetOwner();
158   void      SetTilt(Float_t tilt)    { fTilt = tilt; }
159   void      SetPadLength(Float_t len){ fPadLength = len;}
160   void      SetDetector(Int_t d)     { fDet = d;  }
161   void      SetDX(Float_t inDX)      { fdX = inDX;}
162   void      SetReconstructor(const AliTRDReconstructor *rec) {fReconstructor = rec;}
163   void      SetX0(Float_t x0)        { fX0 = x0; }
164   void      SetYref(Int_t i, Float_t y) { fYref[i]     = y;}
165   void      SetZref(Int_t i, Float_t z) { fZref[i]     = z;}
166 //   void      SetUsabilityMap(Long_t um)  { fUsable = um; }
167   void      UpDate(const AliTRDtrackV1* trk);
168   void      UpdateUsed();
169   void      UseClusters();
170
171 protected:
172   void        Copy(TObject &ref) const;
173
174 private:
175   inline void SetN(Int_t n);
176   inline void SetNUsed(Int_t n);
177   inline void SetNShared(Int_t n);
178
179   const AliTRDReconstructor *fReconstructor;//! local reconstructor
180   AliTRDcluster  **fClusterIter;            //! clusters iterator
181   Int_t            fIndexes[kNclusters];    //! Indexes
182   Float_t          fExB;                    //! tg(a_L) @ tracklet location
183   Float_t          fVD;                     //! drift velocity @ tracklet location
184   Float_t          fT0;                     //! time 0 @ tracklet location
185   Float_t          fS2PRF;                  //! sigma^2 PRF for xd->0 and phi=a_L 
186   Float_t          fDiffL;                  //! longitudinal diffusion coefficient
187   Float_t          fDiffT;                  //! transversal diffusion coefficient
188   Char_t           fClusterIdx;             //! clusters iterator
189 //  ULong_t          fUsable;                 //! bit map of usable clusters
190   UShort_t         fN;                     // number of clusters attached/used/shared
191   Short_t          fDet;                    // TRD detector
192   Float_t          fTilt;                   // local tg of the tilt angle 
193   Float_t          fPadLength;              // local pad length 
194   AliTRDcluster   *fClusters[kNclusters];   // Clusters
195   Float_t          fYref[2];                //  Reference y
196   Float_t          fZref[2];                //  Reference z
197   Float_t          fYfit[2];                //  Y fit position +derivation
198   Float_t          fZfit[2];                //  Z fit position
199   Float_t          fMom;                    //  Momentum estimate @ tracklet [GeV/c]
200   Float_t          fdX;                     // length of time bin
201   Float_t          fX0;                     // anode wire position
202   Float_t          fX;                      // radial position of the tracklet
203   Float_t          fY;                      // r-phi position of the tracklet
204   Float_t          fZ;                      // z position of the tracklet
205   Float_t          fS2Y;                    // estimated resolution in the r-phi direction 
206   Float_t          fS2Z;                    // estimated resolution in the z direction 
207   Float_t          fC;                      // Curvature
208   Float_t          fChi2;                   // Global chi2  
209   Float_t          fdEdx[kNslices];         // dE/dx measurements for tracklet
210   Float_t          fProb[AliPID::kSPECIES]; //  PID probabilities
211   Int_t            fLabels[3];              // most frequent MC labels and total number of different labels
212   Double_t         fRefCov[3];              // covariance matrix of the track in the yz plane
213   Double_t         fCov[3];                 // covariance matrix of the tracklet in the xy plane
214
215   ClassDef(AliTRDseedV1, 6)                 // The offline TRD tracklet 
216 };
217
218 //____________________________________________________________
219 inline Float_t AliTRDseedV1::GetChi2Z() const
220 {
221   Double_t dz = fZref[0]-fZfit[0]; dz*=dz;
222   Double_t cov[3]; GetCovAt(fX, cov);
223   Double_t s2 = fRefCov[2]+cov[2];
224   return s2 > 0. ? dz/s2 : 0.; 
225 }
226
227 //____________________________________________________________
228 inline Float_t AliTRDseedV1::GetChi2Y() const
229 {
230   Double_t dy = fYref[0]-fYfit[0]; dy*=dy;
231   Double_t cov[3]; GetCovAt(fX, cov);
232   Double_t s2 = fRefCov[0]+cov[0];
233   return s2 > 0. ? dy/s2 : 0.; 
234 }
235
236 //____________________________________________________________
237 inline Float_t AliTRDseedV1::GetChi2Phi() const
238 {
239   Double_t dphi = fYref[1]-fYfit[1]; dphi*=dphi;
240   Double_t cov[3]; GetCovAt(fX, cov);
241   Double_t s2 = fRefCov[2]+cov[2];
242   return s2 > 0. ? dphi/s2 : 0.; 
243 }
244
245 //____________________________________________________________
246 inline Double_t AliTRDseedV1::GetPID(Int_t is) const
247 {
248   if(is<0) return fProb[AliPID::kElectron];
249   if(is<AliPID::kSPECIES) return fProb[is];
250   return 0.;
251 }
252
253 //____________________________________________________________
254 inline void AliTRDseedV1::Init(const AliRieman *rieman)
255 {
256   fZref[0] = rieman->GetZat(fX0);
257   fZref[1] = rieman->GetDZat(fX0);
258   fYref[0] = rieman->GetYat(fX0);
259   fYref[1] = rieman->GetDYat(fX0);
260   fC       = rieman->GetC(); 
261   fChi2    = rieman->GetChi2();
262 }
263
264 //____________________________________________________________
265 inline AliTRDcluster* AliTRDseedV1::NextCluster()
266 {
267 // Mimic the usage of STL iterators.
268 // Forward iterator
269
270   fClusterIdx++; fClusterIter++;
271   while(fClusterIdx < kNclusters){
272     if(!(*fClusterIter)){ 
273       fClusterIdx++; 
274       fClusterIter++;
275       continue;
276     }
277     return *fClusterIter;
278   }
279   return 0x0;
280 }
281
282 //____________________________________________________________
283 inline AliTRDcluster* AliTRDseedV1::PrevCluster()
284 {
285 // Mimic the usage of STL iterators.
286 // Backward iterator
287
288   fClusterIdx--; fClusterIter--;
289   while(fClusterIdx >= 0){
290     if(!(*fClusterIter)){ 
291       fClusterIdx--; 
292       fClusterIter--;
293       continue;
294     }
295     return *fClusterIter;
296   }
297   return 0x0;
298 }
299
300 //____________________________________________________________
301 inline void AliTRDseedV1::ResetClusterIter(Bool_t forward) 
302 {
303 // Mimic the usage of STL iterators.
304 // Facilitate the usage of NextCluster for forward like 
305 // iterator (kTRUE) and PrevCluster for backward like iterator (kFALSE)
306
307   if(forward){
308     fClusterIter = &fClusters[0]; fClusterIter--; 
309     fClusterIdx=-1;
310   } else {
311     fClusterIter = &fClusters[kNclusters-1]; fClusterIter++; 
312     fClusterIdx=kNclusters;
313   }
314 }
315
316 //____________________________________________________________
317 inline void AliTRDseedV1::SetN(Int_t n)
318 {
319   if(n<0 || n>= (1<<5)) return; 
320   fN &= ~0x1f;
321   fN |= n;
322 }
323
324 //____________________________________________________________
325 inline void AliTRDseedV1::SetNUsed(Int_t n)
326 {
327   if(n<0 || n>= (1<<5)) return; 
328   fN &= ~(0x1f<<5);
329   n <<= 5; fN |= n;
330 }
331
332 //____________________________________________________________
333 inline void AliTRDseedV1::SetNShared(Int_t n)
334 {
335   if(n<0 || n>= (1<<5)) return; 
336   fN &= ~(0x1f<<10);
337   n <<= 10; fN |= n;
338 }
339
340
341 #endif
342
343
344