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 //-----------------------------------------------------------------------------
19 // Class AliMUONTrackExtrap
20 // ------------------------
21 // Tools for track extrapolation in ALICE dimuon spectrometer
22 // Author: Philippe Pillot
23 //-----------------------------------------------------------------------------
25 #include "AliMUONTrackExtrap.h"
26 #include "AliMUONTrackParam.h"
27 #include "AliMUONConstants.h"
32 #include <TGeoManager.h>
34 #include <Riostream.h>
37 ClassImp(AliMUONTrackExtrap) // Class implementation in ROOT context
40 const AliMagF* AliMUONTrackExtrap::fgkField = 0x0;
41 const Bool_t AliMUONTrackExtrap::fgkUseHelix = kFALSE;
42 const Int_t AliMUONTrackExtrap::fgkMaxStepNumber = 5000;
43 const Double_t AliMUONTrackExtrap::fgkHelixStepLength = 6.;
44 const Double_t AliMUONTrackExtrap::fgkRungeKuttaMaxResidue = 0.002;
46 //__________________________________________________________________________
47 Double_t AliMUONTrackExtrap::GetImpactParamFromBendingMomentum(Double_t bendingMomentum)
49 /// Returns impact parameter at vertex in bending plane (cm),
50 /// from the signed bending momentum "BendingMomentum" in bending plane (GeV/c),
51 /// using simple values for dipole magnetic field.
52 /// The sign of "BendingMomentum" is the sign of the charge.
54 if (bendingMomentum == 0.) return 1.e10;
56 Double_t simpleBPosition = 0.5 * (AliMUONConstants::CoilZ() + AliMUONConstants::YokeZ());
57 Double_t simpleBLength = 0.5 * (AliMUONConstants::CoilL() + AliMUONConstants::YokeL());
58 Float_t b[3], x[3] = {0.,0.,(Float_t) simpleBPosition};
59 if (fgkField) fgkField->Field(x,b);
61 cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl;
64 Double_t simpleBValue = (Double_t) b[0];
66 return (-0.0003 * simpleBValue * simpleBLength * simpleBPosition / bendingMomentum);
69 //__________________________________________________________________________
70 Double_t AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(Double_t impactParam)
72 /// Returns signed bending momentum in bending plane (GeV/c),
73 /// the sign being the sign of the charge for particles moving forward in Z,
74 /// from the impact parameter "ImpactParam" at vertex in bending plane (cm),
75 /// using simple values for dipole magnetic field.
77 if (impactParam == 0.) return 1.e10;
79 Double_t simpleBPosition = 0.5 * (AliMUONConstants::CoilZ() + AliMUONConstants::YokeZ());
80 Double_t simpleBLength = 0.5 * (AliMUONConstants::CoilL() + AliMUONConstants::YokeL());
81 Float_t b[3], x[3] = {0.,0.,(Float_t) simpleBPosition};
82 if (fgkField) fgkField->Field(x,b);
84 cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl;
87 Double_t simpleBValue = (Double_t) b[0];
89 return (-0.0003 * simpleBValue * simpleBLength * simpleBPosition / impactParam);
92 //__________________________________________________________________________
93 void AliMUONTrackExtrap::LinearExtrapToZ(AliMUONTrackParam* trackParam, Double_t zEnd)
95 /// Track parameters (and their covariances if any) linearly extrapolated to the plane at "zEnd".
96 /// On return, results from the extrapolation are updated in trackParam.
98 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z
100 // Compute track parameters
101 Double_t dZ = zEnd - trackParam->GetZ();
102 trackParam->SetNonBendingCoor(trackParam->GetNonBendingCoor() + trackParam->GetNonBendingSlope() * dZ);
103 trackParam->SetBendingCoor(trackParam->GetBendingCoor() + trackParam->GetBendingSlope() * dZ);
104 trackParam->SetZ(zEnd);
106 // Update track parameters covariances if any
107 if (trackParam->CovariancesExist()) {
108 TMatrixD paramCov(trackParam->GetCovariances());
109 paramCov(0,0) += dZ * dZ * paramCov(1,1) + 2. * dZ * paramCov(0,1);
110 paramCov(0,1) += dZ * paramCov(1,1);
111 paramCov(1,0) = paramCov(0,1);
112 paramCov(2,2) += dZ * dZ * paramCov(3,3) + 2. * dZ * paramCov(2,3);
113 paramCov(2,3) += dZ * paramCov(3,3);
114 paramCov(3,2) = paramCov(2,3);
115 trackParam->SetCovariances(paramCov);
120 //__________________________________________________________________________
121 void AliMUONTrackExtrap::ExtrapToZ(AliMUONTrackParam* trackParam, Double_t zEnd)
123 /// Interface to track parameter extrapolation to the plane at "Z" using Helix or Rungekutta algorithm.
124 /// On return, the track parameters resulting from the extrapolation are updated in trackParam.
125 if (fgkUseHelix) AliMUONTrackExtrap::ExtrapToZHelix(trackParam,zEnd);
126 else AliMUONTrackExtrap::ExtrapToZRungekutta(trackParam,zEnd);
129 //__________________________________________________________________________
130 void AliMUONTrackExtrap::ExtrapToZHelix(AliMUONTrackParam* trackParam, Double_t zEnd)
132 /// Track parameter extrapolation to the plane at "Z" using Helix algorithm.
133 /// On return, the track parameters resulting from the extrapolation are updated in trackParam.
134 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same Z
135 Double_t forwardBackward; // +1 if forward, -1 if backward
136 if (zEnd < trackParam->GetZ()) forwardBackward = 1.0; // spectro. z<0
137 else forwardBackward = -1.0;
138 Double_t v3[7], v3New[7]; // 7 in parameter ????
139 Int_t i3, stepNumber;
140 // For safety: return kTRUE or kFALSE ????
141 // Parameter vector for calling EXTRAP_ONESTEP
142 ConvertTrackParamForExtrap(trackParam, forwardBackward, v3);
143 // sign of charge (sign of fInverseBendingMomentum if forward motion)
144 // must be changed if backward extrapolation
145 Double_t chargeExtrap = forwardBackward * TMath::Sign(Double_t(1.0), trackParam->GetInverseBendingMomentum());
146 // Extrapolation loop
148 while (((-forwardBackward * (v3[2] - zEnd)) <= 0.0) && (stepNumber < fgkMaxStepNumber)) { // spectro. z<0
150 ExtrapOneStepHelix(chargeExtrap, fgkHelixStepLength, v3, v3New);
151 if ((-forwardBackward * (v3New[2] - zEnd)) > 0.0) break; // one is beyond Z spectro. z<0
152 // better use TArray ????
153 for (i3 = 0; i3 < 7; i3++) {v3[i3] = v3New[i3];}
155 // check fgkMaxStepNumber ????
156 // Interpolation back to exact Z (2nd order)
157 // should be in function ???? using TArray ????
158 Double_t dZ12 = v3New[2] - v3[2]; // 1->2
159 if (TMath::Abs(dZ12) > 0) {
160 Double_t dZ1i = zEnd - v3[2]; // 1-i
161 Double_t dZi2 = v3New[2] - zEnd; // i->2
162 Double_t xPrime = (v3New[0] - v3[0]) / dZ12;
163 Double_t xSecond = ((v3New[3] / v3New[5]) - (v3[3] / v3[5])) / dZ12;
164 Double_t yPrime = (v3New[1] - v3[1]) / dZ12;
165 Double_t ySecond = ((v3New[4] / v3New[5]) - (v3[4] / v3[5])) / dZ12;
166 v3[0] = v3[0] + xPrime * dZ1i - 0.5 * xSecond * dZ1i * dZi2; // X
167 v3[1] = v3[1] + yPrime * dZ1i - 0.5 * ySecond * dZ1i * dZi2; // Y
169 Double_t xPrimeI = xPrime - 0.5 * xSecond * (dZi2 - dZ1i);
170 Double_t yPrimeI = yPrime - 0.5 * ySecond * (dZi2 - dZ1i);
171 // (PX, PY, PZ)/PTOT assuming forward motion
172 v3[5] = 1.0 / TMath::Sqrt(1.0 + xPrimeI * xPrimeI + yPrimeI * yPrimeI); // PZ/PTOT
173 v3[3] = xPrimeI * v3[5]; // PX/PTOT
174 v3[4] = yPrimeI * v3[5]; // PY/PTOT
176 cout<<"W-AliMUONTrackExtrap::ExtrapToZHelix: Extrap. to Z not reached, Z = "<<zEnd<<endl;
178 // Recover track parameters (charge back for forward motion)
179 RecoverTrackParam(v3, chargeExtrap * forwardBackward, trackParam);
182 //__________________________________________________________________________
183 void AliMUONTrackExtrap::ExtrapToZRungekutta(AliMUONTrackParam* trackParam, Double_t zEnd)
185 /// Track parameter extrapolation to the plane at "Z" using Rungekutta algorithm.
186 /// On return, the track parameters resulting from the extrapolation are updated in trackParam.
187 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same Z
188 Double_t forwardBackward; // +1 if forward, -1 if backward
189 if (zEnd < trackParam->GetZ()) forwardBackward = 1.0; // spectro. z<0
190 else forwardBackward = -1.0;
191 // sign of charge (sign of fInverseBendingMomentum if forward motion)
192 // must be changed if backward extrapolation
193 Double_t chargeExtrap = forwardBackward * TMath::Sign(Double_t(1.0), trackParam->GetInverseBendingMomentum());
194 Double_t v3[7], v3New[7];
196 Int_t stepNumber = 0;
198 // Extrapolation loop (until within tolerance)
199 Double_t residue = zEnd - trackParam->GetZ();
200 while (TMath::Abs(residue) > fgkRungeKuttaMaxResidue && stepNumber <= fgkMaxStepNumber) {
201 dZ = zEnd - trackParam->GetZ();
202 // step lenght assuming linear trajectory
203 step = dZ * TMath::Sqrt(1.0 + trackParam->GetBendingSlope()*trackParam->GetBendingSlope() +
204 trackParam->GetNonBendingSlope()*trackParam->GetNonBendingSlope());
205 ConvertTrackParamForExtrap(trackParam, forwardBackward, v3);
206 do { // reduce step lenght while zEnd oversteped
207 if (stepNumber > fgkMaxStepNumber) {
208 cout<<"W-AliMUONTrackExtrap::ExtrapToZRungekutta: Too many trials: "<<stepNumber<<endl;
212 step = TMath::Abs(step);
213 AliMUONTrackExtrap::ExtrapOneStepRungekutta(chargeExtrap,step,v3,v3New);
214 residue = zEnd - v3New[2];
215 step *= dZ/(v3New[2]-trackParam->GetZ());
216 } while (residue*dZ < 0 && TMath::Abs(residue) > fgkRungeKuttaMaxResidue);
217 RecoverTrackParam(v3New, chargeExtrap * forwardBackward, trackParam);
220 // terminate the extropolation with a straight line up to the exact "zEnd" value
221 trackParam->SetNonBendingCoor(trackParam->GetNonBendingCoor() + residue * trackParam->GetNonBendingSlope());
222 trackParam->SetBendingCoor(trackParam->GetBendingCoor() + residue * trackParam->GetBendingSlope());
223 trackParam->SetZ(zEnd);
226 //__________________________________________________________________________
227 void AliMUONTrackExtrap::ConvertTrackParamForExtrap(AliMUONTrackParam* trackParam, Double_t forwardBackward, Double_t *v3)
229 /// Set vector of Geant3 parameters pointed to by "v3" from track parameters in trackParam.
230 /// Since AliMUONTrackParam is only geometry, one uses "forwardBackward"
231 /// to know whether the particle is going forward (+1) or backward (-1).
232 v3[0] = trackParam->GetNonBendingCoor(); // X
233 v3[1] = trackParam->GetBendingCoor(); // Y
234 v3[2] = trackParam->GetZ(); // Z
235 Double_t pYZ = TMath::Abs(1.0 / trackParam->GetInverseBendingMomentum());
236 Double_t pZ = pYZ / TMath::Sqrt(1.0 + trackParam->GetBendingSlope() * trackParam->GetBendingSlope());
237 v3[6] = TMath::Sqrt(pYZ * pYZ + pZ * pZ * trackParam->GetNonBendingSlope() * trackParam->GetNonBendingSlope()); // PTOT
238 v3[5] = -forwardBackward * pZ / v3[6]; // PZ/PTOT spectro. z<0
239 v3[3] = trackParam->GetNonBendingSlope() * v3[5]; // PX/PTOT
240 v3[4] = trackParam->GetBendingSlope() * v3[5]; // PY/PTOT
243 //__________________________________________________________________________
244 void AliMUONTrackExtrap::RecoverTrackParam(Double_t *v3, Double_t charge, AliMUONTrackParam* trackParam)
246 /// Set track parameters in trackParam from Geant3 parameters pointed to by "v3",
247 /// assumed to be calculated for forward motion in Z.
248 /// "InverseBendingMomentum" is signed with "charge".
249 trackParam->SetNonBendingCoor(v3[0]); // X
250 trackParam->SetBendingCoor(v3[1]); // Y
251 trackParam->SetZ(v3[2]); // Z
252 Double_t pYZ = v3[6] * TMath::Sqrt(1.0 - v3[3] * v3[3]);
253 trackParam->SetInverseBendingMomentum(charge/pYZ);
254 trackParam->SetBendingSlope(v3[4]/v3[5]);
255 trackParam->SetNonBendingSlope(v3[3]/v3[5]);
258 //__________________________________________________________________________
259 void AliMUONTrackExtrap::ExtrapToZCov(AliMUONTrackParam* trackParam, Double_t zEnd, Bool_t updatePropagator)
261 /// Track parameters and their covariances extrapolated to the plane at "zEnd".
262 /// On return, results from the extrapolation are updated in trackParam.
264 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z
266 // No need to propagate the covariance matrix if it does not exist
267 if (!trackParam->CovariancesExist()) {
268 cout<<"W-AliMUONTrackExtrap::ExtrapToZCov: Covariance matrix does not exist"<<endl;
269 // Extrapolate track parameters to "zEnd"
270 ExtrapToZ(trackParam,zEnd);
274 // Save the actual track parameters
275 AliMUONTrackParam trackParamSave(*trackParam);
276 TMatrixD paramSave(trackParamSave.GetParameters());
277 Double_t zBegin = trackParamSave.GetZ();
279 // Get reference to the parameter covariance matrix
280 const TMatrixD& kParamCov = trackParam->GetCovariances();
282 // Extrapolate track parameters to "zEnd"
283 ExtrapToZ(trackParam,zEnd);
285 // Get reference to the extrapolated parameters
286 const TMatrixD& extrapParam = trackParam->GetParameters();
288 // Calculate the jacobian related to the track parameters extrapolation to "zEnd"
291 TMatrixD dParam(5,1);
292 for (Int_t i=0; i<5; i++) {
293 // Skip jacobian calculation for parameters with no associated error
294 if (kParamCov(i,i) == 0.) continue;
296 // Small variation of parameter i only
297 for (Int_t j=0; j<5; j++) {
299 dParam(j,0) = TMath::Sqrt(kParamCov(i,i));
300 if (j == 4) dParam(j,0) *= TMath::Sign(1.,-paramSave(4,0)); // variation always in the same direction
301 } else dParam(j,0) = 0.;
304 // Set new parameters
305 trackParamSave.SetParameters(paramSave);
306 trackParamSave.AddParameters(dParam);
307 trackParamSave.SetZ(zBegin);
309 // Extrapolate new track parameters to "zEnd"
310 ExtrapToZ(&trackParamSave,zEnd);
312 // Calculate the jacobian
313 TMatrixD jacobji(trackParamSave.GetParameters(),TMatrixD::kMinus,extrapParam);
314 jacobji *= 1. / dParam(i,0);
315 jacob.SetSub(0,i,jacobji);
318 // Extrapolate track parameter covariances to "zEnd"
319 TMatrixD tmp(kParamCov,TMatrixD::kMultTranspose,jacob);
320 TMatrixD tmp2(jacob,TMatrixD::kMult,tmp);
321 trackParam->SetCovariances(tmp2);
323 // Update the propagator if required
324 if (updatePropagator) trackParam->UpdatePropagator(jacob);
327 //__________________________________________________________________________
328 void AliMUONTrackExtrap::AddMCSEffectInAbsorber(AliMUONTrackParam* param, Double_t pathLength, Double_t f0, Double_t f1, Double_t f2)
330 /// Add to the track parameter covariances the effects of multiple Coulomb scattering
331 /// The absorber correction parameters are supposed to be calculated at the current track z-position
333 // absorber related covariance parameters
334 Double_t bendingSlope = param->GetBendingSlope();
335 Double_t nonBendingSlope = param->GetNonBendingSlope();
336 Double_t inverseBendingMomentum = param->GetInverseBendingMomentum();
337 Double_t alpha2 = 0.0136 * 0.0136 * inverseBendingMomentum * inverseBendingMomentum * (1.0 + bendingSlope * bendingSlope) /
338 (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope); // velocity = 1
339 Double_t varCoor = alpha2 * (pathLength * pathLength * f0 - 2. * pathLength * f1 + f2);
340 Double_t covCorrSlope = alpha2 * (pathLength * f0 - f1);
341 Double_t varSlop = alpha2 * f0;
343 // compute derivative d(q/Pxy) / dSlopeX and d(q/Pxy) / dSlopeX
344 Double_t dqPxydSlopeX = inverseBendingMomentum * nonBendingSlope / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
345 Double_t dqPxydSlopeY = - inverseBendingMomentum * nonBendingSlope*nonBendingSlope * bendingSlope /
346 (1. + bendingSlope*bendingSlope) / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
348 // Set MCS covariance matrix
349 TMatrixD newParamCov(param->GetCovariances());
351 newParamCov(0,0) += varCoor; newParamCov(0,1) += covCorrSlope;
352 newParamCov(1,0) += covCorrSlope; newParamCov(1,1) += varSlop;
354 newParamCov(2,2) += varCoor; newParamCov(2,3) += covCorrSlope;
355 newParamCov(3,2) += covCorrSlope; newParamCov(3,3) += varSlop;
356 // Inverse bending momentum (due to dependences with bending and non bending slopes)
357 newParamCov(4,0) += dqPxydSlopeX * covCorrSlope; newParamCov(0,4) += dqPxydSlopeX * covCorrSlope;
358 newParamCov(4,1) += dqPxydSlopeX * varSlop; newParamCov(1,4) += dqPxydSlopeX * varSlop;
359 newParamCov(4,2) += dqPxydSlopeY * covCorrSlope; newParamCov(2,4) += dqPxydSlopeY * covCorrSlope;
360 newParamCov(4,3) += dqPxydSlopeY * varSlop; newParamCov(3,4) += dqPxydSlopeY * varSlop;
361 newParamCov(4,4) += (dqPxydSlopeX*dqPxydSlopeX + dqPxydSlopeY*dqPxydSlopeY) * varSlop;
363 // Set new covariances
364 param->SetCovariances(newParamCov);
367 //__________________________________________________________________________
368 void AliMUONTrackExtrap::CorrectMCSEffectInAbsorber(AliMUONTrackParam* param,
369 Double_t xVtx, Double_t yVtx, Double_t zVtx,
370 Double_t errXVtx, Double_t errYVtx,
371 Double_t absZBeg, Double_t pathLength, Double_t f0, Double_t f1, Double_t f2)
373 /// Correct parameters and corresponding covariances using Branson correction
374 /// - input param are parameters and covariances at the end of absorber
375 /// - output param are parameters and covariances at vertex
376 /// Absorber correction parameters are supposed to be calculated at the current track z-position
378 // Position of the Branson plane (spectro. (z<0))
379 Double_t zB = (f1>0.) ? absZBeg - f2/f1 : 0.;
381 // Add MCS effects to current parameter covariances
382 AddMCSEffectInAbsorber(param, pathLength, f0, f1, f2);
384 // Get track parameters and covariances in the Branson plane corrected for magnetic field effect
385 ExtrapToZCov(param,zVtx);
386 LinearExtrapToZ(param,zB);
388 // compute track parameters at vertex
389 TMatrixD newParam(5,1);
390 newParam(0,0) = xVtx;
391 newParam(1,0) = (param->GetNonBendingCoor() - xVtx) / (zB - zVtx);
392 newParam(2,0) = yVtx;
393 newParam(3,0) = (param->GetBendingCoor() - yVtx) / (zB - zVtx);
394 newParam(4,0) = param->GetCharge() / param->P() *
395 TMath::Sqrt(1.0 + newParam(1,0)*newParam(1,0) + newParam(3,0)*newParam(3,0)) /
396 TMath::Sqrt(1.0 + newParam(3,0)*newParam(3,0));
398 // Get covariances in (X, SlopeX, Y, SlopeY, q*PTot) coordinate system
399 TMatrixD paramCovP(param->GetCovariances());
400 Cov2CovP(param->GetParameters(),paramCovP);
402 // Get the covariance matrix in the (XVtx, X, YVtx, Y, q*PTot) coordinate system
403 TMatrixD paramCovVtx(5,5);
405 paramCovVtx(0,0) = errXVtx * errXVtx;
406 paramCovVtx(1,1) = paramCovP(0,0);
407 paramCovVtx(2,2) = errYVtx * errYVtx;
408 paramCovVtx(3,3) = paramCovP(2,2);
409 paramCovVtx(4,4) = paramCovP(4,4);
410 paramCovVtx(1,3) = paramCovP(0,2);
411 paramCovVtx(3,1) = paramCovP(2,0);
412 paramCovVtx(1,4) = paramCovP(0,4);
413 paramCovVtx(4,1) = paramCovP(4,0);
414 paramCovVtx(3,4) = paramCovP(2,4);
415 paramCovVtx(4,3) = paramCovP(4,2);
417 // Jacobian of the transformation (XVtx, X, YVtx, Y, q*PTot) -> (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q*PTotVtx)
420 jacob(1,0) = - 1. / (zB - zVtx);
421 jacob(1,1) = 1. / (zB - zVtx);
422 jacob(3,2) = - 1. / (zB - zVtx);
423 jacob(3,3) = 1. / (zB - zVtx);
425 // Compute covariances at vertex in the (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q*PTotVtx) coordinate system
426 TMatrixD tmp(paramCovVtx,TMatrixD::kMultTranspose,jacob);
427 TMatrixD newParamCov(jacob,TMatrixD::kMult,tmp);
429 // Compute covariances at vertex in the (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q/PyzVtx) coordinate system
430 CovP2Cov(newParam,newParamCov);
432 // Set parameters and covariances at vertex
433 param->SetParameters(newParam);
435 param->SetCovariances(newParamCov);
438 //__________________________________________________________________________
439 void AliMUONTrackExtrap::CorrectELossEffectInAbsorber(AliMUONTrackParam* param, Double_t eLoss, Double_t sigmaELoss2)
441 /// Correct parameters for energy loss and add energy loss fluctuation effect to covariances
443 // Get parameter covariances in (X, SlopeX, Y, SlopeY, q*PTot) coordinate system
444 TMatrixD newParamCov(param->GetCovariances());
445 Cov2CovP(param->GetParameters(),newParamCov);
447 // Add effects of energy loss fluctuation to covariances
448 newParamCov(4,4) += sigmaELoss2;
450 // Compute new parameters corrected for energy loss
451 Double_t nonBendingSlope = param->GetNonBendingSlope();
452 Double_t bendingSlope = param->GetBendingSlope();
453 param->SetInverseBendingMomentum(param->GetCharge() / (param->P() + eLoss) *
454 TMath::Sqrt(1.0 + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope) /
455 TMath::Sqrt(1.0 + bendingSlope*bendingSlope));
457 // Get new parameter covariances in (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system
458 CovP2Cov(param->GetParameters(),newParamCov);
460 // Set new parameter covariances
461 param->SetCovariances(newParamCov);
464 //__________________________________________________________________________
465 void AliMUONTrackExtrap::GetAbsorberCorrectionParam(Double_t trackXYZIn[3], Double_t trackXYZOut[3], Double_t pTotal,
466 Double_t &pathLength, Double_t &f0, Double_t &f1, Double_t &f2,
467 Double_t &meanRho, Double_t &totalELoss, Double_t &sigmaELoss2)
469 /// Parameters used to correct for Multiple Coulomb Scattering and energy loss in absorber
470 /// Calculated assuming a linear propagation from trackXYZIn to trackXYZOut (order is important)
471 // pathLength: path length between trackXYZIn and trackXYZOut (cm)
472 // f0: 0th moment of z calculated with the inverse radiation-length distribution
473 // f1: 1st moment of z calculated with the inverse radiation-length distribution
474 // f2: 2nd moment of z calculated with the inverse radiation-length distribution
475 // meanRho: average density of crossed material (g/cm3)
476 // totalELoss: total energy loss in absorber
478 // Reset absorber's parameters
487 // Check whether the geometry is available
489 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: no TGeo"<<endl;
493 // Initialize starting point and direction
494 pathLength = TMath::Sqrt((trackXYZOut[0] - trackXYZIn[0])*(trackXYZOut[0] - trackXYZIn[0])+
495 (trackXYZOut[1] - trackXYZIn[1])*(trackXYZOut[1] - trackXYZIn[1])+
496 (trackXYZOut[2] - trackXYZIn[2])*(trackXYZOut[2] - trackXYZIn[2]));
497 if (pathLength < TGeoShape::Tolerance()) return;
499 b[0] = (trackXYZOut[0] - trackXYZIn[0]) / pathLength;
500 b[1] = (trackXYZOut[1] - trackXYZIn[1]) / pathLength;
501 b[2] = (trackXYZOut[2] - trackXYZIn[2]) / pathLength;
502 TGeoNode *currentnode = gGeoManager->InitTrack(trackXYZIn, b);
504 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: start point out of geometry"<<endl;
508 // loop over absorber slices and calculate absorber's parameters
509 Double_t rho = 0.; // material density (g/cm3)
510 Double_t x0 = 0.; // radiation-length (cm-1)
511 Double_t atomicA = 0.; // A of material
512 Double_t atomicZ = 0.; // Z of material
513 Double_t localPathLength = 0;
514 Double_t remainingPathLength = pathLength;
515 Double_t zB = trackXYZIn[2];
516 Double_t zE, dzB, dzE;
518 // Get material properties
519 TGeoMaterial *material = currentnode->GetVolume()->GetMedium()->GetMaterial();
520 rho = material->GetDensity();
521 x0 = material->GetRadLen();
522 if (!material->IsMixture()) x0 /= rho; // different normalization in the modeler for mixture
523 atomicA = material->GetA();
524 atomicZ = material->GetZ();
526 // Get path length within this material
527 gGeoManager->FindNextBoundary(remainingPathLength);
528 localPathLength = gGeoManager->GetStep() + 1.e-6;
529 // Check if boundary within remaining path length. If so, make sure to cross the boundary to prepare the next step
530 if (localPathLength >= remainingPathLength) localPathLength = remainingPathLength;
532 currentnode = gGeoManager->Step();
534 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: navigation failed"<<endl;
535 f0 = f1 = f2 = meanRho = 0.;
538 if (!gGeoManager->IsEntering()) {
539 // make another small step to try to enter in new absorber slice
540 gGeoManager->SetStep(0.001);
541 currentnode = gGeoManager->Step();
542 if (!gGeoManager->IsEntering() || !currentnode) {
543 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: navigation failed"<<endl;
544 f0 = f1 = f2 = meanRho = 0.;
547 localPathLength += 0.001;
551 // calculate absorber's parameters
552 zE = b[2] * localPathLength + zB;
553 dzB = zB - trackXYZIn[2];
554 dzE = zE - trackXYZIn[2];
555 f0 += localPathLength / x0;
556 f1 += (dzE*dzE - dzB*dzB) / b[2] / b[2] / x0 / 2.;
557 f2 += (dzE*dzE*dzE - dzB*dzB*dzB) / b[2] / b[2] / b[2] / x0 / 3.;
558 meanRho += localPathLength * rho;
559 totalELoss += BetheBloch(pTotal, localPathLength, rho, atomicA, atomicZ);
560 sigmaELoss2 += EnergyLossFluctuation2(pTotal, localPathLength, rho, atomicA, atomicZ);
564 remainingPathLength -= localPathLength;
565 } while (remainingPathLength > TGeoShape::Tolerance());
567 meanRho /= pathLength;
570 //__________________________________________________________________________
571 Double_t AliMUONTrackExtrap::GetMCSAngle2(const AliMUONTrackParam& param, Double_t dZ, Double_t x0)
573 /// Return the angular dispersion square due to multiple Coulomb scattering
574 /// through a material of thickness "dZ" and of radiation length "x0"
575 /// assuming linear propagation and using the small angle approximation.
577 Double_t bendingSlope = param.GetBendingSlope();
578 Double_t nonBendingSlope = param.GetNonBendingSlope();
579 Double_t inverseTotalMomentum2 = param.GetInverseBendingMomentum() * param.GetInverseBendingMomentum() *
580 (1.0 + bendingSlope * bendingSlope) /
581 (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope);
582 // Path length in the material
583 Double_t pathLength = TMath::Abs(dZ) * TMath::Sqrt(1.0 + bendingSlope*bendingSlope + nonBendingSlope*nonBendingSlope);
584 // relativistic velocity
586 // Angular dispersion square of the track (variance) in a plane perpendicular to the trajectory
587 Double_t theta02 = 0.0136 / velo * (1 + 0.038 * TMath::Log(pathLength/x0));
589 return theta02 * theta02 * inverseTotalMomentum2 * pathLength / x0;
592 //__________________________________________________________________________
593 void AliMUONTrackExtrap::AddMCSEffect(AliMUONTrackParam *param, Double_t dZ, Double_t x0)
595 /// Add to the track parameter covariances the effects of multiple Coulomb scattering
596 /// through a material of thickness "dZ" and of radiation length "x0"
597 /// assuming linear propagation and using the small angle approximation.
599 Double_t bendingSlope = param->GetBendingSlope();
600 Double_t nonBendingSlope = param->GetNonBendingSlope();
601 Double_t inverseBendingMomentum = param->GetInverseBendingMomentum();
602 Double_t inverseTotalMomentum2 = inverseBendingMomentum * inverseBendingMomentum *
603 (1.0 + bendingSlope * bendingSlope) /
604 (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope);
605 // Path length in the material
606 Double_t pathLength = TMath::Abs(dZ) * TMath::Sqrt(1.0 + bendingSlope*bendingSlope + nonBendingSlope*nonBendingSlope);
607 Double_t pathLength2 = pathLength * pathLength;
608 // relativistic velocity
610 // Angular dispersion square of the track (variance) in a plane perpendicular to the trajectory
611 Double_t theta02 = 0.0136 / velo * (1 + 0.038 * TMath::Log(pathLength/x0));
612 theta02 *= theta02 * inverseTotalMomentum2 * pathLength / x0;
614 Double_t varCoor = pathLength2 * theta02 / 3.;
615 Double_t varSlop = theta02;
616 Double_t covCorrSlope = pathLength * theta02 / 2.;
618 // compute derivative d(q/Pxy) / dSlopeX and d(q/Pxy) / dSlopeX
619 Double_t dqPxydSlopeX = inverseBendingMomentum * nonBendingSlope / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
620 Double_t dqPxydSlopeY = - inverseBendingMomentum * nonBendingSlope*nonBendingSlope * bendingSlope /
621 (1. + bendingSlope*bendingSlope) / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
623 // Set MCS covariance matrix
624 TMatrixD newParamCov(param->GetCovariances());
626 newParamCov(0,0) += varCoor; newParamCov(0,1) += covCorrSlope;
627 newParamCov(1,0) += covCorrSlope; newParamCov(1,1) += varSlop;
629 newParamCov(2,2) += varCoor; newParamCov(2,3) += covCorrSlope;
630 newParamCov(3,2) += covCorrSlope; newParamCov(3,3) += varSlop;
631 // Inverse bending momentum (due to dependences with bending and non bending slopes)
632 newParamCov(4,0) += dqPxydSlopeX * covCorrSlope; newParamCov(0,4) += dqPxydSlopeX * covCorrSlope;
633 newParamCov(4,1) += dqPxydSlopeX * varSlop; newParamCov(1,4) += dqPxydSlopeX * varSlop;
634 newParamCov(4,2) += dqPxydSlopeY * covCorrSlope; newParamCov(2,4) += dqPxydSlopeY * covCorrSlope;
635 newParamCov(4,3) += dqPxydSlopeY * varSlop; newParamCov(3,4) += dqPxydSlopeY * varSlop;
636 newParamCov(4,4) += (dqPxydSlopeX*dqPxydSlopeX + dqPxydSlopeY*dqPxydSlopeY) * varSlop;
638 // Set new covariances
639 param->SetCovariances(newParamCov);
642 //__________________________________________________________________________
643 void AliMUONTrackExtrap::ExtrapToVertex(AliMUONTrackParam* trackParam,
644 Double_t xVtx, Double_t yVtx, Double_t zVtx,
645 Double_t errXVtx, Double_t errYVtx,
646 Bool_t correctForMCS, Bool_t correctForEnergyLoss)
648 /// Main method for extrapolation to the vertex:
649 /// Returns the track parameters and covariances resulting from the extrapolation of the current trackParam
650 /// Changes parameters and covariances according to multiple scattering and energy loss corrections:
651 /// if correctForMCS=kTRUE: compute parameters using Branson correction and add correction resolution to covariances
652 /// if correctForMCS=kFALSE: add parameter dispersion due to MCS in parameter covariances
653 /// if correctForEnergyLoss=kTRUE: correct parameters for energy loss and add energy loss fluctuation to covariances
654 /// if correctForEnergyLoss=kFALSE: do nothing about energy loss
656 if (trackParam->GetZ() == zVtx) return; // nothing to be done if already at vertex
658 if (trackParam->GetZ() > zVtx) { // spectro. (z<0)
659 cout<<"E-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ()
660 <<") upstream the vertex (zVtx = "<<zVtx<<")"<<endl;
664 // Check the vertex position relatively to the absorber
665 if (zVtx < AliMUONConstants::AbsZBeg() && zVtx > AliMUONConstants::AbsZEnd()) { // spectro. (z<0)
666 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Ending Z ("<<zVtx
667 <<") inside the front absorber ("<<AliMUONConstants::AbsZBeg()<<","<<AliMUONConstants::AbsZEnd()<<")"<<endl;
668 } else if (zVtx < AliMUONConstants::AbsZEnd() ) { // spectro. (z<0)
669 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Ending Z ("<<zVtx
670 <<") downstream the front absorber (zAbsorberEnd = "<<AliMUONConstants::AbsZEnd()<<")"<<endl;
671 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx);
672 else ExtrapToZ(trackParam,zVtx);
676 // Check the track position relatively to the absorber and extrapolate track parameters to the end of the absorber if needed
677 if (trackParam->GetZ() > AliMUONConstants::AbsZBeg()) { // spectro. (z<0)
678 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ()
679 <<") upstream the front absorber (zAbsorberBegin = "<<AliMUONConstants::AbsZBeg()<<")"<<endl;
680 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx);
681 else ExtrapToZ(trackParam,zVtx);
683 } else if (trackParam->GetZ() > AliMUONConstants::AbsZEnd()) { // spectro. (z<0)
684 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ()
685 <<") inside the front absorber ("<<AliMUONConstants::AbsZBeg()<<","<<AliMUONConstants::AbsZEnd()<<")"<<endl;
687 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,AliMUONConstants::AbsZEnd());
688 else ExtrapToZ(trackParam,AliMUONConstants::AbsZEnd());
691 // Get absorber correction parameters assuming linear propagation in absorber
692 Double_t trackXYZOut[3];
693 trackXYZOut[0] = trackParam->GetNonBendingCoor();
694 trackXYZOut[1] = trackParam->GetBendingCoor();
695 trackXYZOut[2] = trackParam->GetZ();
696 Double_t trackXYZIn[3];
697 if (correctForMCS) { // assume linear propagation until the vertex
698 trackXYZIn[2] = TMath::Min(zVtx, AliMUONConstants::AbsZBeg()); // spectro. (z<0)
699 trackXYZIn[0] = trackXYZOut[0] + (xVtx - trackXYZOut[0]) / (zVtx - trackXYZOut[2]) * (trackXYZIn[2] - trackXYZOut[2]);
700 trackXYZIn[1] = trackXYZOut[1] + (yVtx - trackXYZOut[1]) / (zVtx - trackXYZOut[2]) * (trackXYZIn[2] - trackXYZOut[2]);
702 AliMUONTrackParam trackParamIn(*trackParam);
703 ExtrapToZ(&trackParamIn, TMath::Min(zVtx, AliMUONConstants::AbsZBeg()));
704 trackXYZIn[0] = trackParamIn.GetNonBendingCoor();
705 trackXYZIn[1] = trackParamIn.GetBendingCoor();
706 trackXYZIn[2] = trackParamIn.GetZ();
708 Double_t pTot = trackParam->P();
709 Double_t pathLength = 0.;
713 Double_t meanRho = 0.;
714 Double_t deltaP = 0.;
715 Double_t sigmaDeltaP2 = 0.;
716 GetAbsorberCorrectionParam(trackXYZIn,trackXYZOut,pTot,pathLength,f0,f1,f2,meanRho,deltaP,sigmaDeltaP2);
718 // Compute track parameters and covariances at vertex according to correctForMCS and correctForEnergyLoss flags
721 if (correctForEnergyLoss) {
723 // Correct for multiple scattering and energy loss
724 CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
725 CorrectMCSEffectInAbsorber(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx,
726 trackXYZIn[2], pathLength, f0, f1, f2);
727 CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
731 // Correct for multiple scattering
732 CorrectMCSEffectInAbsorber(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx,
733 trackXYZIn[2], pathLength, f0, f1, f2);
738 if (correctForEnergyLoss) {
740 // Correct for energy loss
741 CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
742 AddMCSEffectInAbsorber(trackParam, pathLength, f0, f1, f2);
743 ExtrapToZCov(trackParam, trackXYZIn[2]);
744 CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
745 ExtrapToZCov(trackParam, zVtx);
749 // Correct for multiple scattering and energy loss
750 AddMCSEffectInAbsorber(trackParam, pathLength, f0, f1, f2);
751 ExtrapToZCov(trackParam, zVtx);
759 //__________________________________________________________________________
760 void AliMUONTrackExtrap::ExtrapToVertex(AliMUONTrackParam* trackParam,
761 Double_t xVtx, Double_t yVtx, Double_t zVtx,
762 Double_t errXVtx, Double_t errYVtx)
764 /// Extrapolate track parameters to vertex, corrected for multiple scattering and energy loss effects
765 /// Add branson correction resolution and energy loss fluctuation to parameter covariances
766 ExtrapToVertex(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx, kTRUE, kTRUE);
769 //__________________________________________________________________________
770 void AliMUONTrackExtrap::ExtrapToVertexWithoutELoss(AliMUONTrackParam* trackParam,
771 Double_t xVtx, Double_t yVtx, Double_t zVtx,
772 Double_t errXVtx, Double_t errYVtx)
774 /// Extrapolate track parameters to vertex, corrected for multiple scattering effects only
775 /// Add branson correction resolution to parameter covariances
776 ExtrapToVertex(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx, kTRUE, kFALSE);
779 //__________________________________________________________________________
780 void AliMUONTrackExtrap::ExtrapToVertexWithoutBranson(AliMUONTrackParam* trackParam, Double_t zVtx)
782 /// Extrapolate track parameters to vertex, corrected for energy loss effects only
783 /// Add dispersion due to multiple scattering and energy loss fluctuation to parameter covariances
784 ExtrapToVertex(trackParam, 0., 0., zVtx, 0., 0., kFALSE, kTRUE);
787 //__________________________________________________________________________
788 void AliMUONTrackExtrap::ExtrapToVertexUncorrected(AliMUONTrackParam* trackParam, Double_t zVtx)
790 /// Extrapolate track parameters to vertex without multiple scattering and energy loss corrections
791 /// Add dispersion due to multiple scattering to parameter covariances
792 ExtrapToVertex(trackParam, 0., 0., zVtx, 0., 0., kFALSE, kFALSE);
795 //__________________________________________________________________________
796 Double_t AliMUONTrackExtrap::TotalMomentumEnergyLoss(AliMUONTrackParam* trackParam, Double_t xVtx, Double_t yVtx, Double_t zVtx)
798 /// Calculate the total momentum energy loss in-between the track position and the vertex assuming a linear propagation
800 if (trackParam->GetZ() == zVtx) return 0.; // nothing to be done if already at vertex
802 // Check whether the geometry is available
804 cout<<"E-AliMUONTrackExtrap::TotalMomentumEnergyLoss: no TGeo"<<endl;
808 // Get encountered material correction parameters assuming linear propagation from vertex to the track position
809 Double_t trackXYZOut[3];
810 trackXYZOut[0] = trackParam->GetNonBendingCoor();
811 trackXYZOut[1] = trackParam->GetBendingCoor();
812 trackXYZOut[2] = trackParam->GetZ();
813 Double_t trackXYZIn[3];
814 trackXYZIn[0] = xVtx;
815 trackXYZIn[1] = yVtx;
816 trackXYZIn[2] = zVtx;
817 Double_t pTot = trackParam->P();
818 Double_t pathLength = 0.;
822 Double_t meanRho = 0.;
823 Double_t totalELoss = 0.;
824 Double_t sigmaELoss2 = 0.;
825 GetAbsorberCorrectionParam(trackXYZIn,trackXYZOut,pTot,pathLength,f0,f1,f2,meanRho,totalELoss,sigmaELoss2);
830 //__________________________________________________________________________
831 Double_t AliMUONTrackExtrap::BetheBloch(Double_t pTotal, Double_t pathLength, Double_t rho, Double_t atomicA, Double_t atomicZ)
833 /// Returns the mean total momentum energy loss of muon with total momentum='pTotal'
834 /// in the absorber layer of lenght='pathLength', density='rho', A='atomicA' and Z='atomicZ'
835 Double_t muMass = 0.105658369; // GeV
836 Double_t eMass = 0.510998918e-3; // GeV
837 Double_t k = 0.307075e-3; // GeV.g^-1.cm^2
838 Double_t i = 9.5e-9; // mean exitation energy per atomic Z (GeV)
839 Double_t p2=pTotal*pTotal;
840 Double_t beta2=p2/(p2 + muMass*muMass);
842 Double_t w = k * rho * pathLength * atomicZ / atomicA / beta2;
844 if (beta2/(1-beta2)>3.5*3.5)
845 return w * (log(2.*eMass*3.5/(i*atomicZ)) + 0.5*log(beta2/(1-beta2)) - beta2);
847 return w * (log(2.*eMass*beta2/(1-beta2)/(i*atomicZ)) - beta2);
850 //__________________________________________________________________________
851 Double_t AliMUONTrackExtrap::EnergyLossFluctuation2(Double_t pTotal, Double_t pathLength, Double_t rho, Double_t atomicA, Double_t atomicZ)
853 /// Returns the total momentum energy loss fluctuation of muon with total momentum='pTotal'
854 /// in the absorber layer of lenght='pathLength', density='rho', A='atomicA' and Z='atomicZ'
855 Double_t muMass = 0.105658369; // GeV
856 //Double_t eMass = 0.510998918e-3; // GeV
857 Double_t k = 0.307075e-3; // GeV.g^-1.cm^2
858 Double_t p2=pTotal*pTotal;
859 Double_t beta2=p2/(p2 + muMass*muMass);
861 Double_t fwhm = 2. * k * rho * pathLength * atomicZ / atomicA / beta2; // FWHM of the energy loss Landau distribution
862 Double_t sigma2 = fwhm * fwhm / (8.*log(2.)); // gaussian: fwmh = 2 * srqt(2*ln(2)) * sigma (i.e. fwmh = 2.35 * sigma)
864 //sigma2 = k * rho * pathLength * atomicZ / atomicA * eMass; // sigma2 of the energy loss gaussian distribution
869 //__________________________________________________________________________
870 void AliMUONTrackExtrap::Cov2CovP(const TMatrixD ¶m, TMatrixD &cov)
872 /// change coordinate system: (X, SlopeX, Y, SlopeY, q/Pyz) -> (X, SlopeX, Y, SlopeY, q*PTot)
873 /// parameters (param) are given in the (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system
875 // charge * total momentum
876 Double_t qPTot = TMath::Sqrt(1. + param(1,0)*param(1,0) + param(3,0)*param(3,0)) /
877 TMath::Sqrt(1. + param(3,0)*param(3,0)) / param(4,0);
879 // Jacobian of the opposite transformation
882 jacob(4,1) = qPTot * param(1,0) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
883 jacob(4,3) = - qPTot * param(1,0) * param(1,0) * param(3,0) /
884 (1. + param(3,0)*param(3,0)) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
885 jacob(4,4) = - qPTot / param(4,0);
887 // compute covariances in new coordinate system
888 TMatrixD tmp(cov,TMatrixD::kMultTranspose,jacob);
892 //__________________________________________________________________________
893 void AliMUONTrackExtrap::CovP2Cov(const TMatrixD ¶m, TMatrixD &covP)
895 /// change coordinate system: (X, SlopeX, Y, SlopeY, q*PTot) -> (X, SlopeX, Y, SlopeY, q/Pyz)
896 /// parameters (param) are given in the (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system
898 // charge * total momentum
899 Double_t qPTot = TMath::Sqrt(1. + param(1,0)*param(1,0) + param(3,0)*param(3,0)) /
900 TMath::Sqrt(1. + param(3,0)*param(3,0)) / param(4,0);
902 // Jacobian of the transformation
905 jacob(4,1) = param(4,0) * param(1,0) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
906 jacob(4,3) = - param(4,0) * param(1,0) * param(1,0) * param(3,0) /
907 (1. + param(3,0)*param(3,0)) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
908 jacob(4,4) = - param(4,0) / qPTot;
910 // compute covariances in new coordinate system
911 TMatrixD tmp(covP,TMatrixD::kMultTranspose,jacob);
912 covP.Mult(jacob,tmp);
915 //__________________________________________________________________________
916 void AliMUONTrackExtrap::ExtrapOneStepHelix(Double_t charge, Double_t step, Double_t *vect, Double_t *vout)
919 /// ******************************************************************
921 /// * Performs the tracking of one step in a magnetic field *
922 /// * The trajectory is assumed to be a helix in a constant field *
923 /// * taken at the mid point of the step. *
926 /// * STEP =arc length of the step asked *
927 /// * VECT =input vector (position,direction cos and momentum) *
928 /// * CHARGE= electric charge of the particle *
930 /// * VOUT = same as VECT after completion of the step *
932 /// * ==>Called by : USER, GUSWIM *
933 /// * Author m.hansroul ********* *
934 /// * modified s.egli, s.v.levonian *
935 /// * modified v.perevoztchikov
937 /// ******************************************************************
940 // modif: everything in double precision
942 Double_t xyz[3], h[4], hxp[3];
943 Double_t h2xy, hp, rho, tet;
944 Double_t sint, sintt, tsint, cos1t;
945 Double_t f1, f2, f3, f4, f5, f6;
950 const Int_t kipx = 3;
951 const Int_t kipy = 4;
952 const Int_t kipz = 5;
953 const Int_t kipp = 6;
955 const Double_t kec = 2.9979251e-4;
957 // ------------------------------------------------------------------
959 // units are kgauss,centimeters,gev/c
961 vout[kipp] = vect[kipp];
962 if (TMath::Abs(charge) < 0.00001) {
963 for (Int_t i = 0; i < 3; i++) {
964 vout[i] = vect[i] + step * vect[i+3];
965 vout[i+3] = vect[i+3];
969 xyz[0] = vect[kix] + 0.5 * step * vect[kipx];
970 xyz[1] = vect[kiy] + 0.5 * step * vect[kipy];
971 xyz[2] = vect[kiz] + 0.5 * step * vect[kipz];
973 //cmodif: call gufld (xyz, h) changed into:
976 h2xy = h[0]*h[0] + h[1]*h[1];
977 h[3] = h[2]*h[2]+ h2xy;
979 for (Int_t i = 0; i < 3; i++) {
980 vout[i] = vect[i] + step * vect[i+3];
981 vout[i+3] = vect[i+3];
985 if (h2xy < 1.e-12*h[3]) {
986 ExtrapOneStepHelix3(charge*h[2], step, vect, vout);
989 h[3] = TMath::Sqrt(h[3]);
995 hxp[0] = h[1]*vect[kipz] - h[2]*vect[kipy];
996 hxp[1] = h[2]*vect[kipx] - h[0]*vect[kipz];
997 hxp[2] = h[0]*vect[kipy] - h[1]*vect[kipx];
999 hp = h[0]*vect[kipx] + h[1]*vect[kipy] + h[2]*vect[kipz];
1001 rho = -charge*h[3]/vect[kipp];
1004 if (TMath::Abs(tet) > 0.15) {
1005 sint = TMath::Sin(tet);
1007 tsint = (tet-sint)/tet;
1008 cos1t = 2.*(TMath::Sin(0.5*tet))*(TMath::Sin(0.5*tet))/tet;
1010 tsint = tet*tet/36.;
1011 sintt = (1. - tsint);
1018 f3 = step * tsint * hp;
1021 f6 = tet * cos1t * hp;
1023 vout[kix] = vect[kix] + f1*vect[kipx] + f2*hxp[0] + f3*h[0];
1024 vout[kiy] = vect[kiy] + f1*vect[kipy] + f2*hxp[1] + f3*h[1];
1025 vout[kiz] = vect[kiz] + f1*vect[kipz] + f2*hxp[2] + f3*h[2];
1027 vout[kipx] = vect[kipx] + f4*vect[kipx] + f5*hxp[0] + f6*h[0];
1028 vout[kipy] = vect[kipy] + f4*vect[kipy] + f5*hxp[1] + f6*h[1];
1029 vout[kipz] = vect[kipz] + f4*vect[kipz] + f5*hxp[2] + f6*h[2];
1034 //__________________________________________________________________________
1035 void AliMUONTrackExtrap::ExtrapOneStepHelix3(Double_t field, Double_t step, Double_t *vect, Double_t *vout)
1038 /// ******************************************************************
1040 /// * Tracking routine in a constant field oriented *
1041 /// * along axis 3 *
1042 /// * Tracking is performed with a conventional *
1043 /// * helix step method *
1045 /// * ==>Called by : USER, GUSWIM *
1046 /// * Authors R.Brun, M.Hansroul ********* *
1047 /// * Rewritten V.Perevoztchikov
1049 /// ******************************************************************
1053 Double_t h4, hp, rho, tet;
1054 Double_t sint, sintt, tsint, cos1t;
1055 Double_t f1, f2, f3, f4, f5, f6;
1057 const Int_t kix = 0;
1058 const Int_t kiy = 1;
1059 const Int_t kiz = 2;
1060 const Int_t kipx = 3;
1061 const Int_t kipy = 4;
1062 const Int_t kipz = 5;
1063 const Int_t kipp = 6;
1065 const Double_t kec = 2.9979251e-4;
1068 // ------------------------------------------------------------------
1070 // units are kgauss,centimeters,gev/c
1072 vout[kipp] = vect[kipp];
1075 hxp[0] = - vect[kipy];
1076 hxp[1] = + vect[kipx];
1080 rho = -h4/vect[kipp];
1082 if (TMath::Abs(tet) > 0.15) {
1083 sint = TMath::Sin(tet);
1085 tsint = (tet-sint)/tet;
1086 cos1t = 2.* TMath::Sin(0.5*tet) * TMath::Sin(0.5*tet)/tet;
1088 tsint = tet*tet/36.;
1089 sintt = (1. - tsint);
1096 f3 = step * tsint * hp;
1099 f6 = tet * cos1t * hp;
1101 vout[kix] = vect[kix] + f1*vect[kipx] + f2*hxp[0];
1102 vout[kiy] = vect[kiy] + f1*vect[kipy] + f2*hxp[1];
1103 vout[kiz] = vect[kiz] + f1*vect[kipz] + f3;
1105 vout[kipx] = vect[kipx] + f4*vect[kipx] + f5*hxp[0];
1106 vout[kipy] = vect[kipy] + f4*vect[kipy] + f5*hxp[1];
1107 vout[kipz] = vect[kipz] + f4*vect[kipz] + f6;
1112 //__________________________________________________________________________
1113 void AliMUONTrackExtrap::ExtrapOneStepRungekutta(Double_t charge, Double_t step, Double_t* vect, Double_t* vout)
1116 /// ******************************************************************
1118 /// * Runge-Kutta method for tracking a particle through a magnetic *
1119 /// * field. Uses Nystroem algorithm (See Handbook Nat. Bur. of *
1120 /// * Standards, procedure 25.5.20) *
1122 /// * Input parameters *
1123 /// * CHARGE Particle charge *
1124 /// * STEP Step size *
1125 /// * VECT Initial co-ords,direction cosines,momentum *
1126 /// * Output parameters *
1127 /// * VOUT Output co-ords,direction cosines,momentum *
1128 /// * User routine called *
1129 /// * CALL GUFLD(X,F) *
1131 /// * ==>Called by : USER, GUSWIM *
1132 /// * Authors R.Brun, M.Hansroul ********* *
1133 /// * V.Perevoztchikov (CUT STEP implementation) *
1136 /// ******************************************************************
1139 Double_t h2, h4, f[4];
1140 Double_t xyzt[3], a, b, c, ph,ph2;
1141 Double_t secxs[4],secys[4],seczs[4],hxp[3];
1142 Double_t g1, g2, g3, g4, g5, g6, ang2, dxt, dyt, dzt;
1143 Double_t est, at, bt, ct, cba;
1144 Double_t f1, f2, f3, f4, rho, tet, hnorm, hp, rho1, sint, cost;
1154 Double_t maxit = 1992;
1155 Double_t maxcut = 11;
1157 const Double_t kdlt = 1e-4;
1158 const Double_t kdlt32 = kdlt/32.;
1159 const Double_t kthird = 1./3.;
1160 const Double_t khalf = 0.5;
1161 const Double_t kec = 2.9979251e-4;
1163 const Double_t kpisqua = 9.86960440109;
1164 const Int_t kix = 0;
1165 const Int_t kiy = 1;
1166 const Int_t kiz = 2;
1167 const Int_t kipx = 3;
1168 const Int_t kipy = 4;
1169 const Int_t kipz = 5;
1172 // *. ------------------------------------------------------------------
1174 // * this constant is for units cm,gev/c and kgauss
1178 for(Int_t j = 0; j < 7; j++)
1181 Double_t pinv = kec * charge / vect[6];
1189 if (TMath::Abs(h) > TMath::Abs(rest)) h = rest;
1190 //cmodif: call gufld(vout,f) changed into:
1195 // * start of integration
1208 secxs[0] = (b * f[2] - c * f[1]) * ph2;
1209 secys[0] = (c * f[0] - a * f[2]) * ph2;
1210 seczs[0] = (a * f[1] - b * f[0]) * ph2;
1211 ang2 = (secxs[0]*secxs[0] + secys[0]*secys[0] + seczs[0]*seczs[0]);
1212 if (ang2 > kpisqua) break;
1214 dxt = h2 * a + h4 * secxs[0];
1215 dyt = h2 * b + h4 * secys[0];
1216 dzt = h2 * c + h4 * seczs[0];
1221 // * second intermediate point
1224 est = TMath::Abs(dxt) + TMath::Abs(dyt) + TMath::Abs(dzt);
1226 if (ncut++ > maxcut) break;
1235 //cmodif: call gufld(xyzt,f) changed into:
1242 secxs[1] = (bt * f[2] - ct * f[1]) * ph2;
1243 secys[1] = (ct * f[0] - at * f[2]) * ph2;
1244 seczs[1] = (at * f[1] - bt * f[0]) * ph2;
1248 secxs[2] = (bt * f[2] - ct * f[1]) * ph2;
1249 secys[2] = (ct * f[0] - at * f[2]) * ph2;
1250 seczs[2] = (at * f[1] - bt * f[0]) * ph2;
1251 dxt = h * (a + secxs[2]);
1252 dyt = h * (b + secys[2]);
1253 dzt = h * (c + seczs[2]);
1257 at = a + 2.*secxs[2];
1258 bt = b + 2.*secys[2];
1259 ct = c + 2.*seczs[2];
1261 est = TMath::Abs(dxt)+TMath::Abs(dyt)+TMath::Abs(dzt);
1262 if (est > 2.*TMath::Abs(h)) {
1263 if (ncut++ > maxcut) break;
1272 //cmodif: call gufld(xyzt,f) changed into:
1275 z = z + (c + (seczs[0] + seczs[1] + seczs[2]) * kthird) * h;
1276 y = y + (b + (secys[0] + secys[1] + secys[2]) * kthird) * h;
1277 x = x + (a + (secxs[0] + secxs[1] + secxs[2]) * kthird) * h;
1279 secxs[3] = (bt*f[2] - ct*f[1])* ph2;
1280 secys[3] = (ct*f[0] - at*f[2])* ph2;
1281 seczs[3] = (at*f[1] - bt*f[0])* ph2;
1282 a = a+(secxs[0]+secxs[3]+2. * (secxs[1]+secxs[2])) * kthird;
1283 b = b+(secys[0]+secys[3]+2. * (secys[1]+secys[2])) * kthird;
1284 c = c+(seczs[0]+seczs[3]+2. * (seczs[1]+seczs[2])) * kthird;
1286 est = TMath::Abs(secxs[0]+secxs[3] - (secxs[1]+secxs[2]))
1287 + TMath::Abs(secys[0]+secys[3] - (secys[1]+secys[2]))
1288 + TMath::Abs(seczs[0]+seczs[3] - (seczs[1]+seczs[2]));
1290 if (est > kdlt && TMath::Abs(h) > 1.e-4) {
1291 if (ncut++ > maxcut) break;
1297 // * if too many iterations, go to helix
1298 if (iter++ > maxit) break;
1303 cba = 1./ TMath::Sqrt(a*a + b*b + c*c);
1311 if (step < 0.) rest = -rest;
1312 if (rest < 1.e-5*TMath::Abs(step)) return;
1316 // angle too big, use helix
1321 f4 = TMath::Sqrt(f1*f1+f2*f2+f3*f3);
1330 hxp[0] = f2*vect[kipz] - f3*vect[kipy];
1331 hxp[1] = f3*vect[kipx] - f1*vect[kipz];
1332 hxp[2] = f1*vect[kipy] - f2*vect[kipx];
1334 hp = f1*vect[kipx] + f2*vect[kipy] + f3*vect[kipz];
1337 sint = TMath::Sin(tet);
1338 cost = 2.*TMath::Sin(khalf*tet)*TMath::Sin(khalf*tet);
1342 g3 = (tet-sint) * hp*rho1;
1347 vout[kix] = vect[kix] + g1*vect[kipx] + g2*hxp[0] + g3*f1;
1348 vout[kiy] = vect[kiy] + g1*vect[kipy] + g2*hxp[1] + g3*f2;
1349 vout[kiz] = vect[kiz] + g1*vect[kipz] + g2*hxp[2] + g3*f3;
1351 vout[kipx] = vect[kipx] + g4*vect[kipx] + g5*hxp[0] + g6*f1;
1352 vout[kipy] = vect[kipy] + g4*vect[kipy] + g5*hxp[1] + g6*f2;
1353 vout[kipz] = vect[kipz] + g4*vect[kipz] + g5*hxp[2] + g6*f3;
1358 //___________________________________________________________
1359 void AliMUONTrackExtrap::GetField(Double_t *Position, Double_t *Field)
1361 /// interface for arguments in double precision (Why ? ChF)
1364 x[0] = Position[0]; x[1] = Position[1]; x[2] = Position[2];
1366 if (fgkField) fgkField->Field(x,b);
1368 cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl;
1372 Field[0] = b[0]; Field[1] = b[1]; Field[2] = b[2];