]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCtrackerMI.h
23caddef30bbb4af3fac168ed5eb110cf250a083
[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);
130   ~AliTPCtrackerMI();
131
132    virtual Int_t Clusters2Tracks(AliESD *event) {return -1;};
133    virtual Int_t PropagateBack(AliESD *event) {return -1;};
134    virtual Int_t RefitInward(AliESD *event) {return -1;};
135    virtual Int_t LoadClusters(TTree *) {return -1;};
136
137    Int_t ReadSeeds(const TFile *in);
138    Int_t LoadClusters();
139    void UnloadClusters();
140
141    void LoadInnerSectors();
142    void LoadOuterSectors();
143    AliCluster * GetCluster (Int_t index) const 
144      {return (AliCluster*) GetClusterMI(index);}
145    AliTPCclusterMI *GetClusterMI(Int_t index) const;
146    Int_t Clusters2Tracks();
147    Int_t PropagateBack() {return -1;};
148
149    virtual void  CookLabel(AliKalmanTrack *t,Float_t wrong) const; 
150    void RotateToLocal(AliTPCseed *seed);
151    virtual Double_t ErrY2(AliTPCseed* seed, AliTPCclusterMI * cl = 0);
152    virtual Double_t ErrZ2(AliTPCseed* seed, AliTPCclusterMI * cl = 0);   
153
154    Double_t f1(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t x3,Double_t y3); 
155    Double_t f2(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t x3,Double_t y3); 
156    Double_t f3(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t z1,Double_t z2); 
157 public:
158 //**************** Internal tracker class ********************** 
159    class AliTPCRow {
160    public:
161      AliTPCRow() {fN=0; fClusterTracks=0;}
162      ~AliTPCRow();
163      void InsertCluster(const AliTPCclusterMI *c, UInt_t index);
164      operator int() const {return fN;}
165      const AliTPCclusterMI* operator[](Int_t i) const {return fClusters[i];}
166      UInt_t GetIndex(Int_t i) const {return fIndex[i];}
167      Int_t Find(Double_t z) const; 
168      AliTPCclusterMI *  FindNearest(Double_t y, Double_t z, Double_t roady, Double_t roadz) const;
169      void SetX(Double_t x) {fX=x;}
170      Double_t GetX() const {return fX;}
171      AliTPCclusterTracks *  GetClusterTracks(Int_t index){ return ( (index<fN) && fClusterTracks!=0)? &(fClusterTracks[index]):0;}
172      void UpdateClusterTrack(Int_t clindex, Int_t trindex,AliTPCseed * seed); 
173      void MakeClusterTracks();
174      void ClearClusterTracks();
175      Float_t fDeadZone;  // the width of the dead zone
176    private:
177      Int_t fN;                                          //number of clusters 
178      const AliTPCclusterMI *fClusters[kMaxClusterPerRow]; //pointers to clusters
179      UInt_t fIndex[kMaxClusterPerRow];                  //indeces of clusters
180      Double_t fX;                                 //X-coordinate of this row
181      AliTPCclusterTracks * fClusterTracks;        // array of cluster tracks - for overlap calculation
182    private:
183      AliTPCRow(const AliTPCRow& r);            //dummy copy constructor
184      AliTPCRow &operator=(const AliTPCRow& r); //dummy assignment operator
185    };
186
187 //**************** Internal tracker class ********************** 
188    class AliTPCSector {
189    public:
190      AliTPCSector() { fN=0; fRow = 0; }
191     ~AliTPCSector() { delete[] fRow; }
192      AliTPCRow& operator[](Int_t i) const { return *(fRow+i); }
193      Int_t GetNRows() const { return fN; }
194      void Setup(const AliTPCParam *par, Int_t flag);
195      Double_t GetX(Int_t l) const {return fRow[l].GetX();}
196      Double_t GetMaxY(Int_t l) const {
197          return GetX(l)*TMath::Tan(0.5*GetAlpha());
198      } 
199      Double_t GetAlpha() const {return fAlpha;}
200      Double_t GetAlphaShift() const {return fAlphaShift;}     
201      Int_t GetRowNumber(Double_t x) const {
202         //return pad row number for this x
203        Double_t r;
204        if (fN < 64){
205          r=fRow[fN-1].GetX();
206          if (x > r) return fN;
207          r=fRow[0].GetX();
208          if (x < r) return -1;
209          return Int_t((x-r)/fPadPitchLength + 0.5);}
210        else{    
211            r=fRow[fN-1].GetX();
212            if (x > r) return fN;
213            r=fRow[0].GetX();
214            if (x < r) return -1;
215           Double_t r1=fRow[64].GetX();
216           if(x<r1){       
217             return Int_t((x-r)/f1PadPitchLength + 0.5);}
218           else{
219             return (Int_t((x-r1)/f2PadPitchLength + 0.5)+64);} 
220        }
221      }
222      Double_t GetPadPitchWidth()  const {return fPadPitchWidth;}
223      Double_t GetPadPitchLength() const {return fPadPitchLength;}
224      Double_t GetPadPitchLength(Float_t x) const {return (x<200) ? fPadPitchLength:f2PadPitchLength ;}
225
226    private:
227      Int_t fN;                        //number of pad rows 
228      AliTPCRow *fRow;                    //array of pad rows
229      Double_t fAlpha;                    //opening angle
230      Double_t fAlphaShift;               //shift angle;
231      Double_t fPadPitchWidth;            //pad pitch width
232      Double_t fPadPitchLength;           //pad pitch length
233      Double_t f1PadPitchLength;           //pad pitch length
234      Double_t f2PadPitchLength;           //pad pitch length
235     
236    private:
237      AliTPCSector(const AliTPCSector &s);           //dummy copy contructor
238      AliTPCSector& operator=(const AliTPCSector &s);//dummy assignment operator
239    };
240
241    Float_t OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t &sum2);
242    void  SignShared(AliTPCseed * s1, AliTPCseed * s2);
243    void  RemoveOverlap(TObjArray * arr, Float_t factor, Int_t removalindex, Bool_t shared=kFALSE);
244    void  RemoveUsed(TObjArray * arr, Float_t factor, Int_t removalindex);
245
246 private:
247    Float_t  GetSigmaY(AliTPCseed * seed);
248    Float_t  GetSigmaZ(AliTPCseed * seed);
249
250    void MakeSeeds(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2);
251    void MakeSeeds2(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2);
252
253    TObjArray * MakeSeedsSectors(Int_t sec1, Int_t sec2);   // make seeds from all sectors
254    void MakeSeedsAll();
255    Int_t FollowProlongation(AliTPCseed& t, Int_t rf=0);
256    //Int_t FollowProlongationFast(AliTPCseed& t, Int_t step);   
257    Int_t FollowBackProlongation(AliTPCseed& t, Int_t rf=0);
258
259    Int_t FollowToNext(AliTPCseed& t, Int_t nr);
260    Int_t UpdateClusters(AliTPCseed& t, Int_t trindex,  Int_t nr);
261    Int_t FollowToNextCluster( Int_t trindex, Int_t nr);
262
263    virtual Int_t PropagateBack (const TFile *, TFile *){return 0;}
264    void ParallelTracking(Int_t rfirst, Int_t rlast);
265    void SetSampledEdx(AliTPCseed *t, Float_t q, Int_t i) {;}
266    Int_t UpdateTrack(AliTPCseed *t,AliTPCclusterMI* c, Double_t chi2, UInt_t i); //update trackinfo
267
268    //   Int_t FollowBackProlongation(AliTPCseed &s, const AliTPCtrack &t);
269
270    AliTPCtrackerMI(const AliTPCtrackerMI& r);           //dummy copy constructor
271    AliTPCtrackerMI &operator=(const AliTPCtrackerMI& r);//dummy assignment operator
272
273    const Int_t fkNIS;        //number of inner sectors
274    AliTPCSector *fInnerSec;  //array of inner sectors;
275    const Int_t fkNOS;        //number of outer sectors
276    AliTPCSector *fOuterSec;  //array of outer sectors;
277
278    Int_t fN;               //number of loaded sectors
279    AliTPCSector *fSectors; //pointer to loaded sectors;
280
281    Int_t fEventN;                      //event number
282    AliTPCClustersArray fClustersArray; //array of TPC clusters
283    Int_t fNtracks;                     //current number of tracks
284    TObjArray *fSeeds;                  //array of track seeds
285    //   TObjArray * fTrackPointPool;        // ! pool with track points
286    const AliTPCParam *fParam;          //pointer to the parameters
287 };
288
289 #endif
290
291