Making online tracklets usable in offline reconstruction
[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
eb38ed55 20#ifndef ALITRACKER_H
21#include "AliTracker.h"
e4f2f73d 22#endif
23
eb38ed55 24#ifndef ALITRDTRACKINGSECTOR_H
25#include "AliTRDtrackingSector.h"
26#endif
e4f2f73d 27
28/**************************************************************************
e165b64b 29* Class Status see source file *
30**************************************************************************/
31
e4f2f73d 32class TFile;
33class TTreeSRedirector;
34class TClonesArray;
eb38ed55 35class TLinearFitter;
e4f2f73d 36
37class AliRieman;
38class AliESDEvent;
eb38ed55 39class AliCluster;
3a039a31 40class AliTrackPoint;
e4f2f73d 41
eb38ed55 42class AliTRDcluster;
e4f2f73d 43class AliTRDseedV1;
eb38ed55 44class AliTRDtrackingChamber;
45class AliTRDchamberTimeBin;
e4f2f73d 46class AliTRDtrackerFitter;
0906e73e 47class AliTRDtrackV1;
3a039a31 48class AliTRDReconstructor;
eb38ed55 49class AliTRDtrackerV1 : public AliTracker
e4f2f73d 50{
eb38ed55 51public:
3b57a3f7 52 enum{
172b6f82 53 kOwner = BIT(14) // owner of clusters
54 ,kRemoveContainers = BIT(15) // delete containers after usage
66f6bfd9 55 };
56 enum{
3b57a3f7 57 kMaxLayersPerSector = 1000
58 , kMaxTimeBinIndex = 216
59 , kTrackingSectors = 18
60 , kNTimeBins = 35
61 , kNPlanes = 6
62 , kNSeedPlanes = 4
63 , kMaxTracksStack = 100
64 , kNConfigs = 15
65 };
3a039a31 66 AliTRDtrackerV1(AliTRDReconstructor *rec = 0x0);
3b57a3f7 67 virtual ~AliTRDtrackerV1();
e4f2f73d 68
eb38ed55 69 //temporary
70 AliTRDtrackingSector* GetTrackingSector(Int_t sec) {return &fTrSec[sec];}
71
3b57a3f7 72 Int_t Clusters2Tracks(AliESDEvent *esd);
3b57a3f7 73 AliCluster* GetCluster(Int_t index) const;
74 AliTRDseedV1* GetTracklet(Int_t index) const;
75 AliKalmanTrack* GetTrack(Int_t index) const;
eb2b4f91 76 TClonesArray* GetListOfClusters() const { return fClusters;}
77 TClonesArray* GetListOfTracklets() const { return fTracklets;}
78 TClonesArray* GetListOfTracks() const { return fTracks;}
79 static Int_t GetNTimeBins() { return fgNTimeBins;}
3b57a3f7 80 static void GetExtrapolationConfig(Int_t iconfig, Int_t planes[2]);
81 static void GetSeedingConfig(Int_t iconfig, Int_t planes[4]);
82 static TLinearFitter* GetTiltedRiemanFitter();
83 static TLinearFitter* GetTiltedRiemanFitterConstraint();
84 static AliRieman* GetRiemanFitter();
85 static void FitRieman(AliTRDcluster **clusters, Double_t chi2[2]);
86 static Float_t FitRieman(AliTRDseedV1 *tracklets, Double_t *chi2, Int_t *planes = 0x0);
87 static Float_t FitTiltedRiemanConstraint(AliTRDseedV1 *tracklets, Double_t zVertex);
88 static Float_t FitTiltedRieman(AliTRDseedV1 *tracklets, Bool_t sigError);
eb38ed55 89
e165b64b 90 static Double_t FitRiemanTilt(const AliTRDtrackV1 *trk, AliTRDseedV1 *tracklets = 0x0, Bool_t err=0, Int_t np = 0, AliTrackPoint *points = 0x0);
91 static Double_t FitLine(const AliTRDtrackV1 *trk, AliTRDseedV1 *tracklets = 0x0, Bool_t err=0, Int_t np = 0, AliTrackPoint *points = 0x0);
92 static Double_t FitKalman(AliTRDtrackV1 *trk, AliTRDseedV1 *tracklets = 0x0, Bool_t up=0, Int_t np = 0, AliTrackPoint *points = 0x0);
8acca6a3 93
eb2b4f91 94 Bool_t IsClustersOwner() const { return TestBit(kOwner);}
172b6f82 95 Bool_t HasRemoveContainers() const { return TestBit(kRemoveContainers);}
66f6bfd9 96 void SetClustersOwner(Bool_t own=kTRUE) {SetBit(kOwner, own); if(!own) fClusters = 0x0;}
172b6f82 97 void SetRemoveContainers(Bool_t rm=kTRUE) {SetBit(kRemoveContainers, rm);}
66f6bfd9 98
3b57a3f7 99 Int_t FollowBackProlongation(AliTRDtrackV1 &t);
100 Int_t FollowProlongation(AliTRDtrackV1 &t);
101 Int_t LoadClusters(TTree *cTree);
66f6bfd9 102 Int_t LoadClusters(TClonesArray *clusters);
3b57a3f7 103 Int_t PropagateBack(AliESDEvent *event);
0e08101e 104 static Int_t PropagateToX(AliTRDtrackV1 &t, Double_t xToGo, Double_t maxStep);
3b57a3f7 105 Int_t ReadClusters(TClonesArray* &array, TTree *in) const;
106 Int_t RefitInward(AliESDEvent *event);
107 static void SetNTimeBins(Int_t nTimeBins){fgNTimeBins = nTimeBins; }
29f95561 108 void SetReconstructor(const AliTRDReconstructor *rec){ fReconstructor = rec; }
172b6f82 109 void UnloadClusters();
3b57a3f7 110
111 class AliTRDLeastSquare{
112 public:
113 AliTRDLeastSquare();
114 ~AliTRDLeastSquare(){};
115
116 void AddPoint(Double_t *x, Double_t y, Double_t sigmaY);
117 void RemovePoint(Double_t *x, Double_t y, Double_t sigmaY);
118 void Eval();
119
120 Double_t GetFunctionParameter(Int_t ParNumber) const {return fParams[ParNumber];}
121 Double_t GetFunctionValue(Double_t *xpos) const;
122 void GetCovarianceMatrix(Double_t *storage) const;
123 private:
124 AliTRDLeastSquare(const AliTRDLeastSquare &);
125 AliTRDLeastSquare& operator=(const AliTRDLeastSquare &);
126 Double_t fParams[2]; // Fitparameter
127 Double_t fCovarianceMatrix[3]; // Covariance Matrix
128 Double_t fSums[6]; // Sums
129 };
fbb2ea06 130
eb38ed55 131protected:
3b57a3f7 132 static Bool_t AdjustSector(AliTRDtrackV1 *track);
133 Double_t BuildSeedingConfigs(AliTRDtrackingChamber **stack, Int_t *configs);
66f6bfd9 134 Int_t BuildTrackingContainers();
3b57a3f7 135 static Float_t CalculateChi2Z(AliTRDseedV1 *tracklets, Double_t offset, Double_t slope, Double_t xref);
136 Int_t Clusters2TracksSM(Int_t sector, AliESDEvent *esd);
137 Int_t Clusters2TracksStack(AliTRDtrackingChamber **stack, TClonesArray *esdTrackList);
138 AliTRDseedV1* GetTracklet(AliTRDtrackV1 *trk, Int_t plane, Int_t &idx);
139 Bool_t GetTrackPoint(Int_t index, AliTrackPoint &p) const;
eb2b4f91 140 Float_t GetR4Layer(Int_t ly) const { return fR[ly];}
3b57a3f7 141 Int_t MakeSeeds(AliTRDtrackingChamber **stack, AliTRDseedV1 *sseed, Int_t *ipar);
142 AliTRDtrackV1* MakeTrack(AliTRDseedV1 *seeds, Double_t *params);
d20df6fc 143 AliTRDtrackV1* SetTrack(AliTRDtrackV1 *track);
3b57a3f7 144 AliTRDseedV1* SetTracklet(AliTRDseedV1 *tracklet);
e4f2f73d 145
0906e73e 146private:
3a039a31 147 AliTRDtrackerV1(const AliTRDtrackerV1 &tracker);
148 AliTRDtrackerV1 &operator=(const AliTRDtrackerV1 &tracker);
91834b8d 149 Double_t CookLikelihood(AliTRDseedV1 *cseed, Int_t planes[4]);
3a039a31 150 Double_t CalculateTrackLikelihood(AliTRDseedV1 *tracklets, Double_t *chi2);
151 Int_t ImproveSeedQuality(AliTRDtrackingChamber **stack, AliTRDseedV1 *tracklet);
152 static Float_t CalculateReferenceX(AliTRDseedV1 *tracklets);
153 void ResetSeedTB();
154 Float_t GetChi2Y(AliTRDseedV1 *tracklets) const;
155 Float_t GetChi2Z(AliTRDseedV1 *tracklets) const;
e4f2f73d 156
0906e73e 157private:
eb2b4f91 158 const AliTRDReconstructor *fReconstructor; // reconstructor manager
159 AliTRDgeometry *fGeom; // Pointer to TRD geometry
160 AliTRDtrackingSector fTrSec[kTrackingSectors]; // Array of tracking sectors;
bb56afff 161 TClonesArray *fClusters; // List of clusters
162 TClonesArray *fTracklets; // List of tracklets
163 TClonesArray *fTracks; // List of tracks
eb2b4f91 164 Float_t fR[kNPlanes]; //! rough radial position of each TRD layer
165
eb38ed55 166 // should go to the recoParam
eb2b4f91 167 static const Double_t fgkMaxChi2; // Max increment in track chi2
168 static const Float_t fgkMinClustersInTrack; // Min number of clusters in track
169 static const Float_t fgkLabelFraction; // Min fraction of same label
170 static const Double_t fgkMaxSnp; // Maximal snp for tracking
171 static const Double_t fgkMaxStep; // Maximal step for tracking
e165b64b 172
173 // stand alone tracking
174 static Double_t fgTopologicQA[kNConfigs]; // Topologic quality
175 Double_t fTrackQuality[kMaxTracksStack]; // Track quality
176 Int_t fSeedLayer[kMaxTracksStack]; // Seed layer
d611c74f 177 AliTRDchamberTimeBin *fSeedTB[kNSeedPlanes]; // seeding time bin planes
e165b64b 178 Int_t fSieveSeeding; //! Seeding iterator
179
180 static const Double_t fgkX0[kNPlanes]; // default values for the position of anode wire
2985ffcb 181 static Int_t fgNTimeBins; // Timebins per plane in track prolongation
e165b64b 182 static TLinearFitter *fgTiltedRieman; // Fitter for the tilted Rieman fit without vertex constriant
183 static TLinearFitter *fgTiltedRiemanConstrained; // Fitter for the tilted Rieman fit with vertex constraint
184 static AliRieman *fgRieman; // Fitter for the untilted Rieman fit
185
186 ClassDef(AliTRDtrackerV1, 3) // TRD tracker - tracklet based tracking
e4f2f73d 187
188};
189#endif