]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCtrackerMI.h
First version of the TPC pedestal online detector algorithm (Sylvain)
[u/mrichter/AliRoot.git] / TPC / AliTPCtrackerMI.h
1 #ifndef ALITPCTRACKERMI_H
2 #define ALITPCTRACKERMI_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6
7 /* $Id$ */
8
9 //-------------------------------------------------------
10 //                       TPC tracker
11 //   Parallel tracker 
12 //
13 //   Origin: 
14 //-------------------------------------------------------
15
16 #include <TError.h>
17 #include "AliTracker.h"
18 #include "AliTPCreco.h"
19 #include "AliPID.h"
20 #include "AliTPCclusterMI.h"
21
22
23 class TFile;
24 class AliTPCParam;
25 class AliTPCseed;
26 class AliTPCTrackerPoint;
27 class AliESDEvent;   
28 class TTree;
29 class AliESDkink;
30 class TTreeSRedirector;
31 class AliTrackPoint;
32
33 class AliTPCtrackerMI : public AliTracker {
34 public:
35   AliTPCtrackerMI();
36   AliTPCtrackerMI(const AliTPCParam *par); 
37   virtual ~AliTPCtrackerMI();
38   //
39   void SetIteration(Int_t iteration){fIteration = iteration;}
40   virtual Int_t Clusters2Tracks (AliESDEvent *esd);
41   virtual Int_t RefitInward (AliESDEvent *esd);
42   virtual Int_t LoadClusters (TTree * tree);
43   Int_t  LoadClusters();
44   void   UnloadClusters();
45   void   Transform(AliTPCclusterMI * cluster);
46   //
47   void SetIO();  //set default IO from folders
48   void SetIO(TTree * input, TTree * output, AliESDEvent * event);
49   void FillESD(TObjArray* arr);
50   void WriteTracks();
51   void WriteTracks(TTree * tree);  
52   void DeleteSeeds();
53   void SetDebug(Int_t debug){ fDebug = debug;}
54   void FindKinks(TObjArray * array, AliESDEvent * esd);
55   void FindV0s(TObjArray * array, AliESDEvent * esd);
56   void UpdateKinkQualityM(AliTPCseed * seed);
57   void UpdateKinkQualityD(AliTPCseed * seed);
58   Int_t CheckKinkPoint(AliTPCseed*seed, AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink);
59   Int_t RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink);
60    Int_t ReadSeeds(const TFile *in);
61    TObjArray * GetSeeds(){return fSeeds;}
62    //   
63    AliCluster * GetCluster(Int_t index) const {return (AliCluster*)GetClusterMI(index);}
64    AliTPCclusterMI *GetClusterMI(Int_t index) const;
65    Int_t Clusters2Tracks();
66    virtual void  CookLabel(AliKalmanTrack *tk,Float_t wrong) const; 
67    virtual Int_t   CookLabel(AliTPCseed *t,Float_t wrong, Int_t first,Int_t last ) const; 
68    
69    void RotateToLocal(AliTPCseed *seed);
70   
71    
72    Int_t FollowProlongation(AliTPCseed& t, Int_t rf=0, Int_t step=1);
73    Int_t FollowProlongationFast(AliTPCseed& t, Int_t rf=0, Int_t step=1);
74    Bool_t GetTrackPoint(Int_t index, AliTrackPoint &p ) const; 
75
76    Int_t FollowBackProlongation(AliTPCseed& t, Int_t rf);
77    Int_t FollowToNext(AliTPCseed& t, Int_t nr);
78    Int_t FollowToNextFast(AliTPCseed& t, Int_t nr);
79    Int_t UpdateClusters(AliTPCseed& t,  Int_t nr);
80    Int_t FollowToNextCluster( AliTPCseed& t, Int_t nr);
81
82    Int_t PropagateBack(TObjArray * arr);
83    Int_t PropagateBack(AliESDEvent * event);
84    Int_t PropagateBack(AliTPCseed *pt, Int_t row0, Int_t row1);   
85    Int_t PropagateForward();
86    Int_t PropagateForward2(TObjArray * arr);
87
88    void SortTracks(TObjArray * arr, Int_t mode) const;
89   
90
91    virtual Double_t ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl = 0);
92    virtual Double_t ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl = 0);   
93
94    Double_t F1(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t x3,Double_t y3); 
95    Double_t F1old(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t x3,Double_t y3); 
96    Double_t F2(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t x3,Double_t y3); 
97    Double_t F2old(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t x3,Double_t y3); 
98
99    Double_t F3(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t z1,Double_t z2); 
100    Double_t F3n(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t z1,Double_t z2, 
101                 Double_t c); 
102    Bool_t GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z);
103
104  public:
105 //**************** Internal tracker class ********************** 
106    class AliTPCSector;
107    class AliTPCRow {
108    public:
109      AliTPCRow();
110      ~AliTPCRow();
111      void InsertCluster(const AliTPCclusterMI *c, UInt_t index);
112      void ResetClusters();
113      operator int() const {return fN;}
114      Int_t GetN() const {return fN;}
115      const AliTPCclusterMI* operator[](Int_t i) const {return fClusters[i];}
116      UInt_t GetIndex(Int_t i) const {return fIndex[i];}
117      inline Int_t Find(Double_t z) const; 
118      AliTPCclusterMI *  FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const;
119      AliTPCclusterMI *  FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz, UInt_t & index) const;
120      AliTPCclusterMI *  FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz, UInt_t & index) const;
121      
122      void SetX(Double_t x) {fX=x;}
123      Double_t GetX() const {return fX;}
124      Float_t GetDeadZone() const {return fDeadZone;}
125      void SetDeadZone(Float_t d) {fDeadZone=d;}
126      Int_t GetN1() const {return fN1;}
127      void SetN1(Int_t n) {fN1=n;}
128      Int_t GetN2() const {return fN2;}
129      void SetN2(Int_t n) {fN2=n;}
130      AliTPCclusterMI* GetClusters1() const {return fClusters1;}
131      AliTPCclusterMI* GetClusters2() const {return fClusters2;}
132      void SetClusters1(AliTPCclusterMI* cl) {fClusters1=cl;}
133      void SetClusters2(AliTPCclusterMI* cl) {fClusters2=cl;}
134      void SetCluster1(Int_t i, AliTPCclusterMI cl) {fClusters1[i]=cl;}
135      void SetCluster2(Int_t i, AliTPCclusterMI cl) {fClusters2[i]=cl;}
136      AliTPCclusterMI* GetCluster1(Int_t i) const {return &fClusters1[i];}
137      AliTPCclusterMI* GetCluster2(Int_t i) const {return &fClusters2[i];}
138      Short_t GetFastCluster(Int_t i) const {return fFastCluster[i];}
139      void SetFastCluster(Int_t i, Short_t cl) {fFastCluster[i]=cl;}
140
141 private:  
142      AliTPCRow & operator=(const AliTPCRow & );
143      AliTPCRow(const AliTPCRow& /*r*/);           //dummy copy constructor
144      Float_t fDeadZone;  // the width of the dead zone
145      AliTPCclusterMI *fClusters1; //array with clusters 1
146      Int_t fN1;  //number of clusters on left side
147      AliTPCclusterMI *fClusters2; //array with clusters 2
148      Int_t fN2; // number of clusters on right side of the TPC
149      Short_t fFastCluster[510];   //index of the nearest cluster at given position
150      Int_t fN;                                          //number of clusters 
151      const AliTPCclusterMI *fClusters[kMaxClusterPerRow]; //pointers to clusters
152                                // indexes for cluster at given position z  
153      // AliTPCclusterMI *fClustersArray;                     // 
154      UInt_t fIndex[kMaxClusterPerRow];                  //indeces of clusters
155      Double_t fX;                                 //X-coordinate of this row
156
157    };
158
159 //**************** Internal tracker class ********************** 
160    class AliTPCSector {
161    public:
162      AliTPCSector():
163        fN(0),
164        fRow(0),
165        fAlpha(0.),
166        fAlphaShift(0.),
167        fPadPitchWidth(0.),
168        fPadPitchLength(0.),
169        f1PadPitchLength(0.),
170        f2PadPitchLength(0.){}
171     ~AliTPCSector() { delete[] fRow; }
172     AliTPCRow& operator[](Int_t i) const { return *(fRow+i); }
173     Int_t GetNRows() const { return fN; }
174     void Setup(const AliTPCParam *par, Int_t flag);
175     Double_t GetX(Int_t l) const {return fRow[l].GetX();}
176     Double_t GetMaxY(Int_t l) const {
177       return GetX(l)*TMath::Tan(0.5*GetAlpha());
178     } 
179     Double_t GetAlpha() const {return fAlpha;}
180     Double_t GetAlphaShift() const {return fAlphaShift;}     
181     //Int_t GetFirst(){return fFirstRow;}
182     Int_t GetRowNumber(Double_t  x) const;
183     Double_t GetPadPitchWidth()  const {return fPadPitchWidth;}
184     Double_t GetPadPitchLength() const {return fPadPitchLength;}
185     Double_t GetPadPitchLength(Float_t x) const {return (x<200) ? fPadPitchLength:f2PadPitchLength ;}
186     
187    private:
188     AliTPCSector & operator=(const AliTPCSector & );
189     AliTPCSector(const AliTPCSector &/*s*/);           //dummy copy contructor 
190     Int_t fN;                        //number of pad rows 
191     //Int_t fFirstRow;                 //offset
192     AliTPCRow *fRow;                    //array of pad rows
193     Double_t fAlpha;                    //opening angle
194     Double_t fAlphaShift;               //shift angle;
195     Double_t fPadPitchWidth;            //pad pitch width
196     Double_t fPadPitchLength;           //pad pitch length
197     Double_t f1PadPitchLength;           //pad pitch length
198     Double_t f2PadPitchLength;           //pad pitch length
199     
200    };
201
202    Float_t OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t &sum2);
203    void  SignShared(AliTPCseed * s1, AliTPCseed * s2);
204    void  SignShared(TObjArray * arr);
205
206    void  RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2,  Int_t removalindex);
207    void  RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal);
208    void  RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2,  Int_t removalindex);
209
210    void  StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const;
211    void  StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const;
212    Int_t AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor, Float_t cory=1., Float_t corz=1.);
213
214 private:
215   AliTPCtrackerMI(const AliTPCtrackerMI& r);           //dummy copy constructor
216   AliTPCtrackerMI &operator=(const AliTPCtrackerMI& r);//dummy assignment operator
217    inline AliTPCRow &GetRow(Int_t sec, Int_t row);
218    inline Bool_t     IsActive(Int_t sec, Int_t row);
219    inline Double_t  GetXrow(Int_t row) const;
220    inline Double_t  GetMaxY(Int_t row) const;
221    inline Int_t GetRowNumber(Double_t x) const;
222    Int_t GetRowNumber(Double_t x[3]) const;
223    inline Double_t GetPadPitchLength(Double_t x) const;
224    inline Double_t GetPadPitchLength(Int_t row) const;
225
226    Float_t  GetSigmaY(AliTPCseed * seed);
227    Float_t  GetSigmaZ(AliTPCseed * seed);
228    void GetShape(AliTPCseed * seed, Int_t row);
229  
230    void ReadSeeds(AliESDEvent *event, Int_t direction);  //read seeds from the event
231
232    void MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4], Float_t deltay = -1, Int_t ddsec=0); 
233    void MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4], Float_t deltay = -1);
234
235    void MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4], Float_t deltay = -1, Bool_t bconstrain=kTRUE);
236   
237
238    AliTPCseed *MakeSeed(AliTPCseed *t, Float_t r0, Float_t r1, Float_t r2); //reseed
239    AliTPCseed *ReSeed(AliTPCseed *t, Float_t r0, Float_t r1, Float_t r2); //reseed
240    AliTPCseed *ReSeed(AliTPCseed *t, Int_t r0, Bool_t forward); //reseed
241
242
243   
244    AliTPCseed * ReSeed(AliTPCseed *t);
245    Int_t LoadInnerSectors();
246    Int_t LoadOuterSectors();
247    void UnsignClusters();
248    void SignClusters(TObjArray * arr, Float_t fnumber=3., Float_t fdensity=2.);  
249
250    void ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast);
251    void Tracking(TObjArray * arr);
252    TObjArray * Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy=-1, Int_t dsec=0);
253    TObjArray * Tracking();
254    TObjArray * TrackingSpecial();
255    void SumTracks(TObjArray *arr1,TObjArray *arr2) const;
256    void PrepareForBackProlongation(TObjArray * arr, Float_t fac) const;
257    void PrepareForProlongation(TObjArray * arr, Float_t fac) const;
258
259    void SetSampledEdx(AliTPCseed */*t*/, Float_t /*q*/, Int_t /*i*/) {;}
260    Int_t UpdateTrack(AliTPCseed *t, Int_t accept); //update trackinfo
261
262
263    const Int_t fkNIS;        //number of inner sectors
264    AliTPCSector *fInnerSec;  //array of inner sectors;
265    const Int_t fkNOS;        //number of outer sectors
266    AliTPCSector *fOuterSec;  //array of outer sectors;
267
268    Int_t fN;               //number of loaded sectors
269    AliTPCSector *fSectors; //pointer to loaded sectors;
270    //
271    TTree * fInput;       // input tree with clusters
272    TTree * fOutput;      // output tree with tracks
273    TTree * fSeedTree;    // output tree with seeds - filled in debug mode 1
274    TTree * fTreeDebug;   // output with a debug information about track
275    AliESDEvent * fEvent;      // output with esd tracks
276    Int_t    fDebug;      // debug option        
277    Bool_t   fNewIO;      // indicated if we have data using New IO 
278    Int_t fNtracks;                     //current number of tracks
279    TObjArray *fSeeds;                  //array of track seeds
280    Int_t fIteration;                   // indicate iteration - 0 - froward -1 back - 2forward - back->forward
281    //   TObjArray * fTrackPointPool;        // ! pool with track points
282    //   TObjArray * fSeedPool;              //! pool with seeds
283    Double_t fXRow[200];                // radius of the pad row
284    Double_t fYMax[200];                // max y for given pad row
285    Double_t fPadLength[200];                // max y for given pad row
286    const AliTPCParam *fParam;          //pointer to the parameters
287    TTreeSRedirector *fDebugStreamer;     //!debug streamer
288    ClassDef(AliTPCtrackerMI,2) 
289 };
290
291
292 AliTPCtrackerMI::AliTPCRow & AliTPCtrackerMI::GetRow(Int_t sec, Int_t row)
293 {
294   //
295   return (row>=fInnerSec->GetNRows()) ? fOuterSec[sec][row-fInnerSec->GetNRows()]:fInnerSec[sec][row];
296 }
297
298 Bool_t   AliTPCtrackerMI::IsActive(Int_t sec, Int_t row)
299 {
300   //
301   // check if the given sector row is active 
302   //
303   return (row>=fInnerSec->GetNRows()) ? fOuterSec[sec][row-fInnerSec->GetNRows()].GetN()>0:fInnerSec[sec][row].GetN()>0;
304 }
305
306
307 Double_t  AliTPCtrackerMI::GetXrow(Int_t row) const {
308   //  return (row>=fInnerSec->GetNRows()) ? fOuterSec->GetX(row-fInnerSec->GetNRows()):fInnerSec->GetX(row);
309   return fXRow[row];
310 }
311
312 Double_t  AliTPCtrackerMI::GetMaxY(Int_t row) const {
313   //return (row>=fInnerSec->GetNRows()) ? fOuterSec->GetMaxY(row-fInnerSec->GetNRows()):fInnerSec->GetMaxY(row);
314   return fYMax[row];
315 }
316
317 Int_t AliTPCtrackerMI::GetRowNumber(Double_t x) const
318 {
319   //
320   return (x>133.) ? fOuterSec->GetRowNumber(x)+fInnerSec->GetNRows():fInnerSec->GetRowNumber(x);
321 }
322
323 Double_t  AliTPCtrackerMI::GetPadPitchLength(Double_t x) const
324 {
325   //
326   return (x>133.) ? fOuterSec->GetPadPitchLength(x):fInnerSec->GetPadPitchLength(x);
327   //return fPadLength[row];
328 }
329
330 Double_t  AliTPCtrackerMI::GetPadPitchLength(Int_t row) const
331 {
332   //
333   return fPadLength[row];
334 }
335
336
337
338 #endif
339
340