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