]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/Rec/AliTPCtracker.h
Big commit.
[u/mrichter/AliRoot.git] / TPC / Rec / AliTPCtracker.h
1 #ifndef ALITPCTRACKER_H
2 #define ALITPCTRACKER_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 <TArrayI.h>
17 #include "AliTracker.h"
18 #include "AliTPCreco.h"
19 #include "AliTPCclusterMI.h"
20 #include "AliTPCtrackerSector.h"
21
22
23 class TFile;
24 class AliTPCParam;
25 class AliTPCseed;
26 class AliTPCTrackerPoint;
27 class AliESDEvent;
28 class AliESDtrack;
29 class TTree;
30 class AliESDkink;
31 class TTreeSRedirector;
32 class AliTrackPoint;
33 class AliDCSSensorArray;
34 class AliDCSSensor;
35 class TGraphErrors;
36
37
38 class AliTPCtracker : public AliTracker {
39 public:
40   AliTPCtracker();
41   AliTPCtracker(const AliTPCParam *par); 
42   virtual ~AliTPCtracker();
43   //
44   void SetIteration(Int_t iteration){fIteration = iteration;}
45   virtual Int_t Clusters2TracksHLT(AliESDEvent *const esd, const AliESDEvent *hltEvent);
46   virtual Int_t Clusters2Tracks (AliESDEvent *const esd);
47   virtual Int_t RefitInward (AliESDEvent *esd);
48   virtual Int_t LoadClusters (TTree * const tree);
49   virtual Int_t LoadClusters (const TObjArray * arr); // another input
50   virtual Int_t LoadClusters (const TClonesArray * arr); // another input
51   virtual Int_t PostProcess(AliESDEvent *esd); 
52   Int_t  LoadClusters();
53   void   UnloadClusters();
54   Int_t LoadInnerSectors();
55   Int_t LoadOuterSectors();
56   virtual void FillClusterArray(TObjArray* array) const;
57   void   Transform(AliTPCclusterMI * cluster);
58   void ApplyTailCancellation();
59   void GetTailValue(const Float_t ampfactor,Double_t &ionTailMax,Double_t &ionTailTotal,TGraphErrors **graphRes,Float_t *indexAmpGraphs,AliTPCclusterMI *cl0,AliTPCclusterMI *cl1);
60   //
61   void FillESD(const TObjArray* arr);
62   void DeleteSeeds();
63   void SetDebug(Int_t debug){ fDebug = debug;}
64   void FindKinks(TObjArray * array, AliESDEvent * esd);
65   //
66   void FindCurling(const TObjArray * array, AliESDEvent * esd, Int_t iter);     
67   void FindSplitted(TObjArray * array, AliESDEvent * esd, Int_t iter);       
68   void FindMultiMC(const TObjArray * array, AliESDEvent * esd, Int_t iter);     
69   //
70   void UpdateKinkQualityM(AliTPCseed * seed);
71   void UpdateKinkQualityD(AliTPCseed * seed);
72   Int_t CheckKinkPoint(AliTPCseed*seed, AliTPCseed &mother, AliTPCseed &daughter, const AliESDkink &kink);
73   Int_t RefitKink(AliTPCseed &mother, AliTPCseed &daughter, const AliESDkink &kink);
74    Int_t ReadSeeds(const TFile *in);
75    TObjArray * GetSeeds() const {return fSeeds;}
76    void SetSeeds(TObjArray * seeds) { fSeeds = seeds;}
77    //   
78    AliCluster * GetCluster(Int_t index) const {return (AliCluster*)GetClusterMI(index);}
79    AliTPCclusterMI *GetClusterMI(Int_t index) const;
80    Int_t Clusters2Tracks();
81    virtual void  CookLabel(AliKalmanTrack *tk,Float_t wrong) const; 
82    virtual Int_t   CookLabel(AliTPCseed *const t,Float_t wrong, Int_t first,Int_t last ) const; 
83    
84    void RotateToLocal(AliTPCseed *seed);
85    
86    Int_t FollowProlongation(AliTPCseed& t, Int_t rf=0, Int_t step=1, Bool_t fromSeeds=0);
87    Bool_t GetTrackPoint(Int_t index, AliTrackPoint &p ) const; 
88
89    Int_t FollowBackProlongation(AliTPCseed& t, Int_t rf, Bool_t fromSeeds=0);
90    Int_t FollowToNext(AliTPCseed& t, Int_t nr);
91    Int_t UpdateClusters(AliTPCseed& t,  Int_t nr);
92    Int_t FollowToNextCluster( AliTPCseed& t, Int_t nr);
93
94    Int_t PropagateBack(const TObjArray *const arr);
95    Int_t PropagateBack(AliESDEvent * event);
96    Int_t PropagateBack(AliTPCseed *const pt, Int_t row0, Int_t row1);   
97    Int_t PropagateForward();
98    Int_t PropagateForward2(const TObjArray *const arr);
99
100    void SortTracks(TObjArray * arr, Int_t mode) const;
101   
102    virtual Double_t ErrY2(AliTPCseed* seed, const AliTPCclusterMI * cl = 0);
103    virtual Double_t ErrZ2(AliTPCseed* seed, const AliTPCclusterMI * cl = 0);   
104
105    Double_t F1(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t x3,Double_t y3) const; 
106    Double_t F1old(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t x3,Double_t y3) const; 
107    Double_t F2(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t x3,Double_t y3) const; 
108    Double_t F2old(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t x3,Double_t y3) const; 
109
110    Double_t F3(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t z1,Double_t z2) const; 
111    Double_t F3n(Double_t x1,Double_t y1, Double_t x2,Double_t y2, Double_t z1,Double_t z2, 
112                 Double_t c) const; 
113    Bool_t GetProlongation(Double_t x1, Double_t x2, Double_t x[5], Double_t &y, Double_t &z) const;
114    //
115    void ResetSeedsPool();
116    void MarkSeedFree( TObject* seed );
117    TObject *&NextFreeSeed();
118    //
119  public:
120    void SetUseHLTClusters(Int_t useHLTClusters) {fUseHLTClusters = useHLTClusters;} // set usage from HLT clusters from rec.C options
121
122    inline void SetTPCtrackerSectors(AliTPCtrackerSector *innerSec, AliTPCtrackerSector *outerSec); // set the AliTPCtrackerSector arrays from outside (toy MC)
123
124    Float_t OverlapFactor(AliTPCseed * s1, AliTPCseed * s2, Int_t &sum1, Int_t &sum2);
125    void  SignShared(AliTPCseed * s1, AliTPCseed * s2);
126    void  SignShared(TObjArray * arr);
127
128    void  RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal);
129
130    Int_t AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster);
131
132    Bool_t IsTPCHVDipEvent(AliESDEvent const *esdEvent);
133
134    // public for ToyMC usage
135    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); 
136    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); 
137    void SumTracks(TObjArray *arr1,TObjArray *&arr2);
138    void SignClusters(const TObjArray * arr, Float_t fnumber=3., Float_t fdensity=2.);  
139
140 private:
141   Bool_t IsFindable(AliTPCseed & t);
142   AliTPCtracker(const AliTPCtracker& r);           //dummy copy constructor
143   AliTPCtracker &operator=(const AliTPCtracker& r);//dummy assignment operator
144   void AddCovariance(AliTPCseed * seed);               // add covariance
145   void AddCovarianceAdd(AliTPCseed * seed);               // add covariance
146
147    inline AliTPCtrackerRow &GetRow(Int_t sec, Int_t row);
148    inline Bool_t     IsActive(Int_t sec, Int_t row);
149    inline Double_t  GetXrow(Int_t row) const;
150    inline Double_t  GetMaxY(Int_t row) const;
151    inline Int_t GetRowNumber(Double_t x) const;
152    Int_t GetRowNumber(Double_t x[3]) const;
153    inline Double_t GetPadPitchLength(Double_t x) const;
154    inline Double_t GetPadPitchLength(Int_t row) const;
155
156     void GetShape(AliTPCseed * seed, Int_t row);
157  
158    void ReadSeeds(const AliESDEvent *const event, Int_t direction);  //read seeds from the event
159
160    void MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4], Float_t deltay = -1);
161   
162
163    AliTPCseed *MakeSeed(AliTPCseed *const track, Float_t r0, Float_t r1, Float_t r2); //reseed
164    AliTPCseed *ReSeed(const AliTPCseed *t, Float_t r0, Float_t r1, Float_t r2); //reseed
165    AliTPCseed *ReSeed(AliTPCseed *t, Int_t r0, Bool_t forward); //reseed
166
167
168   
169    AliTPCseed * ReSeed(AliTPCseed *t);
170    //Int_t LoadInnerSectors();
171    //Int_t LoadOuterSectors();
172    void DumpClusters(Int_t iter, TObjArray *trackArray);
173    void UnsignClusters();
174
175    void ParallelTracking(TObjArray *const arr, Int_t rfirst, Int_t rlast);
176    void Tracking(TObjArray * arr);
177    TObjArray * Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy=-1, Int_t dsec=0);
178    TObjArray * Tracking();
179    TObjArray * TrackingSpecial();
180    void PrepareForBackProlongation(const TObjArray *const arr, Float_t fac) const;
181    void PrepareForProlongation(TObjArray *const arr, Float_t fac) const;
182
183    Int_t UpdateTrack(AliTPCseed *t, Int_t accept); //update trackinfo
184
185    void MakeESDBitmaps(AliTPCseed *t, AliESDtrack *esd);
186
187    Int_t PropagateToRowHLT(AliTPCseed *pt, int nrow);
188    void TrackFollowingHLT(TObjArray *const arr);
189    TObjArray * MakeSeedsHLT(const AliESDEvent *hltEvent);
190
191    const Int_t fkNIS;        //number of inner sectors
192    AliTPCtrackerSector *fInnerSec;  //array of inner sectors;
193    const Int_t fkNOS;        //number of outer sectors
194    AliTPCtrackerSector *fOuterSec;  //array of outer sectors;
195
196    Int_t fN;               //number of loaded sectors
197    AliTPCtrackerSector *fSectors; //pointer to loaded sectors;
198    //
199    TTree * fInput;       // input tree with clusters
200    TTree * fOutput;      // output tree with tracks
201    TTree * fSeedTree;    // output tree with seeds - filled in debug mode 1
202    TTree * fTreeDebug;   // output with a debug information about track
203    AliESDEvent * fEvent;      // output with esd tracks
204    const AliESDEvent * fEventHLT;      // input with HLT tracks
205    Int_t    fDebug;      // debug option        
206    Bool_t   fNewIO;      // indicated if we have data using New IO 
207    Int_t fNtracks;                     //current number of tracks
208    TObjArray *fSeeds;                  //array of track seeds
209    Int_t fIteration;                   // indicate iteration - 0 - froward -1 back - 2forward - back->forward
210    //   TObjArray * fTrackPointPool;        // ! pool with track points
211    Double_t fXRow[200];                // radius of the pad row
212    Double_t fYMax[200];                // max y for given pad row
213    Double_t fPadLength[200];                // max y for given pad row
214    const AliTPCParam *fkParam;          //pointer to the parameters
215    TTreeSRedirector *fDebugStreamer;     //!debug streamer
216    Int_t  fUseHLTClusters;              // use HLT clusters instead of offline clusters
217    //
218    TClonesArray* fSeedsPool;            //! pool of seeds
219    TArrayI fFreeSeedsID;                //! array of ID's of freed seeds
220    Int_t fNFreeSeeds;                   //! number of seeds freed in the pool
221    Int_t fLastSeedID;                   //! id of the pool seed on which is returned by the NextFreeSeed method
222    //
223    ClassDef(AliTPCtracker,4) 
224 };
225
226
227 AliTPCtrackerRow & AliTPCtracker::GetRow(Int_t sec, Int_t row)
228 {
229   //
230   return (row>=fInnerSec->GetNRows()) ? fOuterSec[sec][row-fInnerSec->GetNRows()]:fInnerSec[sec][row];
231 }
232
233 Bool_t   AliTPCtracker::IsActive(Int_t sec, Int_t row)
234 {
235   //
236   // check if the given sector row is active 
237   //
238   return (row>=fInnerSec->GetNRows()) ? fOuterSec[sec][row-fInnerSec->GetNRows()].GetN()>0:fInnerSec[sec][row].GetN()>0;
239 }
240
241
242 Double_t  AliTPCtracker::GetXrow(Int_t row) const {
243   //  return (row>=fInnerSec->GetNRows()) ? fOuterSec->GetX(row-fInnerSec->GetNRows()):fInnerSec->GetX(row);
244   return fXRow[row];
245 }
246
247 Double_t  AliTPCtracker::GetMaxY(Int_t row) const {
248   //return (row>=fInnerSec->GetNRows()) ? fOuterSec->GetMaxY(row-fInnerSec->GetNRows()):fInnerSec->GetMaxY(row);
249   return fYMax[row];
250 }
251
252 Int_t AliTPCtracker::GetRowNumber(Double_t x) const
253 {
254   //
255   return (x>133.) ? fOuterSec->GetRowNumber(x)+fInnerSec->GetNRows():fInnerSec->GetRowNumber(x);
256 }
257
258 Double_t  AliTPCtracker::GetPadPitchLength(Double_t x) const
259 {
260   //
261   return (x>133.) ? fOuterSec->GetPadPitchLength(x):fInnerSec->GetPadPitchLength(x);
262   //return fPadLength[row];
263 }
264
265 Double_t  AliTPCtracker::GetPadPitchLength(Int_t row) const
266 {
267   //
268   return fPadLength[row];
269 }
270
271 void  AliTPCtracker::SetTPCtrackerSectors(AliTPCtrackerSector *innerSec, AliTPCtrackerSector *outerSec)
272 {
273   //
274   fInnerSec = innerSec;
275   fOuterSec = outerSec;
276 }
277
278
279
280 #endif
281
282