1 #ifndef ALIITSTRACKERMI_H
2 #define ALIITSTRACKERMI_H
3 /* Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
8 //-------------------------------------------------------------------------
10 // reads AliITSclusterMI clusters and creates AliITStrackMI tracks
11 // Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch
12 //-------------------------------------------------------------------------
15 class TTreeSRedirector;
18 #include <TObjArray.h>
19 #include "AliITSRecPoint.h"
20 #include "AliITStrackMI.h"
21 #include "AliITSPlaneEff.h"
22 #include "AliPlaneEff.h"
23 #include "AliTracker.h"
25 //-------------------------------------------------------------------------
26 class AliITStrackerMI : public AliTracker {
29 AliITStrackerMI(const Char_t *geom);
30 virtual ~AliITStrackerMI();
31 AliCluster *GetCluster(Int_t index) const;
32 virtual Bool_t GetTrackPoint(Int_t index, AliTrackPoint& p) const;
33 virtual Bool_t GetTrackPointTrackingError(Int_t index,
34 AliTrackPoint& p, const AliESDtrack *t);
35 AliITSRecPoint *GetClusterLayer(Int_t layn, Int_t ncl) const
36 {return fgLayers[layn].GetCluster(ncl);}
37 Int_t GetNumberOfClustersLayer(Int_t layn) const
38 {return fgLayers[layn].GetNumberOfClusters();}
39 Int_t LoadClusters(TTree *cf);
40 void UnloadClusters();
41 Int_t Clusters2Tracks(AliESDEvent *event);
42 Int_t PropagateBack(AliESDEvent *event);
43 Int_t RefitInward(AliESDEvent *event);
44 Bool_t RefitAt(Double_t x, AliITStrackMI *track,
45 const AliITStrackMI *clusters, Bool_t extra=kFALSE, Bool_t planeeff=kFALSE);
46 Bool_t RefitAt(Double_t x, AliITStrackMI *track,
47 const Int_t *clusters, Bool_t extra=kFALSE, Bool_t planeeff=kFALSE);
48 void SetupFirstPass(Int_t *flags, Double_t *cuts=0);
49 void SetupSecondPass(Int_t *flags, Double_t *cuts=0);
51 void SetLastLayerToTrackTo(Int_t l=0) {fLastLayerToTrackTo=l;}
52 void SetLayersNotToSkip(Int_t *l);
53 void UseClusters(const AliKalmanTrack *t, Int_t from=0) const;
55 void GetDCASigma(AliITStrackMI* track, Float_t & sigmarfi, Float_t &sigmaz);
56 Double_t GetPredictedChi2MI(AliITStrackMI* track, const AliITSRecPoint *cluster,Int_t layer);
57 Int_t UpdateMI(AliITStrackMI* track, const AliITSRecPoint* cl,Double_t chi2,Int_t layer) const;
58 AliPlaneEff *GetPlaneEff() {return (AliPlaneEff*)fPlaneEff;} // return the pointer to AliPlaneEff
59 class AliITSdetector {
61 AliITSdetector():fR(0),fPhi(0),fSinPhi(0),fCosPhi(0),fYmin(0),fYmax(0),fZmin(0),fZmax(0){}
62 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) {}
63 inline void GetGlobalXYZ( const AliITSRecPoint *cl, Double_t xyz[3]) const;
64 Double_t GetR() const {return fR;}
65 Double_t GetPhi() const {return fPhi;}
66 Double_t GetYmin() const {return fYmin;}
67 Double_t GetYmax() const {return fYmax;}
68 Double_t GetZmin() const {return fZmin;}
69 Double_t GetZmax() const {return fZmax;}
70 void SetYmin(Double_t min) {fYmin = min;}
71 void SetYmax(Double_t max) {fYmax = max;}
72 void SetZmin(Double_t min) {fZmin = min;}
73 void SetZmax(Double_t max) {fZmax = max;}
75 Double_t fR; // polar coordinates
76 Double_t fPhi; // of this detector
77 Double_t fSinPhi; // sin of phi;
78 Double_t fCosPhi; // cos of phi
79 Double_t fYmin; // local y minimal
80 Double_t fYmax; // local max y
81 Double_t fZmin; // local z min
82 Double_t fZmax; // local z max
88 AliITSlayer(Double_t r, Double_t p, Double_t z, Int_t nl, Int_t nd);
90 Int_t InsertCluster(AliITSRecPoint *c);
94 void SelectClusters(Double_t zmin,Double_t zmax,Double_t ymin,Double_t ymax);
95 const AliITSRecPoint *GetNextCluster(Int_t &ci,Bool_t test=kFALSE);
97 Double_t GetRoad() const {return fRoad;}
98 Double_t GetR() const {return fR;}
99 Int_t FindClusterIndex(Float_t z) const;
100 AliITSRecPoint *GetCluster(Int_t i) const {return i<fN? fClusters[i]:0;}
101 Float_t *GetWeight(Int_t i) {return i<fN ?&fClusterWeight[i]:0;}
102 AliITSdetector &GetDetector(Int_t n) const { return fDetectors[n]; }
103 Int_t FindDetectorIndex(Double_t phi, Double_t z) const;
104 Double_t GetThickness(Double_t y, Double_t z, Double_t &x0) const;
105 Int_t InRoad() const ;
106 Int_t GetNumberOfClusters() const {return fN;}
107 Int_t GetNladders() const {return fNladders;}
108 Int_t GetNdetectors() const {return fNdetectors;}
109 Int_t GetSkip() const {return fSkip;}
110 void SetSkip(Int_t skip){fSkip=skip;}
111 void IncAccepted(){fAccepted++;}
112 Int_t GetAccepted() const {return fAccepted;}
113 Int_t GetClusterTracks(Int_t i, Int_t j) const {return fClusterTracks[i][j];}
114 void SetClusterTracks(Int_t i, Int_t j, Int_t c) {fClusterTracks[i][j]=c;}
116 AliITSlayer(const AliITSlayer& layer);
117 AliITSlayer & operator=(const AliITSlayer& layer){
118 this->~AliITSlayer();new(this) AliITSlayer(layer);
120 Double_t fR; // mean radius of this layer
121 Double_t fPhiOffset; // offset of the first detector in Phi
122 Int_t fNladders; // number of ladders
123 Double_t fZOffset; // offset of the first detector in Z
124 Int_t fNdetectors; // detectors/ladder
125 AliITSdetector *fDetectors; // array of detectors
126 Int_t fN; // number of clusters
127 AliITSRecPoint *fClusters[AliITSRecoParam::fgkMaxClusterPerLayer]; // pointers to clusters
128 Int_t fClusterIndex[AliITSRecoParam::fgkMaxClusterPerLayer]; // pointers to clusters
129 Float_t fY[AliITSRecoParam::fgkMaxClusterPerLayer]; // y position of the clusters
130 Float_t fZ[AliITSRecoParam::fgkMaxClusterPerLayer]; // z position of the clusters
131 Float_t fYB[2]; // ymin and ymax
133 AliITSRecPoint *fClusters5[6][AliITSRecoParam::fgkMaxClusterPerLayer5]; // pointers to clusters - slice in y
134 Int_t fClusterIndex5[6][AliITSRecoParam::fgkMaxClusterPerLayer5]; // pointers to clusters - slice in y
135 Float_t fY5[6][AliITSRecoParam::fgkMaxClusterPerLayer5]; // y position of the clusters slice in y
136 Float_t fZ5[6][AliITSRecoParam::fgkMaxClusterPerLayer5]; // z position of the clusters slice in y
137 Int_t fN5[6]; // number of cluster in slice
138 Float_t fDy5; //delta y
139 Float_t fBy5[6][2]; //slice borders
141 AliITSRecPoint *fClusters10[11][AliITSRecoParam::fgkMaxClusterPerLayer10]; // pointers to clusters - slice in y
142 Int_t fClusterIndex10[11][AliITSRecoParam::fgkMaxClusterPerLayer10]; // pointers to clusters - slice in y
143 Float_t fY10[11][AliITSRecoParam::fgkMaxClusterPerLayer10]; // y position of the clusters slice in y
144 Float_t fZ10[11][AliITSRecoParam::fgkMaxClusterPerLayer10]; // z position of the clusters slice in y
145 Int_t fN10[11]; // number of cluster in slice
146 Float_t fDy10; // delta y
147 Float_t fBy10[11][2]; // slice borders
149 AliITSRecPoint *fClusters20[21][AliITSRecoParam::fgkMaxClusterPerLayer20]; // pointers to clusters - slice in y
150 Int_t fClusterIndex20[21][AliITSRecoParam::fgkMaxClusterPerLayer20]; // pointers to clusters - slice in y
151 Float_t fY20[21][AliITSRecoParam::fgkMaxClusterPerLayer20]; // y position of the clusters slice in y
152 Float_t fZ20[21][AliITSRecoParam::fgkMaxClusterPerLayer20]; // z position of the clusters slice in y
153 Int_t fN20[21]; // number of cluster in slice
154 Float_t fDy20; //delta y
155 Float_t fBy20[21][2]; //slice borders
157 AliITSRecPoint** fClustersCs; //clusters table in current slice
158 Int_t *fClusterIndexCs; //cluster index in current slice
159 Float_t *fYcs; //y position in current slice
160 Float_t *fZcs; //z position in current slice
161 Int_t fNcs; //number of clusters in current slice
162 Int_t fCurrentSlice; //current slice
164 Float_t fClusterWeight[AliITSRecoParam::fgkMaxClusterPerLayer]; // probabilistic weight of the cluster
165 Int_t fClusterTracks[4][AliITSRecoParam::fgkMaxClusterPerLayer]; //tracks registered to given cluster
166 Float_t fZmax; // edges
167 Float_t fYmin; // of the
168 Float_t fYmax; // "window"
169 Int_t fI; // index of the current cluster within the "window"
170 Int_t fImax; // index of the last cluster within the "window"
171 Int_t fSkip; // indicates possibility to skip cluster
172 Int_t fAccepted; // accept indicator
173 Double_t fRoad; // road defined by the cluster density
175 AliITStrackerMI::AliITSlayer & GetLayer(Int_t layer) const;
176 AliITStrackerMI::AliITSdetector & GetDetector(Int_t layer, Int_t n) const {return GetLayer(layer).GetDetector(n); }
179 Int_t GetNearestLayer(const Double_t *xr) const; //get nearest upper layer close to the point xr
180 void FindV02(AliESDEvent *event); //try to find V0
181 void RefitV02(AliESDEvent *event); //try to refit V0's
182 void UpdateTPCV0(AliESDEvent *event); //try to update, or reject TPC V0s
183 void CookLabel(AliKalmanTrack *t,Float_t wrong) const;
184 void CookLabel(AliITStrackMI *t,Float_t wrong) const;
185 Double_t GetEffectiveThickness();
186 void FollowProlongationTree(AliITStrackMI * otrack, Int_t esdindex, Bool_t constrain);
187 void ResetBestTrack() {
188 fBestTrack.~AliITStrackMI();
189 new(&fBestTrack) AliITStrackMI(fTrackToFollow);
191 void ResetTrackToFollow(const AliITStrackMI &t) {
192 fTrackToFollow.~AliITStrackMI();
193 new(&fTrackToFollow) AliITStrackMI(t);
195 void CookdEdx(AliITStrackMI* track);
196 Double_t GetNormalizedChi2(AliITStrackMI * track, Int_t mode);
197 Double_t GetTruncatedChi2(AliITStrackMI * track, Float_t fac);
198 Double_t NormalizedChi2(AliITStrackMI * track, Int_t layer);
199 Double_t GetInterpolatedChi2(AliITStrackMI * forwardtrack, AliITStrackMI * backtrack);
200 Double_t GetMatchingChi2(AliITStrackMI * track1, AliITStrackMI * track2);
201 Double_t GetSPDDeadZoneProbability(Double_t zpos, Double_t zerr);
203 Float_t *GetWeight(Int_t index);
204 void AddTrackHypothesys(AliITStrackMI * track, Int_t esdindex);
205 void SortTrackHypothesys(Int_t esdindex, Int_t maxcut, Int_t mode);
206 AliITStrackMI * GetBestHypothesys(Int_t esdindex, AliITStrackMI * original, Int_t checkmax);
207 void GetBestHypothesysMIP(TObjArray &itsTracks);
208 void RegisterClusterTracks(AliITStrackMI* track, Int_t id);
209 void UnRegisterClusterTracks(AliITStrackMI* track, Int_t id);
210 Float_t GetNumberOfSharedClusters(AliITStrackMI* track,Int_t id, Int_t list[6], AliITSRecPoint *clist[6]);
211 Int_t GetOverlapTrack(AliITStrackMI *track, Int_t trackID, Int_t &shared, Int_t clusterlist[6], Int_t overlist[6]);
212 AliITStrackMI * GetBest2Tracks(Int_t trackID1, Int_t treackID2, Float_t th0, Float_t th1);
213 Float_t * GetErrY(Int_t trackindex) const {return &fCoefficients[trackindex*48];}
214 Float_t * GetErrZ(Int_t trackindex) const {return &fCoefficients[trackindex*48+12];}
215 Float_t * GetNy(Int_t trackindex) const {return &fCoefficients[trackindex*48+24];}
216 Float_t * GetNz(Int_t trackindex) const {return &fCoefficients[trackindex*48+36];}
217 void SignDeltas( TObjArray *ClusterArray, Float_t zv);
218 void MakeCoefficients(Int_t ntracks);
219 void BuildMaterialLUT(TString material);
220 void MakeTrksMaterialLUT(Int_t ntracks);
221 void DeleteTrksMaterialLUT();
222 Int_t CorrectForPipeMaterial(AliITStrackMI *t, TString direction="inward");
223 Int_t CorrectForShieldMaterial(AliITStrackMI *t, TString shield, TString direction="inward");
224 Int_t CorrectForLayerMaterial(AliITStrackMI *t, Int_t layerindex, Double_t oldGlobXYZ[3], TString direction="inward");
225 void UpdateESDtrack(AliITStrackMI* track, ULong_t flags) const;
226 Int_t CheckSkipLayer(AliITStrackMI *track,Int_t ilayer,Int_t idet) const;
227 Int_t CheckDeadZone(/*AliITStrackMI *track,*/Int_t ilayer,Int_t idet,Double_t zmin,Double_t zmax/*,Double_t ymin,Double_t ymax*/) const;
228 Bool_t LocalModuleCoord(Int_t ilayer,Int_t idet,AliITStrackMI *track,
229 Float_t &xloc,Float_t &zloc) const;
230 // method to be used for Plane Efficiency evaluation
231 Bool_t IsOKForPlaneEff(AliITStrackMI* track, Int_t ilayer) const; // Check if a track is usable
232 // for Plane Eff evaluation
233 void UseTrackForPlaneEff(AliITStrackMI* track, Int_t ilayer); // Use this track for Plane Eff
235 Int_t fI; // index of the current layer
236 static AliITSlayer fgLayers[AliITSgeomTGeo::kNLayers];// ITS layers
237 AliITStrackMI fTracks[AliITSgeomTGeo::kNLayers]; // track estimations at the ITS layers
238 AliITStrackMI fBestTrack; // "best" track
239 AliITStrackMI fTrackToFollow; // followed track
240 TObjArray fTrackHypothesys; // ! array with track hypothesys- ARRAY is the owner of tracks- MI
241 TObjArray fBestHypothesys; // ! array with track hypothesys- ARRAY is the owner of tracks- MI
242 TObjArray fOriginal; // ! array with seeds from the TPC
243 Int_t fBestTrackIndex[100000]; // ! index of the best track
244 Int_t fCurrentEsdTrack; // ! current esd track - MI
245 Int_t fPass; // current pass through the data
246 Int_t fConstraint[2]; // constraint flags
247 Bool_t fAfterV0; //indicates V0 founded
248 Int_t fLayersNotToSkip[AliITSgeomTGeo::kNLayers]; // layer masks
249 Int_t fLastLayerToTrackTo; // the innermost layer to track to
250 Float_t * fCoefficients; //! working array with errors and mean cluster shape
251 AliESDEvent * fEsd; //! pointer to the ESD event
252 Double_t fSPDdetzcentre[4]; // centres of SPD modules in z
253 TString fTrackingPhase; // current tracking phase
254 Int_t fUseTGeo; // use TGeo to get material budget
255 Int_t fNtracks; // number of tracks to prolong
256 Float_t fxOverX0Pipe; // material budget
257 Float_t fxTimesRhoPipe; // material budget
258 Float_t fxOverX0Shield[2]; // material budget
259 Float_t fxTimesRhoShield[2]; // material budget
260 Float_t fxOverX0Layer[6]; // material budget
261 Float_t fxTimesRhoLayer[6]; // material budget
262 Float_t *fxOverX0PipeTrks; //! material budget
263 Float_t *fxTimesRhoPipeTrks; //! material budget
264 Float_t *fxOverX0ShieldTrks; //! material budget
265 Float_t *fxTimesRhoShieldTrks; //! material budget
266 Float_t *fxOverX0LayerTrks; //! material budget
267 Float_t *fxTimesRhoLayerTrks; //! material budget
268 TTreeSRedirector *fDebugStreamer; //!debug streamer
269 AliITSPlaneEff *fPlaneEff; //! Pointer to the ITS plane efficicency
271 AliITStrackerMI(const AliITStrackerMI &tracker);
272 AliITStrackerMI & operator=(const AliITStrackerMI &tracker);
273 ClassDef(AliITStrackerMI,4) //ITS tracker MI
279 /////////////////////////////////////////////////////////
280 /////////////////////////////////////////////////////////
281 /////////////////////////////////////////////////////////
287 inline void AliITStrackerMI::SetupFirstPass(Int_t *flags, Double_t *cuts) {
288 // This function sets up flags and cuts for the first tracking pass
290 // flags[0] - vertex constaint flag
291 // negative means "skip the pass"
292 // 0 means "no constraint"
293 // positive means "normal constraint"
295 fConstraint[0]=flags[0];
299 inline void AliITStrackerMI::SetupSecondPass(Int_t *flags, Double_t *cuts) {
300 // This function sets up flags and cuts for the second tracking pass
302 // flags[0] - vertex constaint flag
303 // negative means "skip the pass"
304 // 0 means "no constraint"
305 // positive means "normal constraint"
307 fConstraint[1]=flags[0];
311 inline void AliITStrackerMI::CookLabel(AliKalmanTrack *t,Float_t wrong) const {
312 //--------------------------------------------------------------------
313 //This function "cooks" a track label. If label<0, this track is fake.
314 //--------------------------------------------------------------------
315 Int_t tpcLabel=t->GetLabel();
316 if (tpcLabel<0) return;
317 AliTracker::CookLabel(t,wrong);
318 if (tpcLabel!=TMath::Abs(t->GetLabel())){
321 if (tpcLabel !=t->GetLabel()) {
322 t->SetLabel(-tpcLabel);
326 inline Double_t AliITStrackerMI::NormalizedChi2(AliITStrackMI * track, Int_t layer)
328 //--------------------------------------------------------------------
330 //--------------------------------------------------------------------
331 track->SetNormChi2(layer,2.*track->GetNSkipped()+0.25*track->GetNDeadZone()+track->GetdEdxMismatch()+track->GetChi2()/
332 //track->fNormChi2[layer] = 2.*track->fNSkipped+0.25*track->fNDeadZone+track->fdEdxMismatch+track->fChi22/
333 TMath::Max(double(track->GetNumberOfClusters()-track->GetNSkipped()),
334 1./(1.+track->GetNSkipped())));
335 return track->GetNormChi2(layer);
337 inline void AliITStrackerMI::AliITSdetector::GetGlobalXYZ(const AliITSRecPoint *cl, Double_t xyz[3]) const
340 // get cluster coordinates in global cooordinate
343 xyz[0] = fR*fCosPhi - cl->GetY()*fSinPhi;
344 xyz[1] = fR*fSinPhi + cl->GetY()*fCosPhi;