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