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