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