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"
28 #include "AliMUONReconstructor.h"
29 #include "AliMUONRecoParam.h"
34 #include <TGeoManager.h>
36 #include <Riostream.h>
39 ClassImp(AliMUONTrackExtrap) // Class implementation in ROOT context
42 const AliMagF* AliMUONTrackExtrap::fgkField = 0x0;
43 const Double_t AliMUONTrackExtrap::fgkSimpleBPosition = 0.5 * (AliMUONConstants::CoilZ() + AliMUONConstants::YokeZ());
44 const Double_t AliMUONTrackExtrap::fgkSimpleBLength = 0.5 * (AliMUONConstants::CoilL() + AliMUONConstants::YokeL());
45 Double_t AliMUONTrackExtrap::fgSimpleBValue = 0.;
46 Bool_t AliMUONTrackExtrap::fgFieldON = kFALSE;
47 const Bool_t AliMUONTrackExtrap::fgkUseHelix = kFALSE;
48 const Int_t AliMUONTrackExtrap::fgkMaxStepNumber = 5000;
49 const Double_t AliMUONTrackExtrap::fgkHelixStepLength = 6.;
50 const Double_t AliMUONTrackExtrap::fgkRungeKuttaMaxResidue = 0.002;
52 //__________________________________________________________________________
53 void AliMUONTrackExtrap::SetField(const AliMagF* magField)
55 /// set magnetic field
60 cout<<"E-AliMUONTrackExtrap::SetField: fgkField = 0x0"<<endl;
64 // set field on/off flag
65 fgFieldON = (fgkField->Factor() == 0.) ? kFALSE : kTRUE;
67 // set field at the centre of the dipole
69 Float_t b[3] = {0.,0.,0.}, x[3] = {50.,50.,(Float_t) fgkSimpleBPosition};
71 fgSimpleBValue = (Double_t) b[0];
72 } else fgSimpleBValue = 0.;
76 //__________________________________________________________________________
77 Double_t AliMUONTrackExtrap::GetImpactParamFromBendingMomentum(Double_t bendingMomentum)
79 /// Returns impact parameter at vertex in bending plane (cm),
80 /// from the signed bending momentum "BendingMomentum" in bending plane (GeV/c),
81 /// using simple values for dipole magnetic field.
82 /// The sign of "BendingMomentum" is the sign of the charge.
84 if (bendingMomentum == 0.) return 1.e10;
87 cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl;
91 const Double_t kCorrectionFactor = 0.9; // impact parameter is 10% overestimated
93 return kCorrectionFactor * (-0.0003 * fgSimpleBValue * fgkSimpleBLength * fgkSimpleBPosition / bendingMomentum);
96 //__________________________________________________________________________
97 Double_t AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(Double_t impactParam)
99 /// Returns signed bending momentum in bending plane (GeV/c),
100 /// the sign being the sign of the charge for particles moving forward in Z,
101 /// from the impact parameter "ImpactParam" at vertex in bending plane (cm),
102 /// using simple values for dipole magnetic field.
104 if (impactParam == 0.) return 1.e10;
107 cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl;
111 const Double_t kCorrectionFactor = 1.1; // bending momentum is 10% underestimated
113 if (fgFieldON) return kCorrectionFactor * (-0.0003 * fgSimpleBValue * fgkSimpleBLength * fgkSimpleBPosition / impactParam);
114 else return AliMUONReconstructor::GetRecoParam()->GetMostProbBendingMomentum();
117 //__________________________________________________________________________
118 void AliMUONTrackExtrap::LinearExtrapToZ(AliMUONTrackParam* trackParam, Double_t zEnd, Bool_t updatePropagator)
120 /// Track parameters (and their covariances if any) linearly extrapolated to the plane at "zEnd".
121 /// On return, results from the extrapolation are updated in trackParam.
123 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z
125 // Compute track parameters
126 Double_t dZ = zEnd - trackParam->GetZ();
127 trackParam->SetNonBendingCoor(trackParam->GetNonBendingCoor() + trackParam->GetNonBendingSlope() * dZ);
128 trackParam->SetBendingCoor(trackParam->GetBendingCoor() + trackParam->GetBendingSlope() * dZ);
129 trackParam->SetZ(zEnd);
131 // Update track parameters covariances if any
132 if (trackParam->CovariancesExist()) {
133 TMatrixD paramCov(trackParam->GetCovariances());
134 paramCov(0,0) += dZ * dZ * paramCov(1,1) + 2. * dZ * paramCov(0,1);
135 paramCov(0,1) += dZ * paramCov(1,1);
136 paramCov(1,0) = paramCov(0,1);
137 paramCov(2,2) += dZ * dZ * paramCov(3,3) + 2. * dZ * paramCov(2,3);
138 paramCov(2,3) += dZ * paramCov(3,3);
139 paramCov(3,2) = paramCov(2,3);
140 trackParam->SetCovariances(paramCov);
142 // Update the propagator if required
143 if (updatePropagator) {
148 trackParam->UpdatePropagator(jacob);
155 //__________________________________________________________________________
156 void AliMUONTrackExtrap::ExtrapToZ(AliMUONTrackParam* trackParam, Double_t zEnd)
158 /// Interface to track parameter extrapolation to the plane at "Z" using Helix or Rungekutta algorithm.
159 /// On return, the track parameters resulting from the extrapolation are updated in trackParam.
160 if (!fgFieldON) AliMUONTrackExtrap::LinearExtrapToZ(trackParam,zEnd);
161 else if (fgkUseHelix) AliMUONTrackExtrap::ExtrapToZHelix(trackParam,zEnd);
162 else AliMUONTrackExtrap::ExtrapToZRungekutta(trackParam,zEnd);
165 //__________________________________________________________________________
166 void AliMUONTrackExtrap::ExtrapToZHelix(AliMUONTrackParam* trackParam, Double_t zEnd)
168 /// Track parameter extrapolation to the plane at "Z" using Helix algorithm.
169 /// On return, the track parameters resulting from the extrapolation are updated in trackParam.
170 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same Z
171 Double_t forwardBackward; // +1 if forward, -1 if backward
172 if (zEnd < trackParam->GetZ()) forwardBackward = 1.0; // spectro. z<0
173 else forwardBackward = -1.0;
174 Double_t v3[7], v3New[7]; // 7 in parameter ????
175 Int_t i3, stepNumber;
176 // For safety: return kTRUE or kFALSE ????
177 // Parameter vector for calling EXTRAP_ONESTEP
178 ConvertTrackParamForExtrap(trackParam, forwardBackward, v3);
179 // sign of charge (sign of fInverseBendingMomentum if forward motion)
180 // must be changed if backward extrapolation
181 Double_t chargeExtrap = forwardBackward * TMath::Sign(Double_t(1.0), trackParam->GetInverseBendingMomentum());
182 // Extrapolation loop
184 while (((-forwardBackward * (v3[2] - zEnd)) <= 0.0) && (stepNumber < fgkMaxStepNumber)) { // spectro. z<0
186 ExtrapOneStepHelix(chargeExtrap, fgkHelixStepLength, v3, v3New);
187 if ((-forwardBackward * (v3New[2] - zEnd)) > 0.0) break; // one is beyond Z spectro. z<0
188 // better use TArray ????
189 for (i3 = 0; i3 < 7; i3++) {v3[i3] = v3New[i3];}
191 // check fgkMaxStepNumber ????
192 // Interpolation back to exact Z (2nd order)
193 // should be in function ???? using TArray ????
194 Double_t dZ12 = v3New[2] - v3[2]; // 1->2
195 if (TMath::Abs(dZ12) > 0) {
196 Double_t dZ1i = zEnd - v3[2]; // 1-i
197 Double_t dZi2 = v3New[2] - zEnd; // i->2
198 Double_t xPrime = (v3New[0] - v3[0]) / dZ12;
199 Double_t xSecond = ((v3New[3] / v3New[5]) - (v3[3] / v3[5])) / dZ12;
200 Double_t yPrime = (v3New[1] - v3[1]) / dZ12;
201 Double_t ySecond = ((v3New[4] / v3New[5]) - (v3[4] / v3[5])) / dZ12;
202 v3[0] = v3[0] + xPrime * dZ1i - 0.5 * xSecond * dZ1i * dZi2; // X
203 v3[1] = v3[1] + yPrime * dZ1i - 0.5 * ySecond * dZ1i * dZi2; // Y
205 Double_t xPrimeI = xPrime - 0.5 * xSecond * (dZi2 - dZ1i);
206 Double_t yPrimeI = yPrime - 0.5 * ySecond * (dZi2 - dZ1i);
207 // (PX, PY, PZ)/PTOT assuming forward motion
208 v3[5] = 1.0 / TMath::Sqrt(1.0 + xPrimeI * xPrimeI + yPrimeI * yPrimeI); // PZ/PTOT
209 v3[3] = xPrimeI * v3[5]; // PX/PTOT
210 v3[4] = yPrimeI * v3[5]; // PY/PTOT
212 cout<<"W-AliMUONTrackExtrap::ExtrapToZHelix: Extrap. to Z not reached, Z = "<<zEnd<<endl;
214 // Recover track parameters (charge back for forward motion)
215 RecoverTrackParam(v3, chargeExtrap * forwardBackward, trackParam);
218 //__________________________________________________________________________
219 void AliMUONTrackExtrap::ExtrapToZRungekutta(AliMUONTrackParam* trackParam, Double_t zEnd)
221 /// Track parameter extrapolation to the plane at "Z" using Rungekutta algorithm.
222 /// On return, the track parameters resulting from the extrapolation are updated in trackParam.
223 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same Z
224 Double_t forwardBackward; // +1 if forward, -1 if backward
225 if (zEnd < trackParam->GetZ()) forwardBackward = 1.0; // spectro. z<0
226 else forwardBackward = -1.0;
227 // sign of charge (sign of fInverseBendingMomentum if forward motion)
228 // must be changed if backward extrapolation
229 Double_t chargeExtrap = forwardBackward * TMath::Sign(Double_t(1.0), trackParam->GetInverseBendingMomentum());
230 Double_t v3[7], v3New[7];
232 Int_t stepNumber = 0;
234 // Extrapolation loop (until within tolerance)
235 Double_t residue = zEnd - trackParam->GetZ();
236 while (TMath::Abs(residue) > fgkRungeKuttaMaxResidue && stepNumber <= fgkMaxStepNumber) {
237 dZ = zEnd - trackParam->GetZ();
238 // step lenght assuming linear trajectory
239 step = dZ * TMath::Sqrt(1.0 + trackParam->GetBendingSlope()*trackParam->GetBendingSlope() +
240 trackParam->GetNonBendingSlope()*trackParam->GetNonBendingSlope());
241 ConvertTrackParamForExtrap(trackParam, forwardBackward, v3);
242 do { // reduce step lenght while zEnd oversteped
243 if (stepNumber > fgkMaxStepNumber) {
244 cout<<"W-AliMUONTrackExtrap::ExtrapToZRungekutta: Too many trials: "<<stepNumber<<endl;
248 step = TMath::Abs(step);
249 AliMUONTrackExtrap::ExtrapOneStepRungekutta(chargeExtrap,step,v3,v3New);
250 residue = zEnd - v3New[2];
251 step *= dZ/(v3New[2]-trackParam->GetZ());
252 } while (residue*dZ < 0 && TMath::Abs(residue) > fgkRungeKuttaMaxResidue);
253 RecoverTrackParam(v3New, chargeExtrap * forwardBackward, trackParam);
256 // terminate the extropolation with a straight line up to the exact "zEnd" value
257 trackParam->SetNonBendingCoor(trackParam->GetNonBendingCoor() + residue * trackParam->GetNonBendingSlope());
258 trackParam->SetBendingCoor(trackParam->GetBendingCoor() + residue * trackParam->GetBendingSlope());
259 trackParam->SetZ(zEnd);
262 //__________________________________________________________________________
263 void AliMUONTrackExtrap::ConvertTrackParamForExtrap(AliMUONTrackParam* trackParam, Double_t forwardBackward, Double_t *v3)
265 /// Set vector of Geant3 parameters pointed to by "v3" from track parameters in trackParam.
266 /// Since AliMUONTrackParam is only geometry, one uses "forwardBackward"
267 /// to know whether the particle is going forward (+1) or backward (-1).
268 v3[0] = trackParam->GetNonBendingCoor(); // X
269 v3[1] = trackParam->GetBendingCoor(); // Y
270 v3[2] = trackParam->GetZ(); // Z
271 Double_t pYZ = TMath::Abs(1.0 / trackParam->GetInverseBendingMomentum());
272 Double_t pZ = pYZ / TMath::Sqrt(1.0 + trackParam->GetBendingSlope() * trackParam->GetBendingSlope());
273 v3[6] = TMath::Sqrt(pYZ * pYZ + pZ * pZ * trackParam->GetNonBendingSlope() * trackParam->GetNonBendingSlope()); // PTOT
274 v3[5] = -forwardBackward * pZ / v3[6]; // PZ/PTOT spectro. z<0
275 v3[3] = trackParam->GetNonBendingSlope() * v3[5]; // PX/PTOT
276 v3[4] = trackParam->GetBendingSlope() * v3[5]; // PY/PTOT
279 //__________________________________________________________________________
280 void AliMUONTrackExtrap::RecoverTrackParam(Double_t *v3, Double_t charge, AliMUONTrackParam* trackParam)
282 /// Set track parameters in trackParam from Geant3 parameters pointed to by "v3",
283 /// assumed to be calculated for forward motion in Z.
284 /// "InverseBendingMomentum" is signed with "charge".
285 trackParam->SetNonBendingCoor(v3[0]); // X
286 trackParam->SetBendingCoor(v3[1]); // Y
287 trackParam->SetZ(v3[2]); // Z
288 Double_t pYZ = v3[6] * TMath::Sqrt(1.0 - v3[3] * v3[3]);
289 trackParam->SetInverseBendingMomentum(charge/pYZ);
290 trackParam->SetBendingSlope(v3[4]/v3[5]);
291 trackParam->SetNonBendingSlope(v3[3]/v3[5]);
294 //__________________________________________________________________________
295 void AliMUONTrackExtrap::ExtrapToZCov(AliMUONTrackParam* trackParam, Double_t zEnd, Bool_t updatePropagator)
297 /// Track parameters and their covariances extrapolated to the plane at "zEnd".
298 /// On return, results from the extrapolation are updated in trackParam.
300 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z
302 if (!fgFieldON) { // linear extrapolation if no magnetic field
303 AliMUONTrackExtrap::LinearExtrapToZ(trackParam,zEnd,updatePropagator);
307 // No need to propagate the covariance matrix if it does not exist
308 if (!trackParam->CovariancesExist()) {
309 cout<<"W-AliMUONTrackExtrap::ExtrapToZCov: Covariance matrix does not exist"<<endl;
310 // Extrapolate track parameters to "zEnd"
311 ExtrapToZ(trackParam,zEnd);
315 // Save the actual track parameters
316 AliMUONTrackParam trackParamSave(*trackParam);
317 TMatrixD paramSave(trackParamSave.GetParameters());
318 Double_t zBegin = trackParamSave.GetZ();
320 // Get reference to the parameter covariance matrix
321 const TMatrixD& kParamCov = trackParam->GetCovariances();
323 // Extrapolate track parameters to "zEnd"
324 ExtrapToZ(trackParam,zEnd);
326 // Get reference to the extrapolated parameters
327 const TMatrixD& extrapParam = trackParam->GetParameters();
329 // Calculate the jacobian related to the track parameters extrapolation to "zEnd"
332 TMatrixD dParam(5,1);
333 for (Int_t i=0; i<5; i++) {
334 // Skip jacobian calculation for parameters with no associated error
335 if (kParamCov(i,i) <= 0.) continue;
337 // Small variation of parameter i only
338 for (Int_t j=0; j<5; j++) {
340 dParam(j,0) = TMath::Sqrt(kParamCov(i,i));
341 if (j == 4) dParam(j,0) *= TMath::Sign(1.,-paramSave(4,0)); // variation always in the same direction
342 } else dParam(j,0) = 0.;
345 // Set new parameters
346 trackParamSave.SetParameters(paramSave);
347 trackParamSave.AddParameters(dParam);
348 trackParamSave.SetZ(zBegin);
350 // Extrapolate new track parameters to "zEnd"
351 ExtrapToZ(&trackParamSave,zEnd);
353 // Calculate the jacobian
354 TMatrixD jacobji(trackParamSave.GetParameters(),TMatrixD::kMinus,extrapParam);
355 jacobji *= 1. / dParam(i,0);
356 jacob.SetSub(0,i,jacobji);
359 // Extrapolate track parameter covariances to "zEnd"
360 TMatrixD tmp(kParamCov,TMatrixD::kMultTranspose,jacob);
361 TMatrixD tmp2(jacob,TMatrixD::kMult,tmp);
362 trackParam->SetCovariances(tmp2);
364 // Update the propagator if required
365 if (updatePropagator) trackParam->UpdatePropagator(jacob);
368 //__________________________________________________________________________
369 void AliMUONTrackExtrap::AddMCSEffectInAbsorber(AliMUONTrackParam* param, Double_t pathLength, Double_t f0, Double_t f1, Double_t f2)
371 /// Add to the track parameter covariances the effects of multiple Coulomb scattering
372 /// The absorber correction parameters are supposed to be calculated at the current track z-position
374 // absorber related covariance parameters
375 Double_t bendingSlope = param->GetBendingSlope();
376 Double_t nonBendingSlope = param->GetNonBendingSlope();
377 Double_t inverseBendingMomentum = param->GetInverseBendingMomentum();
378 Double_t alpha2 = 0.0136 * 0.0136 * inverseBendingMomentum * inverseBendingMomentum * (1.0 + bendingSlope * bendingSlope) /
379 (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope); // velocity = 1
380 Double_t varCoor = alpha2 * (pathLength * pathLength * f0 - 2. * pathLength * f1 + f2);
381 Double_t covCorrSlope = alpha2 * (pathLength * f0 - f1);
382 Double_t varSlop = alpha2 * f0;
384 // compute derivative d(q/Pxy) / dSlopeX and d(q/Pxy) / dSlopeX
385 Double_t dqPxydSlopeX = inverseBendingMomentum * nonBendingSlope / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
386 Double_t dqPxydSlopeY = - inverseBendingMomentum * nonBendingSlope*nonBendingSlope * bendingSlope /
387 (1. + bendingSlope*bendingSlope) / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
389 // Set MCS covariance matrix
390 TMatrixD newParamCov(param->GetCovariances());
392 newParamCov(0,0) += varCoor; newParamCov(0,1) += covCorrSlope;
393 newParamCov(1,0) += covCorrSlope; newParamCov(1,1) += varSlop;
395 newParamCov(2,2) += varCoor; newParamCov(2,3) += covCorrSlope;
396 newParamCov(3,2) += covCorrSlope; newParamCov(3,3) += varSlop;
397 // Inverse bending momentum (due to dependences with bending and non bending slopes)
398 newParamCov(4,0) += dqPxydSlopeX * covCorrSlope; newParamCov(0,4) += dqPxydSlopeX * covCorrSlope;
399 newParamCov(4,1) += dqPxydSlopeX * varSlop; newParamCov(1,4) += dqPxydSlopeX * varSlop;
400 newParamCov(4,2) += dqPxydSlopeY * covCorrSlope; newParamCov(2,4) += dqPxydSlopeY * covCorrSlope;
401 newParamCov(4,3) += dqPxydSlopeY * varSlop; newParamCov(3,4) += dqPxydSlopeY * varSlop;
402 newParamCov(4,4) += (dqPxydSlopeX*dqPxydSlopeX + dqPxydSlopeY*dqPxydSlopeY) * varSlop;
404 // Set new covariances
405 param->SetCovariances(newParamCov);
408 //__________________________________________________________________________
409 void AliMUONTrackExtrap::CorrectMCSEffectInAbsorber(AliMUONTrackParam* param,
410 Double_t xVtx, Double_t yVtx, Double_t zVtx,
411 Double_t errXVtx, Double_t errYVtx,
412 Double_t absZBeg, Double_t pathLength, Double_t f0, Double_t f1, Double_t f2)
414 /// Correct parameters and corresponding covariances using Branson correction
415 /// - input param are parameters and covariances at the end of absorber
416 /// - output param are parameters and covariances at vertex
417 /// Absorber correction parameters are supposed to be calculated at the current track z-position
419 // Position of the Branson plane (spectro. (z<0))
420 Double_t zB = (f1>0.) ? absZBeg - f2/f1 : 0.;
422 // Add MCS effects to current parameter covariances
423 AddMCSEffectInAbsorber(param, pathLength, f0, f1, f2);
425 // Get track parameters and covariances in the Branson plane corrected for magnetic field effect
426 ExtrapToZCov(param,zVtx);
427 LinearExtrapToZ(param,zB);
429 // compute track parameters at vertex
430 TMatrixD newParam(5,1);
431 newParam(0,0) = xVtx;
432 newParam(1,0) = (param->GetNonBendingCoor() - xVtx) / (zB - zVtx);
433 newParam(2,0) = yVtx;
434 newParam(3,0) = (param->GetBendingCoor() - yVtx) / (zB - zVtx);
435 newParam(4,0) = param->GetCharge() / param->P() *
436 TMath::Sqrt(1.0 + newParam(1,0)*newParam(1,0) + newParam(3,0)*newParam(3,0)) /
437 TMath::Sqrt(1.0 + newParam(3,0)*newParam(3,0));
439 // Get covariances in (X, SlopeX, Y, SlopeY, q*PTot) coordinate system
440 TMatrixD paramCovP(param->GetCovariances());
441 Cov2CovP(param->GetParameters(),paramCovP);
443 // Get the covariance matrix in the (XVtx, X, YVtx, Y, q*PTot) coordinate system
444 TMatrixD paramCovVtx(5,5);
446 paramCovVtx(0,0) = errXVtx * errXVtx;
447 paramCovVtx(1,1) = paramCovP(0,0);
448 paramCovVtx(2,2) = errYVtx * errYVtx;
449 paramCovVtx(3,3) = paramCovP(2,2);
450 paramCovVtx(4,4) = paramCovP(4,4);
451 paramCovVtx(1,3) = paramCovP(0,2);
452 paramCovVtx(3,1) = paramCovP(2,0);
453 paramCovVtx(1,4) = paramCovP(0,4);
454 paramCovVtx(4,1) = paramCovP(4,0);
455 paramCovVtx(3,4) = paramCovP(2,4);
456 paramCovVtx(4,3) = paramCovP(4,2);
458 // Jacobian of the transformation (XVtx, X, YVtx, Y, q*PTot) -> (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q*PTotVtx)
461 jacob(1,0) = - 1. / (zB - zVtx);
462 jacob(1,1) = 1. / (zB - zVtx);
463 jacob(3,2) = - 1. / (zB - zVtx);
464 jacob(3,3) = 1. / (zB - zVtx);
466 // Compute covariances at vertex in the (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q*PTotVtx) coordinate system
467 TMatrixD tmp(paramCovVtx,TMatrixD::kMultTranspose,jacob);
468 TMatrixD newParamCov(jacob,TMatrixD::kMult,tmp);
470 // Compute covariances at vertex in the (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q/PyzVtx) coordinate system
471 CovP2Cov(newParam,newParamCov);
473 // Set parameters and covariances at vertex
474 param->SetParameters(newParam);
476 param->SetCovariances(newParamCov);
479 //__________________________________________________________________________
480 void AliMUONTrackExtrap::CorrectELossEffectInAbsorber(AliMUONTrackParam* param, Double_t eLoss, Double_t sigmaELoss2)
482 /// Correct parameters for energy loss and add energy loss fluctuation effect to covariances
484 // Get parameter covariances in (X, SlopeX, Y, SlopeY, q*PTot) coordinate system
485 TMatrixD newParamCov(param->GetCovariances());
486 Cov2CovP(param->GetParameters(),newParamCov);
488 // Add effects of energy loss fluctuation to covariances
489 newParamCov(4,4) += sigmaELoss2;
491 // Compute new parameters corrected for energy loss
492 Double_t nonBendingSlope = param->GetNonBendingSlope();
493 Double_t bendingSlope = param->GetBendingSlope();
494 param->SetInverseBendingMomentum(param->GetCharge() / (param->P() + eLoss) *
495 TMath::Sqrt(1.0 + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope) /
496 TMath::Sqrt(1.0 + bendingSlope*bendingSlope));
498 // Get new parameter covariances in (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system
499 CovP2Cov(param->GetParameters(),newParamCov);
501 // Set new parameter covariances
502 param->SetCovariances(newParamCov);
505 //__________________________________________________________________________
506 Bool_t AliMUONTrackExtrap::GetAbsorberCorrectionParam(Double_t trackXYZIn[3], Double_t trackXYZOut[3], Double_t pTotal,
507 Double_t &pathLength, Double_t &f0, Double_t &f1, Double_t &f2,
508 Double_t &meanRho, Double_t &totalELoss, Double_t &sigmaELoss2)
510 /// Parameters used to correct for Multiple Coulomb Scattering and energy loss in absorber
511 /// Calculated assuming a linear propagation from trackXYZIn to trackXYZOut (order is important)
512 // pathLength: path length between trackXYZIn and trackXYZOut (cm)
513 // f0: 0th moment of z calculated with the inverse radiation-length distribution
514 // f1: 1st moment of z calculated with the inverse radiation-length distribution
515 // f2: 2nd moment of z calculated with the inverse radiation-length distribution
516 // meanRho: average density of crossed material (g/cm3)
517 // totalELoss: total energy loss in absorber
519 // Reset absorber's parameters
528 // Check whether the geometry is available
530 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: no TGeo"<<endl;
534 // Initialize starting point and direction
535 pathLength = TMath::Sqrt((trackXYZOut[0] - trackXYZIn[0])*(trackXYZOut[0] - trackXYZIn[0])+
536 (trackXYZOut[1] - trackXYZIn[1])*(trackXYZOut[1] - trackXYZIn[1])+
537 (trackXYZOut[2] - trackXYZIn[2])*(trackXYZOut[2] - trackXYZIn[2]));
538 if (pathLength < TGeoShape::Tolerance()) return kFALSE;
540 b[0] = (trackXYZOut[0] - trackXYZIn[0]) / pathLength;
541 b[1] = (trackXYZOut[1] - trackXYZIn[1]) / pathLength;
542 b[2] = (trackXYZOut[2] - trackXYZIn[2]) / pathLength;
543 TGeoNode *currentnode = gGeoManager->InitTrack(trackXYZIn, b);
545 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: start point out of geometry"<<endl;
549 // loop over absorber slices and calculate absorber's parameters
550 Double_t rho = 0.; // material density (g/cm3)
551 Double_t x0 = 0.; // radiation-length (cm-1)
552 Double_t atomicA = 0.; // A of material
553 Double_t atomicZ = 0.; // Z of material
554 Double_t localPathLength = 0;
555 Double_t remainingPathLength = pathLength;
556 Double_t zB = trackXYZIn[2];
557 Double_t zE, dzB, dzE;
559 // Get material properties
560 TGeoMaterial *material = currentnode->GetVolume()->GetMedium()->GetMaterial();
561 rho = material->GetDensity();
562 x0 = material->GetRadLen();
563 if (!material->IsMixture()) x0 /= rho; // different normalization in the modeler for mixture
564 atomicA = material->GetA();
565 atomicZ = material->GetZ();
567 // Get path length within this material
568 gGeoManager->FindNextBoundary(remainingPathLength);
569 localPathLength = gGeoManager->GetStep() + 1.e-6;
570 // Check if boundary within remaining path length. If so, make sure to cross the boundary to prepare the next step
571 if (localPathLength >= remainingPathLength) localPathLength = remainingPathLength;
573 currentnode = gGeoManager->Step();
575 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: navigation failed"<<endl;
576 f0 = f1 = f2 = meanRho = totalELoss = sigmaELoss2 = 0.;
579 if (!gGeoManager->IsEntering()) {
580 // make another small step to try to enter in new absorber slice
581 gGeoManager->SetStep(0.001);
582 currentnode = gGeoManager->Step();
583 if (!gGeoManager->IsEntering() || !currentnode) {
584 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: navigation failed"<<endl;
585 f0 = f1 = f2 = meanRho = totalELoss = sigmaELoss2 = 0.;
588 localPathLength += 0.001;
592 // calculate absorber's parameters
593 zE = b[2] * localPathLength + zB;
594 dzB = zB - trackXYZIn[2];
595 dzE = zE - trackXYZIn[2];
596 f0 += localPathLength / x0;
597 f1 += (dzE*dzE - dzB*dzB) / b[2] / b[2] / x0 / 2.;
598 f2 += (dzE*dzE*dzE - dzB*dzB*dzB) / b[2] / b[2] / b[2] / x0 / 3.;
599 meanRho += localPathLength * rho;
600 totalELoss += BetheBloch(pTotal, localPathLength, rho, atomicA, atomicZ);
601 sigmaELoss2 += EnergyLossFluctuation2(pTotal, localPathLength, rho, atomicA, atomicZ);
605 remainingPathLength -= localPathLength;
606 } while (remainingPathLength > TGeoShape::Tolerance());
608 meanRho /= pathLength;
613 //__________________________________________________________________________
614 Double_t AliMUONTrackExtrap::GetMCSAngle2(const AliMUONTrackParam& param, Double_t dZ, Double_t x0)
616 /// Return the angular dispersion square due to multiple Coulomb scattering
617 /// through a material of thickness "dZ" and of radiation length "x0"
618 /// assuming linear propagation and using the small angle approximation.
620 Double_t bendingSlope = param.GetBendingSlope();
621 Double_t nonBendingSlope = param.GetNonBendingSlope();
622 Double_t inverseTotalMomentum2 = param.GetInverseBendingMomentum() * param.GetInverseBendingMomentum() *
623 (1.0 + bendingSlope * bendingSlope) /
624 (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope);
625 // Path length in the material
626 Double_t pathLength = TMath::Abs(dZ) * TMath::Sqrt(1.0 + bendingSlope*bendingSlope + nonBendingSlope*nonBendingSlope);
627 // relativistic velocity
629 // Angular dispersion square of the track (variance) in a plane perpendicular to the trajectory
630 Double_t theta02 = 0.0136 / velo * (1 + 0.038 * TMath::Log(pathLength/x0));
632 return theta02 * theta02 * inverseTotalMomentum2 * pathLength / x0;
635 //__________________________________________________________________________
636 void AliMUONTrackExtrap::AddMCSEffect(AliMUONTrackParam *param, Double_t dZ, Double_t x0)
638 /// Add to the track parameter covariances the effects of multiple Coulomb scattering
639 /// through a material of thickness "dZ" and of radiation length "x0"
640 /// assuming linear propagation and using the small angle approximation.
642 Double_t bendingSlope = param->GetBendingSlope();
643 Double_t nonBendingSlope = param->GetNonBendingSlope();
644 Double_t inverseBendingMomentum = param->GetInverseBendingMomentum();
645 Double_t inverseTotalMomentum2 = inverseBendingMomentum * inverseBendingMomentum *
646 (1.0 + bendingSlope * bendingSlope) /
647 (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope);
648 // Path length in the material
649 Double_t pathLength = TMath::Abs(dZ) * TMath::Sqrt(1.0 + bendingSlope*bendingSlope + nonBendingSlope*nonBendingSlope);
650 Double_t pathLength2 = pathLength * pathLength;
651 // relativistic velocity
653 // Angular dispersion square of the track (variance) in a plane perpendicular to the trajectory
654 Double_t theta02 = 0.0136 / velo * (1 + 0.038 * TMath::Log(pathLength/x0));
655 theta02 *= theta02 * inverseTotalMomentum2 * pathLength / x0;
657 Double_t varCoor = pathLength2 * theta02 / 3.;
658 Double_t varSlop = theta02;
659 Double_t covCorrSlope = pathLength * theta02 / 2.;
661 // compute derivative d(q/Pxy) / dSlopeX and d(q/Pxy) / dSlopeX
662 Double_t dqPxydSlopeX = inverseBendingMomentum * nonBendingSlope / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
663 Double_t dqPxydSlopeY = - inverseBendingMomentum * nonBendingSlope*nonBendingSlope * bendingSlope /
664 (1. + bendingSlope*bendingSlope) / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
666 // Set MCS covariance matrix
667 TMatrixD newParamCov(param->GetCovariances());
669 newParamCov(0,0) += varCoor; newParamCov(0,1) += covCorrSlope;
670 newParamCov(1,0) += covCorrSlope; newParamCov(1,1) += varSlop;
672 newParamCov(2,2) += varCoor; newParamCov(2,3) += covCorrSlope;
673 newParamCov(3,2) += covCorrSlope; newParamCov(3,3) += varSlop;
674 // Inverse bending momentum (due to dependences with bending and non bending slopes)
675 newParamCov(4,0) += dqPxydSlopeX * covCorrSlope; newParamCov(0,4) += dqPxydSlopeX * covCorrSlope;
676 newParamCov(4,1) += dqPxydSlopeX * varSlop; newParamCov(1,4) += dqPxydSlopeX * varSlop;
677 newParamCov(4,2) += dqPxydSlopeY * covCorrSlope; newParamCov(2,4) += dqPxydSlopeY * covCorrSlope;
678 newParamCov(4,3) += dqPxydSlopeY * varSlop; newParamCov(3,4) += dqPxydSlopeY * varSlop;
679 newParamCov(4,4) += (dqPxydSlopeX*dqPxydSlopeX + dqPxydSlopeY*dqPxydSlopeY) * varSlop;
681 // Set new covariances
682 param->SetCovariances(newParamCov);
685 //__________________________________________________________________________
686 void AliMUONTrackExtrap::ExtrapToVertex(AliMUONTrackParam* trackParam,
687 Double_t xVtx, Double_t yVtx, Double_t zVtx,
688 Double_t errXVtx, Double_t errYVtx,
689 Bool_t correctForMCS, Bool_t correctForEnergyLoss)
691 /// Main method for extrapolation to the vertex:
692 /// Returns the track parameters and covariances resulting from the extrapolation of the current trackParam
693 /// Changes parameters and covariances according to multiple scattering and energy loss corrections:
694 /// if correctForMCS=kTRUE: compute parameters using Branson correction and add correction resolution to covariances
695 /// if correctForMCS=kFALSE: add parameter dispersion due to MCS in parameter covariances
696 /// if correctForEnergyLoss=kTRUE: correct parameters for energy loss and add energy loss fluctuation to covariances
697 /// if correctForEnergyLoss=kFALSE: do nothing about energy loss
699 if (trackParam->GetZ() == zVtx) return; // nothing to be done if already at vertex
701 if (trackParam->GetZ() > zVtx) { // spectro. (z<0)
702 cout<<"E-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ()
703 <<") upstream the vertex (zVtx = "<<zVtx<<")"<<endl;
707 // Check the vertex position relatively to the absorber
708 if (zVtx < AliMUONConstants::AbsZBeg() && zVtx > AliMUONConstants::AbsZEnd()) { // spectro. (z<0)
709 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Ending Z ("<<zVtx
710 <<") inside the front absorber ("<<AliMUONConstants::AbsZBeg()<<","<<AliMUONConstants::AbsZEnd()<<")"<<endl;
711 } else if (zVtx < AliMUONConstants::AbsZEnd() ) { // spectro. (z<0)
712 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Ending Z ("<<zVtx
713 <<") downstream the front absorber (zAbsorberEnd = "<<AliMUONConstants::AbsZEnd()<<")"<<endl;
714 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx);
715 else ExtrapToZ(trackParam,zVtx);
719 // Check the track position relatively to the absorber and extrapolate track parameters to the end of the absorber if needed
720 if (trackParam->GetZ() > AliMUONConstants::AbsZBeg()) { // spectro. (z<0)
721 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ()
722 <<") upstream the front absorber (zAbsorberBegin = "<<AliMUONConstants::AbsZBeg()<<")"<<endl;
723 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx);
724 else ExtrapToZ(trackParam,zVtx);
726 } else if (trackParam->GetZ() > AliMUONConstants::AbsZEnd()) { // spectro. (z<0)
727 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ()
728 <<") inside the front absorber ("<<AliMUONConstants::AbsZBeg()<<","<<AliMUONConstants::AbsZEnd()<<")"<<endl;
730 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,AliMUONConstants::AbsZEnd());
731 else ExtrapToZ(trackParam,AliMUONConstants::AbsZEnd());
734 // Get absorber correction parameters assuming linear propagation in absorber
735 Double_t trackXYZOut[3];
736 trackXYZOut[0] = trackParam->GetNonBendingCoor();
737 trackXYZOut[1] = trackParam->GetBendingCoor();
738 trackXYZOut[2] = trackParam->GetZ();
739 Double_t trackXYZIn[3];
740 if (correctForMCS) { // assume linear propagation until the vertex
741 trackXYZIn[2] = TMath::Min(zVtx, AliMUONConstants::AbsZBeg()); // spectro. (z<0)
742 trackXYZIn[0] = trackXYZOut[0] + (xVtx - trackXYZOut[0]) / (zVtx - trackXYZOut[2]) * (trackXYZIn[2] - trackXYZOut[2]);
743 trackXYZIn[1] = trackXYZOut[1] + (yVtx - trackXYZOut[1]) / (zVtx - trackXYZOut[2]) * (trackXYZIn[2] - trackXYZOut[2]);
745 AliMUONTrackParam trackParamIn(*trackParam);
746 ExtrapToZ(&trackParamIn, TMath::Min(zVtx, AliMUONConstants::AbsZBeg()));
747 trackXYZIn[0] = trackParamIn.GetNonBendingCoor();
748 trackXYZIn[1] = trackParamIn.GetBendingCoor();
749 trackXYZIn[2] = trackParamIn.GetZ();
751 Double_t pTot = trackParam->P();
752 Double_t pathLength, f0, f1, f2, meanRho, deltaP, sigmaDeltaP2;
753 if (!GetAbsorberCorrectionParam(trackXYZIn,trackXYZOut,pTot,pathLength,f0,f1,f2,meanRho,deltaP,sigmaDeltaP2)) {
754 cout<<"E-AliMUONTrackExtrap::ExtrapToVertex: Unable to take into account the absorber effects"<<endl;
755 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx);
756 else ExtrapToZ(trackParam,zVtx);
760 // Compute track parameters and covariances at vertex according to correctForMCS and correctForEnergyLoss flags
763 if (correctForEnergyLoss) {
765 // Correct for multiple scattering and energy loss
766 CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
767 CorrectMCSEffectInAbsorber(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx,
768 trackXYZIn[2], pathLength, f0, f1, f2);
769 CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
773 // Correct for multiple scattering
774 CorrectMCSEffectInAbsorber(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx,
775 trackXYZIn[2], pathLength, f0, f1, f2);
780 if (correctForEnergyLoss) {
782 // Correct for energy loss add multiple scattering dispersion in covariance matrix
783 CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
784 AddMCSEffectInAbsorber(trackParam, pathLength, f0, f1, f2);
785 ExtrapToZCov(trackParam, trackXYZIn[2]);
786 CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
787 ExtrapToZCov(trackParam, zVtx);
791 // add multiple scattering dispersion in covariance matrix
792 AddMCSEffectInAbsorber(trackParam, pathLength, f0, f1, f2);
793 ExtrapToZCov(trackParam, zVtx);
801 //__________________________________________________________________________
802 void AliMUONTrackExtrap::ExtrapToVertex(AliMUONTrackParam* trackParam,
803 Double_t xVtx, Double_t yVtx, Double_t zVtx,
804 Double_t errXVtx, Double_t errYVtx)
806 /// Extrapolate track parameters to vertex, corrected for multiple scattering and energy loss effects
807 /// Add branson correction resolution and energy loss fluctuation to parameter covariances
808 ExtrapToVertex(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx, kTRUE, kTRUE);
811 //__________________________________________________________________________
812 void AliMUONTrackExtrap::ExtrapToVertexWithoutELoss(AliMUONTrackParam* trackParam,
813 Double_t xVtx, Double_t yVtx, Double_t zVtx,
814 Double_t errXVtx, Double_t errYVtx)
816 /// Extrapolate track parameters to vertex, corrected for multiple scattering effects only
817 /// Add branson correction resolution to parameter covariances
818 ExtrapToVertex(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx, kTRUE, kFALSE);
821 //__________________________________________________________________________
822 void AliMUONTrackExtrap::ExtrapToVertexWithoutBranson(AliMUONTrackParam* trackParam, Double_t zVtx)
824 /// Extrapolate track parameters to vertex, corrected for energy loss effects only
825 /// Add dispersion due to multiple scattering and energy loss fluctuation to parameter covariances
826 ExtrapToVertex(trackParam, 0., 0., zVtx, 0., 0., kFALSE, kTRUE);
829 //__________________________________________________________________________
830 void AliMUONTrackExtrap::ExtrapToVertexUncorrected(AliMUONTrackParam* trackParam, Double_t zVtx)
832 /// Extrapolate track parameters to vertex without multiple scattering and energy loss corrections
833 /// Add dispersion due to multiple scattering to parameter covariances
834 ExtrapToVertex(trackParam, 0., 0., zVtx, 0., 0., kFALSE, kFALSE);
837 //__________________________________________________________________________
838 Double_t AliMUONTrackExtrap::TotalMomentumEnergyLoss(AliMUONTrackParam* trackParam, Double_t xVtx, Double_t yVtx, Double_t zVtx)
840 /// Calculate the total momentum energy loss in-between the track position and the vertex assuming a linear propagation
842 if (trackParam->GetZ() == zVtx) return 0.; // nothing to be done if already at vertex
844 // Check whether the geometry is available
846 cout<<"E-AliMUONTrackExtrap::TotalMomentumEnergyLoss: no TGeo"<<endl;
850 // Get encountered material correction parameters assuming linear propagation from vertex to the track position
851 Double_t trackXYZOut[3];
852 trackXYZOut[0] = trackParam->GetNonBendingCoor();
853 trackXYZOut[1] = trackParam->GetBendingCoor();
854 trackXYZOut[2] = trackParam->GetZ();
855 Double_t trackXYZIn[3];
856 trackXYZIn[0] = xVtx;
857 trackXYZIn[1] = yVtx;
858 trackXYZIn[2] = zVtx;
859 Double_t pTot = trackParam->P();
860 Double_t pathLength, f0, f1, f2, meanRho, totalELoss, sigmaELoss2;
861 GetAbsorberCorrectionParam(trackXYZIn,trackXYZOut,pTot,pathLength,f0,f1,f2,meanRho,totalELoss,sigmaELoss2);
866 //__________________________________________________________________________
867 Double_t AliMUONTrackExtrap::BetheBloch(Double_t pTotal, Double_t pathLength, Double_t rho, Double_t atomicA, Double_t atomicZ)
869 /// Returns the mean total momentum energy loss of muon with total momentum='pTotal'
870 /// in the absorber layer of lenght='pathLength', density='rho', A='atomicA' and Z='atomicZ'
871 Double_t muMass = 0.105658369; // GeV
872 Double_t eMass = 0.510998918e-3; // GeV
873 Double_t k = 0.307075e-3; // GeV.g^-1.cm^2
874 Double_t i = 9.5e-9; // mean exitation energy per atomic Z (GeV)
875 Double_t p2=pTotal*pTotal;
876 Double_t beta2=p2/(p2 + muMass*muMass);
878 Double_t w = k * rho * pathLength * atomicZ / atomicA / beta2;
880 if (beta2/(1-beta2)>3.5*3.5)
881 return w * (log(2.*eMass*3.5/(i*atomicZ)) + 0.5*log(beta2/(1-beta2)) - beta2);
883 return w * (log(2.*eMass*beta2/(1-beta2)/(i*atomicZ)) - beta2);
886 //__________________________________________________________________________
887 Double_t AliMUONTrackExtrap::EnergyLossFluctuation2(Double_t pTotal, Double_t pathLength, Double_t rho, Double_t atomicA, Double_t atomicZ)
889 /// Returns the total momentum energy loss fluctuation of muon with total momentum='pTotal'
890 /// in the absorber layer of lenght='pathLength', density='rho', A='atomicA' and Z='atomicZ'
891 Double_t muMass = 0.105658369; // GeV
892 //Double_t eMass = 0.510998918e-3; // GeV
893 Double_t k = 0.307075e-3; // GeV.g^-1.cm^2
894 Double_t p2=pTotal*pTotal;
895 Double_t beta2=p2/(p2 + muMass*muMass);
897 Double_t fwhm = 2. * k * rho * pathLength * atomicZ / atomicA / beta2; // FWHM of the energy loss Landau distribution
898 Double_t sigma2 = fwhm * fwhm / (8.*log(2.)); // gaussian: fwmh = 2 * srqt(2*ln(2)) * sigma (i.e. fwmh = 2.35 * sigma)
900 //sigma2 = k * rho * pathLength * atomicZ / atomicA * eMass; // sigma2 of the energy loss gaussian distribution
905 //__________________________________________________________________________
906 void AliMUONTrackExtrap::Cov2CovP(const TMatrixD ¶m, TMatrixD &cov)
908 /// change coordinate system: (X, SlopeX, Y, SlopeY, q/Pyz) -> (X, SlopeX, Y, SlopeY, q*PTot)
909 /// parameters (param) are given in the (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system
911 // charge * total momentum
912 Double_t qPTot = TMath::Sqrt(1. + param(1,0)*param(1,0) + param(3,0)*param(3,0)) /
913 TMath::Sqrt(1. + param(3,0)*param(3,0)) / param(4,0);
915 // Jacobian of the opposite transformation
918 jacob(4,1) = qPTot * param(1,0) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
919 jacob(4,3) = - qPTot * param(1,0) * param(1,0) * param(3,0) /
920 (1. + param(3,0)*param(3,0)) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
921 jacob(4,4) = - qPTot / param(4,0);
923 // compute covariances in new coordinate system
924 TMatrixD tmp(cov,TMatrixD::kMultTranspose,jacob);
928 //__________________________________________________________________________
929 void AliMUONTrackExtrap::CovP2Cov(const TMatrixD ¶m, TMatrixD &covP)
931 /// change coordinate system: (X, SlopeX, Y, SlopeY, q*PTot) -> (X, SlopeX, Y, SlopeY, q/Pyz)
932 /// parameters (param) are given in the (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system
934 // charge * total momentum
935 Double_t qPTot = TMath::Sqrt(1. + param(1,0)*param(1,0) + param(3,0)*param(3,0)) /
936 TMath::Sqrt(1. + param(3,0)*param(3,0)) / param(4,0);
938 // Jacobian of the transformation
941 jacob(4,1) = param(4,0) * param(1,0) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
942 jacob(4,3) = - param(4,0) * param(1,0) * param(1,0) * param(3,0) /
943 (1. + param(3,0)*param(3,0)) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
944 jacob(4,4) = - param(4,0) / qPTot;
946 // compute covariances in new coordinate system
947 TMatrixD tmp(covP,TMatrixD::kMultTranspose,jacob);
948 covP.Mult(jacob,tmp);
951 //__________________________________________________________________________
952 void AliMUONTrackExtrap::ExtrapOneStepHelix(Double_t charge, Double_t step, Double_t *vect, Double_t *vout)
955 /// ******************************************************************
957 /// * Performs the tracking of one step in a magnetic field *
958 /// * The trajectory is assumed to be a helix in a constant field *
959 /// * taken at the mid point of the step. *
962 /// * STEP =arc length of the step asked *
963 /// * VECT =input vector (position,direction cos and momentum) *
964 /// * CHARGE= electric charge of the particle *
966 /// * VOUT = same as VECT after completion of the step *
968 /// * ==>Called by : USER, GUSWIM *
969 /// * Author m.hansroul ********* *
970 /// * modified s.egli, s.v.levonian *
971 /// * modified v.perevoztchikov
973 /// ******************************************************************
976 // modif: everything in double precision
978 Double_t xyz[3], h[4], hxp[3];
979 Double_t h2xy, hp, rho, tet;
980 Double_t sint, sintt, tsint, cos1t;
981 Double_t f1, f2, f3, f4, f5, f6;
986 const Int_t kipx = 3;
987 const Int_t kipy = 4;
988 const Int_t kipz = 5;
989 const Int_t kipp = 6;
991 const Double_t kec = 2.9979251e-4;
993 // ------------------------------------------------------------------
995 // units are kgauss,centimeters,gev/c
997 vout[kipp] = vect[kipp];
998 if (TMath::Abs(charge) < 0.00001) {
999 for (Int_t i = 0; i < 3; i++) {
1000 vout[i] = vect[i] + step * vect[i+3];
1001 vout[i+3] = vect[i+3];
1005 xyz[0] = vect[kix] + 0.5 * step * vect[kipx];
1006 xyz[1] = vect[kiy] + 0.5 * step * vect[kipy];
1007 xyz[2] = vect[kiz] + 0.5 * step * vect[kipz];
1009 //cmodif: call gufld (xyz, h) changed into:
1012 h2xy = h[0]*h[0] + h[1]*h[1];
1013 h[3] = h[2]*h[2]+ h2xy;
1014 if (h[3] < 1.e-12) {
1015 for (Int_t i = 0; i < 3; i++) {
1016 vout[i] = vect[i] + step * vect[i+3];
1017 vout[i+3] = vect[i+3];
1021 if (h2xy < 1.e-12*h[3]) {
1022 ExtrapOneStepHelix3(charge*h[2], step, vect, vout);
1025 h[3] = TMath::Sqrt(h[3]);
1031 hxp[0] = h[1]*vect[kipz] - h[2]*vect[kipy];
1032 hxp[1] = h[2]*vect[kipx] - h[0]*vect[kipz];
1033 hxp[2] = h[0]*vect[kipy] - h[1]*vect[kipx];
1035 hp = h[0]*vect[kipx] + h[1]*vect[kipy] + h[2]*vect[kipz];
1037 rho = -charge*h[3]/vect[kipp];
1040 if (TMath::Abs(tet) > 0.15) {
1041 sint = TMath::Sin(tet);
1043 tsint = (tet-sint)/tet;
1044 cos1t = 2.*(TMath::Sin(0.5*tet))*(TMath::Sin(0.5*tet))/tet;
1046 tsint = tet*tet/36.;
1047 sintt = (1. - tsint);
1054 f3 = step * tsint * hp;
1057 f6 = tet * cos1t * hp;
1059 vout[kix] = vect[kix] + f1*vect[kipx] + f2*hxp[0] + f3*h[0];
1060 vout[kiy] = vect[kiy] + f1*vect[kipy] + f2*hxp[1] + f3*h[1];
1061 vout[kiz] = vect[kiz] + f1*vect[kipz] + f2*hxp[2] + f3*h[2];
1063 vout[kipx] = vect[kipx] + f4*vect[kipx] + f5*hxp[0] + f6*h[0];
1064 vout[kipy] = vect[kipy] + f4*vect[kipy] + f5*hxp[1] + f6*h[1];
1065 vout[kipz] = vect[kipz] + f4*vect[kipz] + f5*hxp[2] + f6*h[2];
1070 //__________________________________________________________________________
1071 void AliMUONTrackExtrap::ExtrapOneStepHelix3(Double_t field, Double_t step, Double_t *vect, Double_t *vout)
1074 /// ******************************************************************
1076 /// * Tracking routine in a constant field oriented *
1077 /// * along axis 3 *
1078 /// * Tracking is performed with a conventional *
1079 /// * helix step method *
1081 /// * ==>Called by : USER, GUSWIM *
1082 /// * Authors R.Brun, M.Hansroul ********* *
1083 /// * Rewritten V.Perevoztchikov
1085 /// ******************************************************************
1089 Double_t h4, hp, rho, tet;
1090 Double_t sint, sintt, tsint, cos1t;
1091 Double_t f1, f2, f3, f4, f5, f6;
1093 const Int_t kix = 0;
1094 const Int_t kiy = 1;
1095 const Int_t kiz = 2;
1096 const Int_t kipx = 3;
1097 const Int_t kipy = 4;
1098 const Int_t kipz = 5;
1099 const Int_t kipp = 6;
1101 const Double_t kec = 2.9979251e-4;
1104 // ------------------------------------------------------------------
1106 // units are kgauss,centimeters,gev/c
1108 vout[kipp] = vect[kipp];
1111 hxp[0] = - vect[kipy];
1112 hxp[1] = + vect[kipx];
1116 rho = -h4/vect[kipp];
1118 if (TMath::Abs(tet) > 0.15) {
1119 sint = TMath::Sin(tet);
1121 tsint = (tet-sint)/tet;
1122 cos1t = 2.* TMath::Sin(0.5*tet) * TMath::Sin(0.5*tet)/tet;
1124 tsint = tet*tet/36.;
1125 sintt = (1. - tsint);
1132 f3 = step * tsint * hp;
1135 f6 = tet * cos1t * hp;
1137 vout[kix] = vect[kix] + f1*vect[kipx] + f2*hxp[0];
1138 vout[kiy] = vect[kiy] + f1*vect[kipy] + f2*hxp[1];
1139 vout[kiz] = vect[kiz] + f1*vect[kipz] + f3;
1141 vout[kipx] = vect[kipx] + f4*vect[kipx] + f5*hxp[0];
1142 vout[kipy] = vect[kipy] + f4*vect[kipy] + f5*hxp[1];
1143 vout[kipz] = vect[kipz] + f4*vect[kipz] + f6;
1148 //__________________________________________________________________________
1149 void AliMUONTrackExtrap::ExtrapOneStepRungekutta(Double_t charge, Double_t step, Double_t* vect, Double_t* vout)
1152 /// ******************************************************************
1154 /// * Runge-Kutta method for tracking a particle through a magnetic *
1155 /// * field. Uses Nystroem algorithm (See Handbook Nat. Bur. of *
1156 /// * Standards, procedure 25.5.20) *
1158 /// * Input parameters *
1159 /// * CHARGE Particle charge *
1160 /// * STEP Step size *
1161 /// * VECT Initial co-ords,direction cosines,momentum *
1162 /// * Output parameters *
1163 /// * VOUT Output co-ords,direction cosines,momentum *
1164 /// * User routine called *
1165 /// * CALL GUFLD(X,F) *
1167 /// * ==>Called by : USER, GUSWIM *
1168 /// * Authors R.Brun, M.Hansroul ********* *
1169 /// * V.Perevoztchikov (CUT STEP implementation) *
1172 /// ******************************************************************
1175 Double_t h2, h4, f[4];
1176 Double_t xyzt[3], a, b, c, ph,ph2;
1177 Double_t secxs[4],secys[4],seczs[4],hxp[3];
1178 Double_t g1, g2, g3, g4, g5, g6, ang2, dxt, dyt, dzt;
1179 Double_t est, at, bt, ct, cba;
1180 Double_t f1, f2, f3, f4, rho, tet, hnorm, hp, rho1, sint, cost;
1190 Double_t maxit = 1992;
1191 Double_t maxcut = 11;
1193 const Double_t kdlt = 1e-4;
1194 const Double_t kdlt32 = kdlt/32.;
1195 const Double_t kthird = 1./3.;
1196 const Double_t khalf = 0.5;
1197 const Double_t kec = 2.9979251e-4;
1199 const Double_t kpisqua = 9.86960440109;
1200 const Int_t kix = 0;
1201 const Int_t kiy = 1;
1202 const Int_t kiz = 2;
1203 const Int_t kipx = 3;
1204 const Int_t kipy = 4;
1205 const Int_t kipz = 5;
1208 // *. ------------------------------------------------------------------
1210 // * this constant is for units cm,gev/c and kgauss
1214 for(Int_t j = 0; j < 7; j++)
1217 Double_t pinv = kec * charge / vect[6];
1225 if (TMath::Abs(h) > TMath::Abs(rest)) h = rest;
1226 //cmodif: call gufld(vout,f) changed into:
1231 // * start of integration
1244 secxs[0] = (b * f[2] - c * f[1]) * ph2;
1245 secys[0] = (c * f[0] - a * f[2]) * ph2;
1246 seczs[0] = (a * f[1] - b * f[0]) * ph2;
1247 ang2 = (secxs[0]*secxs[0] + secys[0]*secys[0] + seczs[0]*seczs[0]);
1248 if (ang2 > kpisqua) break;
1250 dxt = h2 * a + h4 * secxs[0];
1251 dyt = h2 * b + h4 * secys[0];
1252 dzt = h2 * c + h4 * seczs[0];
1257 // * second intermediate point
1260 est = TMath::Abs(dxt) + TMath::Abs(dyt) + TMath::Abs(dzt);
1262 if (ncut++ > maxcut) break;
1271 //cmodif: call gufld(xyzt,f) changed into:
1278 secxs[1] = (bt * f[2] - ct * f[1]) * ph2;
1279 secys[1] = (ct * f[0] - at * f[2]) * ph2;
1280 seczs[1] = (at * f[1] - bt * f[0]) * ph2;
1284 secxs[2] = (bt * f[2] - ct * f[1]) * ph2;
1285 secys[2] = (ct * f[0] - at * f[2]) * ph2;
1286 seczs[2] = (at * f[1] - bt * f[0]) * ph2;
1287 dxt = h * (a + secxs[2]);
1288 dyt = h * (b + secys[2]);
1289 dzt = h * (c + seczs[2]);
1293 at = a + 2.*secxs[2];
1294 bt = b + 2.*secys[2];
1295 ct = c + 2.*seczs[2];
1297 est = TMath::Abs(dxt)+TMath::Abs(dyt)+TMath::Abs(dzt);
1298 if (est > 2.*TMath::Abs(h)) {
1299 if (ncut++ > maxcut) break;
1308 //cmodif: call gufld(xyzt,f) changed into:
1311 z = z + (c + (seczs[0] + seczs[1] + seczs[2]) * kthird) * h;
1312 y = y + (b + (secys[0] + secys[1] + secys[2]) * kthird) * h;
1313 x = x + (a + (secxs[0] + secxs[1] + secxs[2]) * kthird) * h;
1315 secxs[3] = (bt*f[2] - ct*f[1])* ph2;
1316 secys[3] = (ct*f[0] - at*f[2])* ph2;
1317 seczs[3] = (at*f[1] - bt*f[0])* ph2;
1318 a = a+(secxs[0]+secxs[3]+2. * (secxs[1]+secxs[2])) * kthird;
1319 b = b+(secys[0]+secys[3]+2. * (secys[1]+secys[2])) * kthird;
1320 c = c+(seczs[0]+seczs[3]+2. * (seczs[1]+seczs[2])) * kthird;
1322 est = TMath::Abs(secxs[0]+secxs[3] - (secxs[1]+secxs[2]))
1323 + TMath::Abs(secys[0]+secys[3] - (secys[1]+secys[2]))
1324 + TMath::Abs(seczs[0]+seczs[3] - (seczs[1]+seczs[2]));
1326 if (est > kdlt && TMath::Abs(h) > 1.e-4) {
1327 if (ncut++ > maxcut) break;
1333 // * if too many iterations, go to helix
1334 if (iter++ > maxit) break;
1339 cba = 1./ TMath::Sqrt(a*a + b*b + c*c);
1347 if (step < 0.) rest = -rest;
1348 if (rest < 1.e-5*TMath::Abs(step)) return;
1352 // angle too big, use helix
1357 f4 = TMath::Sqrt(f1*f1+f2*f2+f3*f3);
1366 hxp[0] = f2*vect[kipz] - f3*vect[kipy];
1367 hxp[1] = f3*vect[kipx] - f1*vect[kipz];
1368 hxp[2] = f1*vect[kipy] - f2*vect[kipx];
1370 hp = f1*vect[kipx] + f2*vect[kipy] + f3*vect[kipz];
1373 sint = TMath::Sin(tet);
1374 cost = 2.*TMath::Sin(khalf*tet)*TMath::Sin(khalf*tet);
1378 g3 = (tet-sint) * hp*rho1;
1383 vout[kix] = vect[kix] + g1*vect[kipx] + g2*hxp[0] + g3*f1;
1384 vout[kiy] = vect[kiy] + g1*vect[kipy] + g2*hxp[1] + g3*f2;
1385 vout[kiz] = vect[kiz] + g1*vect[kipz] + g2*hxp[2] + g3*f3;
1387 vout[kipx] = vect[kipx] + g4*vect[kipx] + g5*hxp[0] + g6*f1;
1388 vout[kipy] = vect[kipy] + g4*vect[kipy] + g5*hxp[1] + g6*f2;
1389 vout[kipz] = vect[kipz] + g4*vect[kipz] + g5*hxp[2] + g6*f3;
1394 //___________________________________________________________
1395 void AliMUONTrackExtrap::GetField(Double_t *Position, Double_t *Field)
1397 /// interface for arguments in double precision (Why ? ChF)
1400 x[0] = Position[0]; x[1] = Position[1]; x[2] = Position[2];
1402 if (fgkField) fgkField->Field(x,b);
1404 cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl;
1408 Field[0] = b[0]; Field[1] = b[1]; Field[2] = b[2];