Put 0.1 as minimal value of the gas gain (Raphaelle)
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackerV1.h
CommitLineData
e4f2f73d 1#ifndef ALITRDTRACKERV1_H
2#define ALITRDTRACKERV1_H
eb38ed55 3
e4f2f73d 4/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
e165b64b 5* See cxx source for full Copyright notice */
e4f2f73d 6/* $Id$ */
7
8////////////////////////////////////////////////////////////////////////////
9// //
10// The TRD tracker //
11// //
12// Authors: //
eb38ed55 13// Marian Ivanov <M.Ivanov@gsi.de> //
e4f2f73d 14// Alex Bercuci <A.Bercuci@gsi.de> //
eb38ed55 15// Jouri Belikov <J.Belikov@cern.ch> //
e4f2f73d 16// Markus Fasel <M.Fasel@gsi.de> //
17// //
eb38ed55 18////////////////////////////////////////////////////////////////////////////
e4f2f73d 19
4d6aee34 20//#ifndef ALITRACKER_H
eb38ed55 21#include "AliTracker.h"
4d6aee34 22//#endif
e4f2f73d 23
4d6aee34 24//#ifndef ALITRDTRACKINGSECTOR_H
eb38ed55 25#include "AliTRDtrackingSector.h"
4d6aee34 26//#endif
e4f2f73d 27
4d6aee34 28//#ifndef ROOT_TMatrixDfwd
6e39bde4 29#include <TMatrixDfwd.h>
4d6aee34 30//#endif
6e39bde4 31
e4f2f73d 32/**************************************************************************
e165b64b 33* Class Status see source file *
34**************************************************************************/
35
e4f2f73d 36class TFile;
37class TTreeSRedirector;
38class TClonesArray;
eb38ed55 39class TLinearFitter;
e4f2f73d 40
41class AliRieman;
42class AliESDEvent;
eb38ed55 43class AliCluster;
3a039a31 44class AliTrackPoint;
e4f2f73d 45
eb38ed55 46class AliTRDcluster;
e4f2f73d 47class AliTRDseedV1;
eb38ed55 48class AliTRDtrackingChamber;
49class AliTRDchamberTimeBin;
e4f2f73d 50class AliTRDtrackerFitter;
0906e73e 51class AliTRDtrackV1;
3a039a31 52class AliTRDReconstructor;
9e85cb05 53class AliTRDrecoParam;
eb38ed55 54class AliTRDtrackerV1 : public AliTracker
e4f2f73d 55{
eb38ed55 56public:
3b57a3f7 57 enum{
172b6f82 58 kOwner = BIT(14) // owner of clusters
59 ,kRemoveContainers = BIT(15) // delete containers after usage
66f6bfd9 60 };
61 enum{
3b57a3f7 62 kMaxLayersPerSector = 1000
63 , kMaxTimeBinIndex = 216
64 , kTrackingSectors = 18
65 , kNTimeBins = 35
66 , kNPlanes = 6
67 , kNSeedPlanes = 4
2ed81ab2 68 , kMaxTracksStack = 100
3b57a3f7 69 , kNConfigs = 15
70 };
4d6aee34 71 AliTRDtrackerV1(AliTRDReconstructor *rec = NULL);
3b57a3f7 72 virtual ~AliTRDtrackerV1();
e4f2f73d 73
eb38ed55 74 //temporary
75 AliTRDtrackingSector* GetTrackingSector(Int_t sec) {return &fTrSec[sec];}
76
3b57a3f7 77 Int_t Clusters2Tracks(AliESDEvent *esd);
3b57a3f7 78 AliCluster* GetCluster(Int_t index) const;
79 AliTRDseedV1* GetTracklet(Int_t index) const;
80 AliKalmanTrack* GetTrack(Int_t index) const;
eb2b4f91 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;}
3b57a3f7 85 static void GetExtrapolationConfig(Int_t iconfig, Int_t planes[2]);
86 static void GetSeedingConfig(Int_t iconfig, Int_t planes[4]);
952051c5 87
3b57a3f7 88 static TLinearFitter* GetTiltedRiemanFitter();
89 static TLinearFitter* GetTiltedRiemanFitterConstraint();
90 static AliRieman* GetRiemanFitter();
91 static void FitRieman(AliTRDcluster **clusters, Double_t chi2[2]);
4d6aee34 92 static Float_t FitRieman(AliTRDseedV1 *tracklets, Double_t *chi2, Int_t *const planes = NULL);
3b57a3f7 93 static Float_t FitTiltedRiemanConstraint(AliTRDseedV1 *tracklets, Double_t zVertex);
94 static Float_t FitTiltedRieman(AliTRDseedV1 *tracklets, Bool_t sigError);
6e39bde4 95 static Double_t FitTiltedRiemanV1(AliTRDseedV1 *tracklets);
eb38ed55 96
4d6aee34 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);
e17f4785 99 static Double_t FitKalman(AliTRDtrackV1 *trk, AliTRDseedV1 * const tracklets = NULL, Bool_t up=0, Int_t np = 0, AliTrackPoint *points = NULL);
8acca6a3 100
eb2b4f91 101 Bool_t IsClustersOwner() const { return TestBit(kOwner);}
172b6f82 102 Bool_t HasRemoveContainers() const { return TestBit(kRemoveContainers);}
4d6aee34 103 void SetClustersOwner(Bool_t own=kTRUE) {SetBit(kOwner, own); if(!own) fClusters = NULL;}
172b6f82 104 void SetRemoveContainers(Bool_t rm=kTRUE) {SetBit(kRemoveContainers, rm);}
66f6bfd9 105
3b57a3f7 106 Int_t FollowBackProlongation(AliTRDtrackV1 &t);
107 Int_t FollowProlongation(AliTRDtrackV1 &t);
108 Int_t LoadClusters(TTree *cTree);
4d6aee34 109 Int_t LoadClusters(TClonesArray *const clusters);
3b57a3f7 110 Int_t PropagateBack(AliESDEvent *event);
0e08101e 111 static Int_t PropagateToX(AliTRDtrackV1 &t, Double_t xToGo, Double_t maxStep);
e7542a7e 112 Bool_t ReadClusters(TTree *in);
3b57a3f7 113 Int_t RefitInward(AliESDEvent *event);
114 static void SetNTimeBins(Int_t nTimeBins){fgNTimeBins = nTimeBins; }
b5c2e373 115 void SetReconstructor(const AliTRDReconstructor *rec) {fkReconstructor = rec;}
172b6f82 116 void UnloadClusters();
3b57a3f7 117
118 class AliTRDLeastSquare{
119 public:
120 AliTRDLeastSquare();
121 ~AliTRDLeastSquare(){};
122
903326c1 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();
3b57a3f7 127
903326c1 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;
3b57a3f7 131 private:
b5c2e373 132 AliTRDLeastSquare(const AliTRDLeastSquare &);
3b57a3f7 133 AliTRDLeastSquare& operator=(const AliTRDLeastSquare &);
903326c1 134 Double_t fParams[2]; // Fitparameter
135 Double_t fCovarianceMatrix[3]; // Covariance Matrix
136 Double_t fSums[6]; // Sums
3b57a3f7 137 };
fbb2ea06 138
6e39bde4 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
4d6aee34 154 void SetRiemanFitter(TLinearFitter *const fitter) { fTrackFitter = fitter; }
155 void SetTracklet(Int_t il, AliTRDseedV1 * const tracklet);
6e39bde4 156 void SetSysClusterError(Double_t err) { fSysClusterError = err; };
157 private:
158 AliTRDtrackFitterRieman(const AliTRDtrackFitterRieman &);
159 AliTRDtrackFitterRieman &operator=(const AliTRDtrackFitterRieman &);
4d6aee34 160 void UpdateFitters(AliTRDseedV1 * const tracklet);
6e39bde4 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
eb38ed55 176protected:
4d6aee34 177 static Bool_t AdjustSector(AliTRDtrackV1 *const track);
3b57a3f7 178 Double_t BuildSeedingConfigs(AliTRDtrackingChamber **stack, Int_t *configs);
66f6bfd9 179 Int_t BuildTrackingContainers();
d8069611 180 static Float_t CalculateChi2Z(const AliTRDseedV1 *tracklets, Double_t offset, Double_t slope, Double_t xref);
3b57a3f7 181 Int_t Clusters2TracksSM(Int_t sector, AliESDEvent *esd);
4d6aee34 182 Int_t Clusters2TracksStack(AliTRDtrackingChamber **stack, TClonesArray * const esdTrackList);
183 AliTRDseedV1* GetTracklet(AliTRDtrackV1 *const trk, Int_t plane, Int_t &idx);
3b57a3f7 184 Bool_t GetTrackPoint(Int_t index, AliTrackPoint &p) const;
eb2b4f91 185 Float_t GetR4Layer(Int_t ly) const { return fR[ly];}
e17f4785 186 Int_t MakeSeeds(AliTRDtrackingChamber **stack, AliTRDseedV1 * const sseed, const Int_t * const ipar);
68f9b6bd 187 AliTRDtrackV1* MakeTrack(AliTRDseedV1 * const tracklet);
4d6aee34 188 AliTRDtrackV1* SetTrack(const AliTRDtrackV1 * const track);
189 AliTRDseedV1* SetTracklet(const AliTRDseedV1 * const tracklet);
68f9b6bd 190 void UnsetTrackletsTrack(const AliTRDtrackV1 * const track);
e4f2f73d 191
0906e73e 192private:
3a039a31 193 AliTRDtrackerV1(const AliTRDtrackerV1 &tracker);
194 AliTRDtrackerV1 &operator=(const AliTRDtrackerV1 &tracker);
b5c2e373 195 Double_t CookLikelihood(AliTRDseedV1 *cseed, Int_t planes[4]);
68f9b6bd 196 Double_t CalculateTrackLikelihood(Double_t *chi2);
197 Bool_t ImproveSeedQuality(AliTRDtrackingChamber **stack, AliTRDseedV1 *tracklet, Double_t &chi2);
4d6aee34 198 static Float_t CalculateReferenceX(const AliTRDseedV1 *const tracklets);
3a039a31 199 void ResetSeedTB();
4d6aee34 200 Float_t GetChi2Y(const AliTRDseedV1 *const tracklets) const;
201 Float_t GetChi2Z(const AliTRDseedV1 *const tracklets) const;
68f9b6bd 202 Float_t GetChi2Phi(const AliTRDseedV1 *const tracklets) const;
e4f2f73d 203
9e85cb05 204 const AliTRDReconstructor *fkReconstructor; // reconstructor manager
205 const AliTRDrecoParam *fkRecoParam; // reco param for the current event
eb2b4f91 206 AliTRDgeometry *fGeom; // Pointer to TRD geometry
207 AliTRDtrackingSector fTrSec[kTrackingSectors]; // Array of tracking sectors;
bb56afff 208 TClonesArray *fClusters; // List of clusters
209 TClonesArray *fTracklets; // List of tracklets
210 TClonesArray *fTracks; // List of tracks
b1135f96 211 TClonesArray *fTracksESD; // List of ESD tracks in current SM
eb2b4f91 212 Float_t fR[kNPlanes]; //! rough radial position of each TRD layer
213
e165b64b 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
d611c74f 218 AliTRDchamberTimeBin *fSeedTB[kNSeedPlanes]; // seeding time bin planes
e165b64b 219 Int_t fSieveSeeding; //! Seeding iterator
220
221 static const Double_t fgkX0[kNPlanes]; // default values for the position of anode wire
2985ffcb 222 static Int_t fgNTimeBins; // Timebins per plane in track prolongation
e165b64b 223 static TLinearFitter *fgTiltedRieman; // Fitter for the tilted Rieman fit without vertex constriant
224 static TLinearFitter *fgTiltedRiemanConstrained; // Fitter for the tilted Rieman fit with vertex constraint
225 static AliRieman *fgRieman; // Fitter for the untilted Rieman fit
226
952051c5 227 ClassDef(AliTRDtrackerV1, 6) // TRD tracker - tracklet based tracking
e4f2f73d 228
229};
230#endif