]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtracker.h
Introduction of AliTRDtransform. Cluster coordinates are now always in tracking c.s.
[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 #include "AliTracker.h" 
16 #include "TObjArray.h" 
17
18 class TFile;
19 class TTree;
20 class TH1D;
21 class TH2D;
22 class TParticle;
23 class TParticlePDG;
24
25 class AliTRDgeometry;
26 class AliTRDtrack;
27 class AliTRDtracklet;
28 class AliTRDcluster;
29 class AliTRDseed;
30 class AliESDEvent;
31 class TTreeSRedirector;
32
33 ///////////////////////////////////////////////////////////////////////////////
34 //                                                                           //
35 //  The standard TRD tracker                                                 //  
36 //  Based on Kalman filltering approach                                      //
37 //                                                                           //
38 ///////////////////////////////////////////////////////////////////////////////
39
40 class AliTRDtracker : public AliTracker { 
41
42   // Histograms
43   TH1D *fHBackfit;  // Histogram for back propagation
44   TH1D *fHClSearch; // Cluster search
45   TH1D *fHRefit;
46   
47   TH1D *fHX;
48   TH1D *fHNCl;
49   TH1D *fHNClTrack;
50   TH1D *fHFindCl[4];
51   TH1D *fHMinYPos;
52   TH1D *fHMinYNeg; 
53   TH1D *fHMinZ;
54
55   TH2D *fHMinD;
56   TH1D *fHDeltaX;
57   TH1D *fHXCl;
58
59   void InitLogHists();
60   void SaveLogHists();
61
62  public:
63
64   enum { kMaxLayersPerSector   = 1000
65        , kMaxTimeBinIndex      = 216
66        , kMaxClusterPerTimeBin = 2300
67        , kZones                = 5
68        , kTrackingSectors      = 18   };
69   
70   AliTRDtracker();
71   AliTRDtracker(const AliTRDtracker &t);
72   AliTRDtracker(const TFile *in);
73   virtual         ~AliTRDtracker(); 
74   AliTRDtracker   &operator=(const AliTRDtracker &/*t*/) { return *this;          } 
75   
76   void             SetAddTRDseeds()               { fAddTRDseeds = kTRUE;         }
77   void             SetNoTilt()                    { fNoTilt      = kTRUE;         }
78   
79   Int_t            GetTimeBinsPerPlane() const    { return fTimeBinsPerPlane;     }   
80   Double_t         GetMaxChi2() const             { return fgkMaxChi2;            }
81   Float_t          GetLabelFraction() const       { return fgkLabelFraction;      }
82   Float_t          GetMinClustersInTrack() const  { return fgkMinClustersInTrack; }
83   Int_t            GetLastPlane(AliTRDtrack *track);
84   Double_t         GetTiltFactor(const AliTRDcluster *c);
85   Bool_t           GetTrackPoint(Int_t index, AliTrackPoint& p) const;
86   Double_t         GetX(Int_t sec, Int_t plane, Int_t localTB) const;
87   Double_t         GetX(Int_t sec, Int_t pl) const
88                                                   { return fTrSec[sec]->GetLayer(pl)->GetX();            }
89   Int_t            GetGlobalTimeBin(Int_t sec, Int_t plane, Int_t localTB) const 
90                                                   { return fTrSec[sec]->CookTimeBinIndex(plane,localTB); }
91   Double_t         GetLayerNumber(Int_t sec, Double_t x) const 
92                                                   { return fTrSec[sec]->GetLayerNumber(x);               }
93   AliCluster      *GetCluster(Int_t index) const  { if (index >= fNclusters) return NULL; 
94                                                     return (AliCluster *) fClusters->UncheckedAt(index); }
95   
96   static Int_t     Freq(Int_t n, const Int_t *inlist, Int_t *outlist, Bool_t down);    
97   Int_t            Clusters2Tracks(AliESDEvent *event);
98   Int_t            PropagateBack(AliESDEvent *event);
99   Int_t            RefitInward(AliESDEvent *event);
100   
101   virtual void     CookLabel(AliKalmanTrack *t, Float_t wrong) const;
102   
103   Int_t            LocalToGlobalID(Int_t lid);
104   Int_t            GlobalToLocalID(Int_t gid);
105   
106   Int_t            LoadClusters(TTree *cTree);
107   void             UnloadClusters();
108   virtual void     UseClusters(const AliKalmanTrack *t, Int_t from = 0) const;  
109   Int_t            ReadClusters(TObjArray *array, TTree *in) const;
110   AliTRDcluster   *GetCluster(AliTRDtrack *track, Int_t plane, Int_t timebin, UInt_t &index);
111   Int_t            FindClusters(Int_t sector, Int_t t0, Int_t t1, AliTRDtrack *track
112                               , Int_t *clusters, AliTRDtracklet &tracklet);
113   
114  protected:
115   
116   class AliTRDpropagationLayer {
117     
118   public: 
119     
120     AliTRDpropagationLayer(Double_t x, Double_t dx, Double_t rho
121                          , Double_t x0, Int_t tbIndex, Int_t plane); 
122     AliTRDpropagationLayer(const AliTRDpropagationLayer &/*p*/);
123     ~AliTRDpropagationLayer() {  if (fTimeBinIndex >= 0) { 
124                                    delete[] fClusters; 
125                                    delete[] fIndex; 
126                                  } 
127                                }
128     AliTRDpropagationLayer &operator=(const AliTRDpropagationLayer &/*p*/) 
129                                                               { return *this; }
130
131     operator Int_t() const                                    { return fN;    }
132     AliTRDcluster  *operator[](Int_t i) {return fClusters[i];}
133     
134     void     SetZmax(Int_t cham, Double_t center, Double_t w) { fZc[cham]      = center; 
135                                                                 fZmax[cham]    = w;           }
136     void     SetYmax(Double_t w, Double_t wsensitive)         { fYmax          = w;
137                                                                 fYmaxSensitive = wsensitive;  }
138
139     void     SetZ(Double_t* center, Double_t *w, Double_t *wsensitive);
140     void     SetHoles(Bool_t* holes);
141     void     SetHole(Double_t Zmax, Double_t Ymax
142                    , Double_t rho = 1.29e-3, Double_t x0 = 36.66
143                    , Double_t Yc = 0.0, Double_t Zc = 0.0);
144     
145     Double_t GetYmax() const           { return fYmax;                  }
146     Double_t GetZmax(Int_t c) const    { return fZmax[c];               }
147     Double_t GetZc(Int_t c) const      { return fZc[c];                 }
148     UInt_t   GetIndex(Int_t i) const   { return fIndex[i];              }  
149     Double_t GetX() const              { return fX;                     }
150     Double_t GetdX() const             { return fdX;                    }
151     Int_t    GetTimeBinIndex() const   { return fTimeBinIndex;          }     
152     Int_t    GetPlane() const          { return fPlane;                 }
153     Bool_t   IsHole(Int_t zone) const  { return fIsHole[zone];          }              
154     Bool_t   IsSensitive() const       { return (fTimeBinIndex >= 0)? kTRUE : kFALSE;} 
155     
156     void     Clear() { 
157       for (Int_t i = 0; i < fN; i++) fClusters[i] = NULL;
158       fN = 0;
159     }
160     
161     void     InsertCluster(AliTRDcluster *c, UInt_t index);
162     Int_t    Find(Float_t y) const; 
163     Int_t    FindNearestCluster(Float_t y, Float_t z, Float_t maxroad, Float_t maxroadz) const;
164  
165     void     SetX(Double_t x)          { fX = x; }
166
167     
168   private:     
169     
170     Int_t                     fN;                            // This is fN
171     Int_t                     fSec;                          // Sector mumber
172     AliTRDcluster           **fClusters;                     // Array of pointers to clusters
173     UInt_t                   *fIndex;                        // Array of cluster indexes
174     Double_t                  fX;                            // X coordinate of the middle plane
175     Double_t                  fdX;                           // Radial thickness of the time bin
176     Double_t                  fRho;                          // Default density of the material 
177     Double_t                  fX0;                           // Default radiation length 
178     Int_t                     fTimeBinIndex;                 // Plane * F(local_tb)  
179     Int_t                     fPlane;                        // Plane number
180     Double_t                  fZc[kZones];                   // Z position of the center for 5 active areas
181     Double_t                  fZmax[kZones];                 // Half of active area length in Z
182     Double_t                  fZmaxSensitive[kZones];        // Sensitive area for detection Z     
183     Bool_t                    fIsHole[kZones];               // Is hole in given sector       
184     Double_t                  fYmax;                         // Half of active area length in Y
185     Double_t                  fYmaxSensitive;                // Half of active area length in Y
186     
187     Bool_t                    fHole;                         // kTRUE if there is a hole in the layer
188     Double_t                  fHoleZc;                       // Z of the center of the hole 
189     Double_t                  fHoleZmax;                     // Half of the hole length in Z
190     Double_t                  fHoleYc;                       // Y of the center of the hole 
191     Double_t                  fHoleYmax;                     // Half of the hole length in Y 
192     Double_t                  fHoleRho;                      // Density of the gas in the hole 
193     Double_t                  fHoleX0;                       // Radiation length of the gas in the hole 
194     
195   };
196   
197   class AliTRDtrackingSector {
198     
199    public:
200     
201     AliTRDtrackingSector(AliTRDgeometry* geo, Int_t gs);
202     AliTRDtrackingSector(const AliTRDtrackingSector &/*t*/);
203     ~AliTRDtrackingSector() { 
204       for (Int_t i = 0; i < fN; i++) delete fLayers[i];           
205     }
206     
207     AliTRDtrackingSector &operator=(const AliTRDtrackingSector &/*t*/){ return *this;}
208     
209     Int_t    GetNumberOfLayers() const             { return fN;}
210     Int_t    GetNumberOfTimeBins() const;
211     Int_t    GetLayerNumber(Double_t x) const;
212     Int_t    GetInnerTimeBin() const;
213     Int_t    GetOuterTimeBin() const;
214     Int_t    GetLayerNumber(Int_t tb) const        { return fTimeBinIndex[tb];}
215     Double_t GetX(Int_t pl) const                  { return fLayers[pl]->GetX();}
216     AliTRDpropagationLayer* GetLayer(Int_t i)      { return fLayers[i];}
217     
218     void     MapTimeBinLayers();
219     Int_t    Find(Double_t x) const; 
220     void     InsertLayer(AliTRDpropagationLayer *pl);
221     Int_t    CookTimeBinIndex(Int_t plane, Int_t localTB) const;     
222     
223   private:
224     
225     Int_t                   fN;                              // Total number of layers
226     AliTRDgeometry         *fGeom;                           // Geometry
227     AliTRDpropagationLayer *fLayers[kMaxLayersPerSector];    // Layers   
228     Int_t                   fTimeBinIndex[kMaxTimeBinIndex]; // Time bin index
229     Int_t                   fGeomSector;                     // Sector# in AliTRDgeometry
230     
231   };
232   
233   AliTRDgeometry          *fGeom;                          // Pointer to TRD geometry
234   AliTRDtrackingSector    *fTrSec[kTrackingSectors];       // Array of tracking sectors;    
235   Int_t                    fNclusters;                     // Number of clusters in TRD 
236   TObjArray               *fClusters;                      // List of clusters for all sectors
237   Int_t                    fNseeds;                        // Number of track seeds  
238   TObjArray               *fSeeds;                         // List of track seeds
239   Int_t                    fNtracks;                       // Number of reconstructed tracks 
240   TObjArray               *fTracks;                        // List of reconstructed tracks   
241   Int_t                    fTimeBinsPerPlane;              // Timebins per plane in track prolongation 
242   
243   static const Double_t    fgkMaxChi2;                     // Max increment in track chi2 
244   static const Float_t     fgkMinClustersInTrack;          // Min number of clusters in track
245   static const Float_t     fgkLabelFraction;               // Min fraction of same label
246   static const Double_t    fgkMaxSnp;                      // Maximal snp for tracking
247   static const Double_t    fgkMaxStep;                     // Maximal step for tracking  
248   
249   Bool_t                   fAddTRDseeds;                   // Something else
250   Bool_t                   fNoTilt;                        // No tilt, or what?
251   Bool_t                   fHoles[5][18];                  // Holes
252   
253   Bool_t   AdjustSector(AliTRDtrack *track); 
254   
255  private:
256   
257   AliTRDtrack *RegisterSeed(AliTRDseed *seeds, Double_t *params);
258   void     MakeSeedsMI(Int_t inner, Int_t outer, AliESDEvent *esd = 0);
259   
260   Int_t    FollowBackProlongation(AliTRDtrack &t);
261   Int_t    FollowProlongation(AliTRDtrack &t);
262   Int_t    PropagateToX(AliTRDtrack &t, Double_t xToGo, Double_t maxStep);
263   Double_t ExpectedSigmaY2(Double_t r, Double_t tgl, Double_t pt) const;
264   Double_t ExpectedSigmaZ2(Double_t r, Double_t tgl) const;
265   
266   TTreeSRedirector        *fDebugStreamer;                 //!Debug streamer
267   
268   ClassDef(AliTRDtracker,2)                                        // TRD tracker
269     
270  };
271 #endif