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"
31 #include "AliExternalTrackParam.h"
33 #include <TGeoGlobalMagField.h>
34 #include <TGeoManager.h>
36 #include <TDatabasePDG.h>
38 #include <Riostream.h>
41 ClassImp(AliMUONTrackExtrap) // Class implementation in ROOT context
44 const Double_t AliMUONTrackExtrap::fgkSimpleBPosition = 0.5 * (AliMUONConstants::CoilZ() + AliMUONConstants::YokeZ());
45 const Double_t AliMUONTrackExtrap::fgkSimpleBLength = 0.5 * (AliMUONConstants::CoilL() + AliMUONConstants::YokeL());
46 Double_t AliMUONTrackExtrap::fgSimpleBValue = 0.;
47 Bool_t AliMUONTrackExtrap::fgFieldON = kFALSE;
48 const Bool_t AliMUONTrackExtrap::fgkUseHelix = kFALSE;
49 const Int_t AliMUONTrackExtrap::fgkMaxStepNumber = 5000;
50 const Double_t AliMUONTrackExtrap::fgkHelixStepLength = 6.;
51 const Double_t AliMUONTrackExtrap::fgkRungeKuttaMaxResidue = 0.002;
53 //__________________________________________________________________________
54 void AliMUONTrackExtrap::SetField()
56 /// set field on/off flag;
57 /// set field at the centre of the dipole
58 const Double_t x[3] = {50.,50.,fgkSimpleBPosition};
59 Double_t b[3] = {0.,0.,0.};
60 TGeoGlobalMagField::Instance()->Field(x,b);
61 fgSimpleBValue = b[0];
62 fgFieldON = fgSimpleBValue ? kTRUE : kFALSE;
66 //__________________________________________________________________________
67 Double_t AliMUONTrackExtrap::GetImpactParamFromBendingMomentum(Double_t bendingMomentum)
69 /// Returns impact parameter at vertex in bending plane (cm),
70 /// from the signed bending momentum "BendingMomentum" in bending plane (GeV/c),
71 /// using simple values for dipole magnetic field.
72 /// The sign of "BendingMomentum" is the sign of the charge.
74 if (bendingMomentum == 0.) return 1.e10;
76 const Double_t kCorrectionFactor = 1.1; // impact parameter is 10% underestimated
78 return kCorrectionFactor * (-0.0003 * fgSimpleBValue * fgkSimpleBLength * fgkSimpleBPosition / bendingMomentum);
81 //__________________________________________________________________________
83 AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(Double_t impactParam)
85 /// Returns signed bending momentum in bending plane (GeV/c),
86 /// the sign being the sign of the charge for particles moving forward in Z,
87 /// from the impact parameter "ImpactParam" at vertex in bending plane (cm),
88 /// using simple values for dipole magnetic field.
90 if (impactParam == 0.) return 1.e10;
92 const Double_t kCorrectionFactor = 1.1; // bending momentum is 10% underestimated
96 return kCorrectionFactor * (-0.0003 * fgSimpleBValue * fgkSimpleBLength * fgkSimpleBPosition / impactParam);
100 return AliMUONConstants::GetMostProbBendingMomentum();
104 //__________________________________________________________________________
105 void AliMUONTrackExtrap::LinearExtrapToZ(AliMUONTrackParam* trackParam, Double_t zEnd)
107 /// Track parameters linearly extrapolated to the plane at "zEnd".
108 /// On return, results from the extrapolation are updated in trackParam.
110 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z
112 // Compute track parameters
113 Double_t dZ = zEnd - trackParam->GetZ();
114 trackParam->SetNonBendingCoor(trackParam->GetNonBendingCoor() + trackParam->GetNonBendingSlope() * dZ);
115 trackParam->SetBendingCoor(trackParam->GetBendingCoor() + trackParam->GetBendingSlope() * dZ);
116 trackParam->SetZ(zEnd);
119 //__________________________________________________________________________
120 void AliMUONTrackExtrap::LinearExtrapToZCov(AliMUONTrackParam* trackParam, Double_t zEnd, Bool_t updatePropagator)
122 /// Track parameters and their covariances linearly extrapolated to the plane at "zEnd".
123 /// On return, results from the extrapolation are updated in trackParam.
125 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z
127 // No need to propagate the covariance matrix if it does not exist
128 if (!trackParam->CovariancesExist()) {
129 cout<<"W-AliMUONTrackExtrap::LinearExtrapToZCov: Covariance matrix does not exist"<<endl;
130 // Extrapolate linearly track parameters to "zEnd"
131 LinearExtrapToZ(trackParam,zEnd);
135 // Compute track parameters
136 Double_t dZ = zEnd - trackParam->GetZ();
137 trackParam->SetNonBendingCoor(trackParam->GetNonBendingCoor() + trackParam->GetNonBendingSlope() * dZ);
138 trackParam->SetBendingCoor(trackParam->GetBendingCoor() + trackParam->GetBendingSlope() * dZ);
139 trackParam->SetZ(zEnd);
141 // Calculate the jacobian related to the track parameters linear extrapolation to "zEnd"
147 // Extrapolate track parameter covariances to "zEnd"
148 TMatrixD tmp(trackParam->GetCovariances(),TMatrixD::kMultTranspose,jacob);
149 TMatrixD tmp2(jacob,TMatrixD::kMult,tmp);
150 trackParam->SetCovariances(tmp2);
152 // Update the propagator if required
153 if (updatePropagator) trackParam->UpdatePropagator(jacob);
156 //__________________________________________________________________________
157 void AliMUONTrackExtrap::ExtrapToZ(AliMUONTrackParam* trackParam, Double_t zEnd)
159 /// Interface to track parameter extrapolation to the plane at "Z" using Helix or Rungekutta algorithm.
160 /// On return, the track parameters resulting from the extrapolation are updated in trackParam.
161 if (!fgFieldON) AliMUONTrackExtrap::LinearExtrapToZ(trackParam,zEnd);
162 else if (fgkUseHelix) AliMUONTrackExtrap::ExtrapToZHelix(trackParam,zEnd);
163 else AliMUONTrackExtrap::ExtrapToZRungekutta(trackParam,zEnd);
166 //__________________________________________________________________________
167 void AliMUONTrackExtrap::ExtrapToZHelix(AliMUONTrackParam* trackParam, Double_t zEnd)
169 /// Track parameter extrapolation to the plane at "Z" using Helix algorithm.
170 /// On return, the track parameters resulting from the extrapolation are updated in trackParam.
171 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same Z
172 Double_t forwardBackward; // +1 if forward, -1 if backward
173 if (zEnd < trackParam->GetZ()) forwardBackward = 1.0; // spectro. z<0
174 else forwardBackward = -1.0;
175 Double_t v3[7], v3New[7]; // 7 in parameter ????
176 Int_t i3, stepNumber;
177 // For safety: return kTRUE or kFALSE ????
178 // Parameter vector for calling EXTRAP_ONESTEP
179 ConvertTrackParamForExtrap(trackParam, forwardBackward, v3);
180 // sign of charge (sign of fInverseBendingMomentum if forward motion)
181 // must be changed if backward extrapolation
182 Double_t chargeExtrap = forwardBackward * TMath::Sign(Double_t(1.0), trackParam->GetInverseBendingMomentum());
183 // Extrapolation loop
185 while (((-forwardBackward * (v3[2] - zEnd)) <= 0.0) && (stepNumber < fgkMaxStepNumber)) { // spectro. z<0
187 ExtrapOneStepHelix(chargeExtrap, fgkHelixStepLength, v3, v3New);
188 if ((-forwardBackward * (v3New[2] - zEnd)) > 0.0) break; // one is beyond Z spectro. z<0
189 // better use TArray ????
190 for (i3 = 0; i3 < 7; i3++) {v3[i3] = v3New[i3];}
192 // check fgkMaxStepNumber ????
193 // Interpolation back to exact Z (2nd order)
194 // should be in function ???? using TArray ????
195 Double_t dZ12 = v3New[2] - v3[2]; // 1->2
196 if (TMath::Abs(dZ12) > 0) {
197 Double_t dZ1i = zEnd - v3[2]; // 1-i
198 Double_t dZi2 = v3New[2] - zEnd; // i->2
199 Double_t xPrime = (v3New[0] - v3[0]) / dZ12;
200 Double_t xSecond = ((v3New[3] / v3New[5]) - (v3[3] / v3[5])) / dZ12;
201 Double_t yPrime = (v3New[1] - v3[1]) / dZ12;
202 Double_t ySecond = ((v3New[4] / v3New[5]) - (v3[4] / v3[5])) / dZ12;
203 v3[0] = v3[0] + xPrime * dZ1i - 0.5 * xSecond * dZ1i * dZi2; // X
204 v3[1] = v3[1] + yPrime * dZ1i - 0.5 * ySecond * dZ1i * dZi2; // Y
206 Double_t xPrimeI = xPrime - 0.5 * xSecond * (dZi2 - dZ1i);
207 Double_t yPrimeI = yPrime - 0.5 * ySecond * (dZi2 - dZ1i);
208 // (PX, PY, PZ)/PTOT assuming forward motion
209 v3[5] = 1.0 / TMath::Sqrt(1.0 + xPrimeI * xPrimeI + yPrimeI * yPrimeI); // PZ/PTOT
210 v3[3] = xPrimeI * v3[5]; // PX/PTOT
211 v3[4] = yPrimeI * v3[5]; // PY/PTOT
213 cout<<"W-AliMUONTrackExtrap::ExtrapToZHelix: Extrap. to Z not reached, Z = "<<zEnd<<endl;
215 // Recover track parameters (charge back for forward motion)
216 RecoverTrackParam(v3, chargeExtrap * forwardBackward, trackParam);
219 //__________________________________________________________________________
220 void AliMUONTrackExtrap::ExtrapToZRungekutta(AliMUONTrackParam* trackParam, Double_t zEnd)
222 /// Track parameter extrapolation to the plane at "Z" using Rungekutta algorithm.
223 /// On return, the track parameters resulting from the extrapolation are updated in trackParam.
224 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same Z
225 Double_t forwardBackward; // +1 if forward, -1 if backward
226 if (zEnd < trackParam->GetZ()) forwardBackward = 1.0; // spectro. z<0
227 else forwardBackward = -1.0;
228 // sign of charge (sign of fInverseBendingMomentum if forward motion)
229 // must be changed if backward extrapolation
230 Double_t chargeExtrap = forwardBackward * TMath::Sign(Double_t(1.0), trackParam->GetInverseBendingMomentum());
231 Double_t v3[7], v3New[7];
233 Int_t stepNumber = 0;
235 // Extrapolation loop (until within tolerance)
236 Double_t residue = zEnd - trackParam->GetZ();
237 while (TMath::Abs(residue) > fgkRungeKuttaMaxResidue && stepNumber <= fgkMaxStepNumber) {
238 dZ = zEnd - trackParam->GetZ();
239 // step lenght assuming linear trajectory
240 step = dZ * TMath::Sqrt(1.0 + trackParam->GetBendingSlope()*trackParam->GetBendingSlope() +
241 trackParam->GetNonBendingSlope()*trackParam->GetNonBendingSlope());
242 ConvertTrackParamForExtrap(trackParam, forwardBackward, v3);
243 do { // reduce step lenght while zEnd oversteped
244 if (stepNumber > fgkMaxStepNumber) {
245 cout<<"W-AliMUONTrackExtrap::ExtrapToZRungekutta: Too many trials: "<<stepNumber<<endl;
249 step = TMath::Abs(step);
250 AliMUONTrackExtrap::ExtrapOneStepRungekutta(chargeExtrap,step,v3,v3New);
251 residue = zEnd - v3New[2];
252 step *= dZ/(v3New[2]-trackParam->GetZ());
253 } while (residue*dZ < 0 && TMath::Abs(residue) > fgkRungeKuttaMaxResidue);
254 RecoverTrackParam(v3New, chargeExtrap * forwardBackward, trackParam);
257 // terminate the extropolation with a straight line up to the exact "zEnd" value
258 trackParam->SetNonBendingCoor(trackParam->GetNonBendingCoor() + residue * trackParam->GetNonBendingSlope());
259 trackParam->SetBendingCoor(trackParam->GetBendingCoor() + residue * trackParam->GetBendingSlope());
260 trackParam->SetZ(zEnd);
263 //__________________________________________________________________________
264 void AliMUONTrackExtrap::ConvertTrackParamForExtrap(AliMUONTrackParam* trackParam, Double_t forwardBackward, Double_t *v3)
266 /// Set vector of Geant3 parameters pointed to by "v3" from track parameters in trackParam.
267 /// Since AliMUONTrackParam is only geometry, one uses "forwardBackward"
268 /// to know whether the particle is going forward (+1) or backward (-1).
269 v3[0] = trackParam->GetNonBendingCoor(); // X
270 v3[1] = trackParam->GetBendingCoor(); // Y
271 v3[2] = trackParam->GetZ(); // Z
272 Double_t pYZ = TMath::Abs(1.0 / trackParam->GetInverseBendingMomentum());
273 Double_t pZ = pYZ / TMath::Sqrt(1.0 + trackParam->GetBendingSlope() * trackParam->GetBendingSlope());
274 v3[6] = TMath::Sqrt(pYZ * pYZ + pZ * pZ * trackParam->GetNonBendingSlope() * trackParam->GetNonBendingSlope()); // PTOT
275 v3[5] = -forwardBackward * pZ / v3[6]; // PZ/PTOT spectro. z<0
276 v3[3] = trackParam->GetNonBendingSlope() * v3[5]; // PX/PTOT
277 v3[4] = trackParam->GetBendingSlope() * v3[5]; // PY/PTOT
280 //__________________________________________________________________________
281 void AliMUONTrackExtrap::RecoverTrackParam(Double_t *v3, Double_t charge, AliMUONTrackParam* trackParam)
283 /// Set track parameters in trackParam from Geant3 parameters pointed to by "v3",
284 /// assumed to be calculated for forward motion in Z.
285 /// "InverseBendingMomentum" is signed with "charge".
286 trackParam->SetNonBendingCoor(v3[0]); // X
287 trackParam->SetBendingCoor(v3[1]); // Y
288 trackParam->SetZ(v3[2]); // Z
289 Double_t pYZ = v3[6] * TMath::Sqrt((1.-v3[3])*(1.+v3[3]));
290 trackParam->SetInverseBendingMomentum(charge/pYZ);
291 trackParam->SetBendingSlope(v3[4]/v3[5]);
292 trackParam->SetNonBendingSlope(v3[3]/v3[5]);
295 //__________________________________________________________________________
296 void AliMUONTrackExtrap::ExtrapToZCov(AliMUONTrackParam* trackParam, Double_t zEnd, Bool_t updatePropagator)
298 /// Track parameters and their covariances extrapolated to the plane at "zEnd".
299 /// On return, results from the extrapolation are updated in trackParam.
301 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z
303 if (!fgFieldON) { // linear extrapolation if no magnetic field
304 AliMUONTrackExtrap::LinearExtrapToZCov(trackParam,zEnd,updatePropagator);
308 // No need to propagate the covariance matrix if it does not exist
309 if (!trackParam->CovariancesExist()) {
310 cout<<"W-AliMUONTrackExtrap::ExtrapToZCov: Covariance matrix does not exist"<<endl;
311 // Extrapolate track parameters to "zEnd"
312 ExtrapToZ(trackParam,zEnd);
316 // Save the actual track parameters
317 AliMUONTrackParam trackParamSave(*trackParam);
318 TMatrixD paramSave(trackParamSave.GetParameters());
319 Double_t zBegin = trackParamSave.GetZ();
321 // Get reference to the parameter covariance matrix
322 const TMatrixD& kParamCov = trackParam->GetCovariances();
324 // Extrapolate track parameters to "zEnd"
325 ExtrapToZ(trackParam,zEnd);
327 // Get reference to the extrapolated parameters
328 const TMatrixD& extrapParam = trackParam->GetParameters();
330 // Calculate the jacobian related to the track parameters extrapolation to "zEnd"
333 TMatrixD dParam(5,1);
334 Double_t direction[5] = {-1.,-1.,1.,1.,-1.};
335 for (Int_t i=0; i<5; i++) {
336 // Skip jacobian calculation for parameters with no associated error
337 if (kParamCov(i,i) <= 0.) continue;
339 // Small variation of parameter i only
340 for (Int_t j=0; j<5; j++) {
342 dParam(j,0) = TMath::Sqrt(kParamCov(i,i));
343 dParam(j,0) *= TMath::Sign(1.,direction[j]*paramSave(j,0)); // variation always in the same direction
344 } else dParam(j,0) = 0.;
347 // Set new parameters
348 trackParamSave.SetParameters(paramSave);
349 trackParamSave.AddParameters(dParam);
350 trackParamSave.SetZ(zBegin);
352 // Extrapolate new track parameters to "zEnd"
353 ExtrapToZ(&trackParamSave,zEnd);
355 // Calculate the jacobian
356 TMatrixD jacobji(trackParamSave.GetParameters(),TMatrixD::kMinus,extrapParam);
357 jacobji *= 1. / dParam(i,0);
358 jacob.SetSub(0,i,jacobji);
361 // Extrapolate track parameter covariances to "zEnd"
362 TMatrixD tmp(kParamCov,TMatrixD::kMultTranspose,jacob);
363 TMatrixD tmp2(jacob,TMatrixD::kMult,tmp);
364 trackParam->SetCovariances(tmp2);
366 // Update the propagator if required
367 if (updatePropagator) trackParam->UpdatePropagator(jacob);
370 //__________________________________________________________________________
371 void AliMUONTrackExtrap::AddMCSEffectInAbsorber(AliMUONTrackParam* param, Double_t pathLength, Double_t f0, Double_t f1, Double_t f2)
373 /// Add to the track parameter covariances the effects of multiple Coulomb scattering
374 /// The absorber correction parameters are supposed to be calculated at the current track z-position
376 // absorber related covariance parameters
377 Double_t bendingSlope = param->GetBendingSlope();
378 Double_t nonBendingSlope = param->GetNonBendingSlope();
379 Double_t inverseBendingMomentum = param->GetInverseBendingMomentum();
380 Double_t alpha2 = 0.0136 * 0.0136 * inverseBendingMomentum * inverseBendingMomentum * (1.0 + bendingSlope * bendingSlope) /
381 (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope); // velocity = 1
382 Double_t varCoor = alpha2 * (pathLength * pathLength * f0 - 2. * pathLength * f1 + f2);
383 Double_t covCorrSlope = alpha2 * (pathLength * f0 - f1);
384 Double_t varSlop = alpha2 * f0;
386 // compute derivative d(q/Pxy) / dSlopeX and d(q/Pxy) / dSlopeX
387 Double_t dqPxydSlopeX = inverseBendingMomentum * nonBendingSlope / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
388 Double_t dqPxydSlopeY = - inverseBendingMomentum * nonBendingSlope*nonBendingSlope * bendingSlope /
389 (1. + bendingSlope*bendingSlope) / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
391 // Set MCS covariance matrix
392 TMatrixD newParamCov(param->GetCovariances());
394 newParamCov(0,0) += varCoor; newParamCov(0,1) += covCorrSlope;
395 newParamCov(1,0) += covCorrSlope; newParamCov(1,1) += varSlop;
397 newParamCov(2,2) += varCoor; newParamCov(2,3) += covCorrSlope;
398 newParamCov(3,2) += covCorrSlope; newParamCov(3,3) += varSlop;
399 // Inverse bending momentum (due to dependences with bending and non bending slopes)
400 newParamCov(4,0) += dqPxydSlopeX * covCorrSlope; newParamCov(0,4) += dqPxydSlopeX * covCorrSlope;
401 newParamCov(4,1) += dqPxydSlopeX * varSlop; newParamCov(1,4) += dqPxydSlopeX * varSlop;
402 newParamCov(4,2) += dqPxydSlopeY * covCorrSlope; newParamCov(2,4) += dqPxydSlopeY * covCorrSlope;
403 newParamCov(4,3) += dqPxydSlopeY * varSlop; newParamCov(3,4) += dqPxydSlopeY * varSlop;
404 newParamCov(4,4) += (dqPxydSlopeX*dqPxydSlopeX + dqPxydSlopeY*dqPxydSlopeY) * varSlop;
406 // Set new covariances
407 param->SetCovariances(newParamCov);
410 //__________________________________________________________________________
411 void AliMUONTrackExtrap::CorrectMCSEffectInAbsorber(AliMUONTrackParam* param,
412 Double_t xVtx, Double_t yVtx, Double_t zVtx,
413 Double_t errXVtx, Double_t errYVtx,
414 Double_t absZBeg, Double_t pathLength, Double_t f0, Double_t f1, Double_t f2)
416 /// Correct parameters and corresponding covariances using Branson correction
417 /// - input param are parameters and covariances at the end of absorber
418 /// - output param are parameters and covariances at vertex
419 /// Absorber correction parameters are supposed to be calculated at the current track z-position
421 // Position of the Branson plane (spectro. (z<0))
422 Double_t zB = (f1>0.) ? absZBeg - f2/f1 : 0.;
424 // Add MCS effects to current parameter covariances
425 AddMCSEffectInAbsorber(param, pathLength, f0, f1, f2);
427 // Get track parameters and covariances in the Branson plane corrected for magnetic field effect
428 ExtrapToZCov(param,zVtx);
429 LinearExtrapToZCov(param,zB);
431 // compute track parameters at vertex
432 TMatrixD newParam(5,1);
433 newParam(0,0) = xVtx;
434 newParam(1,0) = (param->GetNonBendingCoor() - xVtx) / (zB - zVtx);
435 newParam(2,0) = yVtx;
436 newParam(3,0) = (param->GetBendingCoor() - yVtx) / (zB - zVtx);
437 newParam(4,0) = param->GetCharge() / param->P() *
438 TMath::Sqrt(1.0 + newParam(1,0)*newParam(1,0) + newParam(3,0)*newParam(3,0)) /
439 TMath::Sqrt(1.0 + newParam(3,0)*newParam(3,0));
441 // Get covariances in (X, SlopeX, Y, SlopeY, q*PTot) coordinate system
442 TMatrixD paramCovP(param->GetCovariances());
443 Cov2CovP(param->GetParameters(),paramCovP);
445 // Get the covariance matrix in the (XVtx, X, YVtx, Y, q*PTot) coordinate system
446 TMatrixD paramCovVtx(5,5);
448 paramCovVtx(0,0) = errXVtx * errXVtx;
449 paramCovVtx(1,1) = paramCovP(0,0);
450 paramCovVtx(2,2) = errYVtx * errYVtx;
451 paramCovVtx(3,3) = paramCovP(2,2);
452 paramCovVtx(4,4) = paramCovP(4,4);
453 paramCovVtx(1,3) = paramCovP(0,2);
454 paramCovVtx(3,1) = paramCovP(2,0);
455 paramCovVtx(1,4) = paramCovP(0,4);
456 paramCovVtx(4,1) = paramCovP(4,0);
457 paramCovVtx(3,4) = paramCovP(2,4);
458 paramCovVtx(4,3) = paramCovP(4,2);
460 // Jacobian of the transformation (XVtx, X, YVtx, Y, q*PTot) -> (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q*PTotVtx)
463 jacob(1,0) = - 1. / (zB - zVtx);
464 jacob(1,1) = 1. / (zB - zVtx);
465 jacob(3,2) = - 1. / (zB - zVtx);
466 jacob(3,3) = 1. / (zB - zVtx);
468 // Compute covariances at vertex in the (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q*PTotVtx) coordinate system
469 TMatrixD tmp(paramCovVtx,TMatrixD::kMultTranspose,jacob);
470 TMatrixD newParamCov(jacob,TMatrixD::kMult,tmp);
472 // Compute covariances at vertex in the (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q/PyzVtx) coordinate system
473 CovP2Cov(newParam,newParamCov);
475 // Set parameters and covariances at vertex
476 param->SetParameters(newParam);
478 param->SetCovariances(newParamCov);
481 //__________________________________________________________________________
482 void AliMUONTrackExtrap::CorrectELossEffectInAbsorber(AliMUONTrackParam* param, Double_t eLoss, Double_t sigmaELoss2)
484 /// Correct parameters for energy loss and add energy loss fluctuation effect to covariances
486 // Get parameter covariances in (X, SlopeX, Y, SlopeY, q*PTot) coordinate system
487 TMatrixD newParamCov(param->GetCovariances());
488 Cov2CovP(param->GetParameters(),newParamCov);
490 // Compute new parameters corrected for energy loss
491 Double_t muMass = TDatabasePDG::Instance()->GetParticle("mu-")->Mass(); // GeV
492 Double_t p = param->P();
493 Double_t e = TMath::Sqrt(p*p + muMass*muMass);
494 Double_t eCorr = e + eLoss;
495 Double_t pCorr = TMath::Sqrt(eCorr*eCorr - muMass*muMass);
496 Double_t nonBendingSlope = param->GetNonBendingSlope();
497 Double_t bendingSlope = param->GetBendingSlope();
498 param->SetInverseBendingMomentum(param->GetCharge() / pCorr *
499 TMath::Sqrt(1.0 + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope) /
500 TMath::Sqrt(1.0 + bendingSlope*bendingSlope));
502 // Add effects of energy loss fluctuation to covariances
503 newParamCov(4,4) += eCorr * eCorr / pCorr / pCorr * sigmaELoss2;
505 // Get new parameter covariances in (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system
506 CovP2Cov(param->GetParameters(),newParamCov);
508 // Set new parameter covariances
509 param->SetCovariances(newParamCov);
512 //__________________________________________________________________________
513 Bool_t AliMUONTrackExtrap::GetAbsorberCorrectionParam(Double_t trackXYZIn[3], Double_t trackXYZOut[3], Double_t pTotal,
514 Double_t &pathLength, Double_t &f0, Double_t &f1, Double_t &f2,
515 Double_t &meanRho, Double_t &totalELoss, Double_t &sigmaELoss2)
517 /// Parameters used to correct for Multiple Coulomb Scattering and energy loss in absorber
518 /// Calculated assuming a linear propagation from trackXYZIn to trackXYZOut (order is important)
519 // pathLength: path length between trackXYZIn and trackXYZOut (cm)
520 // f0: 0th moment of z calculated with the inverse radiation-length distribution
521 // f1: 1st moment of z calculated with the inverse radiation-length distribution
522 // f2: 2nd moment of z calculated with the inverse radiation-length distribution
523 // meanRho: average density of crossed material (g/cm3)
524 // totalELoss: total energy loss in absorber
526 // Reset absorber's parameters
535 // Check whether the geometry is available
537 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: no TGeo"<<endl;
541 // Initialize starting point and direction
542 pathLength = TMath::Sqrt((trackXYZOut[0] - trackXYZIn[0])*(trackXYZOut[0] - trackXYZIn[0])+
543 (trackXYZOut[1] - trackXYZIn[1])*(trackXYZOut[1] - trackXYZIn[1])+
544 (trackXYZOut[2] - trackXYZIn[2])*(trackXYZOut[2] - trackXYZIn[2]));
545 if (pathLength < TGeoShape::Tolerance()) return kFALSE;
547 b[0] = (trackXYZOut[0] - trackXYZIn[0]) / pathLength;
548 b[1] = (trackXYZOut[1] - trackXYZIn[1]) / pathLength;
549 b[2] = (trackXYZOut[2] - trackXYZIn[2]) / pathLength;
550 TGeoNode *currentnode = gGeoManager->InitTrack(trackXYZIn, b);
552 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: start point out of geometry"<<endl;
556 // loop over absorber slices and calculate absorber's parameters
557 Double_t rho = 0.; // material density (g/cm3)
558 Double_t x0 = 0.; // radiation-length (cm-1)
559 Double_t atomicA = 0.; // A of material
560 Double_t atomicZ = 0.; // Z of material
561 Double_t localPathLength = 0;
562 Double_t remainingPathLength = pathLength;
563 Double_t zB = trackXYZIn[2];
564 Double_t zE, dzB, dzE;
566 // Get material properties
567 TGeoMaterial *material = currentnode->GetVolume()->GetMedium()->GetMaterial();
568 rho = material->GetDensity();
569 x0 = material->GetRadLen();
570 if (!material->IsMixture()) x0 /= rho; // different normalization in the modeler for mixture
571 atomicA = material->GetA();
572 atomicZ = material->GetZ();
574 // Get path length within this material
575 gGeoManager->FindNextBoundary(remainingPathLength);
576 localPathLength = gGeoManager->GetStep() + 1.e-6;
577 // Check if boundary within remaining path length. If so, make sure to cross the boundary to prepare the next step
578 if (localPathLength >= remainingPathLength) localPathLength = remainingPathLength;
580 currentnode = gGeoManager->Step();
582 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: navigation failed"<<endl;
583 f0 = f1 = f2 = meanRho = totalELoss = sigmaELoss2 = 0.;
586 if (!gGeoManager->IsEntering()) {
587 // make another small step to try to enter in new absorber slice
588 gGeoManager->SetStep(0.001);
589 currentnode = gGeoManager->Step();
590 if (!gGeoManager->IsEntering() || !currentnode) {
591 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: navigation failed"<<endl;
592 f0 = f1 = f2 = meanRho = totalELoss = sigmaELoss2 = 0.;
595 localPathLength += 0.001;
599 // calculate absorber's parameters
600 zE = b[2] * localPathLength + zB;
601 dzB = zB - trackXYZIn[2];
602 dzE = zE - trackXYZIn[2];
603 f0 += localPathLength / x0;
604 f1 += (dzE*dzE - dzB*dzB) / b[2] / b[2] / x0 / 2.;
605 f2 += (dzE*dzE*dzE - dzB*dzB*dzB) / b[2] / b[2] / b[2] / x0 / 3.;
606 meanRho += localPathLength * rho;
607 totalELoss += BetheBloch(pTotal, localPathLength, rho, atomicA, atomicZ);
608 sigmaELoss2 += EnergyLossFluctuation2(pTotal, localPathLength, rho, atomicA, atomicZ);
612 remainingPathLength -= localPathLength;
613 } while (remainingPathLength > TGeoShape::Tolerance());
615 meanRho /= pathLength;
620 //__________________________________________________________________________
621 Double_t AliMUONTrackExtrap::GetMCSAngle2(const AliMUONTrackParam& param, Double_t dZ, Double_t x0)
623 /// Return the angular dispersion square due to multiple Coulomb scattering
624 /// through a material of thickness "dZ" and of radiation length "x0"
625 /// assuming linear propagation and using the small angle approximation.
627 Double_t bendingSlope = param.GetBendingSlope();
628 Double_t nonBendingSlope = param.GetNonBendingSlope();
629 Double_t inverseTotalMomentum2 = param.GetInverseBendingMomentum() * param.GetInverseBendingMomentum() *
630 (1.0 + bendingSlope * bendingSlope) /
631 (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope);
632 // Path length in the material
633 Double_t pathLength = TMath::Abs(dZ) * TMath::Sqrt(1.0 + bendingSlope*bendingSlope + nonBendingSlope*nonBendingSlope);
634 // relativistic velocity
636 // Angular dispersion square of the track (variance) in a plane perpendicular to the trajectory
637 Double_t theta02 = 0.0136 / velo * (1 + 0.038 * TMath::Log(pathLength/x0));
639 return theta02 * theta02 * inverseTotalMomentum2 * pathLength / x0;
642 //__________________________________________________________________________
643 void AliMUONTrackExtrap::AddMCSEffect(AliMUONTrackParam *param, Double_t dZ, Double_t x0)
645 /// Add to the track parameter covariances the effects of multiple Coulomb scattering
646 /// through a material of thickness "dZ" and of radiation length "x0"
647 /// assuming linear propagation and using the small angle approximation.
649 Double_t bendingSlope = param->GetBendingSlope();
650 Double_t nonBendingSlope = param->GetNonBendingSlope();
651 Double_t inverseBendingMomentum = param->GetInverseBendingMomentum();
652 Double_t inverseTotalMomentum2 = inverseBendingMomentum * inverseBendingMomentum *
653 (1.0 + bendingSlope * bendingSlope) /
654 (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope);
655 // Path length in the material
656 Double_t pathLength = TMath::Abs(dZ) * TMath::Sqrt(1.0 + bendingSlope*bendingSlope + nonBendingSlope*nonBendingSlope);
657 Double_t pathLength2 = pathLength * pathLength;
658 // relativistic velocity
660 // Angular dispersion square of the track (variance) in a plane perpendicular to the trajectory
661 Double_t theta02 = 0.0136 / velo * (1 + 0.038 * TMath::Log(pathLength/x0));
662 theta02 *= theta02 * inverseTotalMomentum2 * pathLength / x0;
664 Double_t varCoor = pathLength2 * theta02 / 3.;
665 Double_t varSlop = theta02;
666 Double_t covCorrSlope = pathLength * theta02 / 2.;
668 // compute derivative d(q/Pxy) / dSlopeX and d(q/Pxy) / dSlopeY
669 Double_t dqPxydSlopeX = inverseBendingMomentum * nonBendingSlope / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
670 Double_t dqPxydSlopeY = - inverseBendingMomentum * nonBendingSlope*nonBendingSlope * bendingSlope /
671 (1. + bendingSlope*bendingSlope) / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
673 // Set MCS covariance matrix
674 TMatrixD newParamCov(param->GetCovariances());
676 newParamCov(0,0) += varCoor; newParamCov(0,1) += covCorrSlope;
677 newParamCov(1,0) += covCorrSlope; newParamCov(1,1) += varSlop;
679 newParamCov(2,2) += varCoor; newParamCov(2,3) += covCorrSlope;
680 newParamCov(3,2) += covCorrSlope; newParamCov(3,3) += varSlop;
681 // Inverse bending momentum (due to dependences with bending and non bending slopes)
682 newParamCov(4,0) += dqPxydSlopeX * covCorrSlope; newParamCov(0,4) += dqPxydSlopeX * covCorrSlope;
683 newParamCov(4,1) += dqPxydSlopeX * varSlop; newParamCov(1,4) += dqPxydSlopeX * varSlop;
684 newParamCov(4,2) += dqPxydSlopeY * covCorrSlope; newParamCov(2,4) += dqPxydSlopeY * covCorrSlope;
685 newParamCov(4,3) += dqPxydSlopeY * varSlop; newParamCov(3,4) += dqPxydSlopeY * varSlop;
686 newParamCov(4,4) += (dqPxydSlopeX*dqPxydSlopeX + dqPxydSlopeY*dqPxydSlopeY) * varSlop;
688 // Set new covariances
689 param->SetCovariances(newParamCov);
692 //__________________________________________________________________________
693 void AliMUONTrackExtrap::ExtrapToVertex(AliMUONTrackParam* trackParam,
694 Double_t xVtx, Double_t yVtx, Double_t zVtx,
695 Double_t errXVtx, Double_t errYVtx,
696 Bool_t correctForMCS, Bool_t correctForEnergyLoss)
698 /// Main method for extrapolation to the vertex:
699 /// Returns the track parameters and covariances resulting from the extrapolation of the current trackParam
700 /// Changes parameters and covariances according to multiple scattering and energy loss corrections:
701 /// if correctForMCS=kTRUE: compute parameters using Branson correction and add correction resolution to covariances
702 /// if correctForMCS=kFALSE: add parameter dispersion due to MCS in parameter covariances
703 /// if correctForEnergyLoss=kTRUE: correct parameters for energy loss and add energy loss fluctuation to covariances
704 /// if correctForEnergyLoss=kFALSE: do nothing about energy loss
706 if (trackParam->GetZ() == zVtx) return; // nothing to be done if already at vertex
708 if (trackParam->GetZ() > zVtx) { // spectro. (z<0)
709 cout<<"E-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ()
710 <<") upstream the vertex (zVtx = "<<zVtx<<")"<<endl;
714 // Check the vertex position relatively to the absorber
715 if (zVtx < AliMUONConstants::AbsZBeg() && zVtx > AliMUONConstants::AbsZEnd()) { // spectro. (z<0)
716 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Ending Z ("<<zVtx
717 <<") inside the front absorber ("<<AliMUONConstants::AbsZBeg()<<","<<AliMUONConstants::AbsZEnd()<<")"<<endl;
718 } else if (zVtx < AliMUONConstants::AbsZEnd() ) { // spectro. (z<0)
719 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Ending Z ("<<zVtx
720 <<") downstream the front absorber (zAbsorberEnd = "<<AliMUONConstants::AbsZEnd()<<")"<<endl;
721 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx);
722 else ExtrapToZ(trackParam,zVtx);
726 // Check the track position relatively to the absorber and extrapolate track parameters to the end of the absorber if needed
727 if (trackParam->GetZ() > AliMUONConstants::AbsZBeg()) { // spectro. (z<0)
728 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ()
729 <<") upstream the front absorber (zAbsorberBegin = "<<AliMUONConstants::AbsZBeg()<<")"<<endl;
730 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx);
731 else ExtrapToZ(trackParam,zVtx);
733 } else if (trackParam->GetZ() > AliMUONConstants::AbsZEnd()) { // spectro. (z<0)
734 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ()
735 <<") inside the front absorber ("<<AliMUONConstants::AbsZBeg()<<","<<AliMUONConstants::AbsZEnd()<<")"<<endl;
737 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,AliMUONConstants::AbsZEnd());
738 else ExtrapToZ(trackParam,AliMUONConstants::AbsZEnd());
741 // Get absorber correction parameters assuming linear propagation in absorber
742 Double_t trackXYZOut[3];
743 trackXYZOut[0] = trackParam->GetNonBendingCoor();
744 trackXYZOut[1] = trackParam->GetBendingCoor();
745 trackXYZOut[2] = trackParam->GetZ();
746 Double_t trackXYZIn[3];
747 if (correctForMCS) { // assume linear propagation until the vertex
748 trackXYZIn[2] = TMath::Min(zVtx, AliMUONConstants::AbsZBeg()); // spectro. (z<0)
749 trackXYZIn[0] = trackXYZOut[0] + (xVtx - trackXYZOut[0]) / (zVtx - trackXYZOut[2]) * (trackXYZIn[2] - trackXYZOut[2]);
750 trackXYZIn[1] = trackXYZOut[1] + (yVtx - trackXYZOut[1]) / (zVtx - trackXYZOut[2]) * (trackXYZIn[2] - trackXYZOut[2]);
752 AliMUONTrackParam trackParamIn(*trackParam);
753 ExtrapToZ(&trackParamIn, TMath::Min(zVtx, AliMUONConstants::AbsZBeg()));
754 trackXYZIn[0] = trackParamIn.GetNonBendingCoor();
755 trackXYZIn[1] = trackParamIn.GetBendingCoor();
756 trackXYZIn[2] = trackParamIn.GetZ();
758 Double_t pTot = trackParam->P();
759 Double_t pathLength, f0, f1, f2, meanRho, totalELoss, sigmaELoss2;
760 if (!GetAbsorberCorrectionParam(trackXYZIn,trackXYZOut,pTot,pathLength,f0,f1,f2,meanRho,totalELoss,sigmaELoss2)) {
761 cout<<"E-AliMUONTrackExtrap::ExtrapToVertex: Unable to take into account the absorber effects"<<endl;
762 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx);
763 else ExtrapToZ(trackParam,zVtx);
767 // Compute track parameters and covariances at vertex according to correctForMCS and correctForEnergyLoss flags
770 if (correctForEnergyLoss) {
772 // Correct for multiple scattering and energy loss
773 CorrectELossEffectInAbsorber(trackParam, 0.5*totalELoss, 0.5*sigmaELoss2);
774 CorrectMCSEffectInAbsorber(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx,
775 trackXYZIn[2], pathLength, f0, f1, f2);
776 CorrectELossEffectInAbsorber(trackParam, 0.5*totalELoss, 0.5*sigmaELoss2);
780 // Correct for multiple scattering
781 CorrectMCSEffectInAbsorber(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx,
782 trackXYZIn[2], pathLength, f0, f1, f2);
787 if (correctForEnergyLoss) {
789 // Correct for energy loss add multiple scattering dispersion in covariance matrix
790 CorrectELossEffectInAbsorber(trackParam, 0.5*totalELoss, 0.5*sigmaELoss2);
791 AddMCSEffectInAbsorber(trackParam, pathLength, f0, f1, f2);
792 ExtrapToZCov(trackParam, trackXYZIn[2]);
793 CorrectELossEffectInAbsorber(trackParam, 0.5*totalELoss, 0.5*sigmaELoss2);
794 ExtrapToZCov(trackParam, zVtx);
798 // add multiple scattering dispersion in covariance matrix
799 AddMCSEffectInAbsorber(trackParam, pathLength, f0, f1, f2);
800 ExtrapToZCov(trackParam, zVtx);
808 //__________________________________________________________________________
809 void AliMUONTrackExtrap::ExtrapToVertex(AliMUONTrackParam* trackParam,
810 Double_t xVtx, Double_t yVtx, Double_t zVtx,
811 Double_t errXVtx, Double_t errYVtx)
813 /// Extrapolate track parameters to vertex, corrected for multiple scattering and energy loss effects
814 /// Add branson correction resolution and energy loss fluctuation to parameter covariances
815 ExtrapToVertex(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx, kTRUE, kTRUE);
818 //__________________________________________________________________________
819 void AliMUONTrackExtrap::ExtrapToVertexWithoutELoss(AliMUONTrackParam* trackParam,
820 Double_t xVtx, Double_t yVtx, Double_t zVtx,
821 Double_t errXVtx, Double_t errYVtx)
823 /// Extrapolate track parameters to vertex, corrected for multiple scattering effects only
824 /// Add branson correction resolution to parameter covariances
825 ExtrapToVertex(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx, kTRUE, kFALSE);
828 //__________________________________________________________________________
829 void AliMUONTrackExtrap::ExtrapToVertexWithoutBranson(AliMUONTrackParam* trackParam, Double_t zVtx)
831 /// Extrapolate track parameters to vertex, corrected for energy loss effects only
832 /// Add dispersion due to multiple scattering and energy loss fluctuation to parameter covariances
833 ExtrapToVertex(trackParam, 0., 0., zVtx, 0., 0., kFALSE, kTRUE);
836 //__________________________________________________________________________
837 void AliMUONTrackExtrap::ExtrapToVertexUncorrected(AliMUONTrackParam* trackParam, Double_t zVtx)
839 /// Extrapolate track parameters to vertex without multiple scattering and energy loss corrections
840 /// Add dispersion due to multiple scattering to parameter covariances
841 ExtrapToVertex(trackParam, 0., 0., zVtx, 0., 0., kFALSE, kFALSE);
844 //__________________________________________________________________________
845 Double_t AliMUONTrackExtrap::TotalMomentumEnergyLoss(AliMUONTrackParam* trackParam, Double_t xVtx, Double_t yVtx, Double_t zVtx)
847 /// Calculate the total momentum energy loss in-between the track position and the vertex assuming a linear propagation
849 if (trackParam->GetZ() == zVtx) return 0.; // nothing to be done if already at vertex
851 // Check whether the geometry is available
853 cout<<"E-AliMUONTrackExtrap::TotalMomentumEnergyLoss: no TGeo"<<endl;
857 // Get encountered material correction parameters assuming linear propagation from vertex to the track position
858 Double_t trackXYZOut[3];
859 trackXYZOut[0] = trackParam->GetNonBendingCoor();
860 trackXYZOut[1] = trackParam->GetBendingCoor();
861 trackXYZOut[2] = trackParam->GetZ();
862 Double_t trackXYZIn[3];
863 trackXYZIn[0] = xVtx;
864 trackXYZIn[1] = yVtx;
865 trackXYZIn[2] = zVtx;
866 Double_t pTot = trackParam->P();
867 Double_t pathLength, f0, f1, f2, meanRho, totalELoss, sigmaELoss2;
868 GetAbsorberCorrectionParam(trackXYZIn,trackXYZOut,pTot,pathLength,f0,f1,f2,meanRho,totalELoss,sigmaELoss2);
870 // total momentum corrected for energy loss
871 Double_t muMass = TDatabasePDG::Instance()->GetParticle("mu-")->Mass(); // GeV
872 Double_t e = TMath::Sqrt(pTot*pTot + muMass*muMass);
873 Double_t eCorr = e + totalELoss;
874 Double_t pTotCorr = TMath::Sqrt(eCorr*eCorr - muMass*muMass);
876 return pTotCorr - pTot;
879 //__________________________________________________________________________
880 Double_t AliMUONTrackExtrap::BetheBloch(Double_t pTotal, Double_t pathLength, Double_t rho, Double_t atomicA, Double_t atomicZ)
882 /// Returns the mean total momentum energy loss of muon with total momentum='pTotal'
883 /// in the absorber layer of lenght='pathLength', density='rho', A='atomicA' and Z='atomicZ'
884 Double_t muMass = TDatabasePDG::Instance()->GetParticle("mu-")->Mass(); // GeV
886 // mean exitation energy (GeV)
888 if (atomicZ < 13) i = (12. * atomicZ + 7.) * 1.e-9;
889 else i = (9.76 * atomicZ + 58.8 * TMath::Power(atomicZ,-0.19)) * 1.e-9;
891 return pathLength * rho * AliExternalTrackParam::BetheBlochGeant(pTotal/muMass, rho, 0.20, 3.00, i, atomicZ/atomicA);
894 //__________________________________________________________________________
895 Double_t AliMUONTrackExtrap::EnergyLossFluctuation2(Double_t pTotal, Double_t pathLength, Double_t rho, Double_t atomicA, Double_t atomicZ)
897 /// Returns the total momentum energy loss fluctuation of muon with total momentum='pTotal'
898 /// in the absorber layer of lenght='pathLength', density='rho', A='atomicA' and Z='atomicZ'
899 Double_t muMass = TDatabasePDG::Instance()->GetParticle("mu-")->Mass(); // GeV
900 //Double_t eMass = 0.510998918e-3; // GeV
901 Double_t k = 0.307075e-3; // GeV.g^-1.cm^2
902 Double_t p2=pTotal*pTotal;
903 Double_t beta2=p2/(p2 + muMass*muMass);
905 Double_t fwhm = 2. * k * rho * pathLength * atomicZ / atomicA / beta2; // FWHM of the energy loss Landau distribution
906 Double_t sigma2 = fwhm * fwhm / (8.*log(2.)); // gaussian: fwmh = 2 * srqt(2*ln(2)) * sigma (i.e. fwmh = 2.35 * sigma)
908 //sigma2 = k * rho * pathLength * atomicZ / atomicA * eMass; // sigma2 of the energy loss gaussian distribution
913 //__________________________________________________________________________
914 void AliMUONTrackExtrap::Cov2CovP(const TMatrixD ¶m, TMatrixD &cov)
916 /// change coordinate system: (X, SlopeX, Y, SlopeY, q/Pyz) -> (X, SlopeX, Y, SlopeY, q*PTot)
917 /// parameters (param) are given in the (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system
919 // charge * total momentum
920 Double_t qPTot = TMath::Sqrt(1. + param(1,0)*param(1,0) + param(3,0)*param(3,0)) /
921 TMath::Sqrt(1. + param(3,0)*param(3,0)) / param(4,0);
923 // Jacobian of the opposite transformation
926 jacob(4,1) = qPTot * param(1,0) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
927 jacob(4,3) = - qPTot * param(1,0) * param(1,0) * param(3,0) /
928 (1. + param(3,0)*param(3,0)) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
929 jacob(4,4) = - qPTot / param(4,0);
931 // compute covariances in new coordinate system
932 TMatrixD tmp(cov,TMatrixD::kMultTranspose,jacob);
936 //__________________________________________________________________________
937 void AliMUONTrackExtrap::CovP2Cov(const TMatrixD ¶m, TMatrixD &covP)
939 /// change coordinate system: (X, SlopeX, Y, SlopeY, q*PTot) -> (X, SlopeX, Y, SlopeY, q/Pyz)
940 /// parameters (param) are given in the (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system
942 // charge * total momentum
943 Double_t qPTot = TMath::Sqrt(1. + param(1,0)*param(1,0) + param(3,0)*param(3,0)) /
944 TMath::Sqrt(1. + param(3,0)*param(3,0)) / param(4,0);
946 // Jacobian of the transformation
949 jacob(4,1) = param(4,0) * param(1,0) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
950 jacob(4,3) = - param(4,0) * param(1,0) * param(1,0) * param(3,0) /
951 (1. + param(3,0)*param(3,0)) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
952 jacob(4,4) = - param(4,0) / qPTot;
954 // compute covariances in new coordinate system
955 TMatrixD tmp(covP,TMatrixD::kMultTranspose,jacob);
956 covP.Mult(jacob,tmp);
959 //__________________________________________________________________________
960 void AliMUONTrackExtrap::ExtrapOneStepHelix(Double_t charge, Double_t step, Double_t *vect, Double_t *vout)
963 /// ******************************************************************
965 /// * Performs the tracking of one step in a magnetic field *
966 /// * The trajectory is assumed to be a helix in a constant field *
967 /// * taken at the mid point of the step. *
970 /// * STEP =arc length of the step asked *
971 /// * VECT =input vector (position,direction cos and momentum) *
972 /// * CHARGE= electric charge of the particle *
974 /// * VOUT = same as VECT after completion of the step *
976 /// * ==>Called by : USER, GUSWIM *
977 /// * Author m.hansroul ********* *
978 /// * modified s.egli, s.v.levonian *
979 /// * modified v.perevoztchikov
981 /// ******************************************************************
984 // modif: everything in double precision
986 Double_t xyz[3], h[4], hxp[3];
987 Double_t h2xy, hp, rho, tet;
988 Double_t sint, sintt, tsint, cos1t;
989 Double_t f1, f2, f3, f4, f5, f6;
994 const Int_t kipx = 3;
995 const Int_t kipy = 4;
996 const Int_t kipz = 5;
997 const Int_t kipp = 6;
999 const Double_t kec = 2.9979251e-4;
1001 // ------------------------------------------------------------------
1003 // units are kgauss,centimeters,gev/c
1005 vout[kipp] = vect[kipp];
1006 if (TMath::Abs(charge) < 0.00001) {
1007 for (Int_t i = 0; i < 3; i++) {
1008 vout[i] = vect[i] + step * vect[i+3];
1009 vout[i+3] = vect[i+3];
1013 xyz[0] = vect[kix] + 0.5 * step * vect[kipx];
1014 xyz[1] = vect[kiy] + 0.5 * step * vect[kipy];
1015 xyz[2] = vect[kiz] + 0.5 * step * vect[kipz];
1017 //cmodif: call gufld (xyz, h) changed into:
1018 TGeoGlobalMagField::Instance()->Field(xyz,h);
1020 h2xy = h[0]*h[0] + h[1]*h[1];
1021 h[3] = h[2]*h[2]+ h2xy;
1022 if (h[3] < 1.e-12) {
1023 for (Int_t i = 0; i < 3; i++) {
1024 vout[i] = vect[i] + step * vect[i+3];
1025 vout[i+3] = vect[i+3];
1029 if (h2xy < 1.e-12*h[3]) {
1030 ExtrapOneStepHelix3(charge*h[2], step, vect, vout);
1033 h[3] = TMath::Sqrt(h[3]);
1039 hxp[0] = h[1]*vect[kipz] - h[2]*vect[kipy];
1040 hxp[1] = h[2]*vect[kipx] - h[0]*vect[kipz];
1041 hxp[2] = h[0]*vect[kipy] - h[1]*vect[kipx];
1043 hp = h[0]*vect[kipx] + h[1]*vect[kipy] + h[2]*vect[kipz];
1045 rho = -charge*h[3]/vect[kipp];
1048 if (TMath::Abs(tet) > 0.15) {
1049 sint = TMath::Sin(tet);
1051 tsint = (tet-sint)/tet;
1052 cos1t = 2.*(TMath::Sin(0.5*tet))*(TMath::Sin(0.5*tet))/tet;
1054 tsint = tet*tet/36.;
1055 sintt = (1. - tsint);
1062 f3 = step * tsint * hp;
1065 f6 = tet * cos1t * hp;
1067 vout[kix] = vect[kix] + f1*vect[kipx] + f2*hxp[0] + f3*h[0];
1068 vout[kiy] = vect[kiy] + f1*vect[kipy] + f2*hxp[1] + f3*h[1];
1069 vout[kiz] = vect[kiz] + f1*vect[kipz] + f2*hxp[2] + f3*h[2];
1071 vout[kipx] = vect[kipx] + f4*vect[kipx] + f5*hxp[0] + f6*h[0];
1072 vout[kipy] = vect[kipy] + f4*vect[kipy] + f5*hxp[1] + f6*h[1];
1073 vout[kipz] = vect[kipz] + f4*vect[kipz] + f5*hxp[2] + f6*h[2];
1078 //__________________________________________________________________________
1079 void AliMUONTrackExtrap::ExtrapOneStepHelix3(Double_t field, Double_t step, Double_t *vect, Double_t *vout)
1082 /// ******************************************************************
1084 /// * Tracking routine in a constant field oriented *
1085 /// * along axis 3 *
1086 /// * Tracking is performed with a conventional *
1087 /// * helix step method *
1089 /// * ==>Called by : USER, GUSWIM *
1090 /// * Authors R.Brun, M.Hansroul ********* *
1091 /// * Rewritten V.Perevoztchikov
1093 /// ******************************************************************
1097 Double_t h4, hp, rho, tet;
1098 Double_t sint, sintt, tsint, cos1t;
1099 Double_t f1, f2, f3, f4, f5, f6;
1101 const Int_t kix = 0;
1102 const Int_t kiy = 1;
1103 const Int_t kiz = 2;
1104 const Int_t kipx = 3;
1105 const Int_t kipy = 4;
1106 const Int_t kipz = 5;
1107 const Int_t kipp = 6;
1109 const Double_t kec = 2.9979251e-4;
1112 // ------------------------------------------------------------------
1114 // units are kgauss,centimeters,gev/c
1116 vout[kipp] = vect[kipp];
1119 hxp[0] = - vect[kipy];
1120 hxp[1] = + vect[kipx];
1124 rho = -h4/vect[kipp];
1126 if (TMath::Abs(tet) > 0.15) {
1127 sint = TMath::Sin(tet);
1129 tsint = (tet-sint)/tet;
1130 cos1t = 2.* TMath::Sin(0.5*tet) * TMath::Sin(0.5*tet)/tet;
1132 tsint = tet*tet/36.;
1133 sintt = (1. - tsint);
1140 f3 = step * tsint * hp;
1143 f6 = tet * cos1t * hp;
1145 vout[kix] = vect[kix] + f1*vect[kipx] + f2*hxp[0];
1146 vout[kiy] = vect[kiy] + f1*vect[kipy] + f2*hxp[1];
1147 vout[kiz] = vect[kiz] + f1*vect[kipz] + f3;
1149 vout[kipx] = vect[kipx] + f4*vect[kipx] + f5*hxp[0];
1150 vout[kipy] = vect[kipy] + f4*vect[kipy] + f5*hxp[1];
1151 vout[kipz] = vect[kipz] + f4*vect[kipz] + f6;
1156 //__________________________________________________________________________
1157 void AliMUONTrackExtrap::ExtrapOneStepRungekutta(Double_t charge, Double_t step, Double_t* vect, Double_t* vout)
1160 /// ******************************************************************
1162 /// * Runge-Kutta method for tracking a particle through a magnetic *
1163 /// * field. Uses Nystroem algorithm (See Handbook Nat. Bur. of *
1164 /// * Standards, procedure 25.5.20) *
1166 /// * Input parameters *
1167 /// * CHARGE Particle charge *
1168 /// * STEP Step size *
1169 /// * VECT Initial co-ords,direction cosines,momentum *
1170 /// * Output parameters *
1171 /// * VOUT Output co-ords,direction cosines,momentum *
1172 /// * User routine called *
1173 /// * CALL GUFLD(X,F) *
1175 /// * ==>Called by : USER, GUSWIM *
1176 /// * Authors R.Brun, M.Hansroul ********* *
1177 /// * V.Perevoztchikov (CUT STEP implementation) *
1180 /// ******************************************************************
1183 Double_t h2, h4, f[4];
1184 Double_t xyzt[3], a, b, c, ph,ph2;
1185 Double_t secxs[4],secys[4],seczs[4],hxp[3];
1186 Double_t g1, g2, g3, g4, g5, g6, ang2, dxt, dyt, dzt;
1187 Double_t est, at, bt, ct, cba;
1188 Double_t f1, f2, f3, f4, rho, tet, hnorm, hp, rho1, sint, cost;
1198 Double_t maxit = 1992;
1199 Double_t maxcut = 11;
1201 const Double_t kdlt = 1e-4;
1202 const Double_t kdlt32 = kdlt/32.;
1203 const Double_t kthird = 1./3.;
1204 const Double_t khalf = 0.5;
1205 const Double_t kec = 2.9979251e-4;
1207 const Double_t kpisqua = 9.86960440109;
1208 const Int_t kix = 0;
1209 const Int_t kiy = 1;
1210 const Int_t kiz = 2;
1211 const Int_t kipx = 3;
1212 const Int_t kipy = 4;
1213 const Int_t kipz = 5;
1216 // *. ------------------------------------------------------------------
1218 // * this constant is for units cm,gev/c and kgauss
1222 for(Int_t j = 0; j < 7; j++)
1225 Double_t pinv = kec * charge / vect[6];
1233 if (TMath::Abs(h) > TMath::Abs(rest)) h = rest;
1234 //cmodif: call gufld(vout,f) changed into:
1235 TGeoGlobalMagField::Instance()->Field(vout,f);
1238 // * start of integration
1251 secxs[0] = (b * f[2] - c * f[1]) * ph2;
1252 secys[0] = (c * f[0] - a * f[2]) * ph2;
1253 seczs[0] = (a * f[1] - b * f[0]) * ph2;
1254 ang2 = (secxs[0]*secxs[0] + secys[0]*secys[0] + seczs[0]*seczs[0]);
1255 if (ang2 > kpisqua) break;
1257 dxt = h2 * a + h4 * secxs[0];
1258 dyt = h2 * b + h4 * secys[0];
1259 dzt = h2 * c + h4 * seczs[0];
1264 // * second intermediate point
1267 est = TMath::Abs(dxt) + TMath::Abs(dyt) + TMath::Abs(dzt);
1269 if (ncut++ > maxcut) break;
1278 //cmodif: call gufld(xyzt,f) changed into:
1279 TGeoGlobalMagField::Instance()->Field(xyzt,f);
1285 secxs[1] = (bt * f[2] - ct * f[1]) * ph2;
1286 secys[1] = (ct * f[0] - at * f[2]) * ph2;
1287 seczs[1] = (at * f[1] - bt * f[0]) * ph2;
1291 secxs[2] = (bt * f[2] - ct * f[1]) * ph2;
1292 secys[2] = (ct * f[0] - at * f[2]) * ph2;
1293 seczs[2] = (at * f[1] - bt * f[0]) * ph2;
1294 dxt = h * (a + secxs[2]);
1295 dyt = h * (b + secys[2]);
1296 dzt = h * (c + seczs[2]);
1300 at = a + 2.*secxs[2];
1301 bt = b + 2.*secys[2];
1302 ct = c + 2.*seczs[2];
1304 est = TMath::Abs(dxt)+TMath::Abs(dyt)+TMath::Abs(dzt);
1305 if (est > 2.*TMath::Abs(h)) {
1306 if (ncut++ > maxcut) break;
1315 //cmodif: call gufld(xyzt,f) changed into:
1316 TGeoGlobalMagField::Instance()->Field(xyzt,f);
1318 z = z + (c + (seczs[0] + seczs[1] + seczs[2]) * kthird) * h;
1319 y = y + (b + (secys[0] + secys[1] + secys[2]) * kthird) * h;
1320 x = x + (a + (secxs[0] + secxs[1] + secxs[2]) * kthird) * h;
1322 secxs[3] = (bt*f[2] - ct*f[1])* ph2;
1323 secys[3] = (ct*f[0] - at*f[2])* ph2;
1324 seczs[3] = (at*f[1] - bt*f[0])* ph2;
1325 a = a+(secxs[0]+secxs[3]+2. * (secxs[1]+secxs[2])) * kthird;
1326 b = b+(secys[0]+secys[3]+2. * (secys[1]+secys[2])) * kthird;
1327 c = c+(seczs[0]+seczs[3]+2. * (seczs[1]+seczs[2])) * kthird;
1329 est = TMath::Abs(secxs[0]+secxs[3] - (secxs[1]+secxs[2]))
1330 + TMath::Abs(secys[0]+secys[3] - (secys[1]+secys[2]))
1331 + TMath::Abs(seczs[0]+seczs[3] - (seczs[1]+seczs[2]));
1333 if (est > kdlt && TMath::Abs(h) > 1.e-4) {
1334 if (ncut++ > maxcut) break;
1340 // * if too many iterations, go to helix
1341 if (iter++ > maxit) break;
1346 cba = 1./ TMath::Sqrt(a*a + b*b + c*c);
1354 if (step < 0.) rest = -rest;
1355 if (rest < 1.e-5*TMath::Abs(step)) return;
1359 // angle too big, use helix
1364 f4 = TMath::Sqrt(f1*f1+f2*f2+f3*f3);
1373 hxp[0] = f2*vect[kipz] - f3*vect[kipy];
1374 hxp[1] = f3*vect[kipx] - f1*vect[kipz];
1375 hxp[2] = f1*vect[kipy] - f2*vect[kipx];
1377 hp = f1*vect[kipx] + f2*vect[kipy] + f3*vect[kipz];
1380 sint = TMath::Sin(tet);
1381 cost = 2.*TMath::Sin(khalf*tet)*TMath::Sin(khalf*tet);
1385 g3 = (tet-sint) * hp*rho1;
1390 vout[kix] = vect[kix] + g1*vect[kipx] + g2*hxp[0] + g3*f1;
1391 vout[kiy] = vect[kiy] + g1*vect[kipy] + g2*hxp[1] + g3*f2;
1392 vout[kiz] = vect[kiz] + g1*vect[kipz] + g2*hxp[2] + g3*f3;
1394 vout[kipx] = vect[kipx] + g4*vect[kipx] + g5*hxp[0] + g6*f1;
1395 vout[kipy] = vect[kipy] + g4*vect[kipy] + g5*hxp[1] + g6*f2;
1396 vout[kipz] = vect[kipz] + g4*vect[kipz] + g5*hxp[2] + g6*f3;