]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtracker.h
Merging the VirtualMC branch to the main development branch (HEAD)
[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 #include "AliTracker.h" 
8
9 class TFile;
10 class TParticle;
11 class TParticlePDG;
12 class TObjArray;
13
14 class AliTRDgeometry;
15 class AliTRDparameter;
16 class AliTRDtrack;
17 class AliTRDcluster;
18 class AliTRDmcTrack;
19
20 const unsigned kMAX_LAYERS_PER_SECTOR = 1000;  
21 const unsigned kMAX_TIME_BIN_INDEX = 216;  // (30 drift + 6 ampl) * 6 planes  
22 const unsigned kMAX_CLUSTER_PER_TIME_BIN = 3500; 
23 const unsigned kZONES = 5; 
24 const Int_t kTRACKING_SECTORS = 18; 
25
26 class AliTRDtracker : public AliTracker { 
27
28  public:
29
30   AliTRDtracker():AliTracker() {} 
31   AliTRDtracker(const TFile *in);
32   ~AliTRDtracker(); 
33
34   Int_t         Clusters2Tracks(const TFile *in, TFile *out);
35   Int_t         PropagateBack(const TFile *in, TFile *out);
36   AliCluster   *GetCluster(Int_t index) const { return NULL; };
37   virtual void  CookLabel(AliKalmanTrack *t,Float_t wrong) const;
38   virtual void  UseClusters(const AliKalmanTrack *t, Int_t from=0) const;  
39   
40   void          SetEventNumber(Int_t event) { fEvent = event; }
41   void          SetAddTRDseeds() { fAddTRDseeds = kTRUE; }
42
43   void          ReadClusters(TObjArray *array, const Char_t *filename); 
44   Int_t         CookSectorIndex(Int_t gs) { return kTRACKING_SECTORS - 1 - gs; }
45
46
47   Float_t  GetSeedGap()       const {return fSeedGap;}   
48   Int_t    GetMaxGap()        const {return fMaxGap;}   
49   Int_t    GetTimeBinsPerPlane()   const {return fTimeBinsPerPlane;}   
50   Float_t  GetSeedStep()      const {return fSeedStep;}
51   Float_t  GetSeedDepth()     const {return fSeedDepth;}
52   Float_t  GetSkipDepth()     const {return fSkipDepth;}
53   Double_t GetMaxChi2()       const {return fMaxChi2;}
54   Float_t  GetMaxSeedC()      const {return fMaxSeedC;}
55   Float_t  GetMaxSeedTan()    const {return fMaxSeedTan;}
56   Double_t GetSeedErrorSY()   const {return fSeedErrorSY;}
57   Double_t GetSeedErrorSY3()  const {return fSeedErrorSY3;}
58   Double_t GetSeedErrorSZ()   const {return fSeedErrorSZ;}
59   Float_t  GetLabelFraction() const {return fLabelFraction;}
60   Float_t  GetWideRoad()      const {return fWideRoad;}
61
62   Float_t  GetMinClustersInTrack() const {return fMinClustersInTrack;}
63   Float_t  GetMinClustersInSeed()  const {return fMinClustersInSeed;} 
64   Float_t  GetMaxSeedDeltaZ()      const {return fMaxSeedDeltaZ;}
65   Float_t  GetMaxSeedVertexZ()     const {return fMaxSeedVertexZ;}
66
67   // x <-> timebin conversions useful in analysis macros
68   Double_t GetX(Int_t sec, Int_t plane, Int_t local_tb) const;
69   Double_t GetX(Int_t sec, Int_t pl) const { 
70     return fTrSec[sec]->GetLayer(pl)->GetX(); }
71   Int_t GetGlobalTimeBin(Int_t sec, Int_t plane, Int_t local_tb) const {
72     return fTrSec[sec]->CookTimeBinIndex(plane,local_tb); }
73   Double_t GetLayerNumber(Int_t sec, Double_t x) const {
74     return fTrSec[sec]->GetLayerNumber(x); }
75
76  public:
77    class AliTRDpropagationLayer {
78    // *****************  internal class *******************
79    public: 
80      AliTRDpropagationLayer(Double_t x, Double_t dx, Double_t rho, 
81                             Double_t x0, Int_t tb_index); 
82
83      ~AliTRDpropagationLayer() { 
84        if(fTimeBinIndex >= 0) { delete[] fClusters; delete[] fIndex; }
85      }
86      void InsertCluster(AliTRDcluster*, UInt_t);
87      operator       Int_t() const {return fN;}
88      AliTRDcluster* operator[](Int_t i) {return fClusters[i];}
89      UInt_t         GetIndex(Int_t i) const {return fIndex[i];} 
90      Double_t       GetX() const { return fX; }
91      Double_t       GetdX() const { return fdX; }
92      Double_t       GetRho() const { return fRho; }
93      Double_t       GetX0() const { return fX0; }
94      Int_t          GetTimeBinIndex() const { return fTimeBinIndex; }     
95      void           GetPropagationParameters(Double_t y, Double_t z,
96                                 Double_t &dx, Double_t &rho, Double_t &x0, 
97                                 Bool_t &lookForCluster) const;
98      Int_t          Find(Double_t y) const; 
99      void           SetZmax(Int_t cham, Double_t center, Double_t w)
100                       { fZc[cham] = center;  fZmax[cham] = w; }
101      void           SetYmax(Double_t w) { fYmax = w; }
102      Double_t       GetYmax() const { return fYmax; }
103      Double_t       GetZmax(Int_t c) const { return fZmax[c]; }
104      Double_t       GetZc(Int_t c) const { return fZc[c]; }
105      
106      void           SetHole(Double_t Zmax, Double_t Ymax,
107                             Double_t rho = 1.29e-3, Double_t x0 = 36.66,
108                             Double_t Yc = 0, Double_t Zc = 0);
109                             
110      void    Clear() {for(Int_t i=0; i<fN; i++) fClusters[i] = NULL; fN = 0;}
111                    
112    private:     
113
114      Int_t         fN;
115      AliTRDcluster **fClusters; // array of pointers to clusters
116      UInt_t        *fIndex;     // array of cluster indexes
117      Double_t       fX;         // x coordinate of the middle plane
118      Double_t       fdX;        // radial thickness of the time bin
119      Double_t       fRho;       // default density of the material 
120      Double_t       fX0;        // default radiation length 
121      Int_t          fTimeBinIndex;  // plane * F(local_tb)  
122      Double_t       fZc[kZONES];  // Z position of the center for 5 active areas
123      Double_t       fZmax[kZONES]; // half of active area length in Z
124      Double_t       fYmax;        // half of active area length in Y
125
126      Bool_t         fHole;        // kTRUE if there is a hole in the layer
127      Double_t       fHoleZc;      // Z of the center of the hole 
128      Double_t       fHoleZmax;    // half of the hole length in Z
129      Double_t       fHoleYc;      // Y of the center of the hole 
130      Double_t       fHoleYmax;    // half of the hole length in Y 
131      Double_t       fHoleRho;     // density of the gas in the hole 
132      Double_t       fHoleX0;      // radiation length of the gas in the hole 
133    };
134
135    class AliTRDtrackingSector {
136    public:
137      AliTRDtrackingSector(AliTRDgeometry* geo, Int_t gs, AliTRDparameter* par);
138      ~AliTRDtrackingSector() { for(Int_t i=0; i<fN; i++) delete fLayers[i]; }
139      Int_t    GetNumberOfLayers() const { return fN; }
140      Int_t    GetNumberOfTimeBins() const;
141      Double_t GetX(Int_t pl) const { return fLayers[pl]->GetX(); }
142      void     MapTimeBinLayers();
143      Int_t    GetLayerNumber(Double_t x) const;
144      Int_t    GetInnerTimeBin() const;
145      Int_t    GetOuterTimeBin() const;
146      Int_t    GetLayerNumber(Int_t tb) const {return fTimeBinIndex[tb];}
147      Float_t  GetTzeroShift() const { return fTzeroShift; }   
148      Int_t    Find(Double_t x) const; 
149      void     InsertLayer(AliTRDpropagationLayer* pl);
150      //     AliTRDpropagationLayer* operator[](Int_t i) { return fLayers[i]; }
151      AliTRDpropagationLayer* GetLayer(Int_t i) { return fLayers[i]; }
152      Int_t    CookTimeBinIndex(Int_t plane, Int_t local_tb) const;     
153
154    private:
155      Int_t                     fN;      // total number of layers
156      AliTRDgeometry            *fGeom;     
157      AliTRDparameter           *fPar;     
158      AliTRDpropagationLayer    *fLayers[kMAX_LAYERS_PER_SECTOR];     
159      Int_t                     fTimeBinIndex[kMAX_TIME_BIN_INDEX];     
160      Float_t                   fTzeroShift;   // T0 shift in cm
161      Int_t                     fGeomSector;   // sector # in AliTRDgeometry
162    };
163
164  private:
165
166   void          LoadEvent();
167   void          UnloadEvent();
168
169   virtual void  MakeSeeds(Int_t inner, Int_t outer, Int_t turn);
170
171   Int_t         FollowProlongation(AliTRDtrack& t, Int_t rf);
172   Int_t         FollowBackProlongation(AliTRDtrack& t);
173
174   Int_t         PropagateToTPC(AliTRDtrack& t);
175   Int_t         PropagateToOuterPlane(AliTRDtrack& t, Double_t x);
176
177   Int_t         WriteTracks(); 
178   void          ReadClusters(TObjArray *array, const TFile *in = 0);
179
180   void          SetSY2corr(Float_t w)    {fSY2corr = w;}
181   void          SetSZ2corr(Float_t w)    {fSZ2corr = w;}
182   Double_t      ExpectedSigmaY2(Double_t r, Double_t tgl, Double_t pt);
183   Double_t      ExpectedSigmaZ2(Double_t r, Double_t tgl);
184
185
186  protected:
187
188   Int_t              fEvent;            // Event number
189
190   AliTRDgeometry     *fGeom;            // Pointer to TRD geometry
191   AliTRDparameter    *fPar;     
192
193   AliTRDtrackingSector *fTrSec[kTRACKING_SECTORS];       
194                                        // array of tracking sectors;    
195   
196   Int_t            fNclusters;        // Number of clusters in TRD 
197   TObjArray        *fClusters;        // List of clusters for all sectors
198
199   Int_t            fNseeds;           // Number of track seeds  
200   TObjArray        *fSeeds;           // List of track seeds
201    
202   Int_t            fNtracks;          // Number of reconstructed tracks 
203   TObjArray        *fTracks;          // List of reconstructed tracks   
204
205   Float_t          fSY2corr;          // Correction coefficient for
206                                       // cluster SigmaY2 
207
208   Float_t          fSZ2corr;          // Correction coefficient for
209                                       // cluster SigmaZ2 
210
211   static const Float_t  fSeedGap;     // Distance between inner and outer
212                                       // time bin in seeding 
213                                       // (fraction of all time bins) 
214   
215   static const Float_t  fSeedStep;    // Step in iterations
216   static const Float_t  fSeedDepth;   // Fraction of TRD allocated for seeding
217   static const Float_t  fSkipDepth;   // Fraction of TRD which can be skipped
218                                       // in track prolongation             
219   Int_t       fTimeBinsPerPlane;      // number of sensitive timebins per plane
220   Int_t       fMaxGap;                // max gap (in time bins) in the track  
221                                       // in track prolongation             
222
223   static const Double_t fMaxChi2;     // max increment in track chi2 
224         
225   static const Float_t  fMinClustersInTrack; // min number of clusters in track
226                                              // out of total timebins
227
228   static const Float_t  fMinFractionOfFoundClusters; // min found clusters 
229                                                      // out of expected  
230
231   static const Float_t  fMinClustersInSeed;  // min fraction of clusters in seed
232   static const Float_t  fMaxSeedDeltaZ;   // max dZ in MakeSeeds
233   static const Float_t  fMaxSeedDeltaZ12; // max abs(z1-z2) in MakeSeeds
234   static const Float_t  fMaxSeedC;       // max initial curvature in MakeSeeds
235   static const Float_t  fMaxSeedTan;     // max initial Tangens(lambda) in MakeSeeds
236   static const Float_t  fMaxSeedVertexZ; // max vertex Z in MakeSeeds
237   static const Double_t fSeedErrorSY;    // sy parameter in MakeSeeds
238   static const Double_t fSeedErrorSY3;   // sy3 parameter in MakeSeeds
239   static const Double_t fSeedErrorSZ;    // sz parameter in MakeSeeds
240   static const Float_t  fLabelFraction;  // min fraction of same label
241   static const Float_t  fWideRoad;       // max road width in FindProlongation
242
243   Bool_t                fVocal;   
244   Bool_t                fAddTRDseeds;
245  
246   ClassDef(AliTRDtracker,1)           // manager base class  
247
248 };
249
250 #endif