1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////
29 ///////////////////////////////////////////////////
31 #include <Riostream.h>
33 #include "AliMUONTrackExtrap.h"
34 #include "AliMUONTrackParam.h"
35 #include "AliMUONConstants.h"
38 #include "AliTracker.h"
40 ClassImp(AliMUONTrackExtrap) // Class implementation in ROOT context
42 const AliMagF* AliMUONTrackExtrap::fgkField = 0x0;
44 //__________________________________________________________________________
45 void AliMUONTrackExtrap::ExtrapToZ(AliMUONTrackParam* trackParam, Double_t zEnd)
47 /// Track parameter extrapolation to the plane at "Z".
48 /// On return, the track parameters resulting from the extrapolation are updated in trackParam.
49 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same Z
50 Double_t forwardBackward; // +1 if forward, -1 if backward
51 if (zEnd < trackParam->GetZ()) forwardBackward = 1.0; // spectro. z<0
52 else forwardBackward = -1.0;
53 Double_t vGeant3[7], vGeant3New[7]; // 7 in parameter ????
54 Int_t iGeant3, stepNumber;
55 Int_t maxStepNumber = 5000; // in parameter ????
56 // For safety: return kTRUE or kFALSE ????
57 // Parameter vector for calling EXTRAP_ONESTEP
58 SetGeant3ParametersFromTrackParam(trackParam, vGeant3, forwardBackward);
59 // sign of charge (sign of fInverseBendingMomentum if forward motion)
60 // must be changed if backward extrapolation
61 Double_t chargeExtrap = forwardBackward *
62 TMath::Sign(Double_t(1.0), trackParam->GetInverseBendingMomentum());
63 Double_t stepLength = 6.0; // in parameter ????
66 while (((-forwardBackward * (vGeant3[2] - zEnd)) <= 0.0) && // spectro. z<0
67 (stepNumber < maxStepNumber)) {
69 // Option for switching between helix and Runge-Kutta ????
70 //ExtrapOneStepRungekutta(chargeExtrap, stepLength, vGeant3, vGeant3New);
71 ExtrapOneStepHelix(chargeExtrap, stepLength, vGeant3, vGeant3New);
72 if ((-forwardBackward * (vGeant3New[2] - zEnd)) > 0.0) break; // one is beyond Z spectro. z<0
73 // better use TArray ????
74 for (iGeant3 = 0; iGeant3 < 7; iGeant3++)
75 {vGeant3[iGeant3] = vGeant3New[iGeant3];}
77 // check maxStepNumber ????
78 // Interpolation back to exact Z (2nd order)
79 // should be in function ???? using TArray ????
80 Double_t dZ12 = vGeant3New[2] - vGeant3[2]; // 1->2
81 if (TMath::Abs(dZ12) > 0) {
82 Double_t dZ1i = zEnd - vGeant3[2]; // 1-i
83 Double_t dZi2 = vGeant3New[2] - zEnd; // i->2
84 Double_t xPrime = (vGeant3New[0] - vGeant3[0]) / dZ12;
85 Double_t xSecond = ((vGeant3New[3] / vGeant3New[5]) - (vGeant3[3] / vGeant3[5])) / dZ12;
86 Double_t yPrime = (vGeant3New[1] - vGeant3[1]) / dZ12;
87 Double_t ySecond = ((vGeant3New[4] / vGeant3New[5]) - (vGeant3[4] / vGeant3[5])) / dZ12;
88 vGeant3[0] = vGeant3[0] + xPrime * dZ1i - 0.5 * xSecond * dZ1i * dZi2; // X
89 vGeant3[1] = vGeant3[1] + yPrime * dZ1i - 0.5 * ySecond * dZ1i * dZi2; // Y
90 vGeant3[2] = zEnd; // Z
91 Double_t xPrimeI = xPrime - 0.5 * xSecond * (dZi2 - dZ1i);
92 Double_t yPrimeI = yPrime - 0.5 * ySecond * (dZi2 - dZ1i);
93 // (PX, PY, PZ)/PTOT assuming forward motion
95 1.0 / TMath::Sqrt(1.0 + xPrimeI * xPrimeI + yPrimeI * yPrimeI); // PZ/PTOT
96 vGeant3[3] = xPrimeI * vGeant3[5]; // PX/PTOT
97 vGeant3[4] = yPrimeI * vGeant3[5]; // PY/PTOT
99 cout<<"W-AliMUONTrackExtrap::ExtrapToZ: Extrap. to Z not reached, Z = "<<zEnd<<endl;
101 // Track parameters from Geant3 parameters,
102 // with charge back for forward motion
103 SetTrackParamFromGeant3Parameters(vGeant3, chargeExtrap * forwardBackward, trackParam);
106 //__________________________________________________________________________
107 void AliMUONTrackExtrap::SetGeant3ParametersFromTrackParam(AliMUONTrackParam* trackParam, Double_t *vGeant3, Double_t forwardBackward)
109 /// Set vector of Geant3 parameters pointed to by "vGeant3" from track parameters in trackParam.
110 /// Since AliMUONTrackParam is only geometry, one uses "forwardBackward"
111 /// to know whether the particle is going forward (+1) or backward (-1).
112 vGeant3[0] = trackParam->GetNonBendingCoor(); // X
113 vGeant3[1] = trackParam->GetBendingCoor(); // Y
114 vGeant3[2] = trackParam->GetZ(); // Z
115 Double_t pYZ = TMath::Abs(1.0 / trackParam->GetInverseBendingMomentum());
116 Double_t pZ = pYZ / TMath::Sqrt(1.0 + trackParam->GetBendingSlope() * trackParam->GetBendingSlope());
117 vGeant3[6] = TMath::Sqrt(pYZ * pYZ + pZ * pZ * trackParam->GetNonBendingSlope() * trackParam->GetNonBendingSlope()); // PTOT
118 vGeant3[5] = -forwardBackward * pZ / vGeant3[6]; // PZ/PTOT spectro. z<0
119 vGeant3[3] = trackParam->GetNonBendingSlope() * vGeant3[5]; // PX/PTOT
120 vGeant3[4] = trackParam->GetBendingSlope() * vGeant3[5]; // PY/PTOT
123 //__________________________________________________________________________
124 void AliMUONTrackExtrap::SetTrackParamFromGeant3Parameters(Double_t *vGeant3, Double_t charge, AliMUONTrackParam* trackParam)
126 /// Set track parameters in trackParam from Geant3 parameters pointed to by "vGeant3",
127 /// assumed to be calculated for forward motion in Z.
128 /// "InverseBendingMomentum" is signed with "charge".
129 trackParam->SetNonBendingCoor(vGeant3[0]); // X
130 trackParam->SetBendingCoor(vGeant3[1]); // Y
131 trackParam->SetZ(vGeant3[2]); // Z
132 Double_t pYZ = vGeant3[6] * TMath::Sqrt(1.0 - vGeant3[3] * vGeant3[3]);
133 trackParam->SetInverseBendingMomentum(charge/pYZ);
134 trackParam->SetBendingSlope(vGeant3[4]/vGeant3[5]);
135 trackParam->SetNonBendingSlope(vGeant3[3]/vGeant3[5]);
138 //__________________________________________________________________________
139 void AliMUONTrackExtrap::ExtrapToStation(AliMUONTrackParam* trackParamIn, Int_t station, AliMUONTrackParam *trackParamOut)
141 /// Track parameters extrapolated from "trackParamIn" to both chambers of the station(0..) "station"
142 /// are returned in the array (dimension 2) of track parameters pointed to by "TrackParamOut"
143 /// (index 0 and 1 for first and second chambers).
144 Double_t extZ[2], z1, z2;
145 Int_t i1 = -1, i2 = -1; // = -1 to avoid compilation warnings
146 // range of station to be checked ????
147 z1 = AliMUONConstants::DefaultChamberZ(2 * station);
148 z2 = AliMUONConstants::DefaultChamberZ(2 * station + 1);
149 // First and second Z to extrapolate at
150 if ((z1 > trackParamIn->GetZ()) && (z2 > trackParamIn->GetZ())) {i1 = 0; i2 = 1;}
151 else if ((z1 < trackParamIn->GetZ()) && (z2 < trackParamIn->GetZ())) {i1 = 1; i2 = 0;}
153 cout<<"E-AliMUONTrackExtrap::ExtrapToStationAliError: Starting Z ("<<trackParamIn->GetZ()
154 <<") in between z1 ("<<z1<<") and z2 ("<<z2<<") of station(0..)"<<station<<endl;
159 // copy of track parameters
160 trackParamOut[i1] = *trackParamIn;
161 // first extrapolation
162 ExtrapToZ(&(trackParamOut[i1]),extZ[0]);
163 trackParamOut[i2] = trackParamOut[i1];
164 // second extrapolation
165 ExtrapToZ(&(trackParamOut[i2]),extZ[1]);
169 //__________________________________________________________________________
170 void AliMUONTrackExtrap::ExtrapToVertex(AliMUONTrackParam* trackParam, Double_t xVtx, Double_t yVtx, Double_t zVtx)
172 /// Extrapolation to the vertex.
173 /// Returns the track parameters resulting from the extrapolation in the current TrackParam.
174 /// Changes parameters according to Branson correction through the absorber
176 Double_t zAbsorber = -503.0; // to be coherent with the Geant absorber geometry !!!!
178 // Extrapolates track parameters upstream to the "Z" end of the front absorber
179 ExtrapToZ(trackParam,zAbsorber); // !!!
180 // Makes Branson correction (multiple scattering + energy loss)
181 BransonCorrection(trackParam,xVtx,yVtx,zVtx);
182 // Makes a simple magnetic field correction through the absorber
183 FieldCorrection(trackParam,zAbsorber);
187 // Keep this version for future developments
188 //__________________________________________________________________________
189 // void AliMUONTrackExtrap::BransonCorrection(AliMUONTrackParam* trackParam)
191 // /// Branson correction of track parameters
192 // // the entry parameters have to be calculated at the end of the absorber
193 // Double_t zEndAbsorber, zBP, xBP, yBP;
194 // Double_t pYZ, pX, pY, pZ, pTotal, xEndAbsorber, yEndAbsorber, radiusEndAbsorber2, pT, theta;
196 // // Would it be possible to calculate all that from Geant configuration ????
197 // // and to get the Branson parameters from a function in ABSO module ????
198 // // with an eventual contribution from other detectors like START ????
199 // // Radiation lengths outer part theta > 3 degres
200 // static Double_t x01[9] = { 18.8, // C (cm)
201 // 10.397, // Concrete (cm)
202 // 0.56, // Plomb (cm)
203 // 47.26, // Polyethylene (cm)
204 // 0.56, // Plomb (cm)
205 // 47.26, // Polyethylene (cm)
206 // 0.56, // Plomb (cm)
207 // 47.26, // Polyethylene (cm)
208 // 0.56 }; // Plomb (cm)
209 // // inner part theta < 3 degres
210 // static Double_t x02[3] = { 18.8, // C (cm)
211 // 10.397, // Concrete (cm)
213 // // z positions of the materials inside the absober outer part theta > 3 degres
214 // static Double_t z1[10] = { 90, 315, 467, 472, 477, 482, 487, 492, 497, 502 };
215 // // inner part theta < 3 degres
216 // static Double_t z2[4] = { 90, 315, 467, 503 };
217 // static Bool_t first = kTRUE;
218 // static Double_t zBP1, zBP2, rLimit;
219 // // Calculates z positions of the Branson's planes: zBP1 for outer part and zBP2 for inner part (only at the first call)
222 // Double_t aNBP = 0.0;
223 // Double_t aDBP = 0.0;
226 // for (iBound = 0; iBound < 9; iBound++) {
228 // (z1[iBound+1] * z1[iBound+1] * z1[iBound+1] -
229 // z1[iBound] * z1[iBound] * z1[iBound] ) / x01[iBound];
231 // (z1[iBound+1] * z1[iBound+1] - z1[iBound] * z1[iBound] ) / x01[iBound];
233 // zBP1 = (2.0 * aNBP) / (3.0 * aDBP);
236 // for (iBound = 0; iBound < 3; iBound++) {
238 // (z2[iBound+1] * z2[iBound+1] * z2[iBound+1] -
239 // z2[iBound] * z2[iBound ] * z2[iBound] ) / x02[iBound];
241 // (z2[iBound+1] * z2[iBound+1] - z2[iBound] * z2[iBound]) / x02[iBound];
243 // zBP2 = (2.0 * aNBP) / (3.0 * aDBP);
244 // rLimit = z2[3] * TMath::Tan(3.0 * (TMath::Pi()) / 180.);
247 // pYZ = TMath::Abs(1.0 / trackParam->GetInverseBendingMomentum());
249 // if (trackParam->GetInverseBendingMomentum() < 0) sign = -1;
250 // pZ = pYZ / (TMath::Sqrt(1.0 + trackParam->GetBendingSlope() * trackParam->GetBendingSlope()));
251 // pX = pZ * trackParam->GetNonBendingSlope();
252 // pY = pZ * trackParam->GetBendingSlope();
253 // pTotal = TMath::Sqrt(pYZ *pYZ + pX * pX);
254 // xEndAbsorber = trackParam->GetNonBendingCoor();
255 // yEndAbsorber = trackParam->GetBendingCoor();
256 // radiusEndAbsorber2 = xEndAbsorber * xEndAbsorber + yEndAbsorber * yEndAbsorber;
258 // if (radiusEndAbsorber2 > rLimit*rLimit) {
259 // zEndAbsorber = z1[9];
262 // zEndAbsorber = z2[3];
266 // xBP = xEndAbsorber - (pX / pZ) * (zEndAbsorber - zBP);
267 // yBP = yEndAbsorber - (pY / pZ) * (zEndAbsorber - zBP);
269 // // new parameters after Branson and energy loss corrections
270 // pZ = pTotal * zBP / TMath::Sqrt(xBP * xBP + yBP * yBP + zBP * zBP);
271 // pX = pZ * xBP / zBP;
272 // pY = pZ * yBP / zBP;
273 // trackParam->SetBendingSlope(pY/pZ);
274 // trackParam->SetNonBendingSlope(pX/pZ);
276 // pT = TMath::Sqrt(pX * pX + pY * pY);
277 // theta = TMath::ATan2(pT, pZ);
278 // pTotal = TotalMomentumEnergyLoss(rLimit, pTotal, theta, xEndAbsorber, yEndAbsorber);
280 // trackParam->SetInverseBendingMomentum((sign / pTotal) *
282 // trackParam->GetBendingSlope() * trackParam->GetBendingSlope() +
283 // trackParam->GetNonBendingSlope() * trackParam->GetNonBendingSlope()) /
284 // TMath::Sqrt(1.0 + trackParam->GetBendingSlope() * trackParam->GetBendingSlope()));
286 // // vertex position at (0,0,0)
287 // // should be taken from vertex measurement ???
288 // trackParam->SetBendingCoor(0.);
289 // trackParam->SetNonBendingCoor(0.);
290 // trackParam->SetZ(0.);
293 void AliMUONTrackExtrap::BransonCorrection(AliMUONTrackParam* trackParam, Double_t xVtx, Double_t yVtx, Double_t zVtx)
295 /// Branson correction of track parameters
296 // the entry parameters have to be calculated at the end of the absorber
297 // simplified version: the z positions of Branson's planes are no longer calculated
298 // but are given as inputs. One can use the macros MUONTestAbso.C and DrawTestAbso.C
299 // to test this correction.
300 // Would it be possible to calculate all that from Geant configuration ????
301 // and to get the Branson parameters from a function in ABSO module ????
302 // with an eventual contribution from other detectors like START ????
303 // change to take into account the vertex postition (real, reconstruct,....)
305 Double_t zBP, xBP, yBP;
306 Double_t pYZ, pX, pY, pZ, pTotal, xEndAbsorber, yEndAbsorber, radiusEndAbsorber2, pT, theta;
308 static Bool_t first = kTRUE;
309 static Double_t zBP1, zBP2, rLimit, thetaLimit, zEndAbsorber;
310 // zBP1 for outer part and zBP2 for inner part (only at the first call)
314 zEndAbsorber = -503; // spectro (z<0)
315 thetaLimit = 3.0 * (TMath::Pi()) / 180.;
316 rLimit = TMath::Abs(zEndAbsorber) * TMath::Tan(thetaLimit);
317 zBP1 = -450; // values close to those calculated with EvalAbso.C
321 pYZ = TMath::Abs(1.0 / trackParam->GetInverseBendingMomentum());
323 if (trackParam->GetInverseBendingMomentum() < 0) sign = -1;
324 pZ = trackParam->Pz();
325 pX = trackParam->Px();
326 pY = trackParam->Py();
327 pTotal = TMath::Sqrt(pYZ *pYZ + pX * pX);
328 xEndAbsorber = trackParam->GetNonBendingCoor();
329 yEndAbsorber = trackParam->GetBendingCoor();
330 radiusEndAbsorber2 = xEndAbsorber * xEndAbsorber + yEndAbsorber * yEndAbsorber;
332 if (radiusEndAbsorber2 > rLimit*rLimit) {
338 xBP = xEndAbsorber - (pX / pZ) * (zEndAbsorber - zBP);
339 yBP = yEndAbsorber - (pY / pZ) * (zEndAbsorber - zBP);
341 // new parameters after Branson and energy loss corrections
342 // Float_t zSmear = zBP - gRandom->Gaus(0.,2.); // !!! possible smearing of Z vertex position
344 Float_t zSmear = zBP ;
346 pZ = pTotal * (zSmear-zVtx) / TMath::Sqrt((xBP-xVtx) * (xBP-xVtx) + (yBP-yVtx) * (yBP-yVtx) +( zSmear-zVtx) * (zSmear-zVtx) );
347 pX = pZ * (xBP - xVtx)/ (zSmear-zVtx);
348 pY = pZ * (yBP - yVtx) / (zSmear-zVtx);
349 trackParam->SetBendingSlope(pY/pZ);
350 trackParam->SetNonBendingSlope(pX/pZ);
353 pT = TMath::Sqrt(pX * pX + pY * pY);
354 theta = TMath::ATan2(pT, TMath::Abs(pZ));
355 pTotal = TotalMomentumEnergyLoss(thetaLimit, pTotal, theta);
357 trackParam->SetInverseBendingMomentum((sign / pTotal) *
359 trackParam->GetBendingSlope() * trackParam->GetBendingSlope() +
360 trackParam->GetNonBendingSlope() * trackParam->GetNonBendingSlope()) /
361 TMath::Sqrt(1.0 + trackParam->GetBendingSlope() * trackParam->GetBendingSlope()));
363 // vertex position at (0,0,0)
364 // should be taken from vertex measurement ???
366 trackParam->SetBendingCoor(xVtx);
367 trackParam->SetNonBendingCoor(yVtx);
368 trackParam->SetZ(zVtx);
372 //__________________________________________________________________________
373 Double_t AliMUONTrackExtrap::TotalMomentumEnergyLoss(Double_t thetaLimit, Double_t pTotal, Double_t theta)
375 /// Returns the total momentum corrected from energy loss in the front absorber
376 // One can use the macros MUONTestAbso.C and DrawTestAbso.C
377 // to test this correction.
378 // Momentum energy loss behaviour evaluated with the simulation of single muons (april 2002)
379 Double_t deltaP, pTotalCorrected;
381 // Parametrization to be redone according to change of absorber material ????
382 // See remark in function BransonCorrection !!!!
383 // The name is not so good, and there are many arguments !!!!
384 if (theta < thetaLimit ) {
386 deltaP = 2.5938 + 0.0570 * pTotal - 0.001151 * pTotal * pTotal;
388 deltaP = 3.0714 + 0.011767 *pTotal;
390 deltaP *= 0.75; // AZ
393 deltaP = 2.1207 + 0.05478 * pTotal - 0.00145079 * pTotal * pTotal;
395 deltaP = 2.6069 + 0.0051705 * pTotal;
399 pTotalCorrected = pTotal + deltaP / TMath::Cos(theta);
400 return pTotalCorrected;
403 //__________________________________________________________________________
404 void AliMUONTrackExtrap::FieldCorrection(AliMUONTrackParam *trackParam, Double_t zEnd)
406 /// Correction of the effect of the magnetic field in the absorber
407 // Assume a constant field along Z axis.
410 Double_t pYZ,pX,pY,pZ,pT;
411 Double_t pXNew,pYNew;
414 pYZ = TMath::Abs(1.0 / trackParam->GetInverseBendingMomentum());
415 c = TMath::Sign(1.0,trackParam->GetInverseBendingMomentum()); // particle charge
417 pZ = trackParam->Pz();
418 pX = trackParam->Px();
419 pY = trackParam->Py();
420 pT = TMath::Sqrt(pX*pX+pY*pY);
422 if (TMath::Abs(pZ) <= 0) return;
424 x[0] = x[2]*trackParam->GetNonBendingSlope();
425 x[1] = x[2]*trackParam->GetBendingSlope();
427 // Take magn. field value at position x.
428 if (fgkField) fgkField->Field(x,b);
430 cout<<"F-AliMUONTrackExtrap::FieldCorrection: fgkField = 0x0"<<endl;
435 // Transverse momentum rotation
436 // Parameterized with the study of DeltaPhi = phiReco - phiGen as a function of pZ.
437 Double_t phiShift = c*0.436*0.0003*bZ*zEnd/pZ;
438 // Rotate momentum around Z axis.
439 pXNew = pX*TMath::Cos(phiShift) - pY*TMath::Sin(phiShift);
440 pYNew = pX*TMath::Sin(phiShift) + pY*TMath::Cos(phiShift);
442 trackParam->SetBendingSlope(pYNew/pZ);
443 trackParam->SetNonBendingSlope(pXNew/pZ);
445 trackParam->SetInverseBendingMomentum(c/TMath::Sqrt(pYNew*pYNew+pZ*pZ));
449 //__________________________________________________________________________
450 void AliMUONTrackExtrap::ExtrapOneStepHelix(Double_t charge, Double_t step, Double_t *vect, Double_t *vout)
452 /// ******************************************************************
454 /// * Performs the tracking of one step in a magnetic field *
455 /// * The trajectory is assumed to be a helix in a constant field *
456 /// * taken at the mid point of the step. *
459 /// * STEP =arc length of the step asked *
460 /// * VECT =input vector (position,direction cos and momentum) *
461 /// * CHARGE= electric charge of the particle *
463 /// * VOUT = same as VECT after completion of the step *
465 /// * ==>Called by : <USER>, GUSWIM *
466 /// * Author m.hansroul ********* *
467 /// * modified s.egli, s.v.levonian *
468 /// * modified v.perevoztchikov
470 /// ******************************************************************
472 // modif: everything in double precision
474 Double_t xyz[3], h[4], hxp[3];
475 Double_t h2xy, hp, rho, tet;
476 Double_t sint, sintt, tsint, cos1t;
477 Double_t f1, f2, f3, f4, f5, f6;
482 const Int_t kipx = 3;
483 const Int_t kipy = 4;
484 const Int_t kipz = 5;
485 const Int_t kipp = 6;
487 const Double_t kec = 2.9979251e-4;
489 // ------------------------------------------------------------------
491 // units are kgauss,centimeters,gev/c
493 vout[kipp] = vect[kipp];
494 if (TMath::Abs(charge) < 0.00001) {
495 for (Int_t i = 0; i < 3; i++) {
496 vout[i] = vect[i] + step * vect[i+3];
497 vout[i+3] = vect[i+3];
501 xyz[0] = vect[kix] + 0.5 * step * vect[kipx];
502 xyz[1] = vect[kiy] + 0.5 * step * vect[kipy];
503 xyz[2] = vect[kiz] + 0.5 * step * vect[kipz];
505 //cmodif: call gufld (xyz, h) changed into:
508 h2xy = h[0]*h[0] + h[1]*h[1];
509 h[3] = h[2]*h[2]+ h2xy;
511 for (Int_t i = 0; i < 3; i++) {
512 vout[i] = vect[i] + step * vect[i+3];
513 vout[i+3] = vect[i+3];
517 if (h2xy < 1.e-12*h[3]) {
518 ExtrapOneStepHelix3(charge*h[2], step, vect, vout);
521 h[3] = TMath::Sqrt(h[3]);
527 hxp[0] = h[1]*vect[kipz] - h[2]*vect[kipy];
528 hxp[1] = h[2]*vect[kipx] - h[0]*vect[kipz];
529 hxp[2] = h[0]*vect[kipy] - h[1]*vect[kipx];
531 hp = h[0]*vect[kipx] + h[1]*vect[kipy] + h[2]*vect[kipz];
533 rho = -charge*h[3]/vect[kipp];
536 if (TMath::Abs(tet) > 0.15) {
537 sint = TMath::Sin(tet);
539 tsint = (tet-sint)/tet;
540 cos1t = 2.*(TMath::Sin(0.5*tet))*(TMath::Sin(0.5*tet))/tet;
543 sintt = (1. - tsint);
550 f3 = step * tsint * hp;
553 f6 = tet * cos1t * hp;
555 vout[kix] = vect[kix] + f1*vect[kipx] + f2*hxp[0] + f3*h[0];
556 vout[kiy] = vect[kiy] + f1*vect[kipy] + f2*hxp[1] + f3*h[1];
557 vout[kiz] = vect[kiz] + f1*vect[kipz] + f2*hxp[2] + f3*h[2];
559 vout[kipx] = vect[kipx] + f4*vect[kipx] + f5*hxp[0] + f6*h[0];
560 vout[kipy] = vect[kipy] + f4*vect[kipy] + f5*hxp[1] + f6*h[1];
561 vout[kipz] = vect[kipz] + f4*vect[kipz] + f5*hxp[2] + f6*h[2];
566 //__________________________________________________________________________
567 void AliMUONTrackExtrap::ExtrapOneStepHelix3(Double_t field, Double_t step, Double_t *vect, Double_t *vout)
569 /// ******************************************************************
571 /// * Tracking routine in a constant field oriented *
573 /// * Tracking is performed with a conventional *
574 /// * helix step method *
576 /// * ==>Called by : <USER>, GUSWIM *
577 /// * Authors R.Brun, M.Hansroul ********* *
578 /// * Rewritten V.Perevoztchikov
580 /// ******************************************************************
583 Double_t h4, hp, rho, tet;
584 Double_t sint, sintt, tsint, cos1t;
585 Double_t f1, f2, f3, f4, f5, f6;
590 const Int_t kipx = 3;
591 const Int_t kipy = 4;
592 const Int_t kipz = 5;
593 const Int_t kipp = 6;
595 const Double_t kec = 2.9979251e-4;
598 // ------------------------------------------------------------------
600 // units are kgauss,centimeters,gev/c
602 vout[kipp] = vect[kipp];
605 hxp[0] = - vect[kipy];
606 hxp[1] = + vect[kipx];
610 rho = -h4/vect[kipp];
612 if (TMath::Abs(tet) > 0.15) {
613 sint = TMath::Sin(tet);
615 tsint = (tet-sint)/tet;
616 cos1t = 2.* TMath::Sin(0.5*tet) * TMath::Sin(0.5*tet)/tet;
619 sintt = (1. - tsint);
626 f3 = step * tsint * hp;
629 f6 = tet * cos1t * hp;
631 vout[kix] = vect[kix] + f1*vect[kipx] + f2*hxp[0];
632 vout[kiy] = vect[kiy] + f1*vect[kipy] + f2*hxp[1];
633 vout[kiz] = vect[kiz] + f1*vect[kipz] + f3;
635 vout[kipx] = vect[kipx] + f4*vect[kipx] + f5*hxp[0];
636 vout[kipy] = vect[kipy] + f4*vect[kipy] + f5*hxp[1];
637 vout[kipz] = vect[kipz] + f4*vect[kipz] + f6;
641 //__________________________________________________________________________
642 void AliMUONTrackExtrap::ExtrapOneStepRungekutta(Double_t charge, Double_t step, Double_t* vect, Double_t* vout)
644 /// ******************************************************************
646 /// * Runge-Kutta method for tracking a particle through a magnetic *
647 /// * field. Uses Nystroem algorithm (See Handbook Nat. Bur. of *
648 /// * Standards, procedure 25.5.20) *
650 /// * Input parameters *
651 /// * CHARGE Particle charge *
652 /// * STEP Step size *
653 /// * VECT Initial co-ords,direction cosines,momentum *
654 /// * Output parameters *
655 /// * VOUT Output co-ords,direction cosines,momentum *
656 /// * User routine called *
657 /// * CALL GUFLD(X,F) *
659 /// * ==>Called by : <USER>, GUSWIM *
660 /// * Authors R.Brun, M.Hansroul ********* *
661 /// * V.Perevoztchikov (CUT STEP implementation) *
664 /// ******************************************************************
666 Double_t h2, h4, f[4];
667 Double_t xyzt[3], a, b, c, ph,ph2;
668 Double_t secxs[4],secys[4],seczs[4],hxp[3];
669 Double_t g1, g2, g3, g4, g5, g6, ang2, dxt, dyt, dzt;
670 Double_t est, at, bt, ct, cba;
671 Double_t f1, f2, f3, f4, rho, tet, hnorm, hp, rho1, sint, cost;
681 Double_t maxit = 1992;
682 Double_t maxcut = 11;
684 const Double_t kdlt = 1e-4;
685 const Double_t kdlt32 = kdlt/32.;
686 const Double_t kthird = 1./3.;
687 const Double_t khalf = 0.5;
688 const Double_t kec = 2.9979251e-4;
690 const Double_t kpisqua = 9.86960440109;
694 const Int_t kipx = 3;
695 const Int_t kipy = 4;
696 const Int_t kipz = 5;
699 // *. ------------------------------------------------------------------
701 // * this constant is for units cm,gev/c and kgauss
705 for(Int_t j = 0; j < 7; j++)
708 Double_t pinv = kec * charge / vect[6];
716 if (TMath::Abs(h) > TMath::Abs(rest)) h = rest;
717 //cmodif: call gufld(vout,f) changed into:
722 // * start of integration
735 secxs[0] = (b * f[2] - c * f[1]) * ph2;
736 secys[0] = (c * f[0] - a * f[2]) * ph2;
737 seczs[0] = (a * f[1] - b * f[0]) * ph2;
738 ang2 = (secxs[0]*secxs[0] + secys[0]*secys[0] + seczs[0]*seczs[0]);
739 if (ang2 > kpisqua) break;
741 dxt = h2 * a + h4 * secxs[0];
742 dyt = h2 * b + h4 * secys[0];
743 dzt = h2 * c + h4 * seczs[0];
748 // * second intermediate point
751 est = TMath::Abs(dxt) + TMath::Abs(dyt) + TMath::Abs(dzt);
753 if (ncut++ > maxcut) break;
762 //cmodif: call gufld(xyzt,f) changed into:
769 secxs[1] = (bt * f[2] - ct * f[1]) * ph2;
770 secys[1] = (ct * f[0] - at * f[2]) * ph2;
771 seczs[1] = (at * f[1] - bt * f[0]) * ph2;
775 secxs[2] = (bt * f[2] - ct * f[1]) * ph2;
776 secys[2] = (ct * f[0] - at * f[2]) * ph2;
777 seczs[2] = (at * f[1] - bt * f[0]) * ph2;
778 dxt = h * (a + secxs[2]);
779 dyt = h * (b + secys[2]);
780 dzt = h * (c + seczs[2]);
784 at = a + 2.*secxs[2];
785 bt = b + 2.*secys[2];
786 ct = c + 2.*seczs[2];
788 est = TMath::Abs(dxt)+TMath::Abs(dyt)+TMath::Abs(dzt);
789 if (est > 2.*TMath::Abs(h)) {
790 if (ncut++ > maxcut) break;
799 //cmodif: call gufld(xyzt,f) changed into:
802 z = z + (c + (seczs[0] + seczs[1] + seczs[2]) * kthird) * h;
803 y = y + (b + (secys[0] + secys[1] + secys[2]) * kthird) * h;
804 x = x + (a + (secxs[0] + secxs[1] + secxs[2]) * kthird) * h;
806 secxs[3] = (bt*f[2] - ct*f[1])* ph2;
807 secys[3] = (ct*f[0] - at*f[2])* ph2;
808 seczs[3] = (at*f[1] - bt*f[0])* ph2;
809 a = a+(secxs[0]+secxs[3]+2. * (secxs[1]+secxs[2])) * kthird;
810 b = b+(secys[0]+secys[3]+2. * (secys[1]+secys[2])) * kthird;
811 c = c+(seczs[0]+seczs[3]+2. * (seczs[1]+seczs[2])) * kthird;
813 est = TMath::Abs(secxs[0]+secxs[3] - (secxs[1]+secxs[2]))
814 + TMath::Abs(secys[0]+secys[3] - (secys[1]+secys[2]))
815 + TMath::Abs(seczs[0]+seczs[3] - (seczs[1]+seczs[2]));
817 if (est > kdlt && TMath::Abs(h) > 1.e-4) {
818 if (ncut++ > maxcut) break;
824 // * if too many iterations, go to helix
825 if (iter++ > maxit) break;
830 cba = 1./ TMath::Sqrt(a*a + b*b + c*c);
838 if (step < 0.) rest = -rest;
839 if (rest < 1.e-5*TMath::Abs(step)) return;
843 // angle too big, use helix
848 f4 = TMath::Sqrt(f1*f1+f2*f2+f3*f3);
857 hxp[0] = f2*vect[kipz] - f3*vect[kipy];
858 hxp[1] = f3*vect[kipx] - f1*vect[kipz];
859 hxp[2] = f1*vect[kipy] - f2*vect[kipx];
861 hp = f1*vect[kipx] + f2*vect[kipy] + f3*vect[kipz];
864 sint = TMath::Sin(tet);
865 cost = 2.*TMath::Sin(khalf*tet)*TMath::Sin(khalf*tet);
869 g3 = (tet-sint) * hp*rho1;
874 vout[kix] = vect[kix] + g1*vect[kipx] + g2*hxp[0] + g3*f1;
875 vout[kiy] = vect[kiy] + g1*vect[kipy] + g2*hxp[1] + g3*f2;
876 vout[kiz] = vect[kiz] + g1*vect[kipz] + g2*hxp[2] + g3*f3;
878 vout[kipx] = vect[kipx] + g4*vect[kipx] + g5*hxp[0] + g6*f1;
879 vout[kipy] = vect[kipy] + g4*vect[kipy] + g5*hxp[1] + g6*f2;
880 vout[kipz] = vect[kipz] + g4*vect[kipz] + g5*hxp[2] + g6*f3;
884 //___________________________________________________________
885 void AliMUONTrackExtrap::GetField(Double_t *Position, Double_t *Field)
887 /// interface for arguments in double precision (Why ? ChF)
890 x[0] = Position[0]; x[1] = Position[1]; x[2] = Position[2];
892 if (fgkField) fgkField->Field(x,b);
894 cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl;
898 Field[0] = b[0]; Field[1] = b[1]; Field[2] = b[2];