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