]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtracker.h
EffC++ warnings corrected.
[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
10 class TFile;
11 class TTree;
12 class TParticle;class TParticlePDG;
13
14 class AliTRDgeometry;
15 class AliTRDtrack;
16 class AliTRDtracklet;
17 class AliTRDcluster;
18 class AliTRDseed;
19 class AliESD;
20 class TTreeSRedirector;
21
22 ///////////////////////////////////////////////////////////////////////////////
23 //                                                                           //
24 //  The standard TRD tracker                                                 //  
25 //  Based on Kalman filltering approach                                      //
26 //                                                                           //
27 ///////////////////////////////////////////////////////////////////////////////
28
29 class AliTRDtracker : public AliTracker { 
30
31  public:
32
33   enum { kMaxLayersPerSector   = 1000
34        , kMaxTimeBinIndex      = 216
35        , kMaxClusterPerTimeBin = 2300
36        , kZones                = 5
37        , kTrackingSectors      = 18   };
38
39   AliTRDtracker();
40   AliTRDtracker(const TFile *in);
41   virtual ~AliTRDtracker(); 
42
43   static Int_t  Freq(Int_t n, const Int_t *inlist, Int_t *outlist, Bool_t down);    
44   Int_t         Clusters2Tracks(AliESD* event);
45   Int_t         PropagateBack(AliESD* event);
46   Int_t         RefitInward(AliESD* event);
47
48   // transformation
49   Int_t         LocalToGlobalID(Int_t lid);
50   Int_t         GlobalToLocalID(Int_t gid);
51   Bool_t        Transform(AliTRDcluster * cluster);
52   //
53   Int_t         LoadClusters(TTree *cTree);
54   void          UnloadClusters();
55   AliCluster   *GetCluster(Int_t index) const { if (index >= fNclusters) return NULL; 
56                                                 return (AliCluster*) fClusters->UncheckedAt(index); };
57   Bool_t        GetTrackPoint(Int_t index, AliTrackPoint& p) const;
58   virtual void  CookLabel(AliKalmanTrack *t,Float_t wrong) const;
59   virtual void  UseClusters(const AliKalmanTrack *t, Int_t from=0) const;  
60   
61   void          SetAddTRDseeds() { fAddTRDseeds = kTRUE; }
62   void          SetNoTilt() { fNoTilt = kTRUE; }
63
64   Double_t      GetTiltFactor(const AliTRDcluster* c);
65
66   Int_t         ReadClusters(TObjArray *array, TTree *in) const;
67   Int_t         CookSectorIndex(Int_t gs) const { return kTrackingSectors - 1 - gs; }
68   AliTRDcluster * GetCluster(AliTRDtrack * track, Int_t plane, Int_t timebin, UInt_t &index);
69   Int_t         GetLastPlane(AliTRDtrack * track); //return last updated plane
70   Int_t         FindClusters(Int_t sector, Int_t t0, Int_t t1, AliTRDtrack *track
71                            , Int_t *clusters, AliTRDtracklet& tracklet);
72
73   Int_t         GetTimeBinsPerPlane() const   { return fTimeBinsPerPlane;     }   
74   Double_t      GetMaxChi2() const            { return fgkMaxChi2;            }
75   Float_t       GetLabelFraction() const      { return fgkLabelFraction;      }
76   Float_t       GetMinClustersInTrack() const { return fgkMinClustersInTrack; }
77
78   // x <-> timebin conversions useful in analysis macros
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
87  protected:
88
89   class AliTRDpropagationLayer {
90
91    // *****************  internal class *******************
92    public: 
93
94      AliTRDpropagationLayer(Double_t x, Double_t dx, Double_t rho, 
95                             Double_t x0, Int_t tbIndex, Int_t plane); 
96
97      ~AliTRDpropagationLayer() { if(fTimeBinIndex >= 0) { delete[] fClusters; delete[] fIndex; }}
98
99      void           InsertCluster(AliTRDcluster *c, UInt_t index);
100      operator       Int_t() const {return fN;}
101      AliTRDcluster* operator[](Int_t i) {return fClusters[i];}
102      UInt_t         GetIndex(Int_t i) const {return fIndex[i];} 
103      Double_t       GetX() const { return fX; }
104      Double_t       GetdX() const { return fdX; }
105      Int_t          GetTimeBinIndex() const { return fTimeBinIndex; }     
106      Int_t          GetPlane() const { return fPlane;}
107      Int_t          Find(Float_t y) const; 
108      Int_t          FindNearestCluster(Float_t y, Float_t z, Float_t maxroad, Float_t maxroadz) const;
109      void           SetZmax(Int_t cham, Double_t center, Double_t w)
110                       { fZc[cham] = center;  fZmax[cham] = w; }
111      void           SetZ(Double_t* center, Double_t *w, Double_t *wsensitive);
112      void           SetHoles(Bool_t* holes);
113      void           SetYmax(Double_t w, Double_t wsensitive) { fYmax = w; fYmaxSensitive = wsensitive; }
114      Double_t       GetYmax() const { return fYmax; }
115      Double_t       GetZmax(Int_t c) const { return fZmax[c]; }
116      Double_t       GetZc(Int_t c) const { return fZc[c]; }
117      
118      void           SetHole(Double_t Zmax, Double_t Ymax,
119                             Double_t rho = 1.29e-3, Double_t x0 = 36.66,
120                             Double_t Yc = 0, Double_t Zc = 0);
121                             
122      Bool_t         IsSensitive() const {return (fTimeBinIndex>=0)? kTRUE: kFALSE;}
123                        
124      void           Clear() {for(Int_t i=0; i<fN; i++) fClusters[i] = NULL; fN = 0;}
125      Bool_t         IsHole(Int_t zone) const  { return fIsHole[zone];}              
126
127    private:     
128
129      Int_t           fN;                     // this is fN
130      Int_t           fSec;                   // sector mumber
131      AliTRDcluster **fClusters;              // array of pointers to clusters
132      UInt_t         *fIndex;                 // array of cluster indexes
133      Double_t        fX;                     // x coordinate of the middle plane
134      Double_t        fdX;                    // radial thickness of the time bin
135      Double_t        fRho;                   // default density of the material 
136      Double_t        fX0;                    // default radiation length 
137      Int_t           fTimeBinIndex;          // plane * F(local_tb)  
138      Int_t           fPlane;                 // plane number
139      Double_t        fZc[kZones];            // Z position of the center for 5 active areas
140      Double_t        fZmax[kZones];          // half of active area length in Z
141      Double_t        fZmaxSensitive[kZones]; // sensitive area for detection Z     
142      Bool_t          fIsHole[kZones];        // is hole in given sector       
143      Double_t        fYmax;                  // half of active area length in Y
144      Double_t        fYmaxSensitive;         // half of active area length in Y
145
146      Bool_t          fHole;                  // kTRUE if there is a hole in the layer
147      Double_t        fHoleZc;                // Z of the center of the hole 
148      Double_t        fHoleZmax;              // half of the hole length in Z
149      Double_t        fHoleYc;                // Y of the center of the hole 
150      Double_t        fHoleYmax;              // half of the hole length in Y 
151      Double_t        fHoleRho;               // density of the gas in the hole 
152      Double_t        fHoleX0;                // radiation length of the gas in the hole 
153
154   };
155
156   class AliTRDtrackingSector {
157
158    public:
159
160      AliTRDtrackingSector(AliTRDgeometry* geo, Int_t gs);
161      ~AliTRDtrackingSector() { for(Int_t i=0; i<fN; i++) delete fLayers[i]; }
162
163      Int_t    GetNumberOfLayers() const { return fN; }
164      Int_t    GetNumberOfTimeBins() const;
165      Double_t GetX(Int_t pl) const { return fLayers[pl]->GetX(); }
166      void     MapTimeBinLayers();
167      Int_t    GetLayerNumber(Double_t x) const;
168      Int_t    GetInnerTimeBin() const;
169      Int_t    GetOuterTimeBin() const;
170      Int_t    GetLayerNumber(Int_t tb) const {return fTimeBinIndex[tb];}
171      Int_t    Find(Double_t x) const; 
172      void     InsertLayer(AliTRDpropagationLayer* pl);
173
174      //     AliTRDpropagationLayer* operator[](Int_t i) { return fLayers[i]; }
175      AliTRDpropagationLayer* GetLayer(Int_t i) { return fLayers[i]; }
176      Int_t    CookTimeBinIndex(Int_t plane, Int_t localTB) const;     
177
178    private:
179
180      Int_t                     fN;                              // total number of layers
181      AliTRDgeometry           *fGeom;                           // geometry
182      AliTRDpropagationLayer   *fLayers[kMaxLayersPerSector];    // layers   
183      Int_t                     fTimeBinIndex[kMaxTimeBinIndex]; // time bin index
184      Int_t                     fGeomSector;                     // sector # in AliTRDgeometry
185
186   };
187
188   AliTRDgeometry       *fGeom;                    // Pointer to TRD geometry
189   AliTRDtrackingSector *fTrSec[kTrackingSectors]; // array of tracking sectors;    
190   Int_t                 fNclusters;               // Number of clusters in TRD 
191   TObjArray            *fClusters;                // List of clusters for all sectors
192   Int_t                 fNseeds;                  // Number of track seeds  
193   TObjArray            *fSeeds;                   // List of track seeds
194   Int_t                 fNtracks;                 // Number of reconstructed tracks 
195   TObjArray            *fTracks;                  // List of reconstructed tracks   
196   Int_t                 fTimeBinsPerPlane;        // timebins per plane in track prolongation 
197
198   static const Double_t fgkMaxChi2;               // max increment in track chi2 
199   static const Float_t  fgkMinClustersInTrack;    // min number of clusters in track
200   static const Float_t  fgkLabelFraction;         // min fraction of same label
201   static const Double_t fgkMaxSnp;                // maximal snp for tracking
202   static const Double_t fgkMaxStep;               // maximal step for tracking  
203
204   Bool_t                fAddTRDseeds;             // Something else
205   Bool_t                fNoTilt;                  // No tilt, or what?
206   Bool_t                fHoles[5][18];            // holes
207   
208   Bool_t                AdjustSector(AliTRDtrack *track); 
209  
210  private:
211
212   AliTRDtrack         *RegisterSeed(AliTRDseed *seeds, Double_t *params);
213   void                 MakeSeedsMI(Int_t inner, Int_t outer, AliESD *esd=0);
214
215   Int_t                FollowBackProlongation(AliTRDtrack& t);
216   Int_t                FollowProlongation(AliTRDtrack& t);
217   void                 CookdEdxTimBin(AliTRDtrack& t);  
218   Int_t                PropagateToX(AliTRDtrack& t, Double_t xToGo, Double_t maxStep);
219   Double_t             ExpectedSigmaY2(Double_t r, Double_t tgl, Double_t pt) const;
220   Double_t             ExpectedSigmaZ2(Double_t r, Double_t tgl) const;
221
222   TTreeSRedirector    *fDebugStreamer;            //!debug streamer
223
224   ClassDef(AliTRDtracker,2)                      // TRD tracker
225
226 };
227 #endif