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"
33 #include <TGeoManager.h>
35 #include <Riostream.h>
38 ClassImp(AliMUONTrackExtrap) // Class implementation in ROOT context
41 const AliMagF* AliMUONTrackExtrap::fgkField = 0x0;
42 const Double_t AliMUONTrackExtrap::fgkSimpleBPosition = 0.5 * (AliMUONConstants::CoilZ() + AliMUONConstants::YokeZ());
43 const Double_t AliMUONTrackExtrap::fgkSimpleBLength = 0.5 * (AliMUONConstants::CoilL() + AliMUONConstants::YokeL());
44 Double_t AliMUONTrackExtrap::fgSimpleBValue = 0.;
45 Bool_t AliMUONTrackExtrap::fgFieldON = kFALSE;
46 const Bool_t AliMUONTrackExtrap::fgkUseHelix = kFALSE;
47 const Int_t AliMUONTrackExtrap::fgkMaxStepNumber = 5000;
48 const Double_t AliMUONTrackExtrap::fgkHelixStepLength = 6.;
49 const Double_t AliMUONTrackExtrap::fgkRungeKuttaMaxResidue = 0.002;
51 //__________________________________________________________________________
52 void AliMUONTrackExtrap::SetField(const AliMagF* magField)
54 /// set magnetic field
59 cout<<"E-AliMUONTrackExtrap::SetField: fgkField = 0x0"<<endl;
63 // set field on/off flag
64 fgFieldON = (fgkField->Factor() == 0.) ? kFALSE : kTRUE;
66 // set field at the centre of the dipole
68 Float_t b[3] = {0.,0.,0.}, x[3] = {50.,50.,(Float_t) fgkSimpleBPosition};
70 fgSimpleBValue = (Double_t) b[0];
71 } else fgSimpleBValue = 0.;
75 //__________________________________________________________________________
76 Double_t AliMUONTrackExtrap::GetImpactParamFromBendingMomentum(Double_t bendingMomentum)
78 /// Returns impact parameter at vertex in bending plane (cm),
79 /// from the signed bending momentum "BendingMomentum" in bending plane (GeV/c),
80 /// using simple values for dipole magnetic field.
81 /// The sign of "BendingMomentum" is the sign of the charge.
83 if (bendingMomentum == 0.) return 1.e10;
86 cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl;
90 const Double_t kCorrectionFactor = 0.9; // impact parameter is 10% overestimated
92 return kCorrectionFactor * (-0.0003 * fgSimpleBValue * fgkSimpleBLength * fgkSimpleBPosition / bendingMomentum);
95 //__________________________________________________________________________
97 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
115 return kCorrectionFactor * (-0.0003 * fgSimpleBValue * fgkSimpleBLength * fgkSimpleBPosition / impactParam);
119 return AliMUONConstants::GetMostProbBendingMomentum();
123 //__________________________________________________________________________
124 void AliMUONTrackExtrap::LinearExtrapToZ(AliMUONTrackParam* trackParam, Double_t zEnd, Bool_t updatePropagator)
126 /// Track parameters (and their covariances if any) linearly extrapolated to the plane at "zEnd".
127 /// On return, results from the extrapolation are updated in trackParam.
129 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z
131 // Compute track parameters
132 Double_t dZ = zEnd - trackParam->GetZ();
133 trackParam->SetNonBendingCoor(trackParam->GetNonBendingCoor() + trackParam->GetNonBendingSlope() * dZ);
134 trackParam->SetBendingCoor(trackParam->GetBendingCoor() + trackParam->GetBendingSlope() * dZ);
135 trackParam->SetZ(zEnd);
137 // Update track parameters covariances if any
138 if (trackParam->CovariancesExist()) {
139 TMatrixD paramCov(trackParam->GetCovariances());
140 paramCov(0,0) += dZ * dZ * paramCov(1,1) + 2. * dZ * paramCov(0,1);
141 paramCov(0,1) += dZ * paramCov(1,1);
142 paramCov(1,0) = paramCov(0,1);
143 paramCov(2,2) += dZ * dZ * paramCov(3,3) + 2. * dZ * paramCov(2,3);
144 paramCov(2,3) += dZ * paramCov(3,3);
145 paramCov(3,2) = paramCov(2,3);
146 trackParam->SetCovariances(paramCov);
148 // Update the propagator if required
149 if (updatePropagator) {
154 trackParam->UpdatePropagator(jacob);
161 //__________________________________________________________________________
162 void AliMUONTrackExtrap::ExtrapToZ(AliMUONTrackParam* trackParam, Double_t zEnd)
164 /// Interface to track parameter extrapolation to the plane at "Z" using Helix or Rungekutta algorithm.
165 /// On return, the track parameters resulting from the extrapolation are updated in trackParam.
166 if (!fgFieldON) AliMUONTrackExtrap::LinearExtrapToZ(trackParam,zEnd);
167 else if (fgkUseHelix) AliMUONTrackExtrap::ExtrapToZHelix(trackParam,zEnd);
168 else AliMUONTrackExtrap::ExtrapToZRungekutta(trackParam,zEnd);
171 //__________________________________________________________________________
172 void AliMUONTrackExtrap::ExtrapToZHelix(AliMUONTrackParam* trackParam, Double_t zEnd)
174 /// Track parameter extrapolation to the plane at "Z" using Helix algorithm.
175 /// On return, the track parameters resulting from the extrapolation are updated in trackParam.
176 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same Z
177 Double_t forwardBackward; // +1 if forward, -1 if backward
178 if (zEnd < trackParam->GetZ()) forwardBackward = 1.0; // spectro. z<0
179 else forwardBackward = -1.0;
180 Double_t v3[7], v3New[7]; // 7 in parameter ????
181 Int_t i3, stepNumber;
182 // For safety: return kTRUE or kFALSE ????
183 // Parameter vector for calling EXTRAP_ONESTEP
184 ConvertTrackParamForExtrap(trackParam, forwardBackward, v3);
185 // sign of charge (sign of fInverseBendingMomentum if forward motion)
186 // must be changed if backward extrapolation
187 Double_t chargeExtrap = forwardBackward * TMath::Sign(Double_t(1.0), trackParam->GetInverseBendingMomentum());
188 // Extrapolation loop
190 while (((-forwardBackward * (v3[2] - zEnd)) <= 0.0) && (stepNumber < fgkMaxStepNumber)) { // spectro. z<0
192 ExtrapOneStepHelix(chargeExtrap, fgkHelixStepLength, v3, v3New);
193 if ((-forwardBackward * (v3New[2] - zEnd)) > 0.0) break; // one is beyond Z spectro. z<0
194 // better use TArray ????
195 for (i3 = 0; i3 < 7; i3++) {v3[i3] = v3New[i3];}
197 // check fgkMaxStepNumber ????
198 // Interpolation back to exact Z (2nd order)
199 // should be in function ???? using TArray ????
200 Double_t dZ12 = v3New[2] - v3[2]; // 1->2
201 if (TMath::Abs(dZ12) > 0) {
202 Double_t dZ1i = zEnd - v3[2]; // 1-i
203 Double_t dZi2 = v3New[2] - zEnd; // i->2
204 Double_t xPrime = (v3New[0] - v3[0]) / dZ12;
205 Double_t xSecond = ((v3New[3] / v3New[5]) - (v3[3] / v3[5])) / dZ12;
206 Double_t yPrime = (v3New[1] - v3[1]) / dZ12;
207 Double_t ySecond = ((v3New[4] / v3New[5]) - (v3[4] / v3[5])) / dZ12;
208 v3[0] = v3[0] + xPrime * dZ1i - 0.5 * xSecond * dZ1i * dZi2; // X
209 v3[1] = v3[1] + yPrime * dZ1i - 0.5 * ySecond * dZ1i * dZi2; // Y
211 Double_t xPrimeI = xPrime - 0.5 * xSecond * (dZi2 - dZ1i);
212 Double_t yPrimeI = yPrime - 0.5 * ySecond * (dZi2 - dZ1i);
213 // (PX, PY, PZ)/PTOT assuming forward motion
214 v3[5] = 1.0 / TMath::Sqrt(1.0 + xPrimeI * xPrimeI + yPrimeI * yPrimeI); // PZ/PTOT
215 v3[3] = xPrimeI * v3[5]; // PX/PTOT
216 v3[4] = yPrimeI * v3[5]; // PY/PTOT
218 cout<<"W-AliMUONTrackExtrap::ExtrapToZHelix: Extrap. to Z not reached, Z = "<<zEnd<<endl;
220 // Recover track parameters (charge back for forward motion)
221 RecoverTrackParam(v3, chargeExtrap * forwardBackward, trackParam);
224 //__________________________________________________________________________
225 void AliMUONTrackExtrap::ExtrapToZRungekutta(AliMUONTrackParam* trackParam, Double_t zEnd)
227 /// Track parameter extrapolation to the plane at "Z" using Rungekutta algorithm.
228 /// On return, the track parameters resulting from the extrapolation are updated in trackParam.
229 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same Z
230 Double_t forwardBackward; // +1 if forward, -1 if backward
231 if (zEnd < trackParam->GetZ()) forwardBackward = 1.0; // spectro. z<0
232 else forwardBackward = -1.0;
233 // sign of charge (sign of fInverseBendingMomentum if forward motion)
234 // must be changed if backward extrapolation
235 Double_t chargeExtrap = forwardBackward * TMath::Sign(Double_t(1.0), trackParam->GetInverseBendingMomentum());
236 Double_t v3[7], v3New[7];
238 Int_t stepNumber = 0;
240 // Extrapolation loop (until within tolerance)
241 Double_t residue = zEnd - trackParam->GetZ();
242 while (TMath::Abs(residue) > fgkRungeKuttaMaxResidue && stepNumber <= fgkMaxStepNumber) {
243 dZ = zEnd - trackParam->GetZ();
244 // step lenght assuming linear trajectory
245 step = dZ * TMath::Sqrt(1.0 + trackParam->GetBendingSlope()*trackParam->GetBendingSlope() +
246 trackParam->GetNonBendingSlope()*trackParam->GetNonBendingSlope());
247 ConvertTrackParamForExtrap(trackParam, forwardBackward, v3);
248 do { // reduce step lenght while zEnd oversteped
249 if (stepNumber > fgkMaxStepNumber) {
250 cout<<"W-AliMUONTrackExtrap::ExtrapToZRungekutta: Too many trials: "<<stepNumber<<endl;
254 step = TMath::Abs(step);
255 AliMUONTrackExtrap::ExtrapOneStepRungekutta(chargeExtrap,step,v3,v3New);
256 residue = zEnd - v3New[2];
257 step *= dZ/(v3New[2]-trackParam->GetZ());
258 } while (residue*dZ < 0 && TMath::Abs(residue) > fgkRungeKuttaMaxResidue);
259 RecoverTrackParam(v3New, chargeExtrap * forwardBackward, trackParam);
262 // terminate the extropolation with a straight line up to the exact "zEnd" value
263 trackParam->SetNonBendingCoor(trackParam->GetNonBendingCoor() + residue * trackParam->GetNonBendingSlope());
264 trackParam->SetBendingCoor(trackParam->GetBendingCoor() + residue * trackParam->GetBendingSlope());
265 trackParam->SetZ(zEnd);
268 //__________________________________________________________________________
269 void AliMUONTrackExtrap::ConvertTrackParamForExtrap(AliMUONTrackParam* trackParam, Double_t forwardBackward, Double_t *v3)
271 /// Set vector of Geant3 parameters pointed to by "v3" from track parameters in trackParam.
272 /// Since AliMUONTrackParam is only geometry, one uses "forwardBackward"
273 /// to know whether the particle is going forward (+1) or backward (-1).
274 v3[0] = trackParam->GetNonBendingCoor(); // X
275 v3[1] = trackParam->GetBendingCoor(); // Y
276 v3[2] = trackParam->GetZ(); // Z
277 Double_t pYZ = TMath::Abs(1.0 / trackParam->GetInverseBendingMomentum());
278 Double_t pZ = pYZ / TMath::Sqrt(1.0 + trackParam->GetBendingSlope() * trackParam->GetBendingSlope());
279 v3[6] = TMath::Sqrt(pYZ * pYZ + pZ * pZ * trackParam->GetNonBendingSlope() * trackParam->GetNonBendingSlope()); // PTOT
280 v3[5] = -forwardBackward * pZ / v3[6]; // PZ/PTOT spectro. z<0
281 v3[3] = trackParam->GetNonBendingSlope() * v3[5]; // PX/PTOT
282 v3[4] = trackParam->GetBendingSlope() * v3[5]; // PY/PTOT
285 //__________________________________________________________________________
286 void AliMUONTrackExtrap::RecoverTrackParam(Double_t *v3, Double_t charge, AliMUONTrackParam* trackParam)
288 /// Set track parameters in trackParam from Geant3 parameters pointed to by "v3",
289 /// assumed to be calculated for forward motion in Z.
290 /// "InverseBendingMomentum" is signed with "charge".
291 trackParam->SetNonBendingCoor(v3[0]); // X
292 trackParam->SetBendingCoor(v3[1]); // Y
293 trackParam->SetZ(v3[2]); // Z
294 Double_t pYZ = v3[6] * TMath::Sqrt(1.0 - v3[3] * v3[3]);
295 trackParam->SetInverseBendingMomentum(charge/pYZ);
296 trackParam->SetBendingSlope(v3[4]/v3[5]);
297 trackParam->SetNonBendingSlope(v3[3]/v3[5]);
300 //__________________________________________________________________________
301 void AliMUONTrackExtrap::ExtrapToZCov(AliMUONTrackParam* trackParam, Double_t zEnd, Bool_t updatePropagator)
303 /// Track parameters and their covariances extrapolated to the plane at "zEnd".
304 /// On return, results from the extrapolation are updated in trackParam.
306 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z
308 if (!fgFieldON) { // linear extrapolation if no magnetic field
309 AliMUONTrackExtrap::LinearExtrapToZ(trackParam,zEnd,updatePropagator);
313 // No need to propagate the covariance matrix if it does not exist
314 if (!trackParam->CovariancesExist()) {
315 cout<<"W-AliMUONTrackExtrap::ExtrapToZCov: Covariance matrix does not exist"<<endl;
316 // Extrapolate track parameters to "zEnd"
317 ExtrapToZ(trackParam,zEnd);
321 // Save the actual track parameters
322 AliMUONTrackParam trackParamSave(*trackParam);
323 TMatrixD paramSave(trackParamSave.GetParameters());
324 Double_t zBegin = trackParamSave.GetZ();
326 // Get reference to the parameter covariance matrix
327 const TMatrixD& kParamCov = trackParam->GetCovariances();
329 // Extrapolate track parameters to "zEnd"
330 ExtrapToZ(trackParam,zEnd);
332 // Get reference to the extrapolated parameters
333 const TMatrixD& extrapParam = trackParam->GetParameters();
335 // Calculate the jacobian related to the track parameters extrapolation to "zEnd"
338 TMatrixD dParam(5,1);
339 for (Int_t i=0; i<5; i++) {
340 // Skip jacobian calculation for parameters with no associated error
341 if (kParamCov(i,i) <= 0.) continue;
343 // Small variation of parameter i only
344 for (Int_t j=0; j<5; j++) {
346 dParam(j,0) = TMath::Sqrt(kParamCov(i,i));
347 if (j == 4) dParam(j,0) *= TMath::Sign(1.,-paramSave(4,0)); // variation always in the same direction
348 } else dParam(j,0) = 0.;
351 // Set new parameters
352 trackParamSave.SetParameters(paramSave);
353 trackParamSave.AddParameters(dParam);
354 trackParamSave.SetZ(zBegin);
356 // Extrapolate new track parameters to "zEnd"
357 ExtrapToZ(&trackParamSave,zEnd);
359 // Calculate the jacobian
360 TMatrixD jacobji(trackParamSave.GetParameters(),TMatrixD::kMinus,extrapParam);
361 jacobji *= 1. / dParam(i,0);
362 jacob.SetSub(0,i,jacobji);
365 // Extrapolate track parameter covariances to "zEnd"
366 TMatrixD tmp(kParamCov,TMatrixD::kMultTranspose,jacob);
367 TMatrixD tmp2(jacob,TMatrixD::kMult,tmp);
368 trackParam->SetCovariances(tmp2);
370 // Update the propagator if required
371 if (updatePropagator) trackParam->UpdatePropagator(jacob);
374 //__________________________________________________________________________
375 void AliMUONTrackExtrap::AddMCSEffectInAbsorber(AliMUONTrackParam* param, Double_t pathLength, Double_t f0, Double_t f1, Double_t f2)
377 /// Add to the track parameter covariances the effects of multiple Coulomb scattering
378 /// The absorber correction parameters are supposed to be calculated at the current track z-position
380 // absorber related covariance parameters
381 Double_t bendingSlope = param->GetBendingSlope();
382 Double_t nonBendingSlope = param->GetNonBendingSlope();
383 Double_t inverseBendingMomentum = param->GetInverseBendingMomentum();
384 Double_t alpha2 = 0.0136 * 0.0136 * inverseBendingMomentum * inverseBendingMomentum * (1.0 + bendingSlope * bendingSlope) /
385 (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope); // velocity = 1
386 Double_t varCoor = alpha2 * (pathLength * pathLength * f0 - 2. * pathLength * f1 + f2);
387 Double_t covCorrSlope = alpha2 * (pathLength * f0 - f1);
388 Double_t varSlop = alpha2 * f0;
390 // compute derivative d(q/Pxy) / dSlopeX and d(q/Pxy) / dSlopeX
391 Double_t dqPxydSlopeX = inverseBendingMomentum * nonBendingSlope / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
392 Double_t dqPxydSlopeY = - inverseBendingMomentum * nonBendingSlope*nonBendingSlope * bendingSlope /
393 (1. + bendingSlope*bendingSlope) / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
395 // Set MCS covariance matrix
396 TMatrixD newParamCov(param->GetCovariances());
398 newParamCov(0,0) += varCoor; newParamCov(0,1) += covCorrSlope;
399 newParamCov(1,0) += covCorrSlope; newParamCov(1,1) += varSlop;
401 newParamCov(2,2) += varCoor; newParamCov(2,3) += covCorrSlope;
402 newParamCov(3,2) += covCorrSlope; newParamCov(3,3) += varSlop;
403 // Inverse bending momentum (due to dependences with bending and non bending slopes)
404 newParamCov(4,0) += dqPxydSlopeX * covCorrSlope; newParamCov(0,4) += dqPxydSlopeX * covCorrSlope;
405 newParamCov(4,1) += dqPxydSlopeX * varSlop; newParamCov(1,4) += dqPxydSlopeX * varSlop;
406 newParamCov(4,2) += dqPxydSlopeY * covCorrSlope; newParamCov(2,4) += dqPxydSlopeY * covCorrSlope;
407 newParamCov(4,3) += dqPxydSlopeY * varSlop; newParamCov(3,4) += dqPxydSlopeY * varSlop;
408 newParamCov(4,4) += (dqPxydSlopeX*dqPxydSlopeX + dqPxydSlopeY*dqPxydSlopeY) * varSlop;
410 // Set new covariances
411 param->SetCovariances(newParamCov);
414 //__________________________________________________________________________
415 void AliMUONTrackExtrap::CorrectMCSEffectInAbsorber(AliMUONTrackParam* param,
416 Double_t xVtx, Double_t yVtx, Double_t zVtx,
417 Double_t errXVtx, Double_t errYVtx,
418 Double_t absZBeg, Double_t pathLength, Double_t f0, Double_t f1, Double_t f2)
420 /// Correct parameters and corresponding covariances using Branson correction
421 /// - input param are parameters and covariances at the end of absorber
422 /// - output param are parameters and covariances at vertex
423 /// Absorber correction parameters are supposed to be calculated at the current track z-position
425 // Position of the Branson plane (spectro. (z<0))
426 Double_t zB = (f1>0.) ? absZBeg - f2/f1 : 0.;
428 // Add MCS effects to current parameter covariances
429 AddMCSEffectInAbsorber(param, pathLength, f0, f1, f2);
431 // Get track parameters and covariances in the Branson plane corrected for magnetic field effect
432 ExtrapToZCov(param,zVtx);
433 LinearExtrapToZ(param,zB);
435 // compute track parameters at vertex
436 TMatrixD newParam(5,1);
437 newParam(0,0) = xVtx;
438 newParam(1,0) = (param->GetNonBendingCoor() - xVtx) / (zB - zVtx);
439 newParam(2,0) = yVtx;
440 newParam(3,0) = (param->GetBendingCoor() - yVtx) / (zB - zVtx);
441 newParam(4,0) = param->GetCharge() / param->P() *
442 TMath::Sqrt(1.0 + newParam(1,0)*newParam(1,0) + newParam(3,0)*newParam(3,0)) /
443 TMath::Sqrt(1.0 + newParam(3,0)*newParam(3,0));
445 // Get covariances in (X, SlopeX, Y, SlopeY, q*PTot) coordinate system
446 TMatrixD paramCovP(param->GetCovariances());
447 Cov2CovP(param->GetParameters(),paramCovP);
449 // Get the covariance matrix in the (XVtx, X, YVtx, Y, q*PTot) coordinate system
450 TMatrixD paramCovVtx(5,5);
452 paramCovVtx(0,0) = errXVtx * errXVtx;
453 paramCovVtx(1,1) = paramCovP(0,0);
454 paramCovVtx(2,2) = errYVtx * errYVtx;
455 paramCovVtx(3,3) = paramCovP(2,2);
456 paramCovVtx(4,4) = paramCovP(4,4);
457 paramCovVtx(1,3) = paramCovP(0,2);
458 paramCovVtx(3,1) = paramCovP(2,0);
459 paramCovVtx(1,4) = paramCovP(0,4);
460 paramCovVtx(4,1) = paramCovP(4,0);
461 paramCovVtx(3,4) = paramCovP(2,4);
462 paramCovVtx(4,3) = paramCovP(4,2);
464 // Jacobian of the transformation (XVtx, X, YVtx, Y, q*PTot) -> (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q*PTotVtx)
467 jacob(1,0) = - 1. / (zB - zVtx);
468 jacob(1,1) = 1. / (zB - zVtx);
469 jacob(3,2) = - 1. / (zB - zVtx);
470 jacob(3,3) = 1. / (zB - zVtx);
472 // Compute covariances at vertex in the (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q*PTotVtx) coordinate system
473 TMatrixD tmp(paramCovVtx,TMatrixD::kMultTranspose,jacob);
474 TMatrixD newParamCov(jacob,TMatrixD::kMult,tmp);
476 // Compute covariances at vertex in the (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q/PyzVtx) coordinate system
477 CovP2Cov(newParam,newParamCov);
479 // Set parameters and covariances at vertex
480 param->SetParameters(newParam);
482 param->SetCovariances(newParamCov);
485 //__________________________________________________________________________
486 void AliMUONTrackExtrap::CorrectELossEffectInAbsorber(AliMUONTrackParam* param, Double_t eLoss, Double_t sigmaELoss2)
488 /// Correct parameters for energy loss and add energy loss fluctuation effect to covariances
490 // Get parameter covariances in (X, SlopeX, Y, SlopeY, q*PTot) coordinate system
491 TMatrixD newParamCov(param->GetCovariances());
492 Cov2CovP(param->GetParameters(),newParamCov);
494 // Add effects of energy loss fluctuation to covariances
495 newParamCov(4,4) += sigmaELoss2;
497 // Compute new parameters corrected for energy loss
498 Double_t nonBendingSlope = param->GetNonBendingSlope();
499 Double_t bendingSlope = param->GetBendingSlope();
500 param->SetInverseBendingMomentum(param->GetCharge() / (param->P() + eLoss) *
501 TMath::Sqrt(1.0 + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope) /
502 TMath::Sqrt(1.0 + bendingSlope*bendingSlope));
504 // Get new parameter covariances in (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system
505 CovP2Cov(param->GetParameters(),newParamCov);
507 // Set new parameter covariances
508 param->SetCovariances(newParamCov);
511 //__________________________________________________________________________
512 Bool_t AliMUONTrackExtrap::GetAbsorberCorrectionParam(Double_t trackXYZIn[3], Double_t trackXYZOut[3], Double_t pTotal,
513 Double_t &pathLength, Double_t &f0, Double_t &f1, Double_t &f2,
514 Double_t &meanRho, Double_t &totalELoss, Double_t &sigmaELoss2)
516 /// Parameters used to correct for Multiple Coulomb Scattering and energy loss in absorber
517 /// Calculated assuming a linear propagation from trackXYZIn to trackXYZOut (order is important)
518 // pathLength: path length between trackXYZIn and trackXYZOut (cm)
519 // f0: 0th moment of z calculated with the inverse radiation-length distribution
520 // f1: 1st moment of z calculated with the inverse radiation-length distribution
521 // f2: 2nd moment of z calculated with the inverse radiation-length distribution
522 // meanRho: average density of crossed material (g/cm3)
523 // totalELoss: total energy loss in absorber
525 // Reset absorber's parameters
534 // Check whether the geometry is available
536 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: no TGeo"<<endl;
540 // Initialize starting point and direction
541 pathLength = TMath::Sqrt((trackXYZOut[0] - trackXYZIn[0])*(trackXYZOut[0] - trackXYZIn[0])+
542 (trackXYZOut[1] - trackXYZIn[1])*(trackXYZOut[1] - trackXYZIn[1])+
543 (trackXYZOut[2] - trackXYZIn[2])*(trackXYZOut[2] - trackXYZIn[2]));
544 if (pathLength < TGeoShape::Tolerance()) return kFALSE;
546 b[0] = (trackXYZOut[0] - trackXYZIn[0]) / pathLength;
547 b[1] = (trackXYZOut[1] - trackXYZIn[1]) / pathLength;
548 b[2] = (trackXYZOut[2] - trackXYZIn[2]) / pathLength;
549 TGeoNode *currentnode = gGeoManager->InitTrack(trackXYZIn, b);
551 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: start point out of geometry"<<endl;
555 // loop over absorber slices and calculate absorber's parameters
556 Double_t rho = 0.; // material density (g/cm3)
557 Double_t x0 = 0.; // radiation-length (cm-1)
558 Double_t atomicA = 0.; // A of material
559 Double_t atomicZ = 0.; // Z of material
560 Double_t localPathLength = 0;
561 Double_t remainingPathLength = pathLength;
562 Double_t zB = trackXYZIn[2];
563 Double_t zE, dzB, dzE;
565 // Get material properties
566 TGeoMaterial *material = currentnode->GetVolume()->GetMedium()->GetMaterial();
567 rho = material->GetDensity();
568 x0 = material->GetRadLen();
569 if (!material->IsMixture()) x0 /= rho; // different normalization in the modeler for mixture
570 atomicA = material->GetA();
571 atomicZ = material->GetZ();
573 // Get path length within this material
574 gGeoManager->FindNextBoundary(remainingPathLength);
575 localPathLength = gGeoManager->GetStep() + 1.e-6;
576 // Check if boundary within remaining path length. If so, make sure to cross the boundary to prepare the next step
577 if (localPathLength >= remainingPathLength) localPathLength = remainingPathLength;
579 currentnode = gGeoManager->Step();
581 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: navigation failed"<<endl;
582 f0 = f1 = f2 = meanRho = totalELoss = sigmaELoss2 = 0.;
585 if (!gGeoManager->IsEntering()) {
586 // make another small step to try to enter in new absorber slice
587 gGeoManager->SetStep(0.001);
588 currentnode = gGeoManager->Step();
589 if (!gGeoManager->IsEntering() || !currentnode) {
590 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: navigation failed"<<endl;
591 f0 = f1 = f2 = meanRho = totalELoss = sigmaELoss2 = 0.;
594 localPathLength += 0.001;
598 // calculate absorber's parameters
599 zE = b[2] * localPathLength + zB;
600 dzB = zB - trackXYZIn[2];
601 dzE = zE - trackXYZIn[2];
602 f0 += localPathLength / x0;
603 f1 += (dzE*dzE - dzB*dzB) / b[2] / b[2] / x0 / 2.;
604 f2 += (dzE*dzE*dzE - dzB*dzB*dzB) / b[2] / b[2] / b[2] / x0 / 3.;
605 meanRho += localPathLength * rho;
606 totalELoss += BetheBloch(pTotal, localPathLength, rho, atomicA, atomicZ);
607 sigmaELoss2 += EnergyLossFluctuation2(pTotal, localPathLength, rho, atomicA, atomicZ);
611 remainingPathLength -= localPathLength;
612 } while (remainingPathLength > TGeoShape::Tolerance());
614 meanRho /= pathLength;
619 //__________________________________________________________________________
620 Double_t AliMUONTrackExtrap::GetMCSAngle2(const AliMUONTrackParam& param, Double_t dZ, Double_t x0)
622 /// Return the angular dispersion square due to multiple Coulomb scattering
623 /// through a material of thickness "dZ" and of radiation length "x0"
624 /// assuming linear propagation and using the small angle approximation.
626 Double_t bendingSlope = param.GetBendingSlope();
627 Double_t nonBendingSlope = param.GetNonBendingSlope();
628 Double_t inverseTotalMomentum2 = param.GetInverseBendingMomentum() * param.GetInverseBendingMomentum() *
629 (1.0 + bendingSlope * bendingSlope) /
630 (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope);
631 // Path length in the material
632 Double_t pathLength = TMath::Abs(dZ) * TMath::Sqrt(1.0 + bendingSlope*bendingSlope + nonBendingSlope*nonBendingSlope);
633 // relativistic velocity
635 // Angular dispersion square of the track (variance) in a plane perpendicular to the trajectory
636 Double_t theta02 = 0.0136 / velo * (1 + 0.038 * TMath::Log(pathLength/x0));
638 return theta02 * theta02 * inverseTotalMomentum2 * pathLength / x0;
641 //__________________________________________________________________________
642 void AliMUONTrackExtrap::AddMCSEffect(AliMUONTrackParam *param, Double_t dZ, Double_t x0)
644 /// Add to the track parameter covariances the effects of multiple Coulomb scattering
645 /// through a material of thickness "dZ" and of radiation length "x0"
646 /// assuming linear propagation and using the small angle approximation.
648 Double_t bendingSlope = param->GetBendingSlope();
649 Double_t nonBendingSlope = param->GetNonBendingSlope();
650 Double_t inverseBendingMomentum = param->GetInverseBendingMomentum();
651 Double_t inverseTotalMomentum2 = inverseBendingMomentum * inverseBendingMomentum *
652 (1.0 + bendingSlope * bendingSlope) /
653 (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope);
654 // Path length in the material
655 Double_t pathLength = TMath::Abs(dZ) * TMath::Sqrt(1.0 + bendingSlope*bendingSlope + nonBendingSlope*nonBendingSlope);
656 Double_t pathLength2 = pathLength * pathLength;
657 // relativistic velocity
659 // Angular dispersion square of the track (variance) in a plane perpendicular to the trajectory
660 Double_t theta02 = 0.0136 / velo * (1 + 0.038 * TMath::Log(pathLength/x0));
661 theta02 *= theta02 * inverseTotalMomentum2 * pathLength / x0;
663 Double_t varCoor = pathLength2 * theta02 / 3.;
664 Double_t varSlop = theta02;
665 Double_t covCorrSlope = pathLength * theta02 / 2.;
667 // compute derivative d(q/Pxy) / dSlopeX and d(q/Pxy) / dSlopeX
668 Double_t dqPxydSlopeX = inverseBendingMomentum * nonBendingSlope / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
669 Double_t dqPxydSlopeY = - inverseBendingMomentum * nonBendingSlope*nonBendingSlope * bendingSlope /
670 (1. + bendingSlope*bendingSlope) / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
672 // Set MCS covariance matrix
673 TMatrixD newParamCov(param->GetCovariances());
675 newParamCov(0,0) += varCoor; newParamCov(0,1) += covCorrSlope;
676 newParamCov(1,0) += covCorrSlope; newParamCov(1,1) += varSlop;
678 newParamCov(2,2) += varCoor; newParamCov(2,3) += covCorrSlope;
679 newParamCov(3,2) += covCorrSlope; newParamCov(3,3) += varSlop;
680 // Inverse bending momentum (due to dependences with bending and non bending slopes)
681 newParamCov(4,0) += dqPxydSlopeX * covCorrSlope; newParamCov(0,4) += dqPxydSlopeX * covCorrSlope;
682 newParamCov(4,1) += dqPxydSlopeX * varSlop; newParamCov(1,4) += dqPxydSlopeX * varSlop;
683 newParamCov(4,2) += dqPxydSlopeY * covCorrSlope; newParamCov(2,4) += dqPxydSlopeY * covCorrSlope;
684 newParamCov(4,3) += dqPxydSlopeY * varSlop; newParamCov(3,4) += dqPxydSlopeY * varSlop;
685 newParamCov(4,4) += (dqPxydSlopeX*dqPxydSlopeX + dqPxydSlopeY*dqPxydSlopeY) * varSlop;
687 // Set new covariances
688 param->SetCovariances(newParamCov);
691 //__________________________________________________________________________
692 void AliMUONTrackExtrap::ExtrapToVertex(AliMUONTrackParam* trackParam,
693 Double_t xVtx, Double_t yVtx, Double_t zVtx,
694 Double_t errXVtx, Double_t errYVtx,
695 Bool_t correctForMCS, Bool_t correctForEnergyLoss)
697 /// Main method for extrapolation to the vertex:
698 /// Returns the track parameters and covariances resulting from the extrapolation of the current trackParam
699 /// Changes parameters and covariances according to multiple scattering and energy loss corrections:
700 /// if correctForMCS=kTRUE: compute parameters using Branson correction and add correction resolution to covariances
701 /// if correctForMCS=kFALSE: add parameter dispersion due to MCS in parameter covariances
702 /// if correctForEnergyLoss=kTRUE: correct parameters for energy loss and add energy loss fluctuation to covariances
703 /// if correctForEnergyLoss=kFALSE: do nothing about energy loss
705 if (trackParam->GetZ() == zVtx) return; // nothing to be done if already at vertex
707 if (trackParam->GetZ() > zVtx) { // spectro. (z<0)
708 cout<<"E-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ()
709 <<") upstream the vertex (zVtx = "<<zVtx<<")"<<endl;
713 // Check the vertex position relatively to the absorber
714 if (zVtx < AliMUONConstants::AbsZBeg() && zVtx > AliMUONConstants::AbsZEnd()) { // spectro. (z<0)
715 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Ending Z ("<<zVtx
716 <<") inside the front absorber ("<<AliMUONConstants::AbsZBeg()<<","<<AliMUONConstants::AbsZEnd()<<")"<<endl;
717 } else if (zVtx < AliMUONConstants::AbsZEnd() ) { // spectro. (z<0)
718 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Ending Z ("<<zVtx
719 <<") downstream the front absorber (zAbsorberEnd = "<<AliMUONConstants::AbsZEnd()<<")"<<endl;
720 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx);
721 else ExtrapToZ(trackParam,zVtx);
725 // Check the track position relatively to the absorber and extrapolate track parameters to the end of the absorber if needed
726 if (trackParam->GetZ() > AliMUONConstants::AbsZBeg()) { // spectro. (z<0)
727 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ()
728 <<") upstream the front absorber (zAbsorberBegin = "<<AliMUONConstants::AbsZBeg()<<")"<<endl;
729 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx);
730 else ExtrapToZ(trackParam,zVtx);
732 } else if (trackParam->GetZ() > AliMUONConstants::AbsZEnd()) { // spectro. (z<0)
733 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ()
734 <<") inside the front absorber ("<<AliMUONConstants::AbsZBeg()<<","<<AliMUONConstants::AbsZEnd()<<")"<<endl;
736 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,AliMUONConstants::AbsZEnd());
737 else ExtrapToZ(trackParam,AliMUONConstants::AbsZEnd());
740 // Get absorber correction parameters assuming linear propagation in absorber
741 Double_t trackXYZOut[3];
742 trackXYZOut[0] = trackParam->GetNonBendingCoor();
743 trackXYZOut[1] = trackParam->GetBendingCoor();
744 trackXYZOut[2] = trackParam->GetZ();
745 Double_t trackXYZIn[3];
746 if (correctForMCS) { // assume linear propagation until the vertex
747 trackXYZIn[2] = TMath::Min(zVtx, AliMUONConstants::AbsZBeg()); // spectro. (z<0)
748 trackXYZIn[0] = trackXYZOut[0] + (xVtx - trackXYZOut[0]) / (zVtx - trackXYZOut[2]) * (trackXYZIn[2] - trackXYZOut[2]);
749 trackXYZIn[1] = trackXYZOut[1] + (yVtx - trackXYZOut[1]) / (zVtx - trackXYZOut[2]) * (trackXYZIn[2] - trackXYZOut[2]);
751 AliMUONTrackParam trackParamIn(*trackParam);
752 ExtrapToZ(&trackParamIn, TMath::Min(zVtx, AliMUONConstants::AbsZBeg()));
753 trackXYZIn[0] = trackParamIn.GetNonBendingCoor();
754 trackXYZIn[1] = trackParamIn.GetBendingCoor();
755 trackXYZIn[2] = trackParamIn.GetZ();
757 Double_t pTot = trackParam->P();
758 Double_t pathLength, f0, f1, f2, meanRho, deltaP, sigmaDeltaP2;
759 if (!GetAbsorberCorrectionParam(trackXYZIn,trackXYZOut,pTot,pathLength,f0,f1,f2,meanRho,deltaP,sigmaDeltaP2)) {
760 cout<<"E-AliMUONTrackExtrap::ExtrapToVertex: Unable to take into account the absorber effects"<<endl;
761 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx);
762 else ExtrapToZ(trackParam,zVtx);
766 // Compute track parameters and covariances at vertex according to correctForMCS and correctForEnergyLoss flags
769 if (correctForEnergyLoss) {
771 // Correct for multiple scattering and energy loss
772 CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
773 CorrectMCSEffectInAbsorber(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx,
774 trackXYZIn[2], pathLength, f0, f1, f2);
775 CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
779 // Correct for multiple scattering
780 CorrectMCSEffectInAbsorber(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx,
781 trackXYZIn[2], pathLength, f0, f1, f2);
786 if (correctForEnergyLoss) {
788 // Correct for energy loss add multiple scattering dispersion in covariance matrix
789 CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
790 AddMCSEffectInAbsorber(trackParam, pathLength, f0, f1, f2);
791 ExtrapToZCov(trackParam, trackXYZIn[2]);
792 CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
793 ExtrapToZCov(trackParam, zVtx);
797 // add multiple scattering dispersion in covariance matrix
798 AddMCSEffectInAbsorber(trackParam, pathLength, f0, f1, f2);
799 ExtrapToZCov(trackParam, zVtx);
807 //__________________________________________________________________________
808 void AliMUONTrackExtrap::ExtrapToVertex(AliMUONTrackParam* trackParam,
809 Double_t xVtx, Double_t yVtx, Double_t zVtx,
810 Double_t errXVtx, Double_t errYVtx)
812 /// Extrapolate track parameters to vertex, corrected for multiple scattering and energy loss effects
813 /// Add branson correction resolution and energy loss fluctuation to parameter covariances
814 ExtrapToVertex(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx, kTRUE, kTRUE);
817 //__________________________________________________________________________
818 void AliMUONTrackExtrap::ExtrapToVertexWithoutELoss(AliMUONTrackParam* trackParam,
819 Double_t xVtx, Double_t yVtx, Double_t zVtx,
820 Double_t errXVtx, Double_t errYVtx)
822 /// Extrapolate track parameters to vertex, corrected for multiple scattering effects only
823 /// Add branson correction resolution to parameter covariances
824 ExtrapToVertex(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx, kTRUE, kFALSE);
827 //__________________________________________________________________________
828 void AliMUONTrackExtrap::ExtrapToVertexWithoutBranson(AliMUONTrackParam* trackParam, Double_t zVtx)
830 /// Extrapolate track parameters to vertex, corrected for energy loss effects only
831 /// Add dispersion due to multiple scattering and energy loss fluctuation to parameter covariances
832 ExtrapToVertex(trackParam, 0., 0., zVtx, 0., 0., kFALSE, kTRUE);
835 //__________________________________________________________________________
836 void AliMUONTrackExtrap::ExtrapToVertexUncorrected(AliMUONTrackParam* trackParam, Double_t zVtx)
838 /// Extrapolate track parameters to vertex without multiple scattering and energy loss corrections
839 /// Add dispersion due to multiple scattering to parameter covariances
840 ExtrapToVertex(trackParam, 0., 0., zVtx, 0., 0., kFALSE, kFALSE);
843 //__________________________________________________________________________
844 Double_t AliMUONTrackExtrap::TotalMomentumEnergyLoss(AliMUONTrackParam* trackParam, Double_t xVtx, Double_t yVtx, Double_t zVtx)
846 /// Calculate the total momentum energy loss in-between the track position and the vertex assuming a linear propagation
848 if (trackParam->GetZ() == zVtx) return 0.; // nothing to be done if already at vertex
850 // Check whether the geometry is available
852 cout<<"E-AliMUONTrackExtrap::TotalMomentumEnergyLoss: no TGeo"<<endl;
856 // Get encountered material correction parameters assuming linear propagation from vertex to the track position
857 Double_t trackXYZOut[3];
858 trackXYZOut[0] = trackParam->GetNonBendingCoor();
859 trackXYZOut[1] = trackParam->GetBendingCoor();
860 trackXYZOut[2] = trackParam->GetZ();
861 Double_t trackXYZIn[3];
862 trackXYZIn[0] = xVtx;
863 trackXYZIn[1] = yVtx;
864 trackXYZIn[2] = zVtx;
865 Double_t pTot = trackParam->P();
866 Double_t pathLength, f0, f1, f2, meanRho, totalELoss, sigmaELoss2;
867 GetAbsorberCorrectionParam(trackXYZIn,trackXYZOut,pTot,pathLength,f0,f1,f2,meanRho,totalELoss,sigmaELoss2);
872 //__________________________________________________________________________
873 Double_t AliMUONTrackExtrap::BetheBloch(Double_t pTotal, Double_t pathLength, Double_t rho, Double_t atomicA, Double_t atomicZ)
875 /// Returns the mean total momentum energy loss of muon with total momentum='pTotal'
876 /// in the absorber layer of lenght='pathLength', density='rho', A='atomicA' and Z='atomicZ'
877 Double_t muMass = 0.105658369; // GeV
878 Double_t eMass = 0.510998918e-3; // GeV
879 Double_t k = 0.307075e-3; // GeV.g^-1.cm^2
880 Double_t i = 9.5e-9; // mean exitation energy per atomic Z (GeV)
881 Double_t p2=pTotal*pTotal;
882 Double_t beta2=p2/(p2 + muMass*muMass);
884 Double_t w = k * rho * pathLength * atomicZ / atomicA / beta2;
886 if (beta2/(1-beta2)>3.5*3.5)
887 return w * (log(2.*eMass*3.5/(i*atomicZ)) + 0.5*log(beta2/(1-beta2)) - beta2);
889 return w * (log(2.*eMass*beta2/(1-beta2)/(i*atomicZ)) - beta2);
892 //__________________________________________________________________________
893 Double_t AliMUONTrackExtrap::EnergyLossFluctuation2(Double_t pTotal, Double_t pathLength, Double_t rho, Double_t atomicA, Double_t atomicZ)
895 /// Returns the total momentum energy loss fluctuation of muon with total momentum='pTotal'
896 /// in the absorber layer of lenght='pathLength', density='rho', A='atomicA' and Z='atomicZ'
897 Double_t muMass = 0.105658369; // GeV
898 //Double_t eMass = 0.510998918e-3; // GeV
899 Double_t k = 0.307075e-3; // GeV.g^-1.cm^2
900 Double_t p2=pTotal*pTotal;
901 Double_t beta2=p2/(p2 + muMass*muMass);
903 Double_t fwhm = 2. * k * rho * pathLength * atomicZ / atomicA / beta2; // FWHM of the energy loss Landau distribution
904 Double_t sigma2 = fwhm * fwhm / (8.*log(2.)); // gaussian: fwmh = 2 * srqt(2*ln(2)) * sigma (i.e. fwmh = 2.35 * sigma)
906 //sigma2 = k * rho * pathLength * atomicZ / atomicA * eMass; // sigma2 of the energy loss gaussian distribution
911 //__________________________________________________________________________
912 void AliMUONTrackExtrap::Cov2CovP(const TMatrixD ¶m, TMatrixD &cov)
914 /// change coordinate system: (X, SlopeX, Y, SlopeY, q/Pyz) -> (X, SlopeX, Y, SlopeY, q*PTot)
915 /// parameters (param) are given in the (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system
917 // charge * total momentum
918 Double_t qPTot = TMath::Sqrt(1. + param(1,0)*param(1,0) + param(3,0)*param(3,0)) /
919 TMath::Sqrt(1. + param(3,0)*param(3,0)) / param(4,0);
921 // Jacobian of the opposite transformation
924 jacob(4,1) = qPTot * param(1,0) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
925 jacob(4,3) = - qPTot * param(1,0) * param(1,0) * param(3,0) /
926 (1. + param(3,0)*param(3,0)) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
927 jacob(4,4) = - qPTot / param(4,0);
929 // compute covariances in new coordinate system
930 TMatrixD tmp(cov,TMatrixD::kMultTranspose,jacob);
934 //__________________________________________________________________________
935 void AliMUONTrackExtrap::CovP2Cov(const TMatrixD ¶m, TMatrixD &covP)
937 /// change coordinate system: (X, SlopeX, Y, SlopeY, q*PTot) -> (X, SlopeX, Y, SlopeY, q/Pyz)
938 /// parameters (param) are given in the (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system
940 // charge * total momentum
941 Double_t qPTot = TMath::Sqrt(1. + param(1,0)*param(1,0) + param(3,0)*param(3,0)) /
942 TMath::Sqrt(1. + param(3,0)*param(3,0)) / param(4,0);
944 // Jacobian of the transformation
947 jacob(4,1) = param(4,0) * param(1,0) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
948 jacob(4,3) = - param(4,0) * param(1,0) * param(1,0) * param(3,0) /
949 (1. + param(3,0)*param(3,0)) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
950 jacob(4,4) = - param(4,0) / qPTot;
952 // compute covariances in new coordinate system
953 TMatrixD tmp(covP,TMatrixD::kMultTranspose,jacob);
954 covP.Mult(jacob,tmp);
957 //__________________________________________________________________________
958 void AliMUONTrackExtrap::ExtrapOneStepHelix(Double_t charge, Double_t step, Double_t *vect, Double_t *vout)
961 /// ******************************************************************
963 /// * Performs the tracking of one step in a magnetic field *
964 /// * The trajectory is assumed to be a helix in a constant field *
965 /// * taken at the mid point of the step. *
968 /// * STEP =arc length of the step asked *
969 /// * VECT =input vector (position,direction cos and momentum) *
970 /// * CHARGE= electric charge of the particle *
972 /// * VOUT = same as VECT after completion of the step *
974 /// * ==>Called by : USER, GUSWIM *
975 /// * Author m.hansroul ********* *
976 /// * modified s.egli, s.v.levonian *
977 /// * modified v.perevoztchikov
979 /// ******************************************************************
982 // modif: everything in double precision
984 Double_t xyz[3], h[4], hxp[3];
985 Double_t h2xy, hp, rho, tet;
986 Double_t sint, sintt, tsint, cos1t;
987 Double_t f1, f2, f3, f4, f5, f6;
992 const Int_t kipx = 3;
993 const Int_t kipy = 4;
994 const Int_t kipz = 5;
995 const Int_t kipp = 6;
997 const Double_t kec = 2.9979251e-4;
999 // ------------------------------------------------------------------
1001 // units are kgauss,centimeters,gev/c
1003 vout[kipp] = vect[kipp];
1004 if (TMath::Abs(charge) < 0.00001) {
1005 for (Int_t i = 0; i < 3; i++) {
1006 vout[i] = vect[i] + step * vect[i+3];
1007 vout[i+3] = vect[i+3];
1011 xyz[0] = vect[kix] + 0.5 * step * vect[kipx];
1012 xyz[1] = vect[kiy] + 0.5 * step * vect[kipy];
1013 xyz[2] = vect[kiz] + 0.5 * step * vect[kipz];
1015 //cmodif: call gufld (xyz, h) changed into:
1018 h2xy = h[0]*h[0] + h[1]*h[1];
1019 h[3] = h[2]*h[2]+ h2xy;
1020 if (h[3] < 1.e-12) {
1021 for (Int_t i = 0; i < 3; i++) {
1022 vout[i] = vect[i] + step * vect[i+3];
1023 vout[i+3] = vect[i+3];
1027 if (h2xy < 1.e-12*h[3]) {
1028 ExtrapOneStepHelix3(charge*h[2], step, vect, vout);
1031 h[3] = TMath::Sqrt(h[3]);
1037 hxp[0] = h[1]*vect[kipz] - h[2]*vect[kipy];
1038 hxp[1] = h[2]*vect[kipx] - h[0]*vect[kipz];
1039 hxp[2] = h[0]*vect[kipy] - h[1]*vect[kipx];
1041 hp = h[0]*vect[kipx] + h[1]*vect[kipy] + h[2]*vect[kipz];
1043 rho = -charge*h[3]/vect[kipp];
1046 if (TMath::Abs(tet) > 0.15) {
1047 sint = TMath::Sin(tet);
1049 tsint = (tet-sint)/tet;
1050 cos1t = 2.*(TMath::Sin(0.5*tet))*(TMath::Sin(0.5*tet))/tet;
1052 tsint = tet*tet/36.;
1053 sintt = (1. - tsint);
1060 f3 = step * tsint * hp;
1063 f6 = tet * cos1t * hp;
1065 vout[kix] = vect[kix] + f1*vect[kipx] + f2*hxp[0] + f3*h[0];
1066 vout[kiy] = vect[kiy] + f1*vect[kipy] + f2*hxp[1] + f3*h[1];
1067 vout[kiz] = vect[kiz] + f1*vect[kipz] + f2*hxp[2] + f3*h[2];
1069 vout[kipx] = vect[kipx] + f4*vect[kipx] + f5*hxp[0] + f6*h[0];
1070 vout[kipy] = vect[kipy] + f4*vect[kipy] + f5*hxp[1] + f6*h[1];
1071 vout[kipz] = vect[kipz] + f4*vect[kipz] + f5*hxp[2] + f6*h[2];
1076 //__________________________________________________________________________
1077 void AliMUONTrackExtrap::ExtrapOneStepHelix3(Double_t field, Double_t step, Double_t *vect, Double_t *vout)
1080 /// ******************************************************************
1082 /// * Tracking routine in a constant field oriented *
1083 /// * along axis 3 *
1084 /// * Tracking is performed with a conventional *
1085 /// * helix step method *
1087 /// * ==>Called by : USER, GUSWIM *
1088 /// * Authors R.Brun, M.Hansroul ********* *
1089 /// * Rewritten V.Perevoztchikov
1091 /// ******************************************************************
1095 Double_t h4, hp, rho, tet;
1096 Double_t sint, sintt, tsint, cos1t;
1097 Double_t f1, f2, f3, f4, f5, f6;
1099 const Int_t kix = 0;
1100 const Int_t kiy = 1;
1101 const Int_t kiz = 2;
1102 const Int_t kipx = 3;
1103 const Int_t kipy = 4;
1104 const Int_t kipz = 5;
1105 const Int_t kipp = 6;
1107 const Double_t kec = 2.9979251e-4;
1110 // ------------------------------------------------------------------
1112 // units are kgauss,centimeters,gev/c
1114 vout[kipp] = vect[kipp];
1117 hxp[0] = - vect[kipy];
1118 hxp[1] = + vect[kipx];
1122 rho = -h4/vect[kipp];
1124 if (TMath::Abs(tet) > 0.15) {
1125 sint = TMath::Sin(tet);
1127 tsint = (tet-sint)/tet;
1128 cos1t = 2.* TMath::Sin(0.5*tet) * TMath::Sin(0.5*tet)/tet;
1130 tsint = tet*tet/36.;
1131 sintt = (1. - tsint);
1138 f3 = step * tsint * hp;
1141 f6 = tet * cos1t * hp;
1143 vout[kix] = vect[kix] + f1*vect[kipx] + f2*hxp[0];
1144 vout[kiy] = vect[kiy] + f1*vect[kipy] + f2*hxp[1];
1145 vout[kiz] = vect[kiz] + f1*vect[kipz] + f3;
1147 vout[kipx] = vect[kipx] + f4*vect[kipx] + f5*hxp[0];
1148 vout[kipy] = vect[kipy] + f4*vect[kipy] + f5*hxp[1];
1149 vout[kipz] = vect[kipz] + f4*vect[kipz] + f6;
1154 //__________________________________________________________________________
1155 void AliMUONTrackExtrap::ExtrapOneStepRungekutta(Double_t charge, Double_t step, Double_t* vect, Double_t* vout)
1158 /// ******************************************************************
1160 /// * Runge-Kutta method for tracking a particle through a magnetic *
1161 /// * field. Uses Nystroem algorithm (See Handbook Nat. Bur. of *
1162 /// * Standards, procedure 25.5.20) *
1164 /// * Input parameters *
1165 /// * CHARGE Particle charge *
1166 /// * STEP Step size *
1167 /// * VECT Initial co-ords,direction cosines,momentum *
1168 /// * Output parameters *
1169 /// * VOUT Output co-ords,direction cosines,momentum *
1170 /// * User routine called *
1171 /// * CALL GUFLD(X,F) *
1173 /// * ==>Called by : USER, GUSWIM *
1174 /// * Authors R.Brun, M.Hansroul ********* *
1175 /// * V.Perevoztchikov (CUT STEP implementation) *
1178 /// ******************************************************************
1181 Double_t h2, h4, f[4];
1182 Double_t xyzt[3], a, b, c, ph,ph2;
1183 Double_t secxs[4],secys[4],seczs[4],hxp[3];
1184 Double_t g1, g2, g3, g4, g5, g6, ang2, dxt, dyt, dzt;
1185 Double_t est, at, bt, ct, cba;
1186 Double_t f1, f2, f3, f4, rho, tet, hnorm, hp, rho1, sint, cost;
1196 Double_t maxit = 1992;
1197 Double_t maxcut = 11;
1199 const Double_t kdlt = 1e-4;
1200 const Double_t kdlt32 = kdlt/32.;
1201 const Double_t kthird = 1./3.;
1202 const Double_t khalf = 0.5;
1203 const Double_t kec = 2.9979251e-4;
1205 const Double_t kpisqua = 9.86960440109;
1206 const Int_t kix = 0;
1207 const Int_t kiy = 1;
1208 const Int_t kiz = 2;
1209 const Int_t kipx = 3;
1210 const Int_t kipy = 4;
1211 const Int_t kipz = 5;
1214 // *. ------------------------------------------------------------------
1216 // * this constant is for units cm,gev/c and kgauss
1220 for(Int_t j = 0; j < 7; j++)
1223 Double_t pinv = kec * charge / vect[6];
1231 if (TMath::Abs(h) > TMath::Abs(rest)) h = rest;
1232 //cmodif: call gufld(vout,f) changed into:
1237 // * start of integration
1250 secxs[0] = (b * f[2] - c * f[1]) * ph2;
1251 secys[0] = (c * f[0] - a * f[2]) * ph2;
1252 seczs[0] = (a * f[1] - b * f[0]) * ph2;
1253 ang2 = (secxs[0]*secxs[0] + secys[0]*secys[0] + seczs[0]*seczs[0]);
1254 if (ang2 > kpisqua) break;
1256 dxt = h2 * a + h4 * secxs[0];
1257 dyt = h2 * b + h4 * secys[0];
1258 dzt = h2 * c + h4 * seczs[0];
1263 // * second intermediate point
1266 est = TMath::Abs(dxt) + TMath::Abs(dyt) + TMath::Abs(dzt);
1268 if (ncut++ > maxcut) break;
1277 //cmodif: call gufld(xyzt,f) changed into:
1284 secxs[1] = (bt * f[2] - ct * f[1]) * ph2;
1285 secys[1] = (ct * f[0] - at * f[2]) * ph2;
1286 seczs[1] = (at * f[1] - bt * f[0]) * ph2;
1290 secxs[2] = (bt * f[2] - ct * f[1]) * ph2;
1291 secys[2] = (ct * f[0] - at * f[2]) * ph2;
1292 seczs[2] = (at * f[1] - bt * f[0]) * ph2;
1293 dxt = h * (a + secxs[2]);
1294 dyt = h * (b + secys[2]);
1295 dzt = h * (c + seczs[2]);
1299 at = a + 2.*secxs[2];
1300 bt = b + 2.*secys[2];
1301 ct = c + 2.*seczs[2];
1303 est = TMath::Abs(dxt)+TMath::Abs(dyt)+TMath::Abs(dzt);
1304 if (est > 2.*TMath::Abs(h)) {
1305 if (ncut++ > maxcut) break;
1314 //cmodif: call gufld(xyzt,f) changed into:
1317 z = z + (c + (seczs[0] + seczs[1] + seczs[2]) * kthird) * h;
1318 y = y + (b + (secys[0] + secys[1] + secys[2]) * kthird) * h;
1319 x = x + (a + (secxs[0] + secxs[1] + secxs[2]) * kthird) * h;
1321 secxs[3] = (bt*f[2] - ct*f[1])* ph2;
1322 secys[3] = (ct*f[0] - at*f[2])* ph2;
1323 seczs[3] = (at*f[1] - bt*f[0])* ph2;
1324 a = a+(secxs[0]+secxs[3]+2. * (secxs[1]+secxs[2])) * kthird;
1325 b = b+(secys[0]+secys[3]+2. * (secys[1]+secys[2])) * kthird;
1326 c = c+(seczs[0]+seczs[3]+2. * (seczs[1]+seczs[2])) * kthird;
1328 est = TMath::Abs(secxs[0]+secxs[3] - (secxs[1]+secxs[2]))
1329 + TMath::Abs(secys[0]+secys[3] - (secys[1]+secys[2]))
1330 + TMath::Abs(seczs[0]+seczs[3] - (seczs[1]+seczs[2]));
1332 if (est > kdlt && TMath::Abs(h) > 1.e-4) {
1333 if (ncut++ > maxcut) break;
1339 // * if too many iterations, go to helix
1340 if (iter++ > maxit) break;
1345 cba = 1./ TMath::Sqrt(a*a + b*b + c*c);
1353 if (step < 0.) rest = -rest;
1354 if (rest < 1.e-5*TMath::Abs(step)) return;
1358 // angle too big, use helix
1363 f4 = TMath::Sqrt(f1*f1+f2*f2+f3*f3);
1372 hxp[0] = f2*vect[kipz] - f3*vect[kipy];
1373 hxp[1] = f3*vect[kipx] - f1*vect[kipz];
1374 hxp[2] = f1*vect[kipy] - f2*vect[kipx];
1376 hp = f1*vect[kipx] + f2*vect[kipy] + f3*vect[kipz];
1379 sint = TMath::Sin(tet);
1380 cost = 2.*TMath::Sin(khalf*tet)*TMath::Sin(khalf*tet);
1384 g3 = (tet-sint) * hp*rho1;
1389 vout[kix] = vect[kix] + g1*vect[kipx] + g2*hxp[0] + g3*f1;
1390 vout[kiy] = vect[kiy] + g1*vect[kipy] + g2*hxp[1] + g3*f2;
1391 vout[kiz] = vect[kiz] + g1*vect[kipz] + g2*hxp[2] + g3*f3;
1393 vout[kipx] = vect[kipx] + g4*vect[kipx] + g5*hxp[0] + g6*f1;
1394 vout[kipy] = vect[kipy] + g4*vect[kipy] + g5*hxp[1] + g6*f2;
1395 vout[kipz] = vect[kipz] + g4*vect[kipz] + g5*hxp[2] + g6*f3;
1400 //___________________________________________________________
1401 void AliMUONTrackExtrap::GetField(Double_t *Position, Double_t *Field)
1403 /// interface for arguments in double precision (Why ? ChF)
1406 x[0] = Position[0]; x[1] = Position[1]; x[2] = Position[2];
1408 if (fgkField) fgkField->Field(x,b);
1410 cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl;
1414 Field[0] = b[0]; Field[1] = b[1]; Field[2] = b[2];