]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITStrackerMI.h
Part of Reset() moved to base class.
[u/mrichter/AliRoot.git] / ITS / AliITStrackerMI.h
1 #ifndef ALIITSTRACKERMI_H
2 #define ALIITSTRACKERMI_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6
7 //-------------------------------------------------------------------------
8 //                          ITS tracker
9 //     reads AliITSclusterMI clusters and creates AliITStrackMI tracks
10 //           Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch
11 //-------------------------------------------------------------------------
12
13 class TTree;
14 class TTreeSRedirector;
15 class AliESDEvent;
16
17 #include <TObjArray.h>
18 #include "AliITSRecPoint.h"
19 #include "AliITStrackMI.h"
20 #include "AliTracker.h"
21
22 //-------------------------------------------------------------------------
23 class AliITStrackerMI : public AliTracker {
24 public:
25   AliITStrackerMI();
26   AliITStrackerMI(const Char_t *geom);
27   virtual ~AliITStrackerMI();
28   AliCluster *GetCluster(Int_t index) const;
29   virtual Bool_t GetTrackPoint(Int_t index, AliTrackPoint& p) const;
30   AliITSRecPoint *GetClusterLayer(Int_t layn, Int_t ncl) const
31                         {return fgLayers[layn].GetCluster(ncl);}
32   Int_t GetNumberOfClustersLayer(Int_t layn) const 
33                         {return fgLayers[layn].GetNumberOfClusters();}
34   Int_t LoadClusters(TTree *cf);
35   void UnloadClusters();
36   Int_t Clusters2Tracks(AliESDEvent *event);
37   Int_t PropagateBack(AliESDEvent *event);
38   Int_t RefitInward(AliESDEvent *event);
39   Bool_t RefitAt(Double_t x, AliITStrackMI *seed, 
40                  const AliITStrackMI *t, Bool_t extra=kFALSE);
41   Bool_t RefitAt(Double_t x, AliITStrackMI *seed, const Int_t *clindex);
42   void SetupFirstPass(Int_t *flags, Double_t *cuts=0);
43   void SetupSecondPass(Int_t *flags, Double_t *cuts=0);
44
45   void SetLastLayerToTrackTo(Int_t l=0) {fLastLayerToTrackTo=l;} 
46   void SetLayersNotToSkip(Int_t *l);
47   void UseClusters(const AliKalmanTrack *t, Int_t from=0) const;
48   void GetNTeor(Int_t layer, const AliITSRecPoint* cl, Float_t theta, Float_t phi, Float_t &ny, Float_t &nz);
49   Int_t  GetError(Int_t layer, const AliITSRecPoint*cl, Float_t theta, Float_t phi, Float_t expQ, Float_t &erry, Float_t &errz);
50
51   void  GetDCASigma(AliITStrackMI* track, Float_t & sigmarfi, Float_t &sigmaz);
52   Double_t GetPredictedChi2MI(AliITStrackMI* track, const AliITSRecPoint *cluster,Int_t layer);
53   Int_t UpdateMI(AliITStrackMI* track, const AliITSRecPoint* cl,Double_t chi2,Int_t layer) const;
54   class AliITSdetector { 
55   public:
56     AliITSdetector():fR(0),fPhi(0),fSinPhi(0),fCosPhi(0),fYmin(0),fYmax(0),fZmin(0),fZmax(0){}
57     AliITSdetector(Double_t r,Double_t phi):fR(r),fPhi(phi),fSinPhi(TMath::Sin(phi)),fCosPhi(TMath::Cos(phi)),fYmin(10000),fYmax(-1000),fZmin(10000),fZmax(-1000) {}
58     inline void GetGlobalXYZ( const AliITSRecPoint *cl, Double_t xyz[3]) const;
59     Double_t GetR()   const {return fR;}
60     Double_t GetPhi() const {return fPhi;}
61     Double_t GetYmin() const {return fYmin;}
62     Double_t GetYmax() const {return fYmax;}
63     Double_t GetZmin() const {return fZmin;}
64     Double_t GetZmax() const {return fZmax;}
65     void SetYmin(Double_t min) {fYmin = min;}
66     void SetYmax(Double_t max) {fYmax = max;}
67     void SetZmin(Double_t min) {fZmin = min;}
68     void SetZmax(Double_t max) {fZmax = max;}
69   private:
70     Double_t fR;    // polar coordinates 
71     Double_t fPhi;  // of this detector
72     Double_t fSinPhi; // sin of phi;
73     Double_t fCosPhi; // cos of phi 
74     Double_t fYmin;   //  local y minimal
75     Double_t fYmax;   //  local max y
76     Double_t fZmin;   //  local z min
77     Double_t fZmax;   //  local z max
78   };
79
80   class AliITSlayer {
81   public:
82     AliITSlayer();
83     AliITSlayer(Double_t r, Double_t p, Double_t z, Int_t nl, Int_t nd);
84    ~AliITSlayer();
85     Int_t InsertCluster(AliITSRecPoint *c);
86     void  SortClusters();
87     void ResetClusters();
88     void ResetWeights();
89     void SelectClusters(Double_t zmi,Double_t zma,Double_t ymi,Double_t yma);
90     const AliITSRecPoint *GetNextCluster(Int_t &ci);
91     void ResetRoad();
92     Double_t GetRoad() const {return fRoad;}
93     Double_t GetR() const {return fR;}
94     Int_t FindClusterIndex(Float_t z) const;
95     AliITSRecPoint *GetCluster(Int_t i) const {return i<fN? fClusters[i]:0;} 
96     Float_t         *GetWeight(Int_t i) {return i<fN ?&fClusterWeight[i]:0;}
97     AliITSdetector &GetDetector(Int_t n) const { return fDetectors[n]; }
98     Int_t FindDetectorIndex(Double_t phi, Double_t z) const;
99     Double_t GetThickness(Double_t y, Double_t z, Double_t &x0) const;
100     Int_t InRoad() const ;
101     Int_t GetNumberOfClusters() const {return fN;}
102     Int_t GetNladders() const {return fNladders;}
103     Int_t GetNdetectors() const {return fNdetectors;}
104     Int_t GetSkip() const {return fSkip;}
105     void  SetSkip(Int_t skip){fSkip=skip;}
106     void IncAccepted(){fAccepted++;}
107     Int_t GetAccepted() const {return fAccepted;}    
108     Int_t GetClusterTracks(Int_t i, Int_t j) const {return fClusterTracks[i][j];}
109     void SetClusterTracks(Int_t i, Int_t j, Int_t c) {fClusterTracks[i][j]=c;}
110   protected:
111     AliITSlayer(const AliITSlayer& layer);
112     AliITSlayer & operator=(const AliITSlayer& layer){
113       this->~AliITSlayer();new(this) AliITSlayer(layer);
114       return *this;}
115     Double_t fR;                // mean radius of this layer
116     Double_t fPhiOffset;        // offset of the first detector in Phi
117     Int_t fNladders;            // number of ladders
118     Double_t fZOffset;          // offset of the first detector in Z
119     Int_t fNdetectors;          // detectors/ladder
120     AliITSdetector *fDetectors; // array of detectors
121     Int_t fN;                   // number of clusters
122     AliITSRecPoint *fClusters[kMaxClusterPerLayer]; // pointers to clusters
123     Int_t        fClusterIndex[kMaxClusterPerLayer]; // pointers to clusters
124     Float_t fY[kMaxClusterPerLayer];                // y position of the clusters      
125     Float_t fZ[kMaxClusterPerLayer];                // z position of the clusters      
126     Float_t fYB[2];                                       // ymin and ymax
127     //
128     AliITSRecPoint *fClusters5[6][kMaxClusterPerLayer5]; // pointers to clusters -     slice in y
129     Int_t        fClusterIndex5[6][kMaxClusterPerLayer5]; // pointers to clusters -     slice in y    
130     Float_t fY5[6][kMaxClusterPerLayer5];                // y position of the clusters  slice in y    
131     Float_t fZ5[6][kMaxClusterPerLayer5];                // z position of the clusters  slice in y 
132     Int_t fN5[6];                                       // number of cluster in slice
133     Float_t fDy5;                                       //delta y
134     Float_t fBy5[6][2];                                    //slice borders
135     //
136     AliITSRecPoint *fClusters10[11][kMaxClusterPerLayer10]; // pointers to clusters -     slice in y
137     Int_t        fClusterIndex10[11][kMaxClusterPerLayer10]; // pointers to clusters -     slice in y    
138     Float_t fY10[11][kMaxClusterPerLayer10];                // y position of the clusters  slice in y    
139     Float_t fZ10[11][kMaxClusterPerLayer10];                // z position of the clusters  slice in y 
140     Int_t fN10[11];                                       // number of cluster in slice
141     Float_t fDy10;                                        // delta y
142     Float_t fBy10[11][2];                                 // slice borders
143     //
144     AliITSRecPoint *fClusters20[21][kMaxClusterPerLayer20]; // pointers to clusters -     slice in y
145     Int_t        fClusterIndex20[21][kMaxClusterPerLayer20]; // pointers to clusters -     slice in y    
146     Float_t fY20[21][kMaxClusterPerLayer20];                // y position of the clusters  slice in y    
147     Float_t fZ20[21][kMaxClusterPerLayer20];                // z position of the clusters  slice in y 
148     Int_t fN20[21];                                       // number of cluster in slice
149     Float_t fDy20;                                        //delta y 
150     Float_t fBy20[21][2];                                 //slice borders
151     //
152     AliITSRecPoint** fClustersCs;                         //clusters table in current slice
153     Int_t   *fClusterIndexCs;                             //cluster index in current slice 
154     Float_t *fYcs;                                        //y position in current slice
155     Float_t *fZcs;                                        //z position in current slice
156     Int_t    fNcs;                                        //number of clusters in current slice    
157     Int_t fCurrentSlice;                                  //current slice
158     //
159     Float_t  fClusterWeight[kMaxClusterPerLayer]; // probabilistic weight of the cluster
160     Int_t    fClusterTracks[4][kMaxClusterPerLayer]; //tracks registered to given cluster
161     Float_t fZmax;      //    edges
162     Float_t fYmin;      //   of  the
163     Float_t fYmax;      //   "window"
164     Int_t fI;            // index of the current cluster within the "window"
165     Int_t fImax;            // index of the last cluster within the "window"    
166     Int_t fSkip;     // indicates possibility to skip cluster
167     Int_t fAccepted;     // accept indicator 
168     Double_t fRoad;      // road defined by the cluster density
169   };
170   AliITStrackerMI::AliITSlayer    & GetLayer(Int_t layer) const;
171   AliITStrackerMI::AliITSdetector & GetDetector(Int_t layer, Int_t n) const {return GetLayer(layer).GetDetector(n); }
172
173 protected:
174   Int_t GetNearestLayer(const Double_t *xr) const;  //get nearest upper layer close to the point xr
175   void FindV02(AliESDEvent *event);  //try to find V0
176   void RefitV02(AliESDEvent *event);  //try to refit  V0's
177   void UpdateTPCV0(AliESDEvent *event);  //try to update, or reject TPC  V0s
178   void CookLabel(AliKalmanTrack *t,Float_t wrong) const;
179   void CookLabel(AliITStrackMI *t,Float_t wrong) const;
180   Double_t GetEffectiveThickness(Double_t y, Double_t z) const;
181   void FollowProlongationTree(AliITStrackMI * otrack, Int_t esdindex, Bool_t constrain);
182   void ResetBestTrack() {
183      fBestTrack.~AliITStrackMI();
184      new(&fBestTrack) AliITStrackMI(fTrackToFollow);
185   }
186   void ResetTrackToFollow(const AliITStrackMI &t) {
187      fTrackToFollow.~AliITStrackMI();
188      new(&fTrackToFollow) AliITStrackMI(t);
189   }
190   void CookdEdx(AliITStrackMI* track);
191   Double_t GetNormalizedChi2(AliITStrackMI * track, Int_t mode);
192   Double_t GetTruncatedChi2(AliITStrackMI * track, Float_t fac);
193   Double_t NormalizedChi2(AliITStrackMI * track, Int_t layer);
194   Double_t GetInterpolatedChi2(AliITStrackMI * forwardtrack, AliITStrackMI * backtrack);  
195   Double_t GetMatchingChi2(AliITStrackMI * track1, AliITStrackMI * track2);
196   Double_t GetDeadZoneProbability(Double_t zpos, Double_t zerr);
197
198   Float_t    *GetWeight(Int_t index);
199   void AddTrackHypothesys(AliITStrackMI * track, Int_t esdindex);
200   void SortTrackHypothesys(Int_t esdindex, Int_t maxcut, Int_t mode);
201   AliITStrackMI * GetBestHypothesys(Int_t esdindex, AliITStrackMI * original, Int_t checkmax); 
202   void  GetBestHypothesysMIP(TObjArray &itsTracks); 
203   void RegisterClusterTracks(AliITStrackMI* track, Int_t id);
204   void UnRegisterClusterTracks(AliITStrackMI* track, Int_t id);
205   Float_t GetNumberOfSharedClusters(AliITStrackMI* track,Int_t id, Int_t list[6], AliITSRecPoint *clist[6]);
206   Int_t GetOverlapTrack(AliITStrackMI *track, Int_t trackID, Int_t &shared, Int_t clusterlist[6], Int_t overlist[6]);
207   AliITStrackMI * GetBest2Tracks(Int_t trackID1, Int_t treackID2, Float_t th0, Float_t th1);
208   Float_t  * GetErrY(Int_t trackindex) const {return &fCoefficients[trackindex*48];}
209   Float_t  * GetErrZ(Int_t trackindex) const {return &fCoefficients[trackindex*48+12];}
210   Float_t  * GetNy(Int_t trackindex) const {return &fCoefficients[trackindex*48+24];}
211   Float_t  * GetNz(Int_t trackindex) const {return &fCoefficients[trackindex*48+36];}
212   void       SignDeltas( TObjArray *ClusterArray, Float_t zv);
213   void MakeCoefficients(Int_t ntracks);
214   void UpdateESDtrack(AliITStrackMI* track, ULong_t flags) const;
215   Int_t fI;                              // index of the current layer
216   static AliITSlayer fgLayers[kMaxLayer];// ITS layers
217   AliITStrackMI fTracks[kMaxLayer];      // track estimations at the ITS layers
218   AliITStrackMI fBestTrack;              // "best" track 
219   AliITStrackMI fTrackToFollow;          // followed track
220   TObjArray     fTrackHypothesys;        // ! array with track hypothesys- ARRAY is the owner of tracks- MI
221   TObjArray     fBestHypothesys;         // ! array with track hypothesys- ARRAY is the owner of tracks- MI
222   TObjArray     fOriginal;               // ! array with seeds from the TPC
223   Int_t         fBestTrackIndex[100000]; // ! index of the best track
224   Int_t         fCurrentEsdTrack;        // ! current esd track           - MI
225   Int_t fPass;                           // current pass through the data 
226   Int_t fConstraint[2];                  // constraint flags
227   Bool_t fAfterV0;                       //indicates V0 founded
228   Int_t fLayersNotToSkip[kMaxLayer];     // layer masks
229   Int_t fLastLayerToTrackTo;             // the innermost layer to track to
230   Float_t * fCoefficients;                //! working array with errors and mean cluster shape
231   AliESDEvent  * fEsd;                   //! pointer to the ESD event
232   Double_t fSPDdetzcentre[4];            // centres of SPD modules in z
233   Bool_t fUseTGeo;                       // use TGeo to get material budget
234   TTreeSRedirector *fDebugStreamer;     //!debug streamer
235 private:
236   AliITStrackerMI(const AliITStrackerMI &tracker);
237   AliITStrackerMI & operator=(const AliITStrackerMI &tracker);
238   ClassDef(AliITStrackerMI,3)   //ITS tracker MI
239 };
240
241
242
243
244 /////////////////////////////////////////////////////////
245 /////////////////////////////////////////////////////////
246 /////////////////////////////////////////////////////////
247
248
249
250
251
252 inline void AliITStrackerMI::SetupFirstPass(Int_t *flags, Double_t *cuts) {
253   // This function sets up flags and cuts for the first tracking pass   
254   //
255   //   flags[0] - vertex constaint flag                                
256   //              negative means "skip the pass"                        
257   //              0        means "no constraint"                        
258   //              positive means "normal constraint"                    
259
260    fConstraint[0]=flags[0];
261    if (cuts==0) return;
262 }
263
264 inline void AliITStrackerMI::SetupSecondPass(Int_t *flags, Double_t *cuts) {
265   // This function sets up flags and cuts for the second tracking pass   
266   //
267   //   flags[0] - vertex constaint flag                                
268   //              negative means "skip the pass"                        
269   //              0        means "no constraint"                        
270   //              positive means "normal constraint"                    
271
272    fConstraint[1]=flags[0];
273    if (cuts==0) return;
274 }
275
276 inline void AliITStrackerMI::CookLabel(AliKalmanTrack *t,Float_t wrong) const {
277   //--------------------------------------------------------------------
278   //This function "cooks" a track label. If label<0, this track is fake.
279   //--------------------------------------------------------------------
280    Int_t tpcLabel=t->GetLabel();
281    if (tpcLabel<0) return;
282    AliTracker::CookLabel(t,wrong);
283    if (tpcLabel!=TMath::Abs(t->GetLabel())){
284      t->SetFakeRatio(1.);
285    }
286    if (tpcLabel !=t->GetLabel()) {
287      t->SetLabel(-tpcLabel);      
288    }
289 }
290
291 inline Double_t AliITStrackerMI::NormalizedChi2(AliITStrackMI * track, Int_t layer)
292 {
293   //--------------------------------------------------------------------
294   //get normalize chi2
295   //--------------------------------------------------------------------
296   track->SetNormChi2(layer,2.*track->GetNSkipped()+0.25*track->GetNDeadZone()+track->GetdEdxMismatch()+track->GetChi2()/
297   //track->fNormChi2[layer] = 2.*track->fNSkipped+0.25*track->fNDeadZone+track->fdEdxMismatch+track->fChi22/
298     TMath::Max(double(track->GetNumberOfClusters()-track->GetNSkipped()),
299                1./(1.+track->GetNSkipped())));
300   return track->GetNormChi2(layer);
301 }
302 inline void  AliITStrackerMI::AliITSdetector::GetGlobalXYZ(const AliITSRecPoint *cl, Double_t xyz[3]) const
303 {
304   //
305   // get cluster coordinates in global cooordinate 
306   //
307   xyz[2] = cl->GetZ();
308   xyz[0] = fR*fCosPhi - cl->GetY()*fSinPhi;
309   xyz[1] = fR*fSinPhi + cl->GetY()*fCosPhi;
310 }
311 #endif