]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITStrackV2.h
Bug fix concerning multiple found tracks (F. Prino)
[u/mrichter/AliRoot.git] / ITS / AliITStrackV2.h
1 #ifndef ALIITSTRACKV2_H
2 #define ALIITSTRACKV2_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 //-------------------------------------------------------------------------
7 //                       ITS Track Class
8 //
9 //        Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch 
10 //     dEdx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch
11 //-------------------------------------------------------------------------
12
13 #include <AliKalmanTrack.h>
14 #include "AliITSRecoParam.h"
15 #include "AliITSgeomTGeo.h"
16
17 /* $Id$ */
18
19 class AliESDtrack;
20 class AliESDVertex;
21 class AliTracker;
22
23 //_____________________________________________________________________________
24 class AliITStrackV2 : public AliKalmanTrack {
25 public:
26   AliITStrackV2();
27   AliITStrackV2(AliESDtrack& t,Bool_t c=kFALSE) throw (const Char_t *);
28   AliITStrackV2(const AliITStrackV2& t);
29   ~AliITStrackV2(){fESDtrack=0;}
30
31   Bool_t CorrectForMeanMaterial(Double_t xOverX0, Double_t xTimesRho,
32                                 Bool_t anglecorr=kFALSE) {
33     return AliExternalTrackParam::CorrectForMeanMaterial(xOverX0,xTimesRho,GetMass(),anglecorr);
34   }
35   Bool_t CorrectForMaterial(Double_t d, Double_t x0=AliITSRecoParam::GetX0Air()) {
36     // deprecated: use CorrectForMeanMaterial instead
37     return AliExternalTrackParam::CorrectForMaterial(d,x0,GetMass());
38   }
39   Bool_t PropagateTo(Double_t xr, Double_t d, Double_t x0=AliITSRecoParam::GetX0Air());
40   Bool_t PropagateToTGeo(Double_t xToGo, Int_t nstep, Double_t &xOverX0, Double_t &xTimesRho, Bool_t addTime=kTRUE);
41   Bool_t PropagateToTGeo(Double_t xToGo, Int_t nstep=1, Bool_t addTime=kTRUE) {
42     Double_t dummy1,dummy2; return PropagateToTGeo(xToGo,nstep,dummy1,dummy2,addTime);
43   }
44   Double_t GetPredictedChi2(const AliCluster *cluster) const;
45   Bool_t Update(const AliCluster *cl, Double_t chi2, Int_t i);
46
47   Bool_t PropagateToVertex(const AliESDVertex *v,Double_t d=0.,Double_t x0=0.);
48   Bool_t Propagate(Double_t alpha, Double_t xr);
49   Bool_t Propagate(Double_t xr) { return Propagate(GetAlpha(),xr); }
50   Bool_t MeanBudgetToPrimVertex(Double_t xyz[3], Double_t step, Double_t &d) const;
51   Bool_t Improve(Double_t x0,Double_t xyz[3],Double_t ers[3]);
52
53   void SetdEdx(Double_t dedx) {fdEdx=dedx;}
54   void SetSampledEdx(Float_t q, Int_t i);
55   Float_t GetSampledEdx(Int_t i) const {return fdEdxSample[i];}
56   void CookdEdx(Double_t low=0., Double_t up=0.51);
57   void SetDetectorIndex(Int_t i) {SetLabel(i);}
58   void ResetClusters();
59   void UpdateESDtrack(ULong_t flags) const;
60   
61   AliESDtrack *GetESDtrack() const {return fESDtrack;}
62
63   Int_t GetDetectorIndex() const {return GetLabel();}
64   Double_t GetdEdx() const {return fdEdx;}
65   Double_t GetPIDsignal() const {return GetdEdx();}
66   using AliExternalTrackParam::GetC;
67   Double_t GetC() const {return AliExternalTrackParam::GetC(GetBz());}
68   Double_t GetD(Double_t x, Double_t y) const {
69     return AliExternalTrackParam::GetD(x,y,GetBz());
70   }
71   void GetDZ(Double_t xv, Double_t yv, Double_t zv, Float_t dz[2]) const {
72     return AliExternalTrackParam::GetDZ(xv,yv,zv,GetBz(),dz);
73   }
74
75   Bool_t GetGlobalXYZat(Double_t xloc,Double_t &x,Double_t &y,Double_t &z) const;
76   Bool_t GetPhiZat(Double_t r,Double_t &phi,Double_t &z) const;
77   Bool_t GetLocalXat(Double_t r,Double_t &xloc) const;
78
79   Int_t Compare(const TObject *o) const;
80   Int_t GetClusterIndex(Int_t i) const {return fIndex[i];}
81   void  SetModuleIndex(Int_t ilayer,Int_t idx) {fModule[ilayer]=idx;}
82   Int_t GetModuleIndex(Int_t ilayer) const {return fModule[ilayer];}
83   void  SetModuleIndexInfo(Int_t ilayer,Int_t idet,Int_t status=1,Float_t xloc=0,Float_t zloc=0);
84   Bool_t GetModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,Float_t &xloc,Float_t &zloc) const;
85   Bool_t Invariant() const;
86
87   void  SetExtraCluster(Int_t ilayer, Int_t idx) {fIndex[AliITSgeomTGeo::kNLayers+ilayer]=idx;}
88   Int_t GetExtraCluster(Int_t ilayer) const {return fIndex[AliITSgeomTGeo::kNLayers+ilayer];}
89
90   void  SetExtraModule(Int_t ilayer, Int_t idx) {fModule[AliITSgeomTGeo::kNLayers+ilayer]=idx;}
91   Int_t GetExtraModule(Int_t ilayer) const {return fModule[AliITSgeomTGeo::kNLayers+ilayer];}
92
93 protected:
94   Double_t fdEdx;            // dE/dx
95
96   static const Int_t fgkWARN; //! used for debugging purposes
97   Float_t fdEdxSample[4];    // array of dE/dx samples b.b.
98
99   Int_t fIndex[2*AliITSgeomTGeo::kNLayers]; // indices of associated clusters 
100
101   Int_t fModule[2*AliITSgeomTGeo::kNLayers]; // indices of crossed modules: 
102                                              // see SetModuleIndexInfo()
103   AliESDtrack *fESDtrack;    //! pointer to the connected ESD track
104
105 private:
106   AliITStrackV2 &operator=(const AliITStrackV2 &tr);
107   ClassDef(AliITStrackV2,7)  //ITS reconstructed track
108 };
109
110 inline void AliITStrackV2::SetSampledEdx(Float_t q, Int_t i) {
111   //----------------------------------------------------------------------
112   // This function stores dEdx sample corrected for the track segment length 
113   // Origin: Boris Batyunya, JINR, Boris.Batiounia@cern.ch
114   //----------------------------------------------------------------------
115   if (i<0) return;
116   if (i>3) return;
117   Double_t s=GetSnp(), t=GetTgl();
118   q *= TMath::Sqrt((1-s*s)/(1+t*t));
119   fdEdxSample[i]=q;
120   return;
121 }
122
123 inline void  AliITStrackV2::SetModuleIndexInfo(Int_t ilayer,Int_t idet,Int_t status,
124                                                Float_t xloc,Float_t zloc) {
125   //----------------------------------------------------------------------
126   // This function encodes in the module number also the status of cluster association
127   // "status" can have the following values: 
128   // 1 "found" (cluster is associated), 
129   // 2 "dead" (module is dead from OCDB), 
130   // 3 "skipped" (module or layer forced to be skipped),
131   // 4 "outinz" (track out of z acceptance), 
132   // 5 "nocls" (no clusters in the road), 
133   // 6 "norefit" (cluster rejected during refit) 
134   // 7 "deadzspd" (holes in z in SPD)
135   // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliESDtrack::GetITSModuleIndexInfo()!
136   //----------------------------------------------------------------------
137
138   if(idet<0) {
139     idet=0;
140   } else {
141     // same detector numbering as in AliITSCalib classes
142     if(ilayer==1) idet+=AliITSgeomTGeo::GetNLadders(1)*AliITSgeomTGeo::GetNDetectors(1);
143     if(ilayer==3) idet+=AliITSgeomTGeo::GetNLadders(3)*AliITSgeomTGeo::GetNDetectors(3);
144     if(ilayer==5) idet+=AliITSgeomTGeo::GetNLadders(5)*AliITSgeomTGeo::GetNDetectors(5);
145   }
146
147   Int_t xInt = Int_t(xloc*10.);
148   Int_t zInt = Int_t(zloc*10.);
149
150   if(TMath::Abs(xloc*10.-(Float_t)xInt)>0.5){
151     if(zloc>0) { 
152       xInt++; 
153     } 
154     else { 
155       xInt--; 
156     }
157   }
158   if(TMath::Abs(zloc*10.-(Float_t)zInt)>0.5){
159     if(zloc>0) { 
160       zInt++; 
161     } 
162     else { 
163       zInt--; 
164     }
165   }
166   Int_t signs=0;
167   if(xInt>=0 && zInt>=0) signs=10000;
168   if(xInt>=0 && zInt<0)  signs=20000;
169   if(xInt<0 && zInt>=0)  signs=30000;
170   if(xInt<0 && zInt<0)   signs=40000;
171
172   Int_t modindex = signs;
173   
174   modindex += TMath::Abs(zInt);
175   modindex += TMath::Abs(xInt)*100;
176
177   modindex += status*100000;
178
179   modindex += idet*1000000;
180
181   SetModuleIndex(ilayer,modindex);
182   return;
183 }
184
185 inline Bool_t AliITStrackV2::GetModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
186                                                Float_t &xloc,Float_t &zloc) const {
187   //----------------------------------------------------------------------
188   // This function encodes in the module number also the status of cluster association
189   // "status" can have the following values: 
190   // 1 "found" (cluster is associated), 
191   // 2 "dead" (module is dead from OCDB), 
192   // 3 "skipped" (module or layer forced to be skipped),
193   // 4 "outinz" (track out of z acceptance), 
194   // 5 "nocls" (no clusters in the road), 
195   // 6 "norefit" (cluster rejected during refit), 
196   // 7 "deadzspd" (holes in z in SPD)
197   // Also given are the coordinates of the crossing point of track and module
198   // (in the local module ref. system)
199   // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliESDtrack::GetITSModuleIndexInfo()!
200   //----------------------------------------------------------------------
201
202
203   if(fModule[ilayer]==-1) {
204     AliError("fModule was not set !");
205     idet = -1;
206     status=0;
207     xloc=-99.; zloc=-99.;
208     return kFALSE;
209   }
210
211   Int_t module = fModule[ilayer];
212
213   idet = Int_t(module/1000000);
214
215   module -= idet*1000000;
216
217   status = Int_t(module/100000);
218
219   module -= status*100000;
220
221   Int_t signs = Int_t(module/10000);
222
223   module-=signs*10000;
224
225   Int_t xInt = Int_t(module/100);
226   module -= xInt*100;
227
228   Int_t zInt = module;
229
230   if(signs==1) { xInt*=1; zInt*=1; }
231   if(signs==2) { xInt*=1; zInt*=-1; }
232   if(signs==3) { xInt*=-1; zInt*=1; }
233   if(signs==4) { xInt*=-1; zInt*=-1; }
234
235   xloc = 0.1*(Float_t)xInt;
236   zloc = 0.1*(Float_t)zInt;
237
238   if(status==4) idet = -1;
239
240   return kTRUE;
241 }
242
243
244 #endif
245
246