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 // Current support and development:
13 // Andrea Dainese, andrea.dainese@lnl.infn.it
14 //-------------------------------------------------------------------------
17 class TTreeSRedirector;
21 class AliITSChannelStatus;
22 class AliITSDetTypeRec;
25 #include <TObjArray.h>
27 #include "AliITStrackMI.h"
28 #include "AliITSRecPoint.h"
29 #include "AliTracker.h"
32 //-------------------------------------------------------------------------
33 class AliITStrackerMI : public AliTracker {
36 AliITStrackerMI(const Char_t *geom);
37 virtual ~AliITStrackerMI();
38 AliCluster *GetCluster(Int_t index) const;
39 virtual Bool_t GetTrackPoint(Int_t index, AliTrackPoint& p) const;
40 virtual Bool_t GetTrackPointTrackingError(Int_t index,
41 AliTrackPoint& p, const AliESDtrack *t);
42 AliITSRecPoint *GetClusterLayer(Int_t layn, Int_t ncl) const
43 {return fgLayers[layn].GetCluster(ncl);}
44 Int_t GetNumberOfClustersLayer(Int_t layn) const
45 {return fgLayers[layn].GetNumberOfClusters();}
46 Int_t LoadClusters(TTree *cf);
47 void UnloadClusters();
48 void FillClusterArray(TObjArray* array) const;
49 Int_t Clusters2Tracks(AliESDEvent *event);
50 Int_t PropagateBack(AliESDEvent *event);
51 Int_t RefitInward(AliESDEvent *event);
52 Bool_t RefitAt(Double_t x, AliITStrackMI *track,
53 const AliITStrackMI *clusters, Bool_t extra=kFALSE, Bool_t planeeff=kFALSE);
54 Bool_t RefitAt(Double_t x, AliITStrackMI *track,
55 const Int_t *clusters, Bool_t extra=kFALSE, Bool_t planeeff=kFALSE);
56 void SetupFirstPass(const Int_t *flags,const Double_t *cuts=0);
57 void SetupSecondPass(const Int_t *flags,const Double_t *cuts=0);
59 void SetLastLayerToTrackTo(Int_t l=0) {fLastLayerToTrackTo=l;}
60 void SetLayersNotToSkip(const Int_t *l);
61 void UseClusters(const AliKalmanTrack *t, Int_t from=0) const;
63 void GetDCASigma(const AliITStrackMI* track, Float_t & sigmarfi, Float_t &sigmaz);
64 Double_t GetPredictedChi2MI(AliITStrackMI* track, const AliITSRecPoint *cluster,Int_t layer);
65 Int_t UpdateMI(AliITStrackMI* track, const AliITSRecPoint* cl,Double_t chi2,Int_t layer) const;
66 AliPlaneEff *GetPlaneEff() {return (AliPlaneEff*)fPlaneEff;} // return the pointer to AliPlaneEff
67 void SetDetTypeRec(const AliITSDetTypeRec *detTypeRec) {fkDetTypeRec = detTypeRec; ReadBadFromDetTypeRec(); }
69 class AliITSdetector {
71 AliITSdetector():fR(0),fRmisal(0),fPhi(0),fSinPhi(0),fCosPhi(0),fYmin(0),fYmax(0),fZmin(0),fZmax(0),fIsBad(kFALSE),fNChips(0),fChipIsBad(0) {}
72 AliITSdetector(Double_t r,Double_t phi):fR(r),fRmisal(r),fPhi(phi),fSinPhi(TMath::Sin(phi)),fCosPhi(TMath::Cos(phi)),fYmin(10000),fYmax(-1000),fZmin(10000),fZmax(-1000),fIsBad(kFALSE),fNChips(0),fChipIsBad(0) {}
73 ~AliITSdetector() {if(fChipIsBad) delete [] fChipIsBad;}
74 inline void GetGlobalXYZ( const AliITSRecPoint *cl, Double_t xyz[3]) const;
75 Double_t GetR() const {return fR;}
76 Double_t GetRmisal() const {return fRmisal;}
77 Double_t GetPhi() const {return fPhi;}
78 Double_t GetYmin() const {return fYmin;}
79 Double_t GetYmax() const {return fYmax;}
80 Double_t GetZmin() const {return fZmin;}
81 Double_t GetZmax() const {return fZmax;}
82 Bool_t IsBad() const {return fIsBad;}
83 Int_t GetNChips() const {return fNChips;}
84 Bool_t IsChipBad(Int_t iChip) const {return (fChipIsBad ? fChipIsBad[iChip] : kFALSE);}
85 void SetRmisal(Double_t rmisal) {fRmisal = rmisal;}
86 void SetYmin(Double_t min) {fYmin = min;}
87 void SetYmax(Double_t max) {fYmax = max;}
88 void SetZmin(Double_t min) {fZmin = min;}
89 void SetZmax(Double_t max) {fZmax = max;}
90 void SetBad() {fIsBad = kTRUE;}
91 void ReadBadDetectorAndChips(Int_t ilayer,Int_t idet,const AliITSDetTypeRec *detTypeRec);
93 AliITSdetector(const AliITSdetector& det);
94 AliITSdetector & operator=(const AliITSdetector& det){
95 this->~AliITSdetector();new(this) AliITSdetector(det);
97 Double_t fR; // polar coordinates: r
98 Double_t fRmisal; // polar coordinates: r, with misalignment
99 Double_t fPhi; // polar coordinates: phi
100 Double_t fSinPhi; // sin of phi;
101 Double_t fCosPhi; // cos of phi
102 Double_t fYmin; // local y minimal
103 Double_t fYmax; // local max y
104 Double_t fZmin; // local z min
105 Double_t fZmax; // local z max
106 Bool_t fIsBad; // is detector dead or noisy?
107 Int_t fNChips; // number of chips
108 Bool_t *fChipIsBad; //[fNChips] is chip dead or noisy?
114 AliITSlayer(Double_t r, Double_t p, Double_t z, Int_t nl, Int_t nd);
116 Int_t InsertCluster(AliITSRecPoint *c);
118 void ResetClusters();
120 void SelectClusters(Double_t zmin,Double_t zmax,Double_t ymin,Double_t ymax);
121 const AliITSRecPoint *GetNextCluster(Int_t &ci,Bool_t test=kFALSE);
123 Double_t GetRoad() const {return fRoad;}
124 Double_t GetR() const {return fR;}
125 Int_t FindClusterIndex(Float_t z) const;
126 AliITSRecPoint *GetCluster(Int_t i) const {return i<fN? fClusters[i]:0;}
127 Float_t *GetWeight(Int_t i) {return i<fN ?&fClusterWeight[i]:0;}
128 AliITSdetector &GetDetector(Int_t n) const { return fDetectors[n]; }
129 Int_t FindDetectorIndex(Double_t phi, Double_t z) const;
130 Double_t GetThickness(Double_t y, Double_t z, Double_t &x0) const;
131 Int_t InRoad() const ;
132 Int_t GetNumberOfClusters() const {return fN;}
133 Int_t GetNladders() const {return fNladders;}
134 Int_t GetNdetectors() const {return fNdetectors;}
135 Int_t GetSkip() const {return fSkip;}
136 void SetSkip(Int_t skip){fSkip=skip;}
137 void IncAccepted(){fAccepted++;}
138 Int_t GetAccepted() const {return fAccepted;}
139 Int_t GetClusterTracks(Int_t i, Int_t j) const {return fClusterTracks[i][j];}
140 void SetClusterTracks(Int_t i, Int_t j, Int_t c) {fClusterTracks[i][j]=c;}
142 AliITSlayer(const AliITSlayer& layer);
143 AliITSlayer & operator=(const AliITSlayer& layer){
144 this->~AliITSlayer();new(this) AliITSlayer(layer);
146 Double_t fR; // mean radius of this layer
147 Double_t fPhiOffset; // offset of the first detector in Phi
148 Int_t fNladders; // number of ladders
149 Double_t fZOffset; // offset of the first detector in Z
150 Int_t fNdetectors; // detectors/ladder
151 AliITSdetector *fDetectors; // array of detectors
152 Int_t fN; // number of clusters
153 AliITSRecPoint *fClusters[AliITSRecoParam::fgkMaxClusterPerLayer]; // pointers to clusters
154 Int_t fClusterIndex[AliITSRecoParam::fgkMaxClusterPerLayer]; // pointers to clusters
155 Float_t fY[AliITSRecoParam::fgkMaxClusterPerLayer]; // y position of the clusters
156 Float_t fZ[AliITSRecoParam::fgkMaxClusterPerLayer]; // z position of the clusters
157 Float_t fYB[2]; // ymin and ymax
159 AliITSRecPoint *fClusters5[6][AliITSRecoParam::fgkMaxClusterPerLayer5]; // pointers to clusters - slice in y
160 Int_t fClusterIndex5[6][AliITSRecoParam::fgkMaxClusterPerLayer5]; // pointers to clusters - slice in y
161 Float_t fY5[6][AliITSRecoParam::fgkMaxClusterPerLayer5]; // y position of the clusters slice in y
162 Float_t fZ5[6][AliITSRecoParam::fgkMaxClusterPerLayer5]; // z position of the clusters slice in y
163 Int_t fN5[6]; // number of cluster in slice
164 Float_t fDy5; //delta y
165 Float_t fBy5[6][2]; //slice borders
167 AliITSRecPoint *fClusters10[11][AliITSRecoParam::fgkMaxClusterPerLayer10]; // pointers to clusters - slice in y
168 Int_t fClusterIndex10[11][AliITSRecoParam::fgkMaxClusterPerLayer10]; // pointers to clusters - slice in y
169 Float_t fY10[11][AliITSRecoParam::fgkMaxClusterPerLayer10]; // y position of the clusters slice in y
170 Float_t fZ10[11][AliITSRecoParam::fgkMaxClusterPerLayer10]; // z position of the clusters slice in y
171 Int_t fN10[11]; // number of cluster in slice
172 Float_t fDy10; // delta y
173 Float_t fBy10[11][2]; // slice borders
175 AliITSRecPoint *fClusters20[21][AliITSRecoParam::fgkMaxClusterPerLayer20]; // pointers to clusters - slice in y
176 Int_t fClusterIndex20[21][AliITSRecoParam::fgkMaxClusterPerLayer20]; // pointers to clusters - slice in y
177 Float_t fY20[21][AliITSRecoParam::fgkMaxClusterPerLayer20]; // y position of the clusters slice in y
178 Float_t fZ20[21][AliITSRecoParam::fgkMaxClusterPerLayer20]; // z position of the clusters slice in y
179 Int_t fN20[21]; // number of cluster in slice
180 Float_t fDy20; //delta y
181 Float_t fBy20[21][2]; //slice borders
183 AliITSRecPoint** fClustersCs; //clusters table in current slice
184 Int_t *fClusterIndexCs; //cluster index in current slice
185 Float_t *fYcs; //y position in current slice
186 Float_t *fZcs; //z position in current slice
187 Int_t fNcs; //number of clusters in current slice
188 Int_t fCurrentSlice; //current slice
190 Float_t fClusterWeight[AliITSRecoParam::fgkMaxClusterPerLayer]; // probabilistic weight of the cluster
191 Int_t fClusterTracks[4][AliITSRecoParam::fgkMaxClusterPerLayer]; //tracks registered to given cluster
192 Float_t fZmax; // edges
193 Float_t fYmin; // of the
194 Float_t fYmax; // "window"
195 Int_t fI; // index of the current cluster within the "window"
196 Int_t fImax; // index of the last cluster within the "window"
197 Int_t fSkip; // indicates possibility to skip cluster
198 Int_t fAccepted; // accept indicator
199 Double_t fRoad; // road defined by the cluster density
201 AliITStrackerMI::AliITSlayer & GetLayer(Int_t layer) const;
202 AliITStrackerMI::AliITSdetector & GetDetector(Int_t layer, Int_t n) const {return GetLayer(layer).GetDetector(n); }
205 Bool_t ComputeRoad(AliITStrackMI* track,Int_t ilayer,Int_t idet,Double_t &zmin,Double_t &zmax,Double_t &ymin,Double_t &ymax) const;
206 Int_t GetNearestLayer(const Double_t *xr) const; //get nearest upper layer close to the point xr
207 void FindV02(AliESDEvent *event); //try to find V0
208 void RefitV02(const AliESDEvent *event); //try to refit V0's
209 void UpdateTPCV0(const AliESDEvent *event); //try to update, or reject TPC V0s
210 void CookLabel(AliKalmanTrack *t,Float_t wrong) const;
211 void CookLabel(AliITStrackMI *t,Float_t wrong) const;
212 Double_t GetEffectiveThickness();
213 void FollowProlongationTree(AliITStrackMI * otrack, Int_t esdindex, Bool_t constrain);
214 void ResetBestTrack() {
215 fBestTrack.~AliITStrackMI();
216 new(&fBestTrack) AliITStrackMI(fTrackToFollow);
218 void ResetTrackToFollow(const AliITStrackMI &t) {
219 fTrackToFollow.~AliITStrackMI();
220 new(&fTrackToFollow) AliITStrackMI(t);
222 void CookdEdx(AliITStrackMI* track);
223 Double_t GetNormalizedChi2(AliITStrackMI * track, Int_t mode);
224 Double_t GetTruncatedChi2(const AliITStrackMI * track, Float_t fac);
225 Double_t NormalizedChi2(AliITStrackMI * track, Int_t layer);
226 Double_t GetInterpolatedChi2(const AliITStrackMI * forwardtrack,const AliITStrackMI * backtrack);
227 Double_t GetMatchingChi2(const AliITStrackMI * track1,const AliITStrackMI * track2);
228 Double_t GetSPDDeadZoneProbability(Double_t zpos, Double_t zerr) const;
230 Float_t *GetWeight(Int_t index);
231 void AddTrackHypothesys(AliITStrackMI * track, Int_t esdindex);
232 void SortTrackHypothesys(Int_t esdindex, Int_t maxcut, Int_t mode);
233 AliITStrackMI * GetBestHypothesys(Int_t esdindex, AliITStrackMI * original, Int_t checkmax);
234 void GetBestHypothesysMIP(TObjArray &itsTracks);
235 void RegisterClusterTracks(const AliITStrackMI* track, Int_t id);
236 void UnRegisterClusterTracks(const AliITStrackMI* track, Int_t id);
237 Float_t GetNumberOfSharedClusters(AliITStrackMI* track,Int_t id, Int_t list[6], AliITSRecPoint *clist[6]);
238 Int_t GetOverlapTrack(const AliITStrackMI *track, Int_t trackID, Int_t &shared, Int_t clusterlist[6], Int_t overlist[6]);
239 AliITStrackMI * GetBest2Tracks(Int_t trackID1, Int_t treackID2, Float_t th0, Float_t th1);
240 Float_t * GetErrY(Int_t trackindex) const {return &fCoefficients[trackindex*48];}
241 Float_t * GetErrZ(Int_t trackindex) const {return &fCoefficients[trackindex*48+12];}
242 Float_t * GetNy(Int_t trackindex) const {return &fCoefficients[trackindex*48+24];}
243 Float_t * GetNz(Int_t trackindex) const {return &fCoefficients[trackindex*48+36];}
244 void SignDeltas(const TObjArray *clusterArray, Float_t zv);
245 void MakeCoefficients(Int_t ntracks);
246 void BuildMaterialLUT(TString material);
247 void MakeTrksMaterialLUT(Int_t ntracks);
248 void DeleteTrksMaterialLUT();
249 Int_t CorrectForPipeMaterial(AliITStrackMI *t, TString direction="inward");
250 Int_t CorrectForShieldMaterial(AliITStrackMI *t, TString shield, TString direction="inward");
251 Int_t CorrectForLayerMaterial(AliITStrackMI *t, Int_t layerindex, Double_t oldGlobXYZ[3], TString direction="inward");
252 void UpdateESDtrack(AliITStrackMI* track, ULong_t flags) const;
253 void ReadBadFromDetTypeRec();
254 Int_t CheckSkipLayer(const AliITStrackMI *track,Int_t ilayer,Int_t idet) const;
255 Int_t CheckDeadZone(AliITStrackMI *track,Int_t ilayer,Int_t idet,Double_t dz,Double_t dy,Bool_t noClusters=kFALSE) const;
256 Bool_t LocalModuleCoord(Int_t ilayer,Int_t idet,const AliITStrackMI *track,
257 Float_t &xloc,Float_t &zloc) const;
258 // method to be used for Plane Efficiency evaluation
259 Bool_t IsOKForPlaneEff(const AliITStrackMI* track, const Int_t *clusters, Int_t ilayer) const; // Check if a track is usable
260 // for Plane Eff evaluation
261 void UseTrackForPlaneEff(const AliITStrackMI* track, Int_t ilayer); // Use this track for Plane Eff
263 Int_t fI; // index of the current layer
264 static AliITSlayer fgLayers[AliITSgeomTGeo::kNLayers];// ITS layers
265 AliITStrackMI fTracks[AliITSgeomTGeo::kNLayers]; // track estimations at the ITS layers
266 AliITStrackMI fBestTrack; // "best" track
267 AliITStrackMI fTrackToFollow; // followed track
268 TObjArray fTrackHypothesys; // ! array with track hypothesys- ARRAY is the owner of tracks- MI
269 TObjArray fBestHypothesys; // ! array with track hypothesys- ARRAY is the owner of tracks- MI
270 TObjArray fOriginal; // ! array with seeds from the TPC
271 Int_t fBestTrackIndex[100000]; // ! index of the best track
272 Int_t fCurrentEsdTrack; // ! current esd track - MI
273 Int_t fPass; // current pass through the data
274 Int_t fConstraint[2]; // constraint flags
275 Bool_t fAfterV0; //indicates V0 founded
276 Int_t fLayersNotToSkip[AliITSgeomTGeo::kNLayers]; // layer masks
277 Int_t fLastLayerToTrackTo; // the innermost layer to track to
278 Float_t * fCoefficients; //! working array with errors and mean cluster shape
279 AliESDEvent * fEsd; //! pointer to the ESD event
280 Double_t fSPDdetzcentre[4]; // centres of SPD modules in z
281 TString fTrackingPhase; // current tracking phase
282 Int_t fUseTGeo; // use TGeo to get material budget
283 Int_t fNtracks; // number of tracks to prolong
284 Float_t fxOverX0Pipe; // material budget
285 Float_t fxTimesRhoPipe; // material budget
286 Float_t fxOverX0Shield[2]; // material budget
287 Float_t fxTimesRhoShield[2]; // material budget
288 Float_t fxOverX0Layer[6]; // material budget
289 Float_t fxTimesRhoLayer[6]; // material budget
290 Float_t *fxOverX0PipeTrks; //! material budget
291 Float_t *fxTimesRhoPipeTrks; //! material budget
292 Float_t *fxOverX0ShieldTrks; //! material budget
293 Float_t *fxTimesRhoShieldTrks; //! material budget
294 Float_t *fxOverX0LayerTrks; //! material budget
295 Float_t *fxTimesRhoLayerTrks; //! material budget
296 TTreeSRedirector *fDebugStreamer; //!debug streamer
297 AliITSChannelStatus *fITSChannelStatus;//! bitmaps with channel status for SPD and SDD
298 const AliITSDetTypeRec *fkDetTypeRec; //! ITS det type rec, from AliITSReconstructor
299 AliITSPlaneEff *fPlaneEff; //! Pointer to the ITS plane efficicency
301 AliITStrackerMI(const AliITStrackerMI &tracker);
302 AliITStrackerMI & operator=(const AliITStrackerMI &tracker);
303 ClassDef(AliITStrackerMI,7) //ITS tracker MI
309 /////////////////////////////////////////////////////////
310 /////////////////////////////////////////////////////////
311 /////////////////////////////////////////////////////////
317 inline void AliITStrackerMI::SetupFirstPass(const Int_t *flags,const Double_t *cuts) {
318 // This function sets up flags and cuts for the first tracking pass
320 // flags[0] - vertex constaint flag
321 // negative means "skip the pass"
322 // 0 means "no constraint"
323 // positive means "normal constraint"
325 fConstraint[0]=flags[0];
329 inline void AliITStrackerMI::SetupSecondPass(const Int_t *flags,const Double_t *cuts) {
330 // This function sets up flags and cuts for the second tracking pass
332 // flags[0] - vertex constaint flag
333 // negative means "skip the pass"
334 // 0 means "no constraint"
335 // positive means "normal constraint"
337 fConstraint[1]=flags[0];
341 inline void AliITStrackerMI::CookLabel(AliKalmanTrack *t,Float_t wrong) const {
342 //--------------------------------------------------------------------
343 //This function "cooks" a track label. If label<0, this track is fake.
344 //--------------------------------------------------------------------
345 Int_t tpcLabel=t->GetLabel();
346 if (tpcLabel<0) return;
347 AliTracker::CookLabel(t,wrong);
348 if (tpcLabel!=TMath::Abs(t->GetLabel())){
351 if (tpcLabel !=t->GetLabel()) {
352 t->SetLabel(-tpcLabel);
356 inline Double_t AliITStrackerMI::NormalizedChi2(AliITStrackMI * track, Int_t layer)
358 //--------------------------------------------------------------------
360 //--------------------------------------------------------------------
361 track->SetNormChi2(layer,2.*track->GetNSkipped()+0.25*track->GetNDeadZone()+track->GetdEdxMismatch()+track->GetChi2()/
362 //track->fNormChi2[layer] = 2.*track->fNSkipped+0.25*track->fNDeadZone+track->fdEdxMismatch+track->fChi22/
363 TMath::Max(double(track->GetNumberOfClusters()-track->GetNSkipped()),
364 1./(1.+track->GetNSkipped())));
365 return track->GetNormChi2(layer);
367 inline void AliITStrackerMI::AliITSdetector::GetGlobalXYZ(const AliITSRecPoint *cl, Double_t xyz[3]) const
370 // get cluster coordinates in global cooordinate
373 xyz[0] = fR*fCosPhi - cl->GetY()*fSinPhi;
374 xyz[1] = fR*fSinPhi + cl->GetY()*fCosPhi;