Fix coding convention violation
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackParam.cxx
CommitLineData
a9e2aefa 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
88cb7938 16/* $Id$ */
a9e2aefa 17
3831f268 18///////////////////////////////////////////////////
19//
20// Track parameters
21// in
22// ALICE
23// dimuon
24// spectrometer
a9e2aefa 25//
3831f268 26///////////////////////////////////////////////////
a9e2aefa 27
70479d0e 28#include <Riostream.h>
a9e2aefa 29
30#include "AliCallf77.h"
3831f268 31#include "AliMUON.h"
a9e2aefa 32#include "AliMUONTrackParam.h"
3831f268 33#include "AliMUONChamber.h"
a9e2aefa 34#include "AliRun.h"
94de3818 35#include "AliMagF.h"
a9e2aefa 36
37ClassImp(AliMUONTrackParam) // Class implementation in ROOT context
38
a6f03ddb 39 // A few calls in Fortran or from Fortran (extrap.F).
40 // Needed, instead of calls to Geant subroutines,
41 // because double precision is necessary for track fit converging with Minuit.
42 // The "extrap" functions should be translated into C++ ????
a9e2aefa 43#ifndef WIN32
a6f03ddb 44# define extrap_onestep_helix extrap_onestep_helix_
45# define extrap_onestep_helix3 extrap_onestep_helix3_
46# define extrap_onestep_rungekutta extrap_onestep_rungekutta_
47# define gufld_double gufld_double_
a9e2aefa 48#else
a6f03ddb 49# define extrap_onestep_helix EXTRAP_ONESTEP_HELIX
50# define extrap_onestep_helix3 EXTRAP_ONESTEP_HELIX3
51# define extrap_onestep_rungekutta EXTRAP_ONESTEP_RUNGEKUTTA
52# define gufld_double GUFLD_DOUBLE
a9e2aefa 53#endif
54
a6f03ddb 55extern "C" {
56 void type_of_call extrap_onestep_helix
57 (Double_t &Charge, Double_t &StepLength, Double_t *VGeant3, Double_t *VGeant3New);
58
59 void type_of_call extrap_onestep_helix3
60 (Double_t &Field, Double_t &StepLength, Double_t *VGeant3, Double_t *VGeant3New);
61
62 void type_of_call extrap_onestep_rungekutta
63 (Double_t &Charge, Double_t &StepLength, Double_t *VGeant3, Double_t *VGeant3New);
64
65 void type_of_call gufld_double(Double_t *Position, Double_t *Field) {
66 // interface to "gAlice->Field()->Field" for arguments in double precision
67 Float_t x[3], b[3];
68 x[0] = Position[0]; x[1] = Position[1]; x[2] = Position[2];
69 gAlice->Field()->Field(x, b);
70 Field[0] = b[0]; Field[1] = b[1]; Field[2] = b[2];
71 }
a9e2aefa 72}
73
a9e2aefa 74 //__________________________________________________________________________
75void AliMUONTrackParam::ExtrapToZ(Double_t Z)
76{
77 // Track parameter extrapolation to the plane at "Z".
78 // On return, the track parameters resulting from the extrapolation
79 // replace the current track parameters.
a9e2aefa 80 if (this->fZ == Z) return; // nothing to be done if same Z
81 Double_t forwardBackward; // +1 if forward, -1 if backward
5b64e914 82 if (Z < this->fZ) forwardBackward = 1.0; // spectro. z<0
a9e2aefa 83 else forwardBackward = -1.0;
a6f03ddb 84 Double_t vGeant3[7], vGeant3New[7]; // 7 in parameter ????
a9e2aefa 85 Int_t iGeant3, stepNumber;
86 Int_t maxStepNumber = 5000; // in parameter ????
87 // For safety: return kTRUE or kFALSE ????
a6f03ddb 88 // Parameter vector for calling EXTRAP_ONESTEP
a9e2aefa 89 SetGeant3Parameters(vGeant3, forwardBackward);
956019b6 90 // sign of charge (sign of fInverseBendingMomentum if forward motion)
a6f03ddb 91 // must be changed if backward extrapolation
956019b6 92 Double_t chargeExtrap = forwardBackward *
93 TMath::Sign(Double_t(1.0), this->fInverseBendingMomentum);
a9e2aefa 94 Double_t stepLength = 6.0; // in parameter ????
95 // Extrapolation loop
96 stepNumber = 0;
5b64e914 97 while (((-forwardBackward * (vGeant3[2] - Z)) <= 0.0) && // spectro. z<0
a9e2aefa 98 (stepNumber < maxStepNumber)) {
99 stepNumber++;
a6f03ddb 100 // Option for switching between helix and Runge-Kutta ????
101 // extrap_onestep_rungekutta(chargeExtrap, stepLength, vGeant3, vGeant3New);
102 extrap_onestep_helix(chargeExtrap, stepLength, vGeant3, vGeant3New);
5b64e914 103 if ((-forwardBackward * (vGeant3New[2] - Z)) > 0.0) break; // one is beyond Z spectro. z<0
a9e2aefa 104 // better use TArray ????
105 for (iGeant3 = 0; iGeant3 < 7; iGeant3++)
106 {vGeant3[iGeant3] = vGeant3New[iGeant3];}
107 }
108 // check maxStepNumber ????
a9e2aefa 109 // Interpolation back to exact Z (2nd order)
110 // should be in function ???? using TArray ????
111 Double_t dZ12 = vGeant3New[2] - vGeant3[2]; // 1->2
112 Double_t dZ1i = Z - vGeant3[2]; // 1-i
113 Double_t dZi2 = vGeant3New[2] - Z; // i->2
114 Double_t xPrime = (vGeant3New[0] - vGeant3[0]) / dZ12;
115 Double_t xSecond =
116 ((vGeant3New[3] / vGeant3New[5]) - (vGeant3[3] / vGeant3[5])) / dZ12;
117 Double_t yPrime = (vGeant3New[1] - vGeant3[1]) / dZ12;
118 Double_t ySecond =
119 ((vGeant3New[4] / vGeant3New[5]) - (vGeant3[4] / vGeant3[5])) / dZ12;
120 vGeant3[0] = vGeant3[0] + xPrime * dZ1i - 0.5 * xSecond * dZ1i * dZi2; // X
121 vGeant3[1] = vGeant3[1] + yPrime * dZ1i - 0.5 * ySecond * dZ1i * dZi2; // Y
122 vGeant3[2] = Z; // Z
123 Double_t xPrimeI = xPrime - 0.5 * xSecond * (dZi2 - dZ1i);
124 Double_t yPrimeI = yPrime - 0.5 * ySecond * (dZi2 - dZ1i);
956019b6 125 // (PX, PY, PZ)/PTOT assuming forward motion
a9e2aefa 126 vGeant3[5] =
127 1.0 / TMath::Sqrt(1.0 + xPrimeI * xPrimeI + yPrimeI * yPrimeI); // PZ/PTOT
128 vGeant3[3] = xPrimeI * vGeant3[5]; // PX/PTOT
129 vGeant3[4] = yPrimeI * vGeant3[5]; // PY/PTOT
956019b6 130 // Track parameters from Geant3 parameters,
131 // with charge back for forward motion
132 GetFromGeant3Parameters(vGeant3, chargeExtrap * forwardBackward);
a9e2aefa 133}
134
135 //__________________________________________________________________________
136void AliMUONTrackParam::SetGeant3Parameters(Double_t *VGeant3, Double_t ForwardBackward)
137{
138 // Set vector of Geant3 parameters pointed to by "VGeant3"
139 // from track parameters in current AliMUONTrackParam.
140 // Since AliMUONTrackParam is only geometry, one uses "ForwardBackward"
141 // to know whether the particle is going forward (+1) or backward (-1).
142 VGeant3[0] = this->fNonBendingCoor; // X
143 VGeant3[1] = this->fBendingCoor; // Y
144 VGeant3[2] = this->fZ; // Z
145 Double_t pYZ = TMath::Abs(1.0 / this->fInverseBendingMomentum);
146 Double_t pZ =
147 pYZ / TMath::Sqrt(1.0 + this->fBendingSlope * this->fBendingSlope);
148 VGeant3[6] =
149 TMath::Sqrt(pYZ * pYZ +
150 pZ * pZ * this->fNonBendingSlope * this->fNonBendingSlope); // PTOT
5b64e914 151 VGeant3[5] = -ForwardBackward * pZ / VGeant3[6]; // PZ/PTOT spectro. z<0
a9e2aefa 152 VGeant3[3] = this->fNonBendingSlope * VGeant3[5]; // PX/PTOT
153 VGeant3[4] = this->fBendingSlope * VGeant3[5]; // PY/PTOT
154}
155
156 //__________________________________________________________________________
157void AliMUONTrackParam::GetFromGeant3Parameters(Double_t *VGeant3, Double_t Charge)
158{
159 // Get track parameters in current AliMUONTrackParam
956019b6 160 // from Geant3 parameters pointed to by "VGeant3",
161 // assumed to be calculated for forward motion in Z.
a9e2aefa 162 // "InverseBendingMomentum" is signed with "Charge".
163 this->fNonBendingCoor = VGeant3[0]; // X
164 this->fBendingCoor = VGeant3[1]; // Y
165 this->fZ = VGeant3[2]; // Z
166 Double_t pYZ = VGeant3[6] * TMath::Sqrt(1.0 - VGeant3[3] * VGeant3[3]);
167 this->fInverseBendingMomentum = Charge / pYZ;
168 this->fBendingSlope = VGeant3[4] / VGeant3[5];
169 this->fNonBendingSlope = VGeant3[3] / VGeant3[5];
170}
171
172 //__________________________________________________________________________
173void AliMUONTrackParam::ExtrapToStation(Int_t Station, AliMUONTrackParam *TrackParam)
174{
175 // Track parameters extrapolated from current track parameters ("this")
176 // to both chambers of the station(0..) "Station"
177 // are returned in the array (dimension 2) of track parameters
178 // pointed to by "TrackParam" (index 0 and 1 for first and second chambers).
179 Double_t extZ[2], z1, z2;
ecfa008b 180 Int_t i1 = -1, i2 = -1; // = -1 to avoid compilation warnings
a9e2aefa 181 AliMUON *pMUON = (AliMUON*) gAlice->GetModule("MUON"); // necessary ????
182 // range of Station to be checked ????
183 z1 = (&(pMUON->Chamber(2 * Station)))->Z(); // Z of first chamber
184 z2 = (&(pMUON->Chamber(2 * Station + 1)))->Z(); // Z of second chamber
185 // First and second Z to extrapolate at
186 if ((z1 > this->fZ) && (z2 > this->fZ)) {i1 = 0; i2 = 1;}
187 else if ((z1 < this->fZ) && (z2 < this->fZ)) {i1 = 1; i2 = 0;}
188 else {
189 cout << "ERROR in AliMUONTrackParam::CreateExtrapSegmentInStation" << endl;
190 cout << "Starting Z (" << this->fZ << ") in between z1 (" << z1 <<
191 ") and z2 (" << z2 << ") of station(0..) " << Station << endl;
192 }
193 extZ[i1] = z1;
194 extZ[i2] = z2;
195 // copy of track parameters
196 TrackParam[i1] = *this;
197 // first extrapolation
198 (&(TrackParam[i1]))->ExtrapToZ(extZ[0]);
199 TrackParam[i2] = TrackParam[i1];
200 // second extrapolation
201 (&(TrackParam[i2]))->ExtrapToZ(extZ[1]);
202 return;
203}
204
04b5ea16 205 //__________________________________________________________________________
206void AliMUONTrackParam::ExtrapToVertex()
207{
208 // Extrapolation to the vertex.
209 // Returns the track parameters resulting from the extrapolation,
210 // in the current TrackParam.
956019b6 211 // Changes parameters according to Branson correction through the absorber
04b5ea16 212
5b64e914 213 Double_t zAbsorber = -503.0; // to be coherent with the Geant absorber geometry !!!!
214 // spectro. (z<0)
04b5ea16 215 // Extrapolates track parameters upstream to the "Z" end of the front absorber
b45fd22b 216 ExtrapToZ(zAbsorber); // !!!
5b64e914 217 // Makes Branson correction (multiple scattering + energy loss)
04b5ea16 218 BransonCorrection();
5b64e914 219 // Makes a simple magnetic field correction through the absorber
b45fd22b 220 FieldCorrection(zAbsorber);
04b5ea16 221}
222
43af2cb6 223
224// Keep this version for future developments
04b5ea16 225 //__________________________________________________________________________
43af2cb6 226// void AliMUONTrackParam::BransonCorrection()
227// {
228// // Branson correction of track parameters
229// // the entry parameters have to be calculated at the end of the absorber
230// Double_t zEndAbsorber, zBP, xBP, yBP;
231// Double_t pYZ, pX, pY, pZ, pTotal, xEndAbsorber, yEndAbsorber, radiusEndAbsorber2, pT, theta;
232// Int_t sign;
233// // Would it be possible to calculate all that from Geant configuration ????
234// // and to get the Branson parameters from a function in ABSO module ????
235// // with an eventual contribution from other detectors like START ????
236// // Radiation lengths outer part theta > 3 degres
237// static Double_t x01[9] = { 18.8, // C (cm)
238// 10.397, // Concrete (cm)
239// 0.56, // Plomb (cm)
240// 47.26, // Polyethylene (cm)
241// 0.56, // Plomb (cm)
242// 47.26, // Polyethylene (cm)
243// 0.56, // Plomb (cm)
244// 47.26, // Polyethylene (cm)
245// 0.56 }; // Plomb (cm)
246// // inner part theta < 3 degres
247// static Double_t x02[3] = { 18.8, // C (cm)
248// 10.397, // Concrete (cm)
249// 0.35 }; // W (cm)
250// // z positions of the materials inside the absober outer part theta > 3 degres
251// static Double_t z1[10] = { 90, 315, 467, 472, 477, 482, 487, 492, 497, 502 };
252// // inner part theta < 3 degres
253// static Double_t z2[4] = { 90, 315, 467, 503 };
254// static Bool_t first = kTRUE;
255// static Double_t zBP1, zBP2, rLimit;
256// // Calculates z positions of the Branson's planes: zBP1 for outer part and zBP2 for inner part (only at the first call)
257// if (first) {
258// first = kFALSE;
259// Double_t aNBP = 0.0;
260// Double_t aDBP = 0.0;
261// Int_t iBound;
262
263// for (iBound = 0; iBound < 9; iBound++) {
264// aNBP = aNBP +
265// (z1[iBound+1] * z1[iBound+1] * z1[iBound+1] -
266// z1[iBound] * z1[iBound] * z1[iBound] ) / x01[iBound];
267// aDBP = aDBP +
268// (z1[iBound+1] * z1[iBound+1] - z1[iBound] * z1[iBound] ) / x01[iBound];
269// }
270// zBP1 = (2.0 * aNBP) / (3.0 * aDBP);
271// aNBP = 0.0;
272// aDBP = 0.0;
273// for (iBound = 0; iBound < 3; iBound++) {
274// aNBP = aNBP +
275// (z2[iBound+1] * z2[iBound+1] * z2[iBound+1] -
276// z2[iBound] * z2[iBound ] * z2[iBound] ) / x02[iBound];
277// aDBP = aDBP +
278// (z2[iBound+1] * z2[iBound+1] - z2[iBound] * z2[iBound]) / x02[iBound];
279// }
280// zBP2 = (2.0 * aNBP) / (3.0 * aDBP);
281// rLimit = z2[3] * TMath::Tan(3.0 * (TMath::Pi()) / 180.);
282// }
283
284// pYZ = TMath::Abs(1.0 / fInverseBendingMomentum);
285// sign = 1;
286// if (fInverseBendingMomentum < 0) sign = -1;
287// pZ = pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope));
288// pX = pZ * fNonBendingSlope;
289// pY = pZ * fBendingSlope;
290// pTotal = TMath::Sqrt(pYZ *pYZ + pX * pX);
291// xEndAbsorber = fNonBendingCoor;
292// yEndAbsorber = fBendingCoor;
293// radiusEndAbsorber2 = xEndAbsorber * xEndAbsorber + yEndAbsorber * yEndAbsorber;
294
295// if (radiusEndAbsorber2 > rLimit*rLimit) {
296// zEndAbsorber = z1[9];
297// zBP = zBP1;
298// } else {
299// zEndAbsorber = z2[3];
300// zBP = zBP2;
301// }
302
303// xBP = xEndAbsorber - (pX / pZ) * (zEndAbsorber - zBP);
304// yBP = yEndAbsorber - (pY / pZ) * (zEndAbsorber - zBP);
305
306// // new parameters after Branson and energy loss corrections
307// pZ = pTotal * zBP / TMath::Sqrt(xBP * xBP + yBP * yBP + zBP * zBP);
308// pX = pZ * xBP / zBP;
309// pY = pZ * yBP / zBP;
310// fBendingSlope = pY / pZ;
311// fNonBendingSlope = pX / pZ;
312
313// pT = TMath::Sqrt(pX * pX + pY * pY);
314// theta = TMath::ATan2(pT, pZ);
315// pTotal =
316// TotalMomentumEnergyLoss(rLimit, pTotal, theta, xEndAbsorber, yEndAbsorber);
317
318// fInverseBendingMomentum = (sign / pTotal) *
319// TMath::Sqrt(1.0 +
320// fBendingSlope * fBendingSlope +
321// fNonBendingSlope * fNonBendingSlope) /
322// TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope);
323
324// // vertex position at (0,0,0)
325// // should be taken from vertex measurement ???
326// fBendingCoor = 0.0;
327// fNonBendingCoor = 0;
328// fZ= 0;
329// }
330
04b5ea16 331void AliMUONTrackParam::BransonCorrection()
332{
333 // Branson correction of track parameters
334 // the entry parameters have to be calculated at the end of the absorber
43af2cb6 335 // simplified version: the z positions of Branson's planes are no longer calculated
336 // but are given as inputs. One can use the macros MUONTestAbso.C and DrawTestAbso.C
337 // to test this correction.
04b5ea16 338 // Would it be possible to calculate all that from Geant configuration ????
956019b6 339 // and to get the Branson parameters from a function in ABSO module ????
340 // with an eventual contribution from other detectors like START ????
43af2cb6 341 Double_t zBP, xBP, yBP;
342 Double_t pYZ, pX, pY, pZ, pTotal, xEndAbsorber, yEndAbsorber, radiusEndAbsorber2, pT, theta;
343 Int_t sign;
04b5ea16 344 static Bool_t first = kTRUE;
b45fd22b 345 static Double_t zBP1, zBP2, rLimit, thetaLimit, zEndAbsorber;
43af2cb6 346 // zBP1 for outer part and zBP2 for inner part (only at the first call)
04b5ea16 347 if (first) {
348 first = kFALSE;
43af2cb6 349
5b64e914 350 zEndAbsorber = -503; // spectro (z<0)
b45fd22b 351 thetaLimit = 3.0 * (TMath::Pi()) / 180.;
5b64e914 352 rLimit = TMath::Abs(zEndAbsorber) * TMath::Tan(thetaLimit);
353 zBP1 = -450; // values close to those calculated with EvalAbso.C
354 zBP2 = -480;
04b5ea16 355 }
356
357 pYZ = TMath::Abs(1.0 / fInverseBendingMomentum);
358 sign = 1;
359 if (fInverseBendingMomentum < 0) sign = -1;
5b64e914 360 pZ = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro (z<0)
04b5ea16 361 pX = pZ * fNonBendingSlope;
362 pY = pZ * fBendingSlope;
363 pTotal = TMath::Sqrt(pYZ *pYZ + pX * pX);
364 xEndAbsorber = fNonBendingCoor;
365 yEndAbsorber = fBendingCoor;
366 radiusEndAbsorber2 = xEndAbsorber * xEndAbsorber + yEndAbsorber * yEndAbsorber;
367
368 if (radiusEndAbsorber2 > rLimit*rLimit) {
04b5ea16 369 zBP = zBP1;
370 } else {
04b5ea16 371 zBP = zBP2;
372 }
373
374 xBP = xEndAbsorber - (pX / pZ) * (zEndAbsorber - zBP);
375 yBP = yEndAbsorber - (pY / pZ) * (zEndAbsorber - zBP);
376
377 // new parameters after Branson and energy loss corrections
b45fd22b 378// Float_t zSmear = zBP - gRandom->Gaus(0.,2.); // !!! possible smearing of Z vertex position
379 Float_t zSmear = zBP;
380
381 pZ = pTotal * zSmear / TMath::Sqrt(xBP * xBP + yBP * yBP + zSmear * zSmear);
382 pX = pZ * xBP / zSmear;
383 pY = pZ * yBP / zSmear;
04b5ea16 384 fBendingSlope = pY / pZ;
385 fNonBendingSlope = pX / pZ;
5b64e914 386
04b5ea16 387
388 pT = TMath::Sqrt(pX * pX + pY * pY);
5b64e914 389 theta = TMath::ATan2(pT, TMath::Abs(pZ));
b45fd22b 390 pTotal = TotalMomentumEnergyLoss(thetaLimit, pTotal, theta);
04b5ea16 391
392 fInverseBendingMomentum = (sign / pTotal) *
393 TMath::Sqrt(1.0 +
394 fBendingSlope * fBendingSlope +
395 fNonBendingSlope * fNonBendingSlope) /
396 TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope);
397
398 // vertex position at (0,0,0)
399 // should be taken from vertex measurement ???
400 fBendingCoor = 0.0;
401 fNonBendingCoor = 0;
402 fZ= 0;
403}
b45fd22b 404
04b5ea16 405 //__________________________________________________________________________
b45fd22b 406Double_t AliMUONTrackParam::TotalMomentumEnergyLoss(Double_t thetaLimit, Double_t pTotal, Double_t theta)
04b5ea16 407{
408 // Returns the total momentum corrected from energy loss in the front absorber
43af2cb6 409 // One can use the macros MUONTestAbso.C and DrawTestAbso.C
410 // to test this correction.
b45fd22b 411 // Momentum energy loss behaviour evaluated with the simulation of single muons (april 2002)
04b5ea16 412 Double_t deltaP, pTotalCorrected;
413
b45fd22b 414 // Parametrization to be redone according to change of absorber material ????
956019b6 415 // See remark in function BransonCorrection !!!!
04b5ea16 416 // The name is not so good, and there are many arguments !!!!
b45fd22b 417 if (theta < thetaLimit ) {
418 if (pTotal < 20) {
419 deltaP = 2.5938 + 0.0570 * pTotal - 0.001151 * pTotal * pTotal;
04b5ea16 420 } else {
b45fd22b 421 deltaP = 3.0714 + 0.011767 *pTotal;
04b5ea16 422 }
423 } else {
b45fd22b 424 if (pTotal < 20) {
425 deltaP = 2.1207 + 0.05478 * pTotal - 0.00145079 * pTotal * pTotal;
04b5ea16 426 } else {
b45fd22b 427 deltaP = 2.6069 + 0.0051705 * pTotal;
04b5ea16 428 }
429 }
430 pTotalCorrected = pTotal + deltaP / TMath::Cos(theta);
431 return pTotalCorrected;
432}
433
b45fd22b 434 //__________________________________________________________________________
435void AliMUONTrackParam::FieldCorrection(Double_t Z)
436{
437 //
438 // Correction of the effect of the magnetic field in the absorber
439 // Assume a constant field along Z axis.
440
441 Float_t b[3],x[3];
442 Double_t bZ;
443 Double_t pYZ,pX,pY,pZ,pT;
444 Double_t pXNew,pYNew;
445 Double_t c;
446
447 pYZ = TMath::Abs(1.0 / fInverseBendingMomentum);
448 c = TMath::Sign(1.0,fInverseBendingMomentum); // particle charge
449
5b64e914 450 pZ = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro. (z<0)
b45fd22b 451 pX = pZ * fNonBendingSlope;
452 pY = pZ * fBendingSlope;
453 pT = TMath::Sqrt(pX*pX+pY*pY);
454
5b64e914 455 if (TMath::Abs(pZ) <= 0) return;
b45fd22b 456 x[2] = Z/2;
457 x[0] = x[2]*fNonBendingSlope;
458 x[1] = x[2]*fBendingSlope;
459
460 // Take magn. field value at position x.
461 gAlice->Field()->Field(x, b);
462 bZ = b[2];
463
464 // Transverse momentum rotation
465 // Parameterized with the study of DeltaPhi = phiReco - phiGen as a function of pZ.
5b64e914 466 Double_t phiShift = c*0.436*0.0003*bZ*Z/pZ;
b45fd22b 467 // Rotate momentum around Z axis.
468 pXNew = pX*TMath::Cos(phiShift) - pY*TMath::Sin(phiShift);
469 pYNew = pX*TMath::Sin(phiShift) + pY*TMath::Cos(phiShift);
470
471 fBendingSlope = pYNew / pZ;
472 fNonBendingSlope = pXNew / pZ;
473
474 fInverseBendingMomentum = c / TMath::Sqrt(pYNew*pYNew+pZ*pZ);
475
476}