small correction for error calculation
[u/mrichter/AliRoot.git] / TRD / AliTRDtracker.h
1 #ifndef ALITRDTRACKER_H
2 #define ALITRDTRACKER_H   
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */ 
6
7 /* $Id$ */
8
9 ////////////////////////////////////////////////////////////////////////////
10 //                                                                        //
11 //  The TRD tracker                                                       //
12 //                                                                        //
13 ////////////////////////////////////////////////////////////////////////////
14
15 #ifndef ROOT_TObjArray
16 #include "TObjArray.h" 
17 #endif
18
19 #ifndef ALITRACKER_H
20 #include "AliTracker.h" 
21 #endif
22
23 #ifndef ALITRDPROPAGATIONLAYER_H
24 #include "AliTRDpropagationLayer.h"
25 #endif
26
27 class TFile;
28 class TTree;
29 class TH1D;
30 class TH2D;
31 class TParticle;
32 class TParticlePDG;
33 class TTreeSRedirector;
34
35 class AliTRDgeometry;
36 class AliTRDtrack;
37 class AliTRDtracklet;
38 class AliTRDcluster;
39 class AliTRDseed;
40 class AliESDEvent;
41 class AliTRDpropagationLayer;
42 class AliTRDReconstructor;
43
44 ///////////////////////////////////////////////////////////////////////////////
45 //                                                                           //
46 //  The standard TRD tracker                                                 //  
47 //  Based on Kalman filltering approach                                      //
48 //                                                                           //
49 ///////////////////////////////////////////////////////////////////////////////
50
51 class AliTRDtracker : public AliTracker { 
52
53  public:
54
55   void InitLogHists();
56   void SaveLogHists();
57
58   enum { kMaxLayersPerSector   = 1000
59        , kMaxTimeBinIndex      = 216
60        , kTrackingSectors      = 18   };
61   
62   AliTRDtracker(AliTRDReconstructor *rec = 0x0);
63   AliTRDtracker(const AliTRDtracker &t);
64   AliTRDtracker(const TFile *in, AliTRDReconstructor *rec = 0x0);
65   virtual         ~AliTRDtracker(); 
66   AliTRDtracker   &operator=(const AliTRDtracker &/*t*/) { return *this;          } 
67   
68   void             SetReconstructor(AliTRDReconstructor *rec) {fReconstructor = rec;}
69   void             SetAddTRDseeds()               { fAddTRDseeds = kTRUE;         }
70   void             SetNoTilt()                    { fNoTilt      = kTRUE;         }
71   
72   Int_t            GetTimeBinsPerPlane() const    { return fTimeBinsPerPlane;     }   
73   Double_t         GetMaxChi2() const             { return fgkMaxChi2;            }
74   Float_t          GetLabelFraction() const       { return fgkLabelFraction;      }
75   Float_t          GetMinClustersInTrack() const  { return fgkMinClustersInTrack; }
76   Int_t            GetLastPlane(AliTRDtrack *track);
77   Double_t         GetTiltFactor(const AliTRDcluster *c);
78   virtual Bool_t   GetTrackPoint(Int_t index, AliTrackPoint& p) const;
79   Double_t         GetX(Int_t sec, Int_t plane, Int_t localTB) const;
80   Double_t         GetX(Int_t sec, Int_t pl) const
81                                                   { return fTrSec[sec]->GetLayer(pl)->GetX();            }
82   Int_t            GetGlobalTimeBin(Int_t sec, Int_t plane, Int_t localTB) const 
83                                                   { return fTrSec[sec]->CookTimeBinIndex(plane,localTB); }
84   Double_t         GetLayerNumber(Int_t sec, Double_t x) const 
85                                                   { return fTrSec[sec]->GetLayerNumber(x);               }
86   AliCluster      *GetCluster(Int_t index) const  { if (index >= fNclusters) return NULL; 
87                                                     return (AliCluster *) fClusters->UncheckedAt(index); }
88   
89   static Int_t     Freq(Int_t n, const Int_t *inlist, Int_t *outlist, Bool_t down);    
90   Int_t            Clusters2Tracks(AliESDEvent *event);
91   Int_t            PropagateBack(AliESDEvent *event);
92   Int_t            RefitInward(AliESDEvent *event);
93   
94   virtual void     CookLabel(AliKalmanTrack *t, Float_t wrong) const;
95   
96   Int_t            LocalToGlobalID(Int_t lid);
97   Int_t            GlobalToLocalID(Int_t gid);
98   
99   Int_t            LoadClusters(TTree *cTree);
100   void             UnloadClusters();
101   virtual void     UseClusters(const AliKalmanTrack *t, Int_t from = 0) const;  
102   Int_t            ReadClusters(TObjArray *array, TTree *in) const;
103   AliTRDcluster   *GetCluster(AliTRDtrack *track, Int_t plane, Int_t timebin, UInt_t &index);
104   Int_t            FindClusters(Int_t sector, Int_t t0, Int_t t1, AliTRDtrack *track
105                               , Int_t *clusters, AliTRDtracklet &tracklet);  
106   
107  protected:
108
109   Bool_t           AdjustSector(AliTRDtrack *track); 
110   AliTRDtrack     *RegisterSeed(AliTRDseed *seeds, Double_t *params);
111   Int_t            FollowBackProlongation(AliTRDtrack &t);
112   //void             MakeSeedsMI(Int_t inner, Int_t outer, AliESDEvent *esd = 0);
113   
114  protected:
115
116   //__________________________________________________________________________________________________
117   class AliTRDtrackingSector {
118     
119    public:
120     
121     AliTRDtrackingSector(AliTRDgeometry* geo, Int_t gs);
122     AliTRDtrackingSector(const AliTRDtrackingSector &/*t*/);
123     ~AliTRDtrackingSector();
124     
125     AliTRDtrackingSector &operator=(const AliTRDtrackingSector &/*t*/) { return *this; }
126     
127     Int_t    GetNumberOfLayers() const             { return fN; }
128     Int_t    GetNumberOfTimeBins() const;
129     Int_t    GetLayerNumber(Double_t x) const;
130     Int_t    GetInnerTimeBin() const;
131     Int_t    GetOuterTimeBin() const;
132     Int_t    GetLayerNumber(Int_t tb) const        { return fTimeBinIndex[tb];   }
133     Double_t GetX(Int_t pl) const                  { return fLayers[pl]->GetX(); }
134     AliTRDpropagationLayer* GetLayer(Int_t i)      { return fLayers[i];          }
135     Int_t    GetSector() const {return fGeomSector;}    
136     
137     void     MapTimeBinLayers();
138     Int_t    Find(Double_t x) const; 
139     void     InsertLayer(AliTRDpropagationLayer *pl);
140     Int_t    CookTimeBinIndex(Int_t plane, Int_t localTB) const;     
141     
142    private:
143     
144     Int_t                   fN;                              // Total number of layers
145     AliTRDgeometry         *fGeom;                           // Geometry
146     AliTRDpropagationLayer *fLayers[kMaxLayersPerSector];    // Layers   
147     Int_t                   fTimeBinIndex[kMaxTimeBinIndex]; // Time bin index
148     Int_t                   fGeomSector;                     // Sector# in AliTRDgeometry
149     
150   };
151   
152  protected:
153   AliTRDReconstructor     *fReconstructor;
154   AliTRDgeometry          *fGeom;                          // Pointer to TRD geometry
155   AliTRDtrackingSector    *fTrSec[kTrackingSectors];       // Array of tracking sectors;    
156   Int_t                    fNclusters;                     // Number of clusters in TRD 
157   TObjArray               *fClusters;                      // List of clusters for all sectors
158   Int_t                    fNseeds;                        // Number of track seeds  
159   TObjArray               *fSeeds;                         // List of track seeds
160   Int_t                    fNtracks;                       // Number of reconstructed tracks 
161   TObjArray               *fTracks;                        // List of reconstructed tracks   
162   Int_t                    fTimeBinsPerPlane;              // Timebins per plane in track prolongation 
163   
164   static const Double_t    fgkMaxChi2;                     // Max increment in track chi2 
165   static const Float_t     fgkMinClustersInTrack;          // Min number of clusters in track
166   static const Float_t     fgkLabelFraction;               // Min fraction of same label
167   static const Double_t    fgkMaxSnp;                      // Maximal snp for tracking
168   static const Double_t    fgkMaxStep;                     // Maximal step for tracking  
169   
170   Bool_t                   fAddTRDseeds;                   // Something else
171   Bool_t                   fNoTilt;                        // No tilt, or what?
172
173   // Histograms
174   TH1D                    *fHBackfit;                      // QA histogram
175   TH1D                    *fHClSearch;                     // QA histogram
176   TH1D                    *fHRefit;                        // QA histogram
177   TH1D                    *fHX;                            // QA histogram
178   TH1D                    *fHNCl;                          // QA histogram
179   TH1D                    *fHNClTrack;                     // QA histogram
180   TH1D                    *fHFindCl[4];                    // QA histogram
181   TH1D                    *fHMinYPos;                      // QA histogram
182   TH1D                    *fHMinYNeg;                      // QA histogram
183   TH1D                    *fHMinZ;                         // QA histogram
184   TH2D                    *fHMinD;                         // QA histogram
185   TH1D                    *fHDeltaX;                       // QA histogram
186   TH1D                    *fHXCl;                          // QA histogram
187
188  protected:
189
190   Int_t            FollowProlongation(AliTRDtrack &t);
191   Int_t            PropagateToX(AliTRDtrack &t, Double_t xToGo, Double_t maxStep);
192   Double_t         ExpectedSigmaY2(Double_t r, Double_t tgl, Double_t pt) const;
193   Double_t         ExpectedSigmaZ2(Double_t r, Double_t tgl) const;
194
195  
196   TTreeSRedirector        *fDebugStreamer;                 //!Debug streamer
197   
198   ClassDef(AliTRDtracker, 4)                               // TRD tracker
199     
200 };
201
202
203 #endif