]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtrackerV1.h
Remove a run from LHC10e wo AODs; added run list for the new PbPb MC LHC11a10b_bis
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackerV1.h
1 #ifndef ALITRDTRACKERV1_H
2 #define ALITRDTRACKERV1_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice                               */ 
6 /* $Id$ */
7
8 ////////////////////////////////////////////////////////////////////////////
9 //                                                                        //
10 //  The TRD tracker                                                       //
11 //                                                                        //
12 //  Authors:                                                              //
13 //    Marian Ivanov <M.Ivanov@gsi.de>                                     //
14 //    Alex Bercuci <A.Bercuci@gsi.de>                                     //
15 //    Jouri Belikov <J.Belikov@cern.ch>                                   //
16 //    Markus Fasel <M.Fasel@gsi.de>                                       //
17 //                                                                        //
18 ////////////////////////////////////////////////////////////////////////////
19
20 //#ifndef ALITRACKER_H
21 #include "AliTracker.h"
22 //#endif
23
24 //#ifndef ALITRDTRACKINGSECTOR_H
25 #include "AliTRDtrackingSector.h"
26 //#endif
27
28 //#ifndef ROOT_TMatrixDfwd
29 #include <TMatrixDfwd.h>
30 //#endif
31
32 /**************************************************************************
33 * Class Status see source file                                           *
34 **************************************************************************/
35
36 class TFile;
37 class TTreeSRedirector;
38 class TClonesArray;
39 class TLinearFitter;
40
41 class AliRieman;
42 class AliESDEvent;
43 class AliCluster;
44 class AliTrackPoint;
45
46 class AliTRDcluster;
47 class AliTRDseedV1;
48 class AliTRDtrackingChamber;
49 class AliTRDchamberTimeBin;
50 class AliTRDtrackerFitter;
51 class AliTRDtrackV1;
52 class AliTRDReconstructor;
53 class AliTRDrecoParam;
54 class AliTRDtrackerV1 : public AliTracker
55 {
56 public:
57   enum{
58     kOwner            = BIT(14) // owner of clusters
59    ,kRemoveContainers = BIT(15) // delete containers after usage
60   };
61   enum{
62     kMaxLayersPerSector   = 1000
63     , kMaxTimeBinIndex    = 216
64     , kTrackingSectors    = 18
65     , kNTimeBins          = 35
66     , kNPlanes            = 6
67     , kNSeedPlanes        = 4
68     , kMaxTracksStack     = 100
69     , kNConfigs           = 15
70   };
71   AliTRDtrackerV1(AliTRDReconstructor *rec = NULL);
72   virtual ~AliTRDtrackerV1();
73   
74   //temporary
75   AliTRDtrackingSector* GetTrackingSector(Int_t sec) {return &fTrSec[sec];}
76   
77   Int_t           Clusters2Tracks(AliESDEvent *esd);
78   AliCluster*     GetCluster(Int_t index) const;
79   AliTRDseedV1*   GetTracklet(Int_t index) const;
80   AliKalmanTrack* GetTrack(Int_t index) const;
81   TClonesArray*   GetListOfClusters() const  { return fClusters;}
82   TClonesArray*   GetListOfTracklets() const { return fTracklets;}
83   TClonesArray*   GetListOfTracks() const    { return fTracks;}
84   static Int_t    GetNTimeBins()             { return fgNTimeBins;}
85   static void     GetExtrapolationConfig(Int_t iconfig, Int_t planes[2]);
86   static void     GetSeedingConfig(Int_t iconfig, Int_t planes[4]);
87
88   static TLinearFitter*  GetTiltedRiemanFitter();
89   static TLinearFitter*  GetTiltedRiemanFitterConstraint();
90   static AliRieman*      GetRiemanFitter();
91   static void     FitRieman(AliTRDcluster **clusters, Double_t chi2[2]);
92   static Float_t  FitRieman(AliTRDseedV1 *tracklets, Double_t *chi2, Int_t *const planes = NULL);
93   static Float_t  FitTiltedRiemanConstraint(AliTRDseedV1 *tracklets, Double_t zVertex);
94   static Float_t  FitTiltedRieman(AliTRDseedV1 *tracklets, Bool_t sigError);
95   static Double_t FitTiltedRiemanV1(AliTRDseedV1 *tracklets);
96   
97   static Double_t FitRiemanTilt(const AliTRDtrackV1 *trk, AliTRDseedV1 *tracklets = NULL, Bool_t err=0, Int_t np = 0, AliTrackPoint *points = NULL);
98   static Double_t FitLine(const AliTRDtrackV1 *trk, AliTRDseedV1 *tracklets = NULL, Bool_t err=0, Int_t np = 0, AliTrackPoint *points = NULL);
99   static Double_t FitKalman(AliTRDtrackV1 *trk, AliTRDseedV1 * const tracklets = NULL, Bool_t up=0, Int_t np = 0, AliTrackPoint *points = NULL);
100
101   Bool_t          IsClustersOwner() const    { return TestBit(kOwner);}
102   Bool_t          HasRemoveContainers() const    { return TestBit(kRemoveContainers);}
103   void            SetClustersOwner(Bool_t own=kTRUE) {SetBit(kOwner, own); if(!own) fClusters = NULL;}
104   void            SetRemoveContainers(Bool_t rm=kTRUE) {SetBit(kRemoveContainers, rm);}
105
106   Int_t           FollowBackProlongation(AliTRDtrackV1 &t);
107   Int_t           FollowProlongation(AliTRDtrackV1 &t);
108   Int_t           LoadClusters(TTree *cTree);
109   Int_t           LoadClusters(TClonesArray *const clusters);
110   Int_t           PropagateBack(AliESDEvent *event);
111   static Int_t    PropagateToX(AliTRDtrackV1 &t, Double_t xToGo, Double_t maxStep);
112   Bool_t          ReadClusters(TTree *in);
113   Int_t           RefitInward(AliESDEvent *event);
114   static void     SetNTimeBins(Int_t nTimeBins){fgNTimeBins = nTimeBins; }
115   void            SetReconstructor(const AliTRDReconstructor *rec) {fkReconstructor = rec;}
116   void            UnloadClusters();
117
118   class AliTRDLeastSquare{
119   public:
120     AliTRDLeastSquare();
121     ~AliTRDLeastSquare(){};
122     
123     void          AddPoint(const Double_t * const x, Double_t y, Double_t sigmaY);
124     void          RemovePoint(const Double_t * const x, Double_t y, Double_t sigmaY);
125     Bool_t        Eval();
126     void          Reset();
127     
128     Double_t      GetFunctionParameter(Int_t ParNumber) const {return fParams[ParNumber];}
129     Double_t      GetFunctionValue(const Double_t * const xpos) const;
130     void          GetCovarianceMatrix(Double_t *storage) const;
131   private:
132     AliTRDLeastSquare(const AliTRDLeastSquare &);
133     AliTRDLeastSquare& operator=(const AliTRDLeastSquare &);
134     Double_t      fParams[2];           // Fitparameter 
135     Double_t      fCovarianceMatrix[3]; // Covariance Matrix
136     Double_t      fSums[6];             // Sums
137   };
138
139   class AliTRDtrackFitterRieman{
140     public:
141       AliTRDtrackFitterRieman();
142       ~AliTRDtrackFitterRieman();
143
144       Double_t Eval();
145       void Reset();
146
147       Double_t GetYat(Double_t x) const;
148       Double_t GetDyDxAt(Double_t x) const;
149       Double_t GetZat(Double_t x) const;
150       Double_t GetDzDx() const { return fParameters[4]; };
151       Double_t GetCurvature() const;
152       void GetCovAt(Double_t x, Double_t *cov) const;
153
154       void SetRiemanFitter(TLinearFitter *const fitter) { fTrackFitter = fitter; }
155       void SetTracklet(Int_t il, AliTRDseedV1 * const tracklet);
156       void SetSysClusterError(Double_t err) { fSysClusterError = err; };
157     private:
158       AliTRDtrackFitterRieman(const AliTRDtrackFitterRieman &);
159       AliTRDtrackFitterRieman &operator=(const AliTRDtrackFitterRieman &);
160       void UpdateFitters(AliTRDseedV1 * const tracklet);
161       Bool_t CheckAcceptable(Double_t offset, Double_t slope);
162       Double_t CalculateReferenceX();
163
164       TLinearFitter *fTrackFitter;        // Fitter for linearized track model
165       AliTRDLeastSquare *fZfitter;        // Linear fitter in z-Direction
166       AliTRDseedV1 *fTracklets[kNPlanes]; // Tracklet container
167       TMatrixD *fCovarPolY;               // Polynomial Covariance Matrix Estimation (y-direction)
168       TMatrixD *fCovarPolZ;               // Polynomial Covariance Matrix Estimation (z-direction)
169       Double_t fXref;                     // Reference x position for fit in z-Direction
170       Double_t fSysClusterError;          // Systematic cluster Error
171       Double_t fParameters[5];            // Track Model Parameter
172       Double_t fSumPolY[5];               // Sums for polynomial Covariance Matrix Estimation (y-direction)
173       Double_t fSumPolZ[3];               // Sums for polynomial Covariance Matrix Estimation (z-direction)
174   };
175
176 protected:
177   static Bool_t  AdjustSector(AliTRDtrackV1 *const track); 
178   Double_t       BuildSeedingConfigs(AliTRDtrackingChamber **stack, Int_t *configs);
179   Int_t          BuildTrackingContainers();
180   static Float_t CalculateChi2Z(const AliTRDseedV1 *tracklets, Double_t offset, Double_t slope, Double_t xref);
181   Int_t          Clusters2TracksSM(Int_t sector, AliESDEvent *esd);
182   Int_t          Clusters2TracksStack(AliTRDtrackingChamber **stack, TClonesArray * const esdTrackList);
183   AliTRDseedV1*  GetTracklet(AliTRDtrackV1 *const trk, Int_t plane, Int_t &idx);
184   Bool_t         GetTrackPoint(Int_t index, AliTrackPoint &p) const;    
185   Float_t        GetR4Layer(Int_t ly) const { return fR[ly];}
186   Int_t          MakeSeeds(AliTRDtrackingChamber **stack, AliTRDseedV1 * const sseed, const Int_t * const ipar);
187   AliTRDtrackV1* MakeTrack(AliTRDseedV1 * const tracklet);
188   AliTRDtrackV1* SetTrack(const AliTRDtrackV1 * const track);
189   AliTRDseedV1*  SetTracklet(const AliTRDseedV1 * const tracklet);
190   void           UnsetTrackletsTrack(const AliTRDtrackV1 * const track);
191
192 private:
193   AliTRDtrackerV1(const AliTRDtrackerV1 &tracker);
194   AliTRDtrackerV1 &operator=(const AliTRDtrackerV1 &tracker);
195   Double_t       CookLikelihood(AliTRDseedV1 *cseed, Int_t planes[4]);
196   Double_t       CalculateTrackLikelihood(Double_t *chi2);
197   Bool_t         ImproveSeedQuality(AliTRDtrackingChamber **stack, AliTRDseedV1 *tracklet, Double_t &chi2);
198   static Float_t        CalculateReferenceX(const AliTRDseedV1 *const tracklets);
199   void        ResetSeedTB();
200   Float_t     GetChi2Y(const AliTRDseedV1 *const tracklets) const;
201   Float_t     GetChi2Z(const AliTRDseedV1 *const tracklets) const;
202   Float_t     GetChi2Phi(const AliTRDseedV1 *const tracklets) const;
203
204   const AliTRDReconstructor *fkReconstructor;           // reconstructor manager
205   const AliTRDrecoParam     *fkRecoParam;               // reco param for the current event
206   AliTRDgeometry      *fGeom;                           // Pointer to TRD geometry
207   AliTRDtrackingSector fTrSec[kTrackingSectors];        // Array of tracking sectors;    
208   TClonesArray        *fClusters;                       // List of clusters
209   TClonesArray        *fTracklets;                      // List of tracklets
210   TClonesArray        *fTracks;                         // List of tracks
211   TClonesArray        *fTracksESD;                      // List of ESD tracks in current SM
212   Float_t              fR[kNPlanes];                    //! rough radial position of each TRD layer
213
214   // stand alone tracking
215   static Double_t      fgTopologicQA[kNConfigs];        //  Topologic quality
216   Double_t             fTrackQuality[kMaxTracksStack];  //  Track quality 
217   Int_t                fSeedLayer[kMaxTracksStack];     //  Seed layer
218   AliTRDchamberTimeBin *fSeedTB[kNSeedPlanes]; // seeding time bin planes
219   Int_t                fSieveSeeding;                   //! Seeding iterator
220   Int_t                fEventInFile;                    //! event in file being tracked (debug purposes)
221   
222   static const Double_t fgkX0[kNPlanes];                // default values for the position of anode wire
223   static Int_t         fgNTimeBins;                     // Timebins per plane in track prolongation 
224   static TLinearFitter *fgTiltedRieman;                 //  Fitter for the tilted Rieman fit without vertex constriant
225   static TLinearFitter *fgTiltedRiemanConstrained;      //  Fitter for the tilted Rieman fit with vertex constraint     
226   static AliRieman     *fgRieman;                       //  Fitter for the untilted Rieman fit
227   
228   ClassDef(AliTRDtrackerV1, 7)                          //  TRD tracker - tracklet based tracking
229
230 };
231 #endif