]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtracker.h
Applying TGeoManager transformation. Coding convention (M.Ivanov)
[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 AliESD;
19 class TTreeSRedirector;
20
21 const unsigned kMaxLayersPerSector = 1000;  
22 const unsigned kMaxTimeBinIndex = 216;  // (30 drift + 6 ampl) * 6 planes  
23 const unsigned kMaxClusterPerTimeBin = 7000; 
24 const unsigned kZones = 5; 
25 const Int_t    kTrackingSectors = 18; 
26
27 class AliTRDseed : public TObject{
28   friend class AliTRDtracker;
29  public:
30   AliTRDseed();                 // default constructor
31   ~AliTRDseed(){};              // default constructor
32   static  void EvaluateUni(Int_t nvectors, Double_t *data, Double_t &mean, Double_t &sigma, Int_t hh);
33   static  Float_t   FitRiemanTilt(AliTRDseed * seed, Bool_t error);
34   void           UseClusters(); // use clusters
35   void           Update();      // update information - without tilt correction
36   void           CookLabels();  // cook label
37   void           UpdateUsed();
38   void           Reset();       // reset seed
39   Bool_t         IsOK() const {return fN2>8;}
40  private:
41   Float_t        fTilt;         // tilting angle
42   Float_t        fPadLength;    // pad length
43   Float_t        fX0;           // x0 position
44   Float_t        fX[25];        // !x position
45   Float_t        fY[25];        // !y position
46   Float_t        fZ[25];        // !z position
47   Int_t          fIndexes[25];  // !indexes
48   AliTRDcluster *fClusters[25]; // !clusters
49   Bool_t         fUsable[25];   // !indication  - usable cluster
50   Float_t        fYref[2];      // reference y
51   Float_t        fZref[2];      // reference z
52   Float_t        fYfit[2];      // y fit position +derivation
53   Float_t        fYfitR[2];      // y fit position +derivation
54   Float_t        fZfit[2];      // z fit position
55   Float_t        fZfitR[2];      // z fit position
56   Float_t        fSigmaY;        // "robust" sigma in Y - constant fit
57   Float_t        fSigmaY2;       // "robust" sigma in Y - line fit
58   Float_t        fMeanz;         // mean vaue of z
59   Float_t        fZProb;         // max probbable z
60   Int_t          fLabels[2];    // labels
61   Int_t          fN;            // number of associated clusters
62   Int_t          fN2;            // number of not crossed
63   Int_t          fNUsed;        // number of used clusters
64   Int_t          fFreq;         // freq
65   Int_t          fNChange;      // change z counter
66   Float_t        fMPads;        // mean number of pads per cluster
67   // global
68   //
69   Float_t        fC;            // curvature
70   Float_t        fCC;           // curvature with constrain
71   Float_t        fChi2;         // global chi2
72   Float_t        fChi2Z;        // global chi2
73  private:
74   ClassDef(AliTRDseed,1)  
75 };
76
77
78 class AliTRDtracker : public AliTracker { 
79
80  public:
81
82
83   AliTRDtracker();
84   AliTRDtracker(const TFile *in);
85   virtual ~AliTRDtracker(); 
86   static        Int_t  Freq(Int_t n, const Int_t *inlist, Int_t *outlist, Bool_t down);    
87   Int_t         Clusters2Tracks(AliESD* event);
88   Int_t         PropagateBack(AliESD* event);
89   Int_t         RefitInward(AliESD* event);
90   // transformation
91   Int_t         LocalToGlobalID(Int_t lid);
92   Int_t         GlobalToLocalID(Int_t gid);
93   Bool_t        Transform(AliTRDcluster * cluster);
94   //
95   Int_t         LoadClusters(TTree *cTree);
96   void          UnloadClusters();
97   AliCluster   *GetCluster(Int_t index) const { if (index >= fNclusters) return NULL; 
98                                                 return (AliCluster*) fClusters->UncheckedAt(index); };
99   Bool_t        GetTrackPoint(Int_t index, AliTrackPoint& p) const;
100   virtual void  CookLabel(AliKalmanTrack *t,Float_t wrong) const;
101   virtual void  UseClusters(const AliKalmanTrack *t, Int_t from=0) const;  
102   
103   void          SetAddTRDseeds() { fAddTRDseeds = kTRUE; }
104   void          SetNoTilt() { fNoTilt = kTRUE; }
105
106   Double_t      GetTiltFactor(const AliTRDcluster* c);
107
108   Int_t         ReadClusters(TObjArray *array, TTree *in) const;
109   Int_t         CookSectorIndex(Int_t gs) const { return kTrackingSectors - 1 - gs; }
110   AliTRDcluster * GetCluster(AliTRDtrack * track, Int_t plane, Int_t timebin, UInt_t &index);
111   Int_t         GetLastPlane(AliTRDtrack * track); //return last updated plane
112   Int_t FindClusters(Int_t sector, Int_t t0, Int_t t1, AliTRDtrack * track, Int_t *clusters, AliTRDtracklet& tracklet);
113
114   Int_t    GetTimeBinsPerPlane()   const {return fTimeBinsPerPlane;}   
115   Double_t GetMaxChi2()       const {return fgkMaxChi2;}
116   Float_t  GetLabelFraction() const {return fgkLabelFraction;}
117
118   Float_t  GetMinClustersInTrack() const {return fgkMinClustersInTrack;}
119
120   // x <-> timebin conversions useful in analysis macros
121   Double_t GetX(Int_t sec, Int_t plane, Int_t localTB) const;
122   Double_t GetX(Int_t sec, Int_t pl) const { 
123     return fTrSec[sec]->GetLayer(pl)->GetX(); }
124   Int_t GetGlobalTimeBin(Int_t sec, Int_t plane, Int_t localTB) const {
125     return fTrSec[sec]->CookTimeBinIndex(plane,localTB); }
126   Double_t GetLayerNumber(Int_t sec, Double_t x) const {
127     return fTrSec[sec]->GetLayerNumber(x); }
128
129   class AliTRDpropagationLayer {
130    // *****************  internal class *******************
131    public: 
132      AliTRDpropagationLayer(Double_t x, Double_t dx, Double_t rho, 
133                             Double_t x0, Int_t tbIndex, Int_t plane); 
134
135      ~AliTRDpropagationLayer() { 
136        if(fTimeBinIndex >= 0) { delete[] fClusters; delete[] fIndex; }
137      }
138      void InsertCluster(AliTRDcluster *c, UInt_t index);
139      operator       Int_t() const {return fN;}
140      AliTRDcluster* operator[](Int_t i) {return fClusters[i];}
141      UInt_t         GetIndex(Int_t i) const {return fIndex[i];} 
142      Double_t       GetX() const { return fX; }
143      Double_t       GetdX() const { return fdX; }
144      Int_t          GetTimeBinIndex() const { return fTimeBinIndex; }     
145      Int_t          GetPlane() const { return fPlane;}
146      Int_t          Find(Float_t y) const; 
147      Int_t          FindNearestCluster(Float_t y, Float_t z, Float_t maxroad, Float_t maxroadz) const;
148      void           SetZmax(Int_t cham, Double_t center, Double_t w)
149                       { fZc[cham] = center;  fZmax[cham] = w; }
150      void           SetZ(Double_t* center, Double_t *w, Double_t *wsensitive);
151      void           SetHoles(Bool_t* holes);
152      void           SetYmax(Double_t w, Double_t wsensitive) { fYmax = w; fYmaxSensitive = wsensitive; }
153      Double_t       GetYmax() const { return fYmax; }
154      Double_t       GetZmax(Int_t c) const { return fZmax[c]; }
155      Double_t       GetZc(Int_t c) const { return fZc[c]; }
156      
157      void           SetHole(Double_t Zmax, Double_t Ymax,
158                             Double_t rho = 1.29e-3, Double_t x0 = 36.66,
159                             Double_t Yc = 0, Double_t Zc = 0);
160                             
161      Bool_t         IsSensitive() const {return (fTimeBinIndex>=0)? kTRUE: kFALSE;}
162                        
163      void    Clear() {for(Int_t i=0; i<fN; i++) fClusters[i] = NULL; fN = 0;}
164      Bool_t  IsHole(Int_t zone) const  { return fIsHole[zone];}              
165    private:     
166
167      Int_t         fN;          // this is fN
168      Int_t         fSec;        // sector mumber
169      AliTRDcluster **fClusters; // array of pointers to clusters
170      UInt_t        *fIndex;     // array of cluster indexes
171      Double_t       fX;         // x coordinate of the middle plane
172      Double_t       fdX;        // radial thickness of the time bin
173      Double_t       fRho;       // default density of the material 
174      Double_t       fX0;        // default radiation length 
175      Int_t          fTimeBinIndex;  // plane * F(local_tb)  
176      Int_t          fPlane;         // plane number
177      Double_t       fZc[kZones];  // Z position of the center for 5 active areas
178      Double_t       fZmax[kZones]; // half of active area length in Z
179      Double_t       fZmaxSensitive[kZones]; //sensitive area for detection Z     
180      Bool_t         fIsHole[kZones]; //is hole in given sector       
181      Double_t       fYmax;        // half of active area length in Y
182      Double_t       fYmaxSensitive;        // half of active area length in Y
183
184      Bool_t         fHole;        // kTRUE if there is a hole in the layer
185      Double_t       fHoleZc;      // Z of the center of the hole 
186      Double_t       fHoleZmax;    // half of the hole length in Z
187      Double_t       fHoleYc;      // Y of the center of the hole 
188      Double_t       fHoleYmax;    // half of the hole length in Y 
189      Double_t       fHoleRho;     // density of the gas in the hole 
190      Double_t       fHoleX0;      // radiation length of the gas in the hole 
191    };
192
193    class AliTRDtrackingSector {
194    public:
195      AliTRDtrackingSector(AliTRDgeometry* geo, Int_t gs);
196      ~AliTRDtrackingSector() { for(Int_t i=0; i<fN; i++) delete fLayers[i]; }
197      Int_t    GetNumberOfLayers() const { return fN; }
198      Int_t    GetNumberOfTimeBins() const;
199      Double_t GetX(Int_t pl) const { return fLayers[pl]->GetX(); }
200      void     MapTimeBinLayers();
201      Int_t    GetLayerNumber(Double_t x) const;
202      Int_t    GetInnerTimeBin() const;
203      Int_t    GetOuterTimeBin() const;
204      Int_t    GetLayerNumber(Int_t tb) const {return fTimeBinIndex[tb];}
205      Int_t    Find(Double_t x) const; 
206      void     InsertLayer(AliTRDpropagationLayer* pl);
207      //     AliTRDpropagationLayer* operator[](Int_t i) { return fLayers[i]; }
208      AliTRDpropagationLayer* GetLayer(Int_t i) { return fLayers[i]; }
209      Int_t    CookTimeBinIndex(Int_t plane, Int_t localTB) const;     
210
211    private:
212      Int_t                     fN;      // total number of layers
213      AliTRDgeometry            *fGeom;  // geometry
214      AliTRDpropagationLayer    *fLayers[kMaxLayersPerSector];   // layers   
215      Int_t                     fTimeBinIndex[kMaxTimeBinIndex]; // time bin index
216      Int_t                     fGeomSector;   // sector # in AliTRDgeometry
217    };
218
219  protected:
220
221   friend class AliTRDtracker::AliTRDtrackingSector;
222
223   AliTRDgeometry     *fGeom;            // Pointer to TRD geometry
224
225   AliTRDtrackingSector *fTrSec[kTrackingSectors];  // array of tracking sectors;    
226   Int_t            fNclusters;        // Number of clusters in TRD 
227   TObjArray        *fClusters;        // List of clusters for all sectors
228
229   Int_t            fNseeds;           // Number of track seeds  
230   TObjArray        *fSeeds;           // List of track seeds
231    
232   Int_t            fNtracks;          // Number of reconstructed tracks 
233   TObjArray        *fTracks;          // List of reconstructed tracks   
234
235
236   Int_t       fTimeBinsPerPlane;      // number of sensitive timebins per plane
237                                       // in track prolongation             
238
239   static const Double_t fgkMaxChi2;   // max increment in track chi2 
240         
241   static const Float_t  fgkMinClustersInTrack; // min number of clusters in track
242                                                // out of total timebins
243
244   static const Float_t  fgkLabelFraction;  // min fraction of same label
245   //
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
251   Bool_t                fNoTilt;           // No tilt, or what?
252   Bool_t                fHoles[5][18];     // holes
253   
254   Bool_t AdjustSector(AliTRDtrack *track); 
255  
256  private:
257   AliTRDtrack *   RegisterSeed(AliTRDseed * seeds, Double_t *params);
258   void  MakeSeedsMI(Int_t inner, Int_t outer, AliESD *esd=0);
259
260   Int_t         FollowBackProlongation(AliTRDtrack& t);
261   Int_t         FollowProlongation(AliTRDtrack& t);
262   void          CookdEdxTimBin(AliTRDtrack& t);  
263
264   Int_t         PropagateToX(AliTRDtrack& t, Double_t xToGo, Double_t maxStep);
265
266   Double_t      ExpectedSigmaY2(Double_t r, Double_t tgl, Double_t pt) const;
267   Double_t      ExpectedSigmaZ2(Double_t r, Double_t tgl) const;
268   TTreeSRedirector *fDebugStreamer;     //!debug streamer
269   ClassDef(AliTRDtracker,2)           // manager base class  
270
271 };
272
273 #endif