1 #ifndef ALIITSTRACKERU_H
2 #define ALIITSTRACKERU_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
6 //-------------------------------------------------------------------------
7 // ITS upgrade tracker base class
8 //-------------------------------------------------------------------------
9 #include "AliTracker.h"
10 #include "AliESDEvent.h"
11 #include "AliITSUSeed.h"
12 #include "AliITSUTrackCond.h"
13 #include "AliITSUTrackHyp.h"
14 #include "AliITSUAux.h"
17 class AliITSUReconstructor;
19 class AliITSUClusterPix;
21 class AliITSURecoLayer;
25 //-------------------------------------------------------------------------
26 class AliITSUTrackerGlo : public AliTracker {
29 enum {kClus2Tracks,kPropBack,kRefitInw,kNTrackingPhases}; // tracking phases
30 enum { // info from track extrapolation to layer for cluster check
31 kTrXIn ,kTrYIn ,kTrZIn ,kTrPhiIn , // entrance (outer) point on the layer from above
32 kTrXOut,kTrYOut,kTrZOut,kTrPhiOut, // exit (inner) point on the layer
33 kTrPhi0, kTrDPhi, kTrZ0, kTrDZ, // mean phi,dPhi, mean z, dZ (don't change this order)
36 enum {kMissingCluster=0 // no cluster found on this layer
37 ,kTransportFailed=1 // seed did not reach target layer
38 ,kRWCheckFailed =2 // failed to rotate the seed to frame of the layer impact point
40 enum {kStopSearchOnSensor,kClusterNotMatching,kClusterMatching}; // flags for track-to-cluster checks
42 enum {kDummyLabel=-3141593};
44 AliITSUTrackerGlo(AliITSUReconstructor* rec);
45 virtual ~AliITSUTrackerGlo();
47 virtual Int_t Clusters2Tracks(AliESDEvent *event);
48 virtual Int_t PropagateBack(AliESDEvent *event);
49 virtual Int_t RefitInward(AliESDEvent *event);
50 virtual Int_t LoadClusters(TTree * treeRP=0);
51 virtual void UnloadClusters();
52 virtual AliCluster* GetCluster(Int_t index) const;
53 void PrintSeedClusters(const AliITSUSeed* seed, Option_t* option="");
55 Int_t GetCountPronlongationTrials() const {return fCountProlongationTrials;}
56 Int_t GetCountITSin() const {return fCountITSin;}
57 Int_t GetCountITSout() const {return fCountITSout;}
58 Int_t GetCountITSrefit() const {return fCountITSrefit;}
60 //------------------------------------
61 AliITSURecoDet* GetITSInterface() const {return fITS;}
63 //------------------------------------
64 Bool_t NeedToProlong(AliESDtrack* estTr);
65 void Init(AliITSUReconstructor* rec);
66 void FindTrack(AliESDtrack* esdTr, Int_t esdID);
67 void CreateDefaultTrackCond();
68 AliITSUTrackHyp* InitHypothesis(AliESDtrack *esdTr, Int_t esdID);
69 Bool_t TransportToLayer(AliITSUSeed* seed, Int_t lFrom, Int_t lTo, Double_t rLim=-1);
70 Bool_t TransportToLayer(AliExternalTrackParam* seed, Int_t lFrom, Int_t lTo, Double_t rLim=-1);
71 Bool_t TransportToLayerX(AliExternalTrackParam* seed, Int_t lFrom, Int_t lTo, Double_t xStop);
72 Bool_t GoToExitFromLayer(AliITSUSeed* seed, AliITSURecoLayer* lr, Int_t dir, Bool_t check=kTRUE);
73 Bool_t GoToExitFromLayer(AliExternalTrackParam* seed, AliITSURecoLayer* lr, Int_t dir, Bool_t check=kTRUE);
74 Bool_t GoToEntranceToLayer(AliITSUSeed* seed, AliITSURecoLayer* lr, Int_t dir, Bool_t check=kFALSE);
75 Bool_t GoToEntranceToLayer(AliExternalTrackParam* seed, AliITSURecoLayer* lr, Int_t dir, Bool_t check=kFALSE);
76 Bool_t PropagateSeed(AliITSUSeed *seed, Double_t xToGo, Double_t mass, Double_t maxStep=1.0, Bool_t matCorr=kTRUE);
77 Bool_t PropagateSeed(AliExternalTrackParam *seed, Double_t xToGo, Double_t mass, Double_t maxStep=1.0, Bool_t matCorr=kTRUE);
78 Double_t RefitTrack(AliExternalTrackParam* trc, Double_t r, Int_t stopCond=0);
79 Int_t GetTrackingPhase() const {return fTrackPhase;}
82 void KillSeed(AliITSUSeed* seed, Bool_t branch=kFALSE);
83 Bool_t NeedToKill(AliITSUSeed* seed, Int_t flag);
84 Bool_t GetRoadWidth(AliITSUSeed* seed, int ilrA);
85 Bool_t CheckBackwardMatching(AliITSUSeed* seed);
86 Int_t CheckCluster(AliITSUSeed* seed, Int_t lr, Int_t clID);
87 void AddProlongationHypothesis(AliITSUSeed* seed, Int_t lr);
88 Bool_t AddSeedBranch(AliITSUSeed* seed);
89 void ValidateAllowedBranches(Int_t accMax);
90 void ValidateAllowedCandidates(Int_t ilr, Int_t accMax);
91 void FlagSeedClusters(const AliITSUSeed* seed, Bool_t flg, UShort_t hypRef);
93 AliITSUSeed* NewSeedFromPool(const AliITSUSeed* src=0);
94 void ResetSeedsPool();
95 void MarkSeedFree(AliITSUSeed* seed );
97 AliITSUTrackHyp* GetTrackHyp(Int_t id) const {return (AliITSUTrackHyp*)fHypStore.UncheckedAt(id);}
98 void SetTrackHyp(AliITSUTrackHyp* hyp,Int_t id) {fHypStore.AddAtAndExpand(hyp,id);}
99 void DeleteLastSeedFromPool() {fSeedsPool.RemoveLast();}
100 void CheckClusterSharingConflicts(AliITSUTrackHyp* hyp);
101 void SaveReducedHypothesesTree(AliITSUTrackHyp* dest);
102 void FinalizeHypotheses();
103 Bool_t FinalizeHypothesis(AliITSUTrackHyp* hyp);
104 void UpdateESDTrack(AliITSUTrackHyp* hyp,Int_t flag);
105 void CookMCLabel(AliITSUTrackHyp* hyp);
106 void SetTrackingPhase(Int_t p) {fTrackPhase = p;}
109 void FlagSplitClusters();
110 Bool_t ContainsSplitCluster(const AliITSUSeed* seed, Int_t maxSize=99999);
111 void CheckClusterUsage();
114 TObject*& NextFreeSeed();
118 AliITSUTrackerGlo(const AliITSUTrackerGlo&);
119 AliITSUTrackerGlo &operator=(const AliITSUTrackerGlo &tr);
122 AliITSUReconstructor* fReconstructor; // ITS global reconstructor
123 AliITSURecoDet* fITS; // interface to ITS, borrowed from reconstructor
124 AliESDtrack* fCurrESDtrack; // current esd track in processing
125 Int_t fCurrESDtrMClb; // its eventual mc label
126 Double_t fCurrMass; // current track mass
127 Double_t fTrImpData[kNTrImpData]; // data on track impact on the layer
129 Int_t fCountProlongationTrials; // number of TPC seeds
130 Int_t fCountITSin; // number of successful ITSin
131 Int_t fCountITSout; // number of successful ITSout
132 Int_t fCountITSrefit; // number of successful ITSrefit
133 Int_t fNTracksESD; // number of esd tracks
135 // the seeds management to be optimized
136 TObjArray fHypStore; // storage for tracks hypotheses
137 Int_t fLayerMaxCandidates; //! size of tmp candidates array
138 AliITSUSeed** fLayerCandidates;//! array for branches of current track prolongation
139 Int_t fNBranchesAdded; // number of branches created for current seed in prolongation
140 Int_t fNCandidatesAdded; // number of candidates added for current seed in prolongation
141 AliITSUTrackHyp* fCurrHyp; //! hypotheses container for current track
142 AliITSUTrackHyp* fWorkHyp; //! temporary hypothesis for track finding
143 TClonesArray fSeedsPool; //! pool for seeds
144 TArrayI fFreeSeedsID; //! array of ID's of freed seeds
145 TArrayI fESDIndex; //! array of ID's of freed seeds
146 Int_t fNFreeSeeds; //! number of seeds freed in the pool
147 Int_t fLastSeedID; //! id of the pool seed on which is returned by the NextFreeSeed method
148 Int_t fNLrActive; //! number of active layers
150 TObjArray fDefTrackConds; //! default tracking conditions
151 AliITSUTrackCond* fCurrTrackCond; //! current tracking condition
152 Int_t fCurrActLrID; //! current active layer ID being processed (set only when needed, not guaranteed)
153 AliITSURecoLayer* fCurrLayer; //! current layer being processed (set only when needed, not guaranteed)
154 Int_t fTrackPhase; //! tracking phase
156 static const Double_t fgkToler; // tracking tolerance
158 #ifdef _ITSU_TUNING_MODE_
159 // this code is only for special histos needed to extract some control parameters
160 void BookControlHistos(const char* pref);
161 TObjArray* fCHistoArrCorr;
162 TObjArray* fCHistoArrFake;
163 enum {kHResY=0,kHResYP=10,kHResZ=20,kHResZP=30,kHChi2Cl=40,kHChi2Nrm=50,kHBestInBranch=60,kHBestInCand=70};
164 enum {kHChiMatch,kHChiITSSA}; // custom histos
165 enum {kHistosPhase=100};
169 ClassDef(AliITSUTrackerGlo,1) //ITS upgrade tracker
173 //________________________________________
174 inline TObject *&AliITSUTrackerGlo::NextFreeSeed()
176 // return next free slot where the seed can be created
177 fLastSeedID = fNFreeSeeds ? fFreeSeedsID.GetArray()[--fNFreeSeeds] : fSeedsPool.GetEntriesFast();
178 // AliInfo(Form("%d",fLastSeedID));
179 return fSeedsPool[ fLastSeedID ];
183 //_________________________________________________________________________
184 inline AliITSUSeed* AliITSUTrackerGlo::NewSeedFromPool(const AliITSUSeed* src)
186 // create new seed, optionally copying from the source
187 AliITSUSeed* sd = src ? new( NextFreeSeed() ) AliITSUSeed(*src) : new( NextFreeSeed() ) AliITSUSeed();
188 sd->SetPoolID(fLastSeedID);
192 //_________________________________________________________________________
193 inline void AliITSUTrackerGlo::KillSeed(AliITSUSeed* seed, Bool_t branch)
195 // flag seed as killed, if requested, kill recursively its parents whose sole child is the seed being killed
197 seed = (AliITSUSeed*)seed->GetParent();
198 if (seed && !seed->DecChildren() && branch) KillSeed(seed,branch);
201 //_________________________________________________________________________
202 inline void AliITSUTrackerGlo::AddProlongationHypothesis(AliITSUSeed* seed, Int_t lr)
204 // add new seed prolongation hypothesis
205 #ifdef _ITSU_TUNING_MODE_
206 seed->SetOrdCand(fCurrHyp->GetNSeeds(lr));
208 fCurrHyp->AddSeed(seed,lr);