]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCtrackerMI.h
Changes for the kink finder. Coding conventions (M.Ivanov)
[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
18 #include "AliTracker.h"
19 #include "AliTPCtrack.h"
20 #include "AliComplexCluster.h"
21
22 class TFile;
23 class AliTPCParam;
24 class AliTPCseed;
25 class AliTPCclusterMI;
26 class AliTPCTrackerPoint;
27 class AliESD;   
28 class TTree;
29 class AliESDkink;
30
31 class AliTPCseed : public AliTPCtrack {
32   friend class AliTPCtrackerMI;
33   public:  
34      AliTPCseed();
35      virtual ~AliTPCseed();
36      AliTPCseed(const AliTPCtrack &t);
37      AliTPCseed(const AliTPCseed &s);
38      //AliTPCseed(const AliTPCseed &t, Double_t a);
39      AliTPCseed(UInt_t index, const Double_t xx[5], 
40                 const Double_t cc[15], Double_t xr, Double_t alpha);     
41      Int_t Compare(const TObject *o) const;
42      void Reset(Bool_t all = kTRUE);
43      Int_t GetProlongation(Double_t xr, Double_t &y, Double_t & z) const;
44      virtual Double_t GetPredictedChi2(const AliTPCclusterMI *cluster) const;
45      virtual Int_t Update(const AliTPCclusterMI* c, Double_t chi2, UInt_t i);
46      AliTPCTrackerPoint * GetTrackPoint(Int_t i);
47      void RebuildSeed(); // rebuild seed to be ready for storing
48      Double_t GetDensityFirst(Int_t n);
49      Double_t GetSigma2C() const {return fC44;};
50      void GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2);
51      
52      void Modify(Double_t factor);
53      void SetClusterIndex2(Int_t row, Int_t index) {
54        fIndex[row] = index;
55      }
56      Int_t  GetClusterIndex2(Int_t row) const {
57        return fIndex[row];
58      }
59      Int_t GetClusterSector(Int_t row) const {
60        Int_t pica = -1;
61        if (fIndex[row]>=0) pica =  ((fIndex[row]&0xff000000)>>24);
62        return pica;
63      }
64     
65      void SetErrorY2(Float_t sy2){fErrorY2=sy2;}
66      void SetErrorZ2(Float_t sz2){fErrorZ2=sz2;}
67      void CookdEdx(Double_t low=0.05, Double_t up=0.70, Int_t i1=0, Int_t i2=159, Bool_t onlyused = kFALSE);
68      //     void CookdEdx2(Double_t low=0.05, Double_t up=0.70);
69      Bool_t IsActive() const { return !(fRemoval);}
70      void Desactivate(Int_t reason){ fRemoval = reason;} 
71      //
72      //
73  private:
74      //     AliTPCseed & operator = (const AliTPCseed &)
75      //  {::Fatal("= operator","Not Implemented\n");return *this;}
76      AliESDtrack * fEsd; //!
77      AliTPCclusterMI*   fClusterPointer[160];  //! array of cluster pointers  - 
78      TClonesArray * fPoints;              // array with points along the track
79      TClonesArray * fEPoints;             // array with exact points - calculated in special macro not used in tracking
80      //---CURRENT VALUES
81      Int_t fRow;                 //!current row number  
82      Int_t fSector;              //!current sector number
83      Int_t fRelativeSector;      //! index of current relative sector
84      Float_t fCurrentSigmaY2;    //!expected current cluster sigma Y
85      Float_t fCurrentSigmaZ2;    //!expected current cluster sigma Z
86      Float_t fErrorY2;           //!sigma of current cluster 
87      Float_t fErrorZ2;           //!sigma of current cluster    
88      AliTPCclusterMI * fCurrentCluster; //!pointer to the current cluster for prolongation
89      Int_t   fCurrentClusterIndex1; //! index of the current cluster
90      Bool_t  fInDead;            //! indicate if the track is in dead zone
91      Bool_t  fIsSeeding;         //!indicates if it is proces of seeading
92      Int_t   fNoCluster;         //!indicates number of rows without clusters
93      Int_t   fSort;              //!indicate criteria for sorting
94      Bool_t  fBSigned;        //indicates that clusters of this trackes are signed to be used
95      //
96      //
97      Float_t fDEDX[4];         // dedx according padrows
98      Float_t fSDEDX[4];        // sdedx according padrows
99      Int_t   fNCDEDX[4];       // number of clusters for dedx measurment
100      //
101      Int_t   fSeedType;         //seeding type
102      Int_t   fSeed1;            //first row for seeding
103      Int_t   fSeed2;            //last row for seeding
104      Int_t   fOverlapLabels[12];  //track labels and the length of the  overlap     
105      Float_t fMAngular;        // mean angular factor
106      AliTPCTrackerPoint  fTrackPoints[160];  //!track points - array track points
107    
108      ClassDef(AliTPCseed,1)  
109 };
110
111
112
113
114 class AliTPCtrackerMI : public AliTracker {
115 public:
116   AliTPCtrackerMI():AliTracker(),fkNIS(0),fkNOS(0) {
117     fInnerSec=fOuterSec=0; fSeeds=0; 
118   }
119   AliTPCtrackerMI(const AliTPCParam *par); 
120    AliTPCtrackerMI(const AliTPCtrackerMI& r);           //dummy copy constructor
121    AliTPCtrackerMI &operator=(const AliTPCtrackerMI& r);//dummy assignment operator
122   virtual ~AliTPCtrackerMI();
123   //
124   void SetIteration(Int_t iteration){fIteration = iteration;}
125   virtual Int_t Clusters2Tracks (AliESD *esd);
126   virtual Int_t RefitInward (AliESD *esd);
127   virtual Int_t LoadClusters (TTree * tree);
128   Int_t  LoadClusters();
129   void   UnloadClusters();
130
131   //
132   void SetIO();  //set default IO from folders
133   void SetIO(TTree * input, TTree * output, AliESD * event);
134   void FillESD(TObjArray* arr);
135   void WriteTracks();
136   void WriteTracks(TTree * tree);  
137   void DeleteSeeds();
138   void SetDebug(Int_t debug){ fDebug = debug;}
139   void FindKinks(TObjArray * array, AliESD * esd);
140   void UpdateKinkQualityM(AliTPCseed * seed);
141   void UpdateKinkQualityD(AliTPCseed * seed);
142   Int_t CheckKinkPoint(AliTPCseed*seed, AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink);
143   Int_t RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink);
144    Int_t ReadSeeds(const TFile *in);
145    TObjArray * GetSeeds(){return fSeeds;}
146    //   
147    AliCluster * GetCluster (int) const {return 0;}
148    AliTPCclusterMI *GetClusterMI(Int_t index) const;
149    Int_t Clusters2Tracks();
150    virtual void  CookLabel(AliTPCseed *t,Float_t wrong) const; 
151    virtual Int_t   CookLabel(AliTPCseed *t,Float_t wrong, Int_t first,Int_t last ) const; 
152    
153    void RotateToLocal(AliTPCseed *seed);
154   
155    
156    Int_t FollowProlongation(AliTPCseed& t, Int_t rf=0, Int_t step=1);
157    Int_t FollowProlongationFast(AliTPCseed& t, Int_t rf=0, Int_t step=1);
158    
159    Int_t FollowBackProlongation(AliTPCseed& t, Int_t rf);
160    Int_t FollowToNext(AliTPCseed& t, Int_t nr);
161    Int_t FollowToNextFast(AliTPCseed& t, Int_t nr);
162    Int_t UpdateClusters(AliTPCseed& t,  Int_t nr);
163    Int_t FollowToNextCluster( AliTPCseed& t, Int_t nr);
164
165    Int_t PropagateBack(TObjArray * arr);
166    Int_t PropagateBack(AliESD * event);
167    Int_t PropagateBack(AliTPCseed *pt, Int_t row0, Int_t row1);   
168    Int_t PropagateForward();
169    Int_t PropagateForward2(TObjArray * arr);
170
171    void SortTracks(TObjArray * arr, Int_t mode) const;
172   
173
174    virtual Double_t ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl = 0);
175    virtual Double_t ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl = 0);   
176
177    Double_t F1(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t x3,Double_t y3); 
178    Double_t F1old(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t x3,Double_t y3); 
179    Double_t F2(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t x3,Double_t y3); 
180    Double_t F2old(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t x3,Double_t y3); 
181
182    Double_t F3(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t z1,Double_t z2); 
183    Double_t F3n(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t z1,Double_t z2, 
184                 Double_t c); 
185    Bool_t GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z);
186
187  public:
188 //**************** Internal tracker class ********************** 
189    class AliTPCSector;
190    class AliTPCRow {
191      friend class AliTPCtrackerMI;
192      friend class AliTPCtrackerMI::AliTPCSector;
193    public:
194      AliTPCRow();
195      AliTPCRow(const AliTPCRow& /*r*/){;}           //dummy copy constructor
196      AliTPCRow &operator=(const AliTPCRow& /*r*/){return *this;} //dummy assignment operator
197      ~AliTPCRow();
198      void InsertCluster(const AliTPCclusterMI *c, UInt_t index);
199      void ResetClusters();
200      operator int() const {return fN;}
201      Int_t GetN() const {return fN;}
202      const AliTPCclusterMI* operator[](Int_t i) const {return fClusters[i];}
203      UInt_t GetIndex(Int_t i) const {return fIndex[i];}
204      inline Int_t Find(Double_t z) const; 
205      AliTPCclusterMI *  FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const;
206      AliTPCclusterMI *  FindNearest2(Double_t y, Double_t z, Double_t roady, Double_t roadz, UInt_t & index) const;
207      AliTPCclusterMI *  FindNearest3(Double_t y, Double_t z, Double_t roady, Double_t roadz, UInt_t & index) const;
208      
209      void SetX(Double_t x) {fX=x;}
210      Double_t GetX() const {return fX;}
211 private:  
212      Float_t fDeadZone;  // the width of the dead zone
213      AliTPCclusterMI *fClusters1; //array with clusters 1
214      Int_t fN1;  //number of clusters on left side
215      AliTPCclusterMI *fClusters2; //array with clusters 2
216      Int_t fN2; // number of clusters on right side of the TPC
217      Short_t fFastCluster[510];   //index of the nearest cluster at given position
218      Int_t fN;                                          //number of clusters 
219      const AliTPCclusterMI *fClusters[kMaxClusterPerRow]; //pointers to clusters
220                                // indexes for cluster at given position z  
221      // AliTPCclusterMI *fClustersArray;                     // 
222      UInt_t fIndex[kMaxClusterPerRow];                  //indeces of clusters
223      Double_t fX;                                 //X-coordinate of this row
224
225    };
226
227 //**************** Internal tracker class ********************** 
228    class AliTPCSector {
229      friend class AliTPCtrackerMI;
230    public:
231      AliTPCSector() { fN=0; fRow = 0; }
232     ~AliTPCSector() { delete[] fRow; }
233     AliTPCSector(const AliTPCSector &/*s*/){;}           //dummy copy contructor 
234     AliTPCSector& operator=(const AliTPCSector &/*s*/){return *this;}//dummy assignment operator
235      AliTPCRow& operator[](Int_t i) const { return *(fRow+i); }
236      Int_t GetNRows() const { return fN; }
237      void Setup(const AliTPCParam *par, Int_t flag);
238      Double_t GetX(Int_t l) const {return fRow[l].GetX();}
239      Double_t GetMaxY(Int_t l) const {
240          return GetX(l)*TMath::Tan(0.5*GetAlpha());
241      } 
242      Double_t GetAlpha() const {return fAlpha;}
243      Double_t GetAlphaShift() const {return fAlphaShift;}     
244      //Int_t GetFirst(){return fFirstRow;}
245      Int_t GetRowNumber(Double_t  x) const;
246      Double_t GetPadPitchWidth()  const {return fPadPitchWidth;}
247      Double_t GetPadPitchLength() const {return fPadPitchLength;}
248      Double_t GetPadPitchLength(Float_t x) const {return (x<200) ? fPadPitchLength:f2PadPitchLength ;}
249
250    private:
251      Int_t fN;                        //number of pad rows 
252      //Int_t fFirstRow;                 //offset
253      AliTPCRow *fRow;                    //array of pad rows
254      Double_t fAlpha;                    //opening angle
255      Double_t fAlphaShift;               //shift angle;
256      Double_t fPadPitchWidth;            //pad pitch width
257      Double_t fPadPitchLength;           //pad pitch length
258      Double_t f1PadPitchLength;           //pad pitch length
259      Double_t f2PadPitchLength;           //pad pitch length
260     
261    };
262
263    Float_t OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t &sum2);
264    void  SignShared(AliTPCseed * s1, AliTPCseed * s2);
265    void  SignShared(TObjArray * arr);
266
267    void  RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2,  Int_t removalindex);
268    void  RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal);
269    void  RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2,  Int_t removalindex);
270
271    void  StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const;
272    void  StopNotActive(AliTPCseed * seed, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const;
273    Int_t AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor, Float_t cory=1., Float_t corz=1.);
274
275 private:
276    inline AliTPCRow &GetRow(Int_t sec, Int_t row);
277    inline Double_t  GetXrow(Int_t row) const;
278    inline Double_t  GetMaxY(Int_t row) const;
279    inline Int_t GetRowNumber(Double_t x) const;
280    Int_t GetRowNumber(Double_t x[3]) const;
281    inline Double_t GetPadPitchLength(Double_t x) const;
282    inline Double_t GetPadPitchLength(Int_t row) const;
283
284    Float_t  GetSigmaY(AliTPCseed * seed);
285    Float_t  GetSigmaZ(AliTPCseed * seed);
286    void GetShape(AliTPCseed * seed, Int_t row);
287  
288    void ReadSeeds(AliESD *event, Int_t direction);  //read seeds from the event
289
290    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); 
291    void MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4], Float_t deltay = -1);
292
293    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);
294   
295
296    AliTPCseed *MakeSeed(AliTPCseed *t, Float_t r0, Float_t r1, Float_t r2); //reseed
297    AliTPCseed *ReSeed(AliTPCseed *t, Float_t r0, Float_t r1, Float_t r2); //reseed
298    AliTPCseed *ReSeed(AliTPCseed *t, Int_t r0, Bool_t forward); //reseed
299
300
301   
302    AliTPCseed * ReSeed(AliTPCseed *t);
303    Int_t LoadInnerSectors();
304    Int_t LoadOuterSectors();
305    void UnsignClusters();
306    void SignClusters(TObjArray * arr, Float_t fnumber=3., Float_t fdensity=2.);  
307
308    void ParallelTracking(TObjArray * arr, Int_t rfirst, Int_t rlast);
309    void Tracking(TObjArray * arr);
310    TObjArray * Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy=-1, Int_t dsec=0);
311    TObjArray * Tracking();
312    void SumTracks(TObjArray *arr1,TObjArray *arr2) const;
313    void PrepareForBackProlongation(TObjArray * arr, Float_t fac) const;
314    void PrepareForProlongation(TObjArray * arr, Float_t fac) const;
315
316    void SetSampledEdx(AliTPCseed */*t*/, Float_t /*q*/, Int_t /*i*/) {;}
317    Int_t UpdateTrack(AliTPCseed *t, Int_t accept); //update trackinfo
318
319
320    const Int_t fkNIS;        //number of inner sectors
321    AliTPCSector *fInnerSec;  //array of inner sectors;
322    const Int_t fkNOS;        //number of outer sectors
323    AliTPCSector *fOuterSec;  //array of outer sectors;
324
325    Int_t fN;               //number of loaded sectors
326    AliTPCSector *fSectors; //pointer to loaded sectors;
327    //
328    TTree * fInput;       // input tree with clusters
329    TTree * fOutput;      // output tree with tracks
330    TTree * fSeedTree;    // output tree with seeds - filled in debug mode 1
331    TTree * fTreeDebug;   // output with a debug information about track
332    AliESD * fEvent;      // output with esd tracks
333    Int_t    fDebug;      // debug option        
334    Bool_t   fNewIO;      // indicated if we have data using New IO 
335    Int_t fNtracks;                     //current number of tracks
336    TObjArray *fSeeds;                  //array of track seeds
337    Int_t fIteration;                   // indicate iteration - 0 - froward -1 back - 2forward - back->forward
338    //   TObjArray * fTrackPointPool;        // ! pool with track points
339    //   TObjArray * fSeedPool;              //! pool with seeds
340    Double_t fXRow[200];                // radius of the pad row
341    Double_t fYMax[200];                // max y for given pad row
342    Double_t fPadLength[200];                // max y for given pad row
343    const AliTPCParam *fParam;          //pointer to the parameters
344    ClassDef(AliTPCtrackerMI,1) 
345 };
346
347
348 AliTPCtrackerMI::AliTPCRow & AliTPCtrackerMI::GetRow(Int_t sec, Int_t row)
349 {
350   //
351   return (row>=fInnerSec->GetNRows()) ? fOuterSec[sec][row-fInnerSec->GetNRows()]:fInnerSec[sec][row];
352 }
353
354 Double_t  AliTPCtrackerMI::GetXrow(Int_t row) const {
355   //  return (row>=fInnerSec->GetNRows()) ? fOuterSec->GetX(row-fInnerSec->GetNRows()):fInnerSec->GetX(row);
356   return fXRow[row];
357 }
358
359 Double_t  AliTPCtrackerMI::GetMaxY(Int_t row) const {
360   //return (row>=fInnerSec->GetNRows()) ? fOuterSec->GetMaxY(row-fInnerSec->GetNRows()):fInnerSec->GetMaxY(row);
361   return fYMax[row];
362 }
363
364 Int_t AliTPCtrackerMI::GetRowNumber(Double_t x) const
365 {
366   //
367   return (x>133.) ? fOuterSec->GetRowNumber(x)+fInnerSec->GetNRows():fInnerSec->GetRowNumber(x);
368 }
369
370 Double_t  AliTPCtrackerMI::GetPadPitchLength(Double_t x) const
371 {
372   //
373   return (x>133.) ? fOuterSec->GetPadPitchLength(x):fInnerSec->GetPadPitchLength(x);
374   //return fPadLength[row];
375 }
376
377 Double_t  AliTPCtrackerMI::GetPadPitchLength(Int_t row) const
378 {
379   //
380   return fPadLength[row];
381 }
382
383
384
385 #endif
386
387