]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCtrackerMI.h
Improved parallel tracking (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 /* $Id$ */
7
8 //-------------------------------------------------------
9 //                       TPC trackerMI
10 //
11 //   Origin: 
12 //-------------------------------------------------------
13 #include "AliTracker.h"
14 #include "AliTPCtrack.h"
15 #include "AliTPCClustersArray.h"
16
17 #include "AliTPCreco.h" 
18 #include "Rtypes.h"
19
20 class TFile;
21 class AliTPCParam;
22 class AliTPCseed;
23 class AliTPCclusterMI;
24 class AliTPCTrackPoint;
25
26
27
28 class AliTPCclusterTracks {
29  public: 
30   AliTPCclusterTracks();
31   Float_t fDistance[3];   // distance to the 3 nerest track if there overlap with cluster
32   Short_t fTrackIndex[3]; // indexes of the  tracks overlapped with clusters 
33 };
34
35 class AliTPCseed;
36
37 class AliTPCKalmanSegment: public TObject {
38   //
39   // class to store tracklet parameters
40   // needed to probabilistically define track beginning and track end  
41  public:
42   AliTPCKalmanSegment();
43   void Init(AliTPCseed* seed);             // in initialization initial entrance integral chi2, fNCFoundable and fNC stored 
44   void Finish(AliTPCseed* seed);           // in finish state vector stored and chi2 and fNC... calculated
45   void GetState(Double_t &x, Double_t & alpha, Double_t state[5]);        
46   void GetCovariance(Double_t covariance[15]);
47   void GetStatistic(Int_t & nclusters, Int_t & nfoundable, Float_t & chi2); 
48  private:
49   Float_t fX;               //  x - state
50   Float_t fAlpha;           //  Rotation angle the local (TPC sector) 
51   Float_t fState[5];        // state vector
52   Float_t fChi2;            // chi2 - for given tracklet
53   Float_t fCovariance[15];  // 15 elements of covariance matrix
54   Int_t fNCFoundable;       // number of foundable clusters on tracklet (effect of dead zone)
55   Int_t fNC;                // number of accepted clusters for tracklet  
56   //  Int_t fN;                 // total number of padrows for given tracklet
57   ClassDef(AliTPCKalmanSegment,1) 
58 }; 
59
60
61 class AliTPCseed : public AliTPCtrack {
62    public:
63      AliTPCseed();
64      virtual ~AliTPCseed();
65      AliTPCseed(const AliTPCtrack &t);
66      AliTPCseed(const AliKalmanTrack &t, Double_t a);
67      Int_t Compare(const TObject *o) const;
68      void Reset();
69      Int_t GetProlongation(Double_t xr, Double_t &y, Double_t & z) const;
70      virtual Double_t GetPredictedChi2(const AliTPCclusterMI *cluster) const;
71      virtual Int_t Update(const AliTPCclusterMI* c, Double_t chi2, UInt_t i);
72      AliTPCTrackPoint * GetTrackPoint(Int_t i);
73      void RebuildSeed(); // rebuild seed to be ready for storing
74      AliTPCseed(UInt_t index, const Double_t xx[5], 
75                 const Double_t cc[15], Double_t xr, Double_t alpha);
76      void SetClusterIndex(Int_t index){
77        fClusterIndex[fRow] = index;
78      }
79      void SetErrorY2(Float_t sy2){fErrorY2=sy2;}
80      void SetErrorZ2(Float_t sz2){fErrorZ2=sz2;}
81      void CookdEdx(Double_t low=0.05, Double_t up=0.70);
82      Bool_t IsActive(){ return !(fRemoval);}
83      void Desactivate(Int_t reason){ fRemoval = reason;} 
84      
85      //     Float_t GetRadius(){ return (1-fP2)/fP4;}  
86      Int_t fRelativeSector;  // ! index of current relative sector
87      Int_t   fClusterIndex[200];  //array of cluster indexes
88      Float_t fClusterDensity[16]; //array with cluster densities 
89     
90      Int_t fRemoval;               //reason - why was track removed - 0 - means still active     
91      TClonesArray * fPoints;              // array with points along the track   
92      TClonesArray * fEPoints;             // array with exact points - calculated in special macro not used in tracking
93      Int_t fRow;                 //!current row number  
94      Int_t fSector;              //!current sector number
95      Float_t fCurrentSigmaY;     //!expected current cluster sigma Y
96      Float_t fCurrentSigmaZ;     //!expected current cluster sigma Z
97      AliTPCclusterMI * fCurrentCluster; //!pointer to the current cluster for prolongation
98      Int_t   fCurrentClusterIndex1; //! index of the current cluster
99      Int_t   fCurrentClusterIndex2; //! index of the current cluster
100     
101      Float_t fErrorY2;   //!sigma of current cluster 
102      Float_t fErrorZ2;   //!sigma of current cluster    
103      Int_t   fNFoundable;      //number of foundable clusters - dead zone taken to the account
104      Bool_t  fInDead;         // indicate if the track is in dead zone
105      Int_t   fFirstPoint;    // first cluster position
106      Int_t   fLastPoint;     // last  cluster position     
107      Int_t   fNShared;       // number of shared points
108      Bool_t  fIsSeeding;     //indicates if it is proces of seeading
109      Bool_t  fStopped;      // indicate that track cann't be prolongate anymore (for secondaries)
110    private:
111      Float_t fSdEdx;           // sigma of dedx
112      Float_t fMAngular;        // mean angular factor
113      AliTPCTrackPoint   ** fTrackPoints;  //!track points - array track points
114      Float_t fDEDX[4];         // dedx according padrows
115      Float_t fSDEDX[4];        // sdedx according padrows
116      Int_t   fNCDEDX[4];       // number of clusters for dedx measurment
117    
118      ClassDef(AliTPCseed,1)  
119 };
120
121
122
123
124 class AliTPCtrackerMI : public AliTracker {
125 public:
126    AliTPCtrackerMI():AliTracker(),fkNIS(0),fkNOS(0) {
127       fInnerSec=fOuterSec=0; fSeeds=0; 
128    }
129    AliTPCtrackerMI(const AliTPCParam *par, Int_t eventn=0);
130   ~AliTPCtrackerMI();
131
132    Int_t ReadSeeds(const TFile *in);
133    void LoadClusters();
134    void UnloadClusters();
135
136    void LoadInnerSectors();
137    void LoadOuterSectors();
138    AliCluster * GetCluster (int) const {return 0;}
139    AliTPCclusterMI *GetClusterMI(Int_t index) const;
140    Int_t Clusters2Tracks(const TFile *in, TFile *out);
141    //   Int_t PropagateBack(const TFile *in, TFile *out);
142
143    virtual void  CookLabel(AliKalmanTrack *t,Float_t wrong) const; 
144    void RotateToLocal(AliTPCseed *seed);
145    virtual Double_t ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl = 0);
146    virtual Double_t ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl = 0);   
147
148    Double_t f1(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t x3,Double_t y3); 
149    Double_t f2(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t x3,Double_t y3); 
150    Double_t f3(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t z1,Double_t z2); 
151 public:
152 //**************** Internal tracker class ********************** 
153    class AliTPCRow {
154    public:
155      AliTPCRow() {fN=0; fClusterTracks=0;}
156      ~AliTPCRow();
157      void InsertCluster(const AliTPCclusterMI *c, UInt_t index);
158      operator int() const {return fN;}
159      const AliTPCclusterMI* operator[](Int_t i) const {return fClusters[i];}
160      UInt_t GetIndex(Int_t i) const {return fIndex[i];}
161      Int_t Find(Double_t z) const; 
162      AliTPCclusterMI *  FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const;
163      void SetX(Double_t x) {fX=x;}
164      Double_t GetX() const {return fX;}
165      AliTPCclusterTracks *  GetClusterTracks(Int_t index){ return ( (index<fN) && fClusterTracks!=0)? &(fClusterTracks[index]):0;}
166      void UpdateClusterTrack(Int_t clindex, Int_t trindex,AliTPCseed * seed); 
167      void MakeClusterTracks();
168      void ClearClusterTracks();
169      Float_t fDeadZone;  // the width of the dead zone
170    private:
171      Int_t fN;                                          //number of clusters 
172      const AliTPCclusterMI *fClusters[kMaxClusterPerRow]; //pointers to clusters
173      UInt_t fIndex[kMaxClusterPerRow];                  //indeces of clusters
174      Double_t fX;                                 //X-coordinate of this row
175      AliTPCclusterTracks * fClusterTracks;        // array of cluster tracks - for overlap calculation
176    private:
177      AliTPCRow(const AliTPCRow& r);            //dummy copy constructor
178      AliTPCRow &operator=(const AliTPCRow& r); //dummy assignment operator
179    };
180
181 //**************** Internal tracker class ********************** 
182    class AliTPCSector {
183    public:
184      AliTPCSector() { fN=0; fRow = 0; }
185     ~AliTPCSector() { delete[] fRow; }
186      AliTPCRow& operator[](Int_t i) const { return *(fRow+i); }
187      Int_t GetNRows() const { return fN; }
188      void Setup(const AliTPCParam *par, Int_t flag);
189      Double_t GetX(Int_t l) const {return fRow[l].GetX();}
190      Double_t GetMaxY(Int_t l) const {
191          return GetX(l)*TMath::Tan(0.5*GetAlpha());
192      } 
193      Double_t GetAlpha() const {return fAlpha;}
194      Double_t GetAlphaShift() const {return fAlphaShift;}     
195      Int_t GetRowNumber(Double_t x) const {
196         //return pad row number for this x
197        Double_t r;
198        if (fN < 64){
199          r=fRow[fN-1].GetX();
200          if (x > r) return fN;
201          r=fRow[0].GetX();
202          if (x < r) return -1;
203          return Int_t((x-r)/fPadPitchLength + 0.5);}
204        else{    
205            r=fRow[fN-1].GetX();
206            if (x > r) return fN;
207            r=fRow[0].GetX();
208            if (x < r) return -1;
209           Double_t r1=fRow[64].GetX();
210           if(x<r1){       
211             return Int_t((x-r)/f1PadPitchLength + 0.5);}
212           else{
213             return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);} 
214        }
215      }
216      Double_t GetPadPitchWidth()  const {return fPadPitchWidth;}
217      Double_t GetPadPitchLength() const {return fPadPitchLength;}
218      Double_t GetPadPitchLength(Float_t x) const {return (x<200) ? fPadPitchLength:f2PadPitchLength ;}
219
220    private:
221      Int_t fN;                        //number of pad rows 
222      AliTPCRow *fRow;                    //array of pad rows
223      Double_t fAlpha;                    //opening angle
224      Double_t fAlphaShift;               //shift angle;
225      Double_t fPadPitchWidth;            //pad pitch width
226      Double_t fPadPitchLength;           //pad pitch length
227      Double_t f1PadPitchLength;           //pad pitch length
228      Double_t f2PadPitchLength;           //pad pitch length
229     
230    private:
231      AliTPCSector(const AliTPCSector &s);           //dummy copy contructor
232      AliTPCSector& operator=(const AliTPCSector &s);//dummy assignment operator
233    };
234
235    Float_t OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t &sum2);
236    void  SignShared(AliTPCseed * s1, AliTPCseed * s2);
237    void  RemoveOverlap(TObjArray * arr, Float_t factor, Int_t removalindex, Bool_t shared=kFALSE);
238    void  RemoveUsed(TObjArray * arr, Float_t factor, Int_t removalindex);
239
240 private:
241    Float_t  GetSigmaY(AliTPCseed * seed);
242    Float_t  GetSigmaZ(AliTPCseed * seed);
243
244    void MakeSeeds(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2);
245    void MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2);
246
247    TObjArray * MakeSeedsSectors(Int_t sec1, Int_t sec2);   // make seeds from all sectors
248    void MakeSeedsAll();
249    Int_t FollowProlongation(AliTPCseed& t, Int_t rf=0);
250    //Int_t FollowProlongationFast(AliTPCseed& t, Int_t step);   
251    Int_t FollowBackProlongation(AliTPCseed& t, Int_t rf=0);
252
253    Int_t FollowToNext(AliTPCseed& t, Int_t nr);
254    Int_t UpdateClusters(AliTPCseed& t, Int_t trindex,  Int_t nr);
255    Int_t FollowToNextCluster( Int_t trindex, Int_t nr);
256
257    virtual Int_t PropagateBack (const TFile *, TFile *){return 0;}
258    void ParallelTracking(Int_t rfirst, Int_t rlast);
259    void SetSampledEdx(AliTPCseed *t, Float_t q, Int_t i) {;}
260    Int_t UpdateTrack(AliTPCseed *t,AliTPCclusterMI* c, Double_t chi2, UInt_t i); //update trackinfo
261
262    //   Int_t FollowBackProlongation(AliTPCseed &s, const AliTPCtrack &t);
263
264    AliTPCtrackerMI(const AliTPCtrackerMI& r);           //dummy copy constructor
265    AliTPCtrackerMI &operator=(const AliTPCtrackerMI& r);//dummy assignment operator
266
267    const Int_t fkNIS;        //number of inner sectors
268    AliTPCSector *fInnerSec;  //array of inner sectors;
269    const Int_t fkNOS;        //number of outer sectors
270    AliTPCSector *fOuterSec;  //array of outer sectors;
271
272    Int_t fN;               //number of loaded sectors
273    AliTPCSector *fSectors; //pointer to loaded sectors;
274
275    Int_t fEventN;                      //event number
276    AliTPCClustersArray fClustersArray; //array of TPC clusters
277    Int_t fNtracks;                     //current number of tracks
278    TObjArray *fSeeds;                  //array of track seeds
279    //   TObjArray * fTrackPointPool;        // ! pool with track points
280    const AliTPCParam *fParam;          //pointer to the parameters
281 };
282
283 #endif
284
285