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