Line data Source code
1 : #ifndef ALIEXTERNALTRACKPARAM_H
2 : #define ALIEXTERNALTRACKPARAM_H
3 : /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 : * See cxx source for full Copyright notice */
5 :
6 : /* $Id$ */
7 :
8 : /*****************************************************************************
9 : * "External" track parametrisation class *
10 : * *
11 : * external param0: local Y-coordinate of a track (cm) *
12 : * external param1: local Z-coordinate of a track (cm) *
13 : * external param2: local sine of the track momentum azimuthal angle *
14 : * external param3: tangent of the track momentum dip angle *
15 : * external param4: 1/pt (1/(GeV/c)) *
16 : * *
17 : * The parameters are estimated at an exact position x in a local coord. *
18 : * system rotated by angle alpha with respect to the global coord.system. *
19 : * Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch *
20 : *****************************************************************************/
21 : #include "TMath.h"
22 :
23 : #include "AliVTrack.h"
24 : #include "AliVMisc.h"
25 : const Double_t kVeryBig=1./kAlmost0;
26 : const Double_t kMostProbablePt=0.35;
27 :
28 : class AliVVertex;
29 : class TPolyMarker3D;
30 :
31 : const Double_t kC0max=100*100, // SigmaY<=100cm
32 : kC2max=100*100, // SigmaZ<=100cm
33 : kC5max=1*1, // SigmaSin<=1
34 : kC9max=1*1, // SigmaTan<=1
35 : kC14max=100*100; // Sigma1/Pt<=100 1/GeV
36 :
37 : class AliExternalTrackParam: public AliVTrack {
38 : public:
39 : AliExternalTrackParam();
40 : AliExternalTrackParam(const AliExternalTrackParam &);
41 : AliExternalTrackParam& operator=(const AliExternalTrackParam & trkPar);
42 : AliExternalTrackParam(Double_t x, Double_t alpha,
43 : const Double_t param[5], const Double_t covar[15]);
44 : AliExternalTrackParam(Double_t xyz[3],Double_t pxpypz[3],
45 : Double_t cv[21],Short_t sign);
46 : // constructor for reinitialisation of vtable
47 0 : AliExternalTrackParam( AliVConstructorReinitialisationFlag f) :AliVTrack(f), fX(), fAlpha(){}
48 0 : void Reinitialize() { new (this) AliExternalTrackParam( AliVReinitialize ); }
49 :
50 159456 : virtual ~AliExternalTrackParam(){}
51 : void CopyFromVTrack(const AliVTrack *vTrack);
52 :
53 : template <typename T>
54 : void Set(T x, T alpha, const T param[5], const T covar[15]) {
55 : // Sets the parameters
56 9554 : if (alpha < -TMath::Pi()) alpha += 2*TMath::Pi();
57 5041 : else if (alpha >= TMath::Pi()) alpha -= 2*TMath::Pi();
58 4777 : fX=x; fAlpha=alpha;
59 57324 : for (Int_t i = 0; i < 5; i++) fP[i] = param[i];
60 152864 : for (Int_t i = 0; i < 15; i++) fC[i] = covar[i];
61 :
62 4777 : CheckCovariance();
63 :
64 4777 : }
65 :
66 : void SetParamOnly(double x, double alpha, const double param[5]) {
67 : // Sets the parameters, neglect cov matrix
68 0 : if (alpha < -TMath::Pi()) alpha += 2*TMath::Pi();
69 0 : else if (alpha >= TMath::Pi()) alpha -= 2*TMath::Pi();
70 0 : fX=x; fAlpha=alpha;
71 0 : for (Int_t i = 0; i < 5; i++) fP[i] = param[i];
72 0 : }
73 :
74 : void Set(Double_t xyz[3],Double_t pxpypz[3],Double_t cv[21],Short_t sign);
75 :
76 16 : static void SetMostProbablePt(Double_t pt) { fgMostProbablePt=pt; }
77 1436 : static Double_t GetMostProbablePt() { return fgMostProbablePt; }
78 :
79 : void Reset();
80 : void ResetCovariance(Double_t s2);
81 : void AddCovariance(const Double_t cov[15]);
82 :
83 907792 : const Double_t *GetParameter() const {return fP;}
84 1154832 : const Double_t *GetCovariance() const {return fC;}
85 0 : virtual Bool_t IsStartedTimeIntegral() const {return kFALSE;}
86 0 : virtual void AddTimeStep(Double_t ) {} // dummy method, real stuff is done in AliKalmanTrack
87 481674 : Double_t GetAlpha() const {return fAlpha;}
88 3078316 : Double_t GetX() const {return fX;}
89 2573934 : Double_t GetY() const {return fP[0];}
90 2824224 : Double_t GetZ() const {return fP[1];}
91 2162438 : Double_t GetSnp() const {return fP[2];}
92 3258024 : virtual Double_t GetTgl() const {return fP[3];}
93 : using AliVTrack::GetImpactParameters;
94 0 : virtual void GetImpactParameters(Float_t& ,Float_t&) const {}
95 45972 : Double_t GetSigned1Pt() const {return fP[4];}
96 :
97 362368 : Double_t GetSigmaY2() const {return fC[0];}
98 32528 : Double_t GetSigmaZY() const {return fC[1];}
99 364032 : Double_t GetSigmaZ2() const {return fC[2];}
100 4568 : Double_t GetSigmaSnpY() const {return fC[3];}
101 4568 : Double_t GetSigmaSnpZ() const {return fC[4];}
102 4640 : Double_t GetSigmaSnp2() const {return fC[5];}
103 4568 : Double_t GetSigmaTglY() const {return fC[6];}
104 4568 : Double_t GetSigmaTglZ() const {return fC[7];}
105 4568 : Double_t GetSigmaTglSnp() const {return fC[8];}
106 4640 : Double_t GetSigmaTgl2() const {return fC[9];}
107 4568 : Double_t GetSigma1PtY() const {return fC[10];}
108 4568 : Double_t GetSigma1PtZ() const {return fC[11];}
109 4568 : Double_t GetSigma1PtSnp() const {return fC[12];}
110 4568 : Double_t GetSigma1PtTgl() const {return fC[13];}
111 7056 : Double_t GetSigma1Pt2() const {return fC[14];}
112 :
113 : // additional functions for AliVParticle
114 : Double_t Px() const;
115 : Double_t Py() const;
116 0 : Double_t Pz() const { return Pt()*GetTgl(); }
117 53316 : Double_t Pt() const { return TMath::Abs(GetSignedPt()); }
118 376 : Double_t P() const { return GetP(); }
119 224 : Bool_t PxPyPz(Double_t p[3]) const { return GetPxPyPz(p); }
120 :
121 : Double_t Xv() const;
122 : Double_t Yv() const;
123 0 : Double_t Zv() const {return GetZ();}
124 0 : Bool_t XvYvZv(Double_t x[3]) const { return GetXYZ(x); }
125 :
126 45988 : Double_t OneOverPt() const { return 1./Pt(); }
127 : Double_t Phi() const;
128 : Double_t PhiPos() const;
129 : Double_t Theta() const;
130 : virtual Double_t E() const;
131 : virtual Double_t M() const;
132 : Double_t Eta() const;
133 : virtual Double_t Y() const;
134 3836 : virtual Short_t Charge() const { return (Short_t)GetSign(); }
135 0 : virtual const Double_t *PID() const { return 0x0; }
136 :
137 : // additional functions from AliVTrack
138 0 : virtual Int_t GetID() const { return -999; }
139 0 : virtual UChar_t GetITSClusterMap() const {return 0; }
140 0 : virtual ULong_t GetStatus() const { return 0; }
141 :
142 1192878 : Double_t GetSign() const {return (fP[4]>0) ? 1 : -1;}
143 : Double_t GetP() const;
144 : Double_t GetSignedPt() const {
145 106872 : return (TMath::Abs(fP[4])>kAlmost0) ? 1./fP[4]:TMath::Sign(kVeryBig,fP[4]);
146 : }
147 : Double_t Get1P() const;
148 1678818 : virtual Double_t GetC(Double_t b) const {return fP[4]*b*kB2C;}
149 : void GetDZ(Double_t x,Double_t y,Double_t z,Double_t b,Float_t dz[2]) const;
150 : Double_t GetD(Double_t xv, Double_t yv, Double_t b) const;
151 : Double_t GetLinearD(Double_t xv, Double_t yv) const;
152 :
153 : Bool_t CorrectForMeanMaterial(Double_t xOverX0, Double_t xTimesRho,
154 : Double_t mass, Bool_t anglecorr=kFALSE,
155 : Double_t (*f)(Double_t)=AliExternalTrackParam::BetheBlochSolid);
156 :
157 : Bool_t CorrectForMeanMaterialdEdx(Double_t xOverX0, Double_t xTimesRho,
158 : Double_t mass, Double_t dEdx, Bool_t anglecorr=kFALSE);
159 :
160 : Bool_t CorrectForMeanMaterialZA(Double_t xOverX0, Double_t xTimesRho,
161 : Double_t mass,
162 : Double_t zOverA=0.49848,
163 : Double_t density=2.33,
164 : Double_t exEnergy=173e-9,
165 : Double_t jp1=0.20,
166 : Double_t jp2=3.00,
167 : Bool_t anglecorr=kFALSE
168 : );
169 :
170 : //
171 : // Bethe-Bloch formula parameterizations
172 : //
173 : static Double_t BetheBlochAleph(Double_t bg,
174 : Double_t kp1=0.76176e-1,
175 : Double_t kp2=10.632,
176 : Double_t kp3=0.13279e-4,
177 : Double_t kp4=1.8631,
178 : Double_t kp5=1.9479
179 : );
180 : static Double_t BetheBlochGeant(Double_t bg,
181 : Double_t kp0=2.33,
182 : Double_t kp1=0.20,
183 : Double_t kp2=3.00,
184 : Double_t kp3=173e-9,
185 : Double_t kp4=0.49848
186 : );
187 :
188 : static Double_t BetheBlochSolid(Double_t bg);
189 : static Double_t BetheBlochGas(Double_t bg);
190 :
191 : Double_t GetPredictedChi2(const Double_t p[2],const Double_t cov[3]) const;
192 :
193 : Double_t
194 : GetPredictedChi2(const Double_t p[3],const Double_t covyz[3],const Double_t covxyz[3]) const;
195 :
196 : Double_t GetPredictedChi2(const AliExternalTrackParam *t) const;
197 :
198 : Bool_t
199 : PropagateTo(Double_t p[3],Double_t covyz[3],Double_t covxyz[3],Double_t b);
200 :
201 : Double_t *GetResiduals(Double_t *p,Double_t *cov,Bool_t updated=kTRUE) const;
202 : Bool_t Update(const Double_t p[2],const Double_t cov[3]);
203 : Bool_t Rotate(Double_t alpha);
204 : Bool_t RotateParamOnly(Double_t alpha);
205 : Bool_t Invert();
206 : Bool_t PropagateTo(Double_t x, Double_t b);
207 : Bool_t PropagateParamOnlyTo(Double_t xk, Double_t b);
208 : Bool_t Propagate(Double_t alpha, Double_t x, Double_t b);
209 : Bool_t PropagateBxByBz(Double_t alpha, Double_t x, Double_t b[3]);
210 : Bool_t PropagateParamOnlyBxByBzTo(Double_t xk, const Double_t b[3]);
211 : void Propagate(Double_t len,Double_t x[3],Double_t p[3],Double_t bz) const;
212 : Bool_t Intersect(Double_t pnt[3], Double_t norm[3], Double_t bz) const;
213 :
214 : static void g3helx3(Double_t qfield, Double_t step, Double_t vect[7]);
215 : Bool_t PropagateToBxByBz(Double_t x, const Double_t b[3]);
216 :
217 : void GetHelixParameters(Double_t h[6], Double_t b) const;
218 : Double_t GetDCA(const AliExternalTrackParam *p, Double_t b,
219 : Double_t &xthis,Double_t &xp) const;
220 : Double_t PropagateToDCA(AliExternalTrackParam *p, Double_t b);
221 : Bool_t PropagateToDCA(const AliVVertex *vtx, Double_t b, Double_t maxd,
222 : Double_t dz[2]=0, Double_t cov[3]=0);
223 : Bool_t PropagateToDCABxByBz(const AliVVertex *vtx, Double_t b[3],
224 : Double_t maxd, Double_t dz[2]=0, Double_t cov[3]=0);
225 : Bool_t ConstrainToVertex(const AliVVertex* vtx, Double_t b[3]);
226 :
227 : void GetDirection(Double_t d[3]) const;
228 : Bool_t GetPxPyPz(Double_t *p) const;
229 : Bool_t GetXYZ(Double_t *p) const;
230 : Bool_t GetCovarianceXYZPxPyPz(Double_t cv[21]) const;
231 : Bool_t GetPxPyPzAt(Double_t x, Double_t b, Double_t p[3]) const;
232 : Bool_t GetXYZAt(Double_t x, Double_t b, Double_t r[3]) const;
233 : Double_t GetParameterAtRadius(Double_t r, Double_t bz, Int_t parType) const;
234 :
235 : Bool_t GetYAt(Double_t x, Double_t b, Double_t &y) const;
236 : Bool_t GetZAt(Double_t x, Double_t b, Double_t &z) const;
237 0 : Double_t GetYAtFast(Double_t x, Double_t b) const {double y=0; return GetYAt(x,b,y) ? y : -99999;}
238 0 : Double_t GetZAtFast(Double_t x, Double_t b) const {double z=0; return GetZAt(x,b,z) ? z : -99999;}
239 : Bool_t GetYZAt(Double_t x, Double_t b, Double_t *yz) const;
240 : void Print(Option_t* option = "") const;
241 : Double_t GetSnpAt(Double_t x,Double_t b) const;
242 : Bool_t GetXatLabR(Double_t r,Double_t &x, Double_t bz, Int_t dir=0) const;
243 : Bool_t GetXYZatR(Double_t xr,Double_t bz, Double_t *xyz=0, Double_t* alpSect=0) const;
244 :
245 : //Deprecated
246 : Bool_t CorrectForMaterial(Double_t d, Double_t x0, Double_t mass,
247 : Double_t (*f)(Double_t)=AliExternalTrackParam::BetheBlochSolid);
248 :
249 : Bool_t GetDistance(AliExternalTrackParam *param2, Double_t x, Double_t dist[3], Double_t b);
250 : static Int_t GetIndex(Int_t i, Int_t j);
251 0 : Int_t GetLabel() const {return -1;}
252 0 : Int_t PdgCode() const {return 0;}
253 :
254 : //
255 : // visualization (M. Ivanov)
256 : //
257 : virtual void FillPolymarker(TPolyMarker3D *pol, Float_t magf, Float_t minR, Float_t maxR, Float_t stepR);
258 : virtual void DrawTrack(Float_t magF, Float_t minR, Float_t maxR, Float_t stepR);
259 :
260 : virtual Bool_t Translate(Double_t *vTrasl,Double_t *covV);
261 :
262 : void CheckCovariance();
263 :
264 401784 : static Bool_t GetUseLogTermMS() {return fgUseLogTermMS;}
265 0 : static void SetUseLogTermMS(Bool_t v=kTRUE) {fgUseLogTermMS = v;}
266 :
267 : //---------------------------------------------------------------------------
268 : //--the calibration interface--
269 : //--to be used in online calibration/QA
270 : //--should also be implemented in ESD so it works offline as well
271 : //-----------
272 0 : virtual Int_t GetTrackParam ( AliExternalTrackParam & ) const {return 0;}
273 0 : virtual Int_t GetTrackParamRefitted ( AliExternalTrackParam & ) const {return 0;}
274 0 : virtual Int_t GetTrackParamIp ( AliExternalTrackParam & ) const {return 0;}
275 0 : virtual Int_t GetTrackParamTPCInner ( AliExternalTrackParam & ) const {return 0;}
276 0 : virtual Int_t GetTrackParamOp ( AliExternalTrackParam & ) const {return 0;}
277 0 : virtual Int_t GetTrackParamCp ( AliExternalTrackParam & ) const {return 0;}
278 0 : virtual Int_t GetTrackParamITSOut ( AliExternalTrackParam & ) const {return 0;}
279 :
280 : protected:
281 : AliExternalTrackParam(const AliVTrack *vTrack);
282 :
283 : /* protected: */
284 : private:
285 : Double_t &Par(Int_t i) {return fP[i];}
286 : Double_t &Cov(Int_t i) {return fC[i];}
287 : protected:
288 : Double32_t fX; // X coordinate for the point of parametrisation
289 : Double32_t fAlpha; // Local <-->global coor.system rotation angle
290 : Double32_t fP[5]; // The track parameters
291 : Double32_t fC[15]; // The track parameter covariance matrix
292 :
293 : static Double32_t fgMostProbablePt; // "Most probable" pt
294 : // (to be used if Bz=0)
295 : static Bool_t fgUseLogTermMS; // use log term in Mult.Stattering evaluation
296 5994 : ClassDef(AliExternalTrackParam, 8)
297 : };
298 :
299 : inline void AliExternalTrackParam::ResetCovariance(Double_t s2) {
300 : //
301 : // Reset the covarince matrix to "something big"
302 : //
303 :
304 3412 : s2 = TMath::Abs(s2);
305 1706 : Double_t fC0=fC[0]*s2,
306 1706 : fC2=fC[2]*s2,
307 1706 : fC5=fC[5]*s2,
308 1706 : fC9=fC[9]*s2,
309 1706 : fC14=fC[14]*s2;
310 :
311 1708 : if (fC0>kC0max) fC0 = kC0max;
312 1706 : if (fC2>kC2max) fC2 = kC2max;
313 1710 : if (fC5>kC5max) fC5 = kC5max;
314 1706 : if (fC9>kC9max) fC9 = kC9max;
315 1708 : if (fC14>kC14max) fC14 = kC14max;
316 :
317 :
318 1706 : fC[0] = fC0;
319 1706 : fC[1] = 0.; fC[2] = fC2;
320 1706 : fC[3] = 0.; fC[4] = 0.; fC[5] = fC5;
321 1706 : fC[6] = 0.; fC[7] = 0.; fC[8] = 0.; fC[9] = fC9;
322 1706 : fC[10]= 0.; fC[11]= 0.; fC[12]= 0.; fC[13]= 0.; fC[14] = fC14;
323 1706 : }
324 :
325 :
326 :
327 :
328 : #endif
|