1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 // Class AliMUONTrackExtrap
20 // ------------------------
21 // Tools for track extrapolation in ALICE dimuon spectrometer
22 // Author: Philippe Pillot
23 //-----------------------------------------------------------------------------
25 #include "AliMUONTrackExtrap.h"
26 #include "AliMUONTrackParam.h"
27 #include "AliMUONConstants.h"
32 #include <TGeoManager.h>
34 #include <Riostream.h>
37 ClassImp(AliMUONTrackExtrap) // Class implementation in ROOT context
40 const AliMagF* AliMUONTrackExtrap::fgkField = 0x0;
41 const Bool_t AliMUONTrackExtrap::fgkUseHelix = kFALSE;
42 const Int_t AliMUONTrackExtrap::fgkMaxStepNumber = 5000;
43 const Double_t AliMUONTrackExtrap::fgkHelixStepLength = 6.;
44 const Double_t AliMUONTrackExtrap::fgkRungeKuttaMaxResidue = 0.002;
46 //__________________________________________________________________________
47 Double_t AliMUONTrackExtrap::GetImpactParamFromBendingMomentum(Double_t bendingMomentum)
49 /// Returns impact parameter at vertex in bending plane (cm),
50 /// from the signed bending momentum "BendingMomentum" in bending plane (GeV/c),
51 /// using simple values for dipole magnetic field.
52 /// The sign of "BendingMomentum" is the sign of the charge.
54 if (bendingMomentum == 0.) return 1.e10;
56 Double_t simpleBPosition = 0.5 * (AliMUONConstants::CoilZ() + AliMUONConstants::YokeZ());
57 Double_t simpleBLength = 0.5 * (AliMUONConstants::CoilL() + AliMUONConstants::YokeL());
58 Float_t b[3], x[3] = {0.,0.,(Float_t) simpleBPosition};
59 if (fgkField) fgkField->Field(x,b);
61 cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl;
64 Double_t simpleBValue = (Double_t) b[0];
66 return (-0.0003 * simpleBValue * simpleBLength * simpleBPosition / bendingMomentum);
69 //__________________________________________________________________________
70 Double_t AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(Double_t impactParam)
72 /// Returns signed bending momentum in bending plane (GeV/c),
73 /// the sign being the sign of the charge for particles moving forward in Z,
74 /// from the impact parameter "ImpactParam" at vertex in bending plane (cm),
75 /// using simple values for dipole magnetic field.
77 if (impactParam == 0.) return 1.e10;
79 Double_t simpleBPosition = 0.5 * (AliMUONConstants::CoilZ() + AliMUONConstants::YokeZ());
80 Double_t simpleBLength = 0.5 * (AliMUONConstants::CoilL() + AliMUONConstants::YokeL());
81 Float_t b[3], x[3] = {0.,0.,(Float_t) simpleBPosition};
82 if (fgkField) fgkField->Field(x,b);
84 cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl;
87 Double_t simpleBValue = (Double_t) b[0];
89 return (-0.0003 * simpleBValue * simpleBLength * simpleBPosition / impactParam);
92 //__________________________________________________________________________
93 void AliMUONTrackExtrap::LinearExtrapToZ(AliMUONTrackParam* trackParam, Double_t zEnd)
95 /// Track parameters (and their covariances if any) linearly extrapolated to the plane at "zEnd".
96 /// On return, results from the extrapolation are updated in trackParam.
98 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z
100 // Compute track parameters
101 Double_t dZ = zEnd - trackParam->GetZ();
102 trackParam->SetNonBendingCoor(trackParam->GetNonBendingCoor() + trackParam->GetNonBendingSlope() * dZ);
103 trackParam->SetBendingCoor(trackParam->GetBendingCoor() + trackParam->GetBendingSlope() * dZ);
104 trackParam->SetZ(zEnd);
106 // Update track parameters covariances if any
107 if (trackParam->CovariancesExist()) {
108 TMatrixD paramCov(trackParam->GetCovariances());
109 paramCov(0,0) += dZ * dZ * paramCov(1,1) + 2. * dZ * paramCov(0,1);
110 paramCov(0,1) += dZ * paramCov(1,1);
111 paramCov(1,0) = paramCov(0,1);
112 paramCov(2,2) += dZ * dZ * paramCov(3,3) + 2. * dZ * paramCov(2,3);
113 paramCov(2,3) += dZ * paramCov(3,3);
114 paramCov(3,2) = paramCov(2,3);
115 trackParam->SetCovariances(paramCov);
120 //__________________________________________________________________________
121 void AliMUONTrackExtrap::ExtrapToZ(AliMUONTrackParam* trackParam, Double_t zEnd)
123 /// Interface to track parameter extrapolation to the plane at "Z" using Helix or Rungekutta algorithm.
124 /// On return, the track parameters resulting from the extrapolation are updated in trackParam.
125 if (fgkUseHelix) AliMUONTrackExtrap::ExtrapToZHelix(trackParam,zEnd);
126 else AliMUONTrackExtrap::ExtrapToZRungekutta(trackParam,zEnd);
129 //__________________________________________________________________________
130 void AliMUONTrackExtrap::ExtrapToZHelix(AliMUONTrackParam* trackParam, Double_t zEnd)
132 /// Track parameter extrapolation to the plane at "Z" using Helix algorithm.
133 /// On return, the track parameters resulting from the extrapolation are updated in trackParam.
134 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same Z
135 Double_t forwardBackward; // +1 if forward, -1 if backward
136 if (zEnd < trackParam->GetZ()) forwardBackward = 1.0; // spectro. z<0
137 else forwardBackward = -1.0;
138 Double_t v3[7], v3New[7]; // 7 in parameter ????
139 Int_t i3, stepNumber;
140 // For safety: return kTRUE or kFALSE ????
141 // Parameter vector for calling EXTRAP_ONESTEP
142 ConvertTrackParamForExtrap(trackParam, forwardBackward, v3);
143 // sign of charge (sign of fInverseBendingMomentum if forward motion)
144 // must be changed if backward extrapolation
145 Double_t chargeExtrap = forwardBackward * TMath::Sign(Double_t(1.0), trackParam->GetInverseBendingMomentum());
146 // Extrapolation loop
148 while (((-forwardBackward * (v3[2] - zEnd)) <= 0.0) && (stepNumber < fgkMaxStepNumber)) { // spectro. z<0
150 ExtrapOneStepHelix(chargeExtrap, fgkHelixStepLength, v3, v3New);
151 if ((-forwardBackward * (v3New[2] - zEnd)) > 0.0) break; // one is beyond Z spectro. z<0
152 // better use TArray ????
153 for (i3 = 0; i3 < 7; i3++) {v3[i3] = v3New[i3];}
155 // check fgkMaxStepNumber ????
156 // Interpolation back to exact Z (2nd order)
157 // should be in function ???? using TArray ????
158 Double_t dZ12 = v3New[2] - v3[2]; // 1->2
159 if (TMath::Abs(dZ12) > 0) {
160 Double_t dZ1i = zEnd - v3[2]; // 1-i
161 Double_t dZi2 = v3New[2] - zEnd; // i->2
162 Double_t xPrime = (v3New[0] - v3[0]) / dZ12;
163 Double_t xSecond = ((v3New[3] / v3New[5]) - (v3[3] / v3[5])) / dZ12;
164 Double_t yPrime = (v3New[1] - v3[1]) / dZ12;
165 Double_t ySecond = ((v3New[4] / v3New[5]) - (v3[4] / v3[5])) / dZ12;
166 v3[0] = v3[0] + xPrime * dZ1i - 0.5 * xSecond * dZ1i * dZi2; // X
167 v3[1] = v3[1] + yPrime * dZ1i - 0.5 * ySecond * dZ1i * dZi2; // Y
169 Double_t xPrimeI = xPrime - 0.5 * xSecond * (dZi2 - dZ1i);
170 Double_t yPrimeI = yPrime - 0.5 * ySecond * (dZi2 - dZ1i);
171 // (PX, PY, PZ)/PTOT assuming forward motion
172 v3[5] = 1.0 / TMath::Sqrt(1.0 + xPrimeI * xPrimeI + yPrimeI * yPrimeI); // PZ/PTOT
173 v3[3] = xPrimeI * v3[5]; // PX/PTOT
174 v3[4] = yPrimeI * v3[5]; // PY/PTOT
176 cout<<"W-AliMUONTrackExtrap::ExtrapToZHelix: Extrap. to Z not reached, Z = "<<zEnd<<endl;
178 // Recover track parameters (charge back for forward motion)
179 RecoverTrackParam(v3, chargeExtrap * forwardBackward, trackParam);
182 //__________________________________________________________________________
183 void AliMUONTrackExtrap::ExtrapToZRungekutta(AliMUONTrackParam* trackParam, Double_t zEnd)
185 /// Track parameter extrapolation to the plane at "Z" using Rungekutta algorithm.
186 /// On return, the track parameters resulting from the extrapolation are updated in trackParam.
187 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same Z
188 Double_t forwardBackward; // +1 if forward, -1 if backward
189 if (zEnd < trackParam->GetZ()) forwardBackward = 1.0; // spectro. z<0
190 else forwardBackward = -1.0;
191 // sign of charge (sign of fInverseBendingMomentum if forward motion)
192 // must be changed if backward extrapolation
193 Double_t chargeExtrap = forwardBackward * TMath::Sign(Double_t(1.0), trackParam->GetInverseBendingMomentum());
194 Double_t v3[7], v3New[7];
196 Int_t stepNumber = 0;
198 // Extrapolation loop (until within tolerance)
199 Double_t residue = zEnd - trackParam->GetZ();
200 while (TMath::Abs(residue) > fgkRungeKuttaMaxResidue && stepNumber <= fgkMaxStepNumber) {
201 dZ = zEnd - trackParam->GetZ();
202 // step lenght assuming linear trajectory
203 step = dZ * TMath::Sqrt(1.0 + trackParam->GetBendingSlope()*trackParam->GetBendingSlope() +
204 trackParam->GetNonBendingSlope()*trackParam->GetNonBendingSlope());
205 ConvertTrackParamForExtrap(trackParam, forwardBackward, v3);
206 do { // reduce step lenght while zEnd oversteped
207 if (stepNumber > fgkMaxStepNumber) {
208 cout<<"W-AliMUONTrackExtrap::ExtrapToZRungekutta: Too many trials: "<<stepNumber<<endl;
212 step = TMath::Abs(step);
213 AliMUONTrackExtrap::ExtrapOneStepRungekutta(chargeExtrap,step,v3,v3New);
214 residue = zEnd - v3New[2];
215 step *= dZ/(v3New[2]-trackParam->GetZ());
216 } while (residue*dZ < 0 && TMath::Abs(residue) > fgkRungeKuttaMaxResidue);
217 RecoverTrackParam(v3New, chargeExtrap * forwardBackward, trackParam);
220 // terminate the extropolation with a straight line up to the exact "zEnd" value
221 trackParam->SetNonBendingCoor(trackParam->GetNonBendingCoor() + residue * trackParam->GetNonBendingSlope());
222 trackParam->SetBendingCoor(trackParam->GetBendingCoor() + residue * trackParam->GetBendingSlope());
223 trackParam->SetZ(zEnd);
226 //__________________________________________________________________________
227 void AliMUONTrackExtrap::ConvertTrackParamForExtrap(AliMUONTrackParam* trackParam, Double_t forwardBackward, Double_t *v3)
229 /// Set vector of Geant3 parameters pointed to by "v3" from track parameters in trackParam.
230 /// Since AliMUONTrackParam is only geometry, one uses "forwardBackward"
231 /// to know whether the particle is going forward (+1) or backward (-1).
232 v3[0] = trackParam->GetNonBendingCoor(); // X
233 v3[1] = trackParam->GetBendingCoor(); // Y
234 v3[2] = trackParam->GetZ(); // Z
235 Double_t pYZ = TMath::Abs(1.0 / trackParam->GetInverseBendingMomentum());
236 Double_t pZ = pYZ / TMath::Sqrt(1.0 + trackParam->GetBendingSlope() * trackParam->GetBendingSlope());
237 v3[6] = TMath::Sqrt(pYZ * pYZ + pZ * pZ * trackParam->GetNonBendingSlope() * trackParam->GetNonBendingSlope()); // PTOT
238 v3[5] = -forwardBackward * pZ / v3[6]; // PZ/PTOT spectro. z<0
239 v3[3] = trackParam->GetNonBendingSlope() * v3[5]; // PX/PTOT
240 v3[4] = trackParam->GetBendingSlope() * v3[5]; // PY/PTOT
243 //__________________________________________________________________________
244 void AliMUONTrackExtrap::RecoverTrackParam(Double_t *v3, Double_t charge, AliMUONTrackParam* trackParam)
246 /// Set track parameters in trackParam from Geant3 parameters pointed to by "v3",
247 /// assumed to be calculated for forward motion in Z.
248 /// "InverseBendingMomentum" is signed with "charge".
249 trackParam->SetNonBendingCoor(v3[0]); // X
250 trackParam->SetBendingCoor(v3[1]); // Y
251 trackParam->SetZ(v3[2]); // Z
252 Double_t pYZ = v3[6] * TMath::Sqrt(1.0 - v3[3] * v3[3]);
253 trackParam->SetInverseBendingMomentum(charge/pYZ);
254 trackParam->SetBendingSlope(v3[4]/v3[5]);
255 trackParam->SetNonBendingSlope(v3[3]/v3[5]);
258 //__________________________________________________________________________
259 void AliMUONTrackExtrap::ExtrapToZCov(AliMUONTrackParam* trackParam, Double_t zEnd, Bool_t updatePropagator)
261 /// Track parameters and their covariances extrapolated to the plane at "zEnd".
262 /// On return, results from the extrapolation are updated in trackParam.
264 if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z
266 // No need to propagate the covariance matrix if it does not exist
267 if (!trackParam->CovariancesExist()) {
268 cout<<"W-AliMUONTrackExtrap::ExtrapToZCov: Covariance matrix does not exist"<<endl;
269 // Extrapolate track parameters to "zEnd"
270 ExtrapToZ(trackParam,zEnd);
274 // Save the actual track parameters
275 AliMUONTrackParam trackParamSave(*trackParam);
276 TMatrixD paramSave(trackParamSave.GetParameters());
277 Double_t zBegin = trackParamSave.GetZ();
279 // Get reference to the parameter covariance matrix
280 const TMatrixD& kParamCov = trackParam->GetCovariances();
282 // Extrapolate track parameters to "zEnd"
283 ExtrapToZ(trackParam,zEnd);
285 // Get reference to the extrapolated parameters
286 const TMatrixD& extrapParam = trackParam->GetParameters();
288 // Calculate the jacobian related to the track parameters extrapolation to "zEnd"
291 TMatrixD dParam(5,1);
292 for (Int_t i=0; i<5; i++) {
293 // Skip jacobian calculation for parameters with no associated error
294 if (kParamCov(i,i) <= 0.) continue;
296 // Small variation of parameter i only
297 for (Int_t j=0; j<5; j++) {
299 dParam(j,0) = TMath::Sqrt(kParamCov(i,i));
300 if (j == 4) dParam(j,0) *= TMath::Sign(1.,-paramSave(4,0)); // variation always in the same direction
301 } else dParam(j,0) = 0.;
304 // Set new parameters
305 trackParamSave.SetParameters(paramSave);
306 trackParamSave.AddParameters(dParam);
307 trackParamSave.SetZ(zBegin);
309 // Extrapolate new track parameters to "zEnd"
310 ExtrapToZ(&trackParamSave,zEnd);
312 // Calculate the jacobian
313 TMatrixD jacobji(trackParamSave.GetParameters(),TMatrixD::kMinus,extrapParam);
314 jacobji *= 1. / dParam(i,0);
315 jacob.SetSub(0,i,jacobji);
318 // Extrapolate track parameter covariances to "zEnd"
319 TMatrixD tmp(kParamCov,TMatrixD::kMultTranspose,jacob);
320 TMatrixD tmp2(jacob,TMatrixD::kMult,tmp);
321 trackParam->SetCovariances(tmp2);
323 // Update the propagator if required
324 if (updatePropagator) trackParam->UpdatePropagator(jacob);
327 //__________________________________________________________________________
328 void AliMUONTrackExtrap::AddMCSEffectInAbsorber(AliMUONTrackParam* param, Double_t pathLength, Double_t f0, Double_t f1, Double_t f2)
330 /// Add to the track parameter covariances the effects of multiple Coulomb scattering
331 /// The absorber correction parameters are supposed to be calculated at the current track z-position
333 // absorber related covariance parameters
334 Double_t bendingSlope = param->GetBendingSlope();
335 Double_t nonBendingSlope = param->GetNonBendingSlope();
336 Double_t inverseBendingMomentum = param->GetInverseBendingMomentum();
337 Double_t alpha2 = 0.0136 * 0.0136 * inverseBendingMomentum * inverseBendingMomentum * (1.0 + bendingSlope * bendingSlope) /
338 (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope); // velocity = 1
339 Double_t varCoor = alpha2 * (pathLength * pathLength * f0 - 2. * pathLength * f1 + f2);
340 Double_t covCorrSlope = alpha2 * (pathLength * f0 - f1);
341 Double_t varSlop = alpha2 * f0;
343 // compute derivative d(q/Pxy) / dSlopeX and d(q/Pxy) / dSlopeX
344 Double_t dqPxydSlopeX = inverseBendingMomentum * nonBendingSlope / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
345 Double_t dqPxydSlopeY = - inverseBendingMomentum * nonBendingSlope*nonBendingSlope * bendingSlope /
346 (1. + bendingSlope*bendingSlope) / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
348 // Set MCS covariance matrix
349 TMatrixD newParamCov(param->GetCovariances());
351 newParamCov(0,0) += varCoor; newParamCov(0,1) += covCorrSlope;
352 newParamCov(1,0) += covCorrSlope; newParamCov(1,1) += varSlop;
354 newParamCov(2,2) += varCoor; newParamCov(2,3) += covCorrSlope;
355 newParamCov(3,2) += covCorrSlope; newParamCov(3,3) += varSlop;
356 // Inverse bending momentum (due to dependences with bending and non bending slopes)
357 newParamCov(4,0) += dqPxydSlopeX * covCorrSlope; newParamCov(0,4) += dqPxydSlopeX * covCorrSlope;
358 newParamCov(4,1) += dqPxydSlopeX * varSlop; newParamCov(1,4) += dqPxydSlopeX * varSlop;
359 newParamCov(4,2) += dqPxydSlopeY * covCorrSlope; newParamCov(2,4) += dqPxydSlopeY * covCorrSlope;
360 newParamCov(4,3) += dqPxydSlopeY * varSlop; newParamCov(3,4) += dqPxydSlopeY * varSlop;
361 newParamCov(4,4) += (dqPxydSlopeX*dqPxydSlopeX + dqPxydSlopeY*dqPxydSlopeY) * varSlop;
363 // Set new covariances
364 param->SetCovariances(newParamCov);
367 //__________________________________________________________________________
368 void AliMUONTrackExtrap::CorrectMCSEffectInAbsorber(AliMUONTrackParam* param,
369 Double_t xVtx, Double_t yVtx, Double_t zVtx,
370 Double_t errXVtx, Double_t errYVtx,
371 Double_t absZBeg, Double_t pathLength, Double_t f0, Double_t f1, Double_t f2)
373 /// Correct parameters and corresponding covariances using Branson correction
374 /// - input param are parameters and covariances at the end of absorber
375 /// - output param are parameters and covariances at vertex
376 /// Absorber correction parameters are supposed to be calculated at the current track z-position
378 // Position of the Branson plane (spectro. (z<0))
379 Double_t zB = (f1>0.) ? absZBeg - f2/f1 : 0.;
381 // Add MCS effects to current parameter covariances
382 AddMCSEffectInAbsorber(param, pathLength, f0, f1, f2);
384 // Get track parameters and covariances in the Branson plane corrected for magnetic field effect
385 ExtrapToZCov(param,zVtx);
386 LinearExtrapToZ(param,zB);
388 // compute track parameters at vertex
389 TMatrixD newParam(5,1);
390 newParam(0,0) = xVtx;
391 newParam(1,0) = (param->GetNonBendingCoor() - xVtx) / (zB - zVtx);
392 newParam(2,0) = yVtx;
393 newParam(3,0) = (param->GetBendingCoor() - yVtx) / (zB - zVtx);
394 newParam(4,0) = param->GetCharge() / param->P() *
395 TMath::Sqrt(1.0 + newParam(1,0)*newParam(1,0) + newParam(3,0)*newParam(3,0)) /
396 TMath::Sqrt(1.0 + newParam(3,0)*newParam(3,0));
398 // Get covariances in (X, SlopeX, Y, SlopeY, q*PTot) coordinate system
399 TMatrixD paramCovP(param->GetCovariances());
400 Cov2CovP(param->GetParameters(),paramCovP);
402 // Get the covariance matrix in the (XVtx, X, YVtx, Y, q*PTot) coordinate system
403 TMatrixD paramCovVtx(5,5);
405 paramCovVtx(0,0) = errXVtx * errXVtx;
406 paramCovVtx(1,1) = paramCovP(0,0);
407 paramCovVtx(2,2) = errYVtx * errYVtx;
408 paramCovVtx(3,3) = paramCovP(2,2);
409 paramCovVtx(4,4) = paramCovP(4,4);
410 paramCovVtx(1,3) = paramCovP(0,2);
411 paramCovVtx(3,1) = paramCovP(2,0);
412 paramCovVtx(1,4) = paramCovP(0,4);
413 paramCovVtx(4,1) = paramCovP(4,0);
414 paramCovVtx(3,4) = paramCovP(2,4);
415 paramCovVtx(4,3) = paramCovP(4,2);
417 // Jacobian of the transformation (XVtx, X, YVtx, Y, q*PTot) -> (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q*PTotVtx)
420 jacob(1,0) = - 1. / (zB - zVtx);
421 jacob(1,1) = 1. / (zB - zVtx);
422 jacob(3,2) = - 1. / (zB - zVtx);
423 jacob(3,3) = 1. / (zB - zVtx);
425 // Compute covariances at vertex in the (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q*PTotVtx) coordinate system
426 TMatrixD tmp(paramCovVtx,TMatrixD::kMultTranspose,jacob);
427 TMatrixD newParamCov(jacob,TMatrixD::kMult,tmp);
429 // Compute covariances at vertex in the (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q/PyzVtx) coordinate system
430 CovP2Cov(newParam,newParamCov);
432 // Set parameters and covariances at vertex
433 param->SetParameters(newParam);
435 param->SetCovariances(newParamCov);
438 //__________________________________________________________________________
439 void AliMUONTrackExtrap::CorrectELossEffectInAbsorber(AliMUONTrackParam* param, Double_t eLoss, Double_t sigmaELoss2)
441 /// Correct parameters for energy loss and add energy loss fluctuation effect to covariances
443 // Get parameter covariances in (X, SlopeX, Y, SlopeY, q*PTot) coordinate system
444 TMatrixD newParamCov(param->GetCovariances());
445 Cov2CovP(param->GetParameters(),newParamCov);
447 // Add effects of energy loss fluctuation to covariances
448 newParamCov(4,4) += sigmaELoss2;
450 // Compute new parameters corrected for energy loss
451 Double_t nonBendingSlope = param->GetNonBendingSlope();
452 Double_t bendingSlope = param->GetBendingSlope();
453 param->SetInverseBendingMomentum(param->GetCharge() / (param->P() + eLoss) *
454 TMath::Sqrt(1.0 + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope) /
455 TMath::Sqrt(1.0 + bendingSlope*bendingSlope));
457 // Get new parameter covariances in (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system
458 CovP2Cov(param->GetParameters(),newParamCov);
460 // Set new parameter covariances
461 param->SetCovariances(newParamCov);
464 //__________________________________________________________________________
465 Bool_t AliMUONTrackExtrap::GetAbsorberCorrectionParam(Double_t trackXYZIn[3], Double_t trackXYZOut[3], Double_t pTotal,
466 Double_t &pathLength, Double_t &f0, Double_t &f1, Double_t &f2,
467 Double_t &meanRho, Double_t &totalELoss, Double_t &sigmaELoss2)
469 /// Parameters used to correct for Multiple Coulomb Scattering and energy loss in absorber
470 /// Calculated assuming a linear propagation from trackXYZIn to trackXYZOut (order is important)
471 // pathLength: path length between trackXYZIn and trackXYZOut (cm)
472 // f0: 0th moment of z calculated with the inverse radiation-length distribution
473 // f1: 1st moment of z calculated with the inverse radiation-length distribution
474 // f2: 2nd moment of z calculated with the inverse radiation-length distribution
475 // meanRho: average density of crossed material (g/cm3)
476 // totalELoss: total energy loss in absorber
478 // Reset absorber's parameters
487 // Check whether the geometry is available
489 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: no TGeo"<<endl;
493 // Initialize starting point and direction
494 pathLength = TMath::Sqrt((trackXYZOut[0] - trackXYZIn[0])*(trackXYZOut[0] - trackXYZIn[0])+
495 (trackXYZOut[1] - trackXYZIn[1])*(trackXYZOut[1] - trackXYZIn[1])+
496 (trackXYZOut[2] - trackXYZIn[2])*(trackXYZOut[2] - trackXYZIn[2]));
497 if (pathLength < TGeoShape::Tolerance()) return kFALSE;
499 b[0] = (trackXYZOut[0] - trackXYZIn[0]) / pathLength;
500 b[1] = (trackXYZOut[1] - trackXYZIn[1]) / pathLength;
501 b[2] = (trackXYZOut[2] - trackXYZIn[2]) / pathLength;
502 TGeoNode *currentnode = gGeoManager->InitTrack(trackXYZIn, b);
504 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: start point out of geometry"<<endl;
508 // loop over absorber slices and calculate absorber's parameters
509 Double_t rho = 0.; // material density (g/cm3)
510 Double_t x0 = 0.; // radiation-length (cm-1)
511 Double_t atomicA = 0.; // A of material
512 Double_t atomicZ = 0.; // Z of material
513 Double_t localPathLength = 0;
514 Double_t remainingPathLength = pathLength;
515 Double_t zB = trackXYZIn[2];
516 Double_t zE, dzB, dzE;
518 // Get material properties
519 TGeoMaterial *material = currentnode->GetVolume()->GetMedium()->GetMaterial();
520 rho = material->GetDensity();
521 x0 = material->GetRadLen();
522 if (!material->IsMixture()) x0 /= rho; // different normalization in the modeler for mixture
523 atomicA = material->GetA();
524 atomicZ = material->GetZ();
526 // Get path length within this material
527 gGeoManager->FindNextBoundary(remainingPathLength);
528 localPathLength = gGeoManager->GetStep() + 1.e-6;
529 // Check if boundary within remaining path length. If so, make sure to cross the boundary to prepare the next step
530 if (localPathLength >= remainingPathLength) localPathLength = remainingPathLength;
532 currentnode = gGeoManager->Step();
534 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: navigation failed"<<endl;
535 f0 = f1 = f2 = meanRho = totalELoss = sigmaELoss2 = 0.;
538 if (!gGeoManager->IsEntering()) {
539 // make another small step to try to enter in new absorber slice
540 gGeoManager->SetStep(0.001);
541 currentnode = gGeoManager->Step();
542 if (!gGeoManager->IsEntering() || !currentnode) {
543 cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: navigation failed"<<endl;
544 f0 = f1 = f2 = meanRho = totalELoss = sigmaELoss2 = 0.;
547 localPathLength += 0.001;
551 // calculate absorber's parameters
552 zE = b[2] * localPathLength + zB;
553 dzB = zB - trackXYZIn[2];
554 dzE = zE - trackXYZIn[2];
555 f0 += localPathLength / x0;
556 f1 += (dzE*dzE - dzB*dzB) / b[2] / b[2] / x0 / 2.;
557 f2 += (dzE*dzE*dzE - dzB*dzB*dzB) / b[2] / b[2] / b[2] / x0 / 3.;
558 meanRho += localPathLength * rho;
559 totalELoss += BetheBloch(pTotal, localPathLength, rho, atomicA, atomicZ);
560 sigmaELoss2 += EnergyLossFluctuation2(pTotal, localPathLength, rho, atomicA, atomicZ);
564 remainingPathLength -= localPathLength;
565 } while (remainingPathLength > TGeoShape::Tolerance());
567 meanRho /= pathLength;
572 //__________________________________________________________________________
573 Double_t AliMUONTrackExtrap::GetMCSAngle2(const AliMUONTrackParam& param, Double_t dZ, Double_t x0)
575 /// Return the angular dispersion square due to multiple Coulomb scattering
576 /// through a material of thickness "dZ" and of radiation length "x0"
577 /// assuming linear propagation and using the small angle approximation.
579 Double_t bendingSlope = param.GetBendingSlope();
580 Double_t nonBendingSlope = param.GetNonBendingSlope();
581 Double_t inverseTotalMomentum2 = param.GetInverseBendingMomentum() * param.GetInverseBendingMomentum() *
582 (1.0 + bendingSlope * bendingSlope) /
583 (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope);
584 // Path length in the material
585 Double_t pathLength = TMath::Abs(dZ) * TMath::Sqrt(1.0 + bendingSlope*bendingSlope + nonBendingSlope*nonBendingSlope);
586 // relativistic velocity
588 // Angular dispersion square of the track (variance) in a plane perpendicular to the trajectory
589 Double_t theta02 = 0.0136 / velo * (1 + 0.038 * TMath::Log(pathLength/x0));
591 return theta02 * theta02 * inverseTotalMomentum2 * pathLength / x0;
594 //__________________________________________________________________________
595 void AliMUONTrackExtrap::AddMCSEffect(AliMUONTrackParam *param, Double_t dZ, Double_t x0)
597 /// Add to the track parameter covariances the effects of multiple Coulomb scattering
598 /// through a material of thickness "dZ" and of radiation length "x0"
599 /// assuming linear propagation and using the small angle approximation.
601 Double_t bendingSlope = param->GetBendingSlope();
602 Double_t nonBendingSlope = param->GetNonBendingSlope();
603 Double_t inverseBendingMomentum = param->GetInverseBendingMomentum();
604 Double_t inverseTotalMomentum2 = inverseBendingMomentum * inverseBendingMomentum *
605 (1.0 + bendingSlope * bendingSlope) /
606 (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope);
607 // Path length in the material
608 Double_t pathLength = TMath::Abs(dZ) * TMath::Sqrt(1.0 + bendingSlope*bendingSlope + nonBendingSlope*nonBendingSlope);
609 Double_t pathLength2 = pathLength * pathLength;
610 // relativistic velocity
612 // Angular dispersion square of the track (variance) in a plane perpendicular to the trajectory
613 Double_t theta02 = 0.0136 / velo * (1 + 0.038 * TMath::Log(pathLength/x0));
614 theta02 *= theta02 * inverseTotalMomentum2 * pathLength / x0;
616 Double_t varCoor = pathLength2 * theta02 / 3.;
617 Double_t varSlop = theta02;
618 Double_t covCorrSlope = pathLength * theta02 / 2.;
620 // compute derivative d(q/Pxy) / dSlopeX and d(q/Pxy) / dSlopeX
621 Double_t dqPxydSlopeX = inverseBendingMomentum * nonBendingSlope / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
622 Double_t dqPxydSlopeY = - inverseBendingMomentum * nonBendingSlope*nonBendingSlope * bendingSlope /
623 (1. + bendingSlope*bendingSlope) / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope);
625 // Set MCS covariance matrix
626 TMatrixD newParamCov(param->GetCovariances());
628 newParamCov(0,0) += varCoor; newParamCov(0,1) += covCorrSlope;
629 newParamCov(1,0) += covCorrSlope; newParamCov(1,1) += varSlop;
631 newParamCov(2,2) += varCoor; newParamCov(2,3) += covCorrSlope;
632 newParamCov(3,2) += covCorrSlope; newParamCov(3,3) += varSlop;
633 // Inverse bending momentum (due to dependences with bending and non bending slopes)
634 newParamCov(4,0) += dqPxydSlopeX * covCorrSlope; newParamCov(0,4) += dqPxydSlopeX * covCorrSlope;
635 newParamCov(4,1) += dqPxydSlopeX * varSlop; newParamCov(1,4) += dqPxydSlopeX * varSlop;
636 newParamCov(4,2) += dqPxydSlopeY * covCorrSlope; newParamCov(2,4) += dqPxydSlopeY * covCorrSlope;
637 newParamCov(4,3) += dqPxydSlopeY * varSlop; newParamCov(3,4) += dqPxydSlopeY * varSlop;
638 newParamCov(4,4) += (dqPxydSlopeX*dqPxydSlopeX + dqPxydSlopeY*dqPxydSlopeY) * varSlop;
640 // Set new covariances
641 param->SetCovariances(newParamCov);
644 //__________________________________________________________________________
645 void AliMUONTrackExtrap::ExtrapToVertex(AliMUONTrackParam* trackParam,
646 Double_t xVtx, Double_t yVtx, Double_t zVtx,
647 Double_t errXVtx, Double_t errYVtx,
648 Bool_t correctForMCS, Bool_t correctForEnergyLoss)
650 /// Main method for extrapolation to the vertex:
651 /// Returns the track parameters and covariances resulting from the extrapolation of the current trackParam
652 /// Changes parameters and covariances according to multiple scattering and energy loss corrections:
653 /// if correctForMCS=kTRUE: compute parameters using Branson correction and add correction resolution to covariances
654 /// if correctForMCS=kFALSE: add parameter dispersion due to MCS in parameter covariances
655 /// if correctForEnergyLoss=kTRUE: correct parameters for energy loss and add energy loss fluctuation to covariances
656 /// if correctForEnergyLoss=kFALSE: do nothing about energy loss
658 if (trackParam->GetZ() == zVtx) return; // nothing to be done if already at vertex
660 if (trackParam->GetZ() > zVtx) { // spectro. (z<0)
661 cout<<"E-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ()
662 <<") upstream the vertex (zVtx = "<<zVtx<<")"<<endl;
666 // Check the vertex position relatively to the absorber
667 if (zVtx < AliMUONConstants::AbsZBeg() && zVtx > AliMUONConstants::AbsZEnd()) { // spectro. (z<0)
668 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Ending Z ("<<zVtx
669 <<") inside the front absorber ("<<AliMUONConstants::AbsZBeg()<<","<<AliMUONConstants::AbsZEnd()<<")"<<endl;
670 } else if (zVtx < AliMUONConstants::AbsZEnd() ) { // spectro. (z<0)
671 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Ending Z ("<<zVtx
672 <<") downstream the front absorber (zAbsorberEnd = "<<AliMUONConstants::AbsZEnd()<<")"<<endl;
673 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx);
674 else ExtrapToZ(trackParam,zVtx);
678 // Check the track position relatively to the absorber and extrapolate track parameters to the end of the absorber if needed
679 if (trackParam->GetZ() > AliMUONConstants::AbsZBeg()) { // spectro. (z<0)
680 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ()
681 <<") upstream the front absorber (zAbsorberBegin = "<<AliMUONConstants::AbsZBeg()<<")"<<endl;
682 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx);
683 else ExtrapToZ(trackParam,zVtx);
685 } else if (trackParam->GetZ() > AliMUONConstants::AbsZEnd()) { // spectro. (z<0)
686 cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ()
687 <<") inside the front absorber ("<<AliMUONConstants::AbsZBeg()<<","<<AliMUONConstants::AbsZEnd()<<")"<<endl;
689 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,AliMUONConstants::AbsZEnd());
690 else ExtrapToZ(trackParam,AliMUONConstants::AbsZEnd());
693 // Get absorber correction parameters assuming linear propagation in absorber
694 Double_t trackXYZOut[3];
695 trackXYZOut[0] = trackParam->GetNonBendingCoor();
696 trackXYZOut[1] = trackParam->GetBendingCoor();
697 trackXYZOut[2] = trackParam->GetZ();
698 Double_t trackXYZIn[3];
699 if (correctForMCS) { // assume linear propagation until the vertex
700 trackXYZIn[2] = TMath::Min(zVtx, AliMUONConstants::AbsZBeg()); // spectro. (z<0)
701 trackXYZIn[0] = trackXYZOut[0] + (xVtx - trackXYZOut[0]) / (zVtx - trackXYZOut[2]) * (trackXYZIn[2] - trackXYZOut[2]);
702 trackXYZIn[1] = trackXYZOut[1] + (yVtx - trackXYZOut[1]) / (zVtx - trackXYZOut[2]) * (trackXYZIn[2] - trackXYZOut[2]);
704 AliMUONTrackParam trackParamIn(*trackParam);
705 ExtrapToZ(&trackParamIn, TMath::Min(zVtx, AliMUONConstants::AbsZBeg()));
706 trackXYZIn[0] = trackParamIn.GetNonBendingCoor();
707 trackXYZIn[1] = trackParamIn.GetBendingCoor();
708 trackXYZIn[2] = trackParamIn.GetZ();
710 Double_t pTot = trackParam->P();
711 Double_t pathLength, f0, f1, f2, meanRho, deltaP, sigmaDeltaP2;
712 if (!GetAbsorberCorrectionParam(trackXYZIn,trackXYZOut,pTot,pathLength,f0,f1,f2,meanRho,deltaP,sigmaDeltaP2)) {
713 cout<<"E-AliMUONTrackExtrap::ExtrapToVertex: Unable to take into account the absorber effects"<<endl;
714 if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx);
715 else ExtrapToZ(trackParam,zVtx);
719 // Compute track parameters and covariances at vertex according to correctForMCS and correctForEnergyLoss flags
722 if (correctForEnergyLoss) {
724 // Correct for multiple scattering and energy loss
725 CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
726 CorrectMCSEffectInAbsorber(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx,
727 trackXYZIn[2], pathLength, f0, f1, f2);
728 CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
732 // Correct for multiple scattering
733 CorrectMCSEffectInAbsorber(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx,
734 trackXYZIn[2], pathLength, f0, f1, f2);
739 if (correctForEnergyLoss) {
741 // Correct for energy loss add multiple scattering dispersion in covariance matrix
742 CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
743 AddMCSEffectInAbsorber(trackParam, pathLength, f0, f1, f2);
744 ExtrapToZCov(trackParam, trackXYZIn[2]);
745 CorrectELossEffectInAbsorber(trackParam, 0.5*deltaP, 0.5*sigmaDeltaP2);
746 ExtrapToZCov(trackParam, zVtx);
750 // add multiple scattering dispersion in covariance matrix
751 AddMCSEffectInAbsorber(trackParam, pathLength, f0, f1, f2);
752 ExtrapToZCov(trackParam, zVtx);
760 //__________________________________________________________________________
761 void AliMUONTrackExtrap::ExtrapToVertex(AliMUONTrackParam* trackParam,
762 Double_t xVtx, Double_t yVtx, Double_t zVtx,
763 Double_t errXVtx, Double_t errYVtx)
765 /// Extrapolate track parameters to vertex, corrected for multiple scattering and energy loss effects
766 /// Add branson correction resolution and energy loss fluctuation to parameter covariances
767 ExtrapToVertex(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx, kTRUE, kTRUE);
770 //__________________________________________________________________________
771 void AliMUONTrackExtrap::ExtrapToVertexWithoutELoss(AliMUONTrackParam* trackParam,
772 Double_t xVtx, Double_t yVtx, Double_t zVtx,
773 Double_t errXVtx, Double_t errYVtx)
775 /// Extrapolate track parameters to vertex, corrected for multiple scattering effects only
776 /// Add branson correction resolution to parameter covariances
777 ExtrapToVertex(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx, kTRUE, kFALSE);
780 //__________________________________________________________________________
781 void AliMUONTrackExtrap::ExtrapToVertexWithoutBranson(AliMUONTrackParam* trackParam, Double_t zVtx)
783 /// Extrapolate track parameters to vertex, corrected for energy loss effects only
784 /// Add dispersion due to multiple scattering and energy loss fluctuation to parameter covariances
785 ExtrapToVertex(trackParam, 0., 0., zVtx, 0., 0., kFALSE, kTRUE);
788 //__________________________________________________________________________
789 void AliMUONTrackExtrap::ExtrapToVertexUncorrected(AliMUONTrackParam* trackParam, Double_t zVtx)
791 /// Extrapolate track parameters to vertex without multiple scattering and energy loss corrections
792 /// Add dispersion due to multiple scattering to parameter covariances
793 ExtrapToVertex(trackParam, 0., 0., zVtx, 0., 0., kFALSE, kFALSE);
796 //__________________________________________________________________________
797 Double_t AliMUONTrackExtrap::TotalMomentumEnergyLoss(AliMUONTrackParam* trackParam, Double_t xVtx, Double_t yVtx, Double_t zVtx)
799 /// Calculate the total momentum energy loss in-between the track position and the vertex assuming a linear propagation
801 if (trackParam->GetZ() == zVtx) return 0.; // nothing to be done if already at vertex
803 // Check whether the geometry is available
805 cout<<"E-AliMUONTrackExtrap::TotalMomentumEnergyLoss: no TGeo"<<endl;
809 // Get encountered material correction parameters assuming linear propagation from vertex to the track position
810 Double_t trackXYZOut[3];
811 trackXYZOut[0] = trackParam->GetNonBendingCoor();
812 trackXYZOut[1] = trackParam->GetBendingCoor();
813 trackXYZOut[2] = trackParam->GetZ();
814 Double_t trackXYZIn[3];
815 trackXYZIn[0] = xVtx;
816 trackXYZIn[1] = yVtx;
817 trackXYZIn[2] = zVtx;
818 Double_t pTot = trackParam->P();
819 Double_t pathLength, f0, f1, f2, meanRho, totalELoss, sigmaELoss2;
820 GetAbsorberCorrectionParam(trackXYZIn,trackXYZOut,pTot,pathLength,f0,f1,f2,meanRho,totalELoss,sigmaELoss2);
825 //__________________________________________________________________________
826 Double_t AliMUONTrackExtrap::BetheBloch(Double_t pTotal, Double_t pathLength, Double_t rho, Double_t atomicA, Double_t atomicZ)
828 /// Returns the mean total momentum energy loss of muon with total momentum='pTotal'
829 /// in the absorber layer of lenght='pathLength', density='rho', A='atomicA' and Z='atomicZ'
830 Double_t muMass = 0.105658369; // GeV
831 Double_t eMass = 0.510998918e-3; // GeV
832 Double_t k = 0.307075e-3; // GeV.g^-1.cm^2
833 Double_t i = 9.5e-9; // mean exitation energy per atomic Z (GeV)
834 Double_t p2=pTotal*pTotal;
835 Double_t beta2=p2/(p2 + muMass*muMass);
837 Double_t w = k * rho * pathLength * atomicZ / atomicA / beta2;
839 if (beta2/(1-beta2)>3.5*3.5)
840 return w * (log(2.*eMass*3.5/(i*atomicZ)) + 0.5*log(beta2/(1-beta2)) - beta2);
842 return w * (log(2.*eMass*beta2/(1-beta2)/(i*atomicZ)) - beta2);
845 //__________________________________________________________________________
846 Double_t AliMUONTrackExtrap::EnergyLossFluctuation2(Double_t pTotal, Double_t pathLength, Double_t rho, Double_t atomicA, Double_t atomicZ)
848 /// Returns the total momentum energy loss fluctuation of muon with total momentum='pTotal'
849 /// in the absorber layer of lenght='pathLength', density='rho', A='atomicA' and Z='atomicZ'
850 Double_t muMass = 0.105658369; // GeV
851 //Double_t eMass = 0.510998918e-3; // GeV
852 Double_t k = 0.307075e-3; // GeV.g^-1.cm^2
853 Double_t p2=pTotal*pTotal;
854 Double_t beta2=p2/(p2 + muMass*muMass);
856 Double_t fwhm = 2. * k * rho * pathLength * atomicZ / atomicA / beta2; // FWHM of the energy loss Landau distribution
857 Double_t sigma2 = fwhm * fwhm / (8.*log(2.)); // gaussian: fwmh = 2 * srqt(2*ln(2)) * sigma (i.e. fwmh = 2.35 * sigma)
859 //sigma2 = k * rho * pathLength * atomicZ / atomicA * eMass; // sigma2 of the energy loss gaussian distribution
864 //__________________________________________________________________________
865 void AliMUONTrackExtrap::Cov2CovP(const TMatrixD ¶m, TMatrixD &cov)
867 /// change coordinate system: (X, SlopeX, Y, SlopeY, q/Pyz) -> (X, SlopeX, Y, SlopeY, q*PTot)
868 /// parameters (param) are given in the (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system
870 // charge * total momentum
871 Double_t qPTot = TMath::Sqrt(1. + param(1,0)*param(1,0) + param(3,0)*param(3,0)) /
872 TMath::Sqrt(1. + param(3,0)*param(3,0)) / param(4,0);
874 // Jacobian of the opposite transformation
877 jacob(4,1) = qPTot * param(1,0) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
878 jacob(4,3) = - qPTot * param(1,0) * param(1,0) * param(3,0) /
879 (1. + param(3,0)*param(3,0)) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
880 jacob(4,4) = - qPTot / param(4,0);
882 // compute covariances in new coordinate system
883 TMatrixD tmp(cov,TMatrixD::kMultTranspose,jacob);
887 //__________________________________________________________________________
888 void AliMUONTrackExtrap::CovP2Cov(const TMatrixD ¶m, TMatrixD &covP)
890 /// change coordinate system: (X, SlopeX, Y, SlopeY, q*PTot) -> (X, SlopeX, Y, SlopeY, q/Pyz)
891 /// parameters (param) are given in the (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system
893 // charge * total momentum
894 Double_t qPTot = TMath::Sqrt(1. + param(1,0)*param(1,0) + param(3,0)*param(3,0)) /
895 TMath::Sqrt(1. + param(3,0)*param(3,0)) / param(4,0);
897 // Jacobian of the transformation
900 jacob(4,1) = param(4,0) * param(1,0) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
901 jacob(4,3) = - param(4,0) * param(1,0) * param(1,0) * param(3,0) /
902 (1. + param(3,0)*param(3,0)) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0));
903 jacob(4,4) = - param(4,0) / qPTot;
905 // compute covariances in new coordinate system
906 TMatrixD tmp(covP,TMatrixD::kMultTranspose,jacob);
907 covP.Mult(jacob,tmp);
910 //__________________________________________________________________________
911 void AliMUONTrackExtrap::ExtrapOneStepHelix(Double_t charge, Double_t step, Double_t *vect, Double_t *vout)
914 /// ******************************************************************
916 /// * Performs the tracking of one step in a magnetic field *
917 /// * The trajectory is assumed to be a helix in a constant field *
918 /// * taken at the mid point of the step. *
921 /// * STEP =arc length of the step asked *
922 /// * VECT =input vector (position,direction cos and momentum) *
923 /// * CHARGE= electric charge of the particle *
925 /// * VOUT = same as VECT after completion of the step *
927 /// * ==>Called by : USER, GUSWIM *
928 /// * Author m.hansroul ********* *
929 /// * modified s.egli, s.v.levonian *
930 /// * modified v.perevoztchikov
932 /// ******************************************************************
935 // modif: everything in double precision
937 Double_t xyz[3], h[4], hxp[3];
938 Double_t h2xy, hp, rho, tet;
939 Double_t sint, sintt, tsint, cos1t;
940 Double_t f1, f2, f3, f4, f5, f6;
945 const Int_t kipx = 3;
946 const Int_t kipy = 4;
947 const Int_t kipz = 5;
948 const Int_t kipp = 6;
950 const Double_t kec = 2.9979251e-4;
952 // ------------------------------------------------------------------
954 // units are kgauss,centimeters,gev/c
956 vout[kipp] = vect[kipp];
957 if (TMath::Abs(charge) < 0.00001) {
958 for (Int_t i = 0; i < 3; i++) {
959 vout[i] = vect[i] + step * vect[i+3];
960 vout[i+3] = vect[i+3];
964 xyz[0] = vect[kix] + 0.5 * step * vect[kipx];
965 xyz[1] = vect[kiy] + 0.5 * step * vect[kipy];
966 xyz[2] = vect[kiz] + 0.5 * step * vect[kipz];
968 //cmodif: call gufld (xyz, h) changed into:
971 h2xy = h[0]*h[0] + h[1]*h[1];
972 h[3] = h[2]*h[2]+ h2xy;
974 for (Int_t i = 0; i < 3; i++) {
975 vout[i] = vect[i] + step * vect[i+3];
976 vout[i+3] = vect[i+3];
980 if (h2xy < 1.e-12*h[3]) {
981 ExtrapOneStepHelix3(charge*h[2], step, vect, vout);
984 h[3] = TMath::Sqrt(h[3]);
990 hxp[0] = h[1]*vect[kipz] - h[2]*vect[kipy];
991 hxp[1] = h[2]*vect[kipx] - h[0]*vect[kipz];
992 hxp[2] = h[0]*vect[kipy] - h[1]*vect[kipx];
994 hp = h[0]*vect[kipx] + h[1]*vect[kipy] + h[2]*vect[kipz];
996 rho = -charge*h[3]/vect[kipp];
999 if (TMath::Abs(tet) > 0.15) {
1000 sint = TMath::Sin(tet);
1002 tsint = (tet-sint)/tet;
1003 cos1t = 2.*(TMath::Sin(0.5*tet))*(TMath::Sin(0.5*tet))/tet;
1005 tsint = tet*tet/36.;
1006 sintt = (1. - tsint);
1013 f3 = step * tsint * hp;
1016 f6 = tet * cos1t * hp;
1018 vout[kix] = vect[kix] + f1*vect[kipx] + f2*hxp[0] + f3*h[0];
1019 vout[kiy] = vect[kiy] + f1*vect[kipy] + f2*hxp[1] + f3*h[1];
1020 vout[kiz] = vect[kiz] + f1*vect[kipz] + f2*hxp[2] + f3*h[2];
1022 vout[kipx] = vect[kipx] + f4*vect[kipx] + f5*hxp[0] + f6*h[0];
1023 vout[kipy] = vect[kipy] + f4*vect[kipy] + f5*hxp[1] + f6*h[1];
1024 vout[kipz] = vect[kipz] + f4*vect[kipz] + f5*hxp[2] + f6*h[2];
1029 //__________________________________________________________________________
1030 void AliMUONTrackExtrap::ExtrapOneStepHelix3(Double_t field, Double_t step, Double_t *vect, Double_t *vout)
1033 /// ******************************************************************
1035 /// * Tracking routine in a constant field oriented *
1036 /// * along axis 3 *
1037 /// * Tracking is performed with a conventional *
1038 /// * helix step method *
1040 /// * ==>Called by : USER, GUSWIM *
1041 /// * Authors R.Brun, M.Hansroul ********* *
1042 /// * Rewritten V.Perevoztchikov
1044 /// ******************************************************************
1048 Double_t h4, hp, rho, tet;
1049 Double_t sint, sintt, tsint, cos1t;
1050 Double_t f1, f2, f3, f4, f5, f6;
1052 const Int_t kix = 0;
1053 const Int_t kiy = 1;
1054 const Int_t kiz = 2;
1055 const Int_t kipx = 3;
1056 const Int_t kipy = 4;
1057 const Int_t kipz = 5;
1058 const Int_t kipp = 6;
1060 const Double_t kec = 2.9979251e-4;
1063 // ------------------------------------------------------------------
1065 // units are kgauss,centimeters,gev/c
1067 vout[kipp] = vect[kipp];
1070 hxp[0] = - vect[kipy];
1071 hxp[1] = + vect[kipx];
1075 rho = -h4/vect[kipp];
1077 if (TMath::Abs(tet) > 0.15) {
1078 sint = TMath::Sin(tet);
1080 tsint = (tet-sint)/tet;
1081 cos1t = 2.* TMath::Sin(0.5*tet) * TMath::Sin(0.5*tet)/tet;
1083 tsint = tet*tet/36.;
1084 sintt = (1. - tsint);
1091 f3 = step * tsint * hp;
1094 f6 = tet * cos1t * hp;
1096 vout[kix] = vect[kix] + f1*vect[kipx] + f2*hxp[0];
1097 vout[kiy] = vect[kiy] + f1*vect[kipy] + f2*hxp[1];
1098 vout[kiz] = vect[kiz] + f1*vect[kipz] + f3;
1100 vout[kipx] = vect[kipx] + f4*vect[kipx] + f5*hxp[0];
1101 vout[kipy] = vect[kipy] + f4*vect[kipy] + f5*hxp[1];
1102 vout[kipz] = vect[kipz] + f4*vect[kipz] + f6;
1107 //__________________________________________________________________________
1108 void AliMUONTrackExtrap::ExtrapOneStepRungekutta(Double_t charge, Double_t step, Double_t* vect, Double_t* vout)
1111 /// ******************************************************************
1113 /// * Runge-Kutta method for tracking a particle through a magnetic *
1114 /// * field. Uses Nystroem algorithm (See Handbook Nat. Bur. of *
1115 /// * Standards, procedure 25.5.20) *
1117 /// * Input parameters *
1118 /// * CHARGE Particle charge *
1119 /// * STEP Step size *
1120 /// * VECT Initial co-ords,direction cosines,momentum *
1121 /// * Output parameters *
1122 /// * VOUT Output co-ords,direction cosines,momentum *
1123 /// * User routine called *
1124 /// * CALL GUFLD(X,F) *
1126 /// * ==>Called by : USER, GUSWIM *
1127 /// * Authors R.Brun, M.Hansroul ********* *
1128 /// * V.Perevoztchikov (CUT STEP implementation) *
1131 /// ******************************************************************
1134 Double_t h2, h4, f[4];
1135 Double_t xyzt[3], a, b, c, ph,ph2;
1136 Double_t secxs[4],secys[4],seczs[4],hxp[3];
1137 Double_t g1, g2, g3, g4, g5, g6, ang2, dxt, dyt, dzt;
1138 Double_t est, at, bt, ct, cba;
1139 Double_t f1, f2, f3, f4, rho, tet, hnorm, hp, rho1, sint, cost;
1149 Double_t maxit = 1992;
1150 Double_t maxcut = 11;
1152 const Double_t kdlt = 1e-4;
1153 const Double_t kdlt32 = kdlt/32.;
1154 const Double_t kthird = 1./3.;
1155 const Double_t khalf = 0.5;
1156 const Double_t kec = 2.9979251e-4;
1158 const Double_t kpisqua = 9.86960440109;
1159 const Int_t kix = 0;
1160 const Int_t kiy = 1;
1161 const Int_t kiz = 2;
1162 const Int_t kipx = 3;
1163 const Int_t kipy = 4;
1164 const Int_t kipz = 5;
1167 // *. ------------------------------------------------------------------
1169 // * this constant is for units cm,gev/c and kgauss
1173 for(Int_t j = 0; j < 7; j++)
1176 Double_t pinv = kec * charge / vect[6];
1184 if (TMath::Abs(h) > TMath::Abs(rest)) h = rest;
1185 //cmodif: call gufld(vout,f) changed into:
1190 // * start of integration
1203 secxs[0] = (b * f[2] - c * f[1]) * ph2;
1204 secys[0] = (c * f[0] - a * f[2]) * ph2;
1205 seczs[0] = (a * f[1] - b * f[0]) * ph2;
1206 ang2 = (secxs[0]*secxs[0] + secys[0]*secys[0] + seczs[0]*seczs[0]);
1207 if (ang2 > kpisqua) break;
1209 dxt = h2 * a + h4 * secxs[0];
1210 dyt = h2 * b + h4 * secys[0];
1211 dzt = h2 * c + h4 * seczs[0];
1216 // * second intermediate point
1219 est = TMath::Abs(dxt) + TMath::Abs(dyt) + TMath::Abs(dzt);
1221 if (ncut++ > maxcut) break;
1230 //cmodif: call gufld(xyzt,f) changed into:
1237 secxs[1] = (bt * f[2] - ct * f[1]) * ph2;
1238 secys[1] = (ct * f[0] - at * f[2]) * ph2;
1239 seczs[1] = (at * f[1] - bt * f[0]) * ph2;
1243 secxs[2] = (bt * f[2] - ct * f[1]) * ph2;
1244 secys[2] = (ct * f[0] - at * f[2]) * ph2;
1245 seczs[2] = (at * f[1] - bt * f[0]) * ph2;
1246 dxt = h * (a + secxs[2]);
1247 dyt = h * (b + secys[2]);
1248 dzt = h * (c + seczs[2]);
1252 at = a + 2.*secxs[2];
1253 bt = b + 2.*secys[2];
1254 ct = c + 2.*seczs[2];
1256 est = TMath::Abs(dxt)+TMath::Abs(dyt)+TMath::Abs(dzt);
1257 if (est > 2.*TMath::Abs(h)) {
1258 if (ncut++ > maxcut) break;
1267 //cmodif: call gufld(xyzt,f) changed into:
1270 z = z + (c + (seczs[0] + seczs[1] + seczs[2]) * kthird) * h;
1271 y = y + (b + (secys[0] + secys[1] + secys[2]) * kthird) * h;
1272 x = x + (a + (secxs[0] + secxs[1] + secxs[2]) * kthird) * h;
1274 secxs[3] = (bt*f[2] - ct*f[1])* ph2;
1275 secys[3] = (ct*f[0] - at*f[2])* ph2;
1276 seczs[3] = (at*f[1] - bt*f[0])* ph2;
1277 a = a+(secxs[0]+secxs[3]+2. * (secxs[1]+secxs[2])) * kthird;
1278 b = b+(secys[0]+secys[3]+2. * (secys[1]+secys[2])) * kthird;
1279 c = c+(seczs[0]+seczs[3]+2. * (seczs[1]+seczs[2])) * kthird;
1281 est = TMath::Abs(secxs[0]+secxs[3] - (secxs[1]+secxs[2]))
1282 + TMath::Abs(secys[0]+secys[3] - (secys[1]+secys[2]))
1283 + TMath::Abs(seczs[0]+seczs[3] - (seczs[1]+seczs[2]));
1285 if (est > kdlt && TMath::Abs(h) > 1.e-4) {
1286 if (ncut++ > maxcut) break;
1292 // * if too many iterations, go to helix
1293 if (iter++ > maxit) break;
1298 cba = 1./ TMath::Sqrt(a*a + b*b + c*c);
1306 if (step < 0.) rest = -rest;
1307 if (rest < 1.e-5*TMath::Abs(step)) return;
1311 // angle too big, use helix
1316 f4 = TMath::Sqrt(f1*f1+f2*f2+f3*f3);
1325 hxp[0] = f2*vect[kipz] - f3*vect[kipy];
1326 hxp[1] = f3*vect[kipx] - f1*vect[kipz];
1327 hxp[2] = f1*vect[kipy] - f2*vect[kipx];
1329 hp = f1*vect[kipx] + f2*vect[kipy] + f3*vect[kipz];
1332 sint = TMath::Sin(tet);
1333 cost = 2.*TMath::Sin(khalf*tet)*TMath::Sin(khalf*tet);
1337 g3 = (tet-sint) * hp*rho1;
1342 vout[kix] = vect[kix] + g1*vect[kipx] + g2*hxp[0] + g3*f1;
1343 vout[kiy] = vect[kiy] + g1*vect[kipy] + g2*hxp[1] + g3*f2;
1344 vout[kiz] = vect[kiz] + g1*vect[kipz] + g2*hxp[2] + g3*f3;
1346 vout[kipx] = vect[kipx] + g4*vect[kipx] + g5*hxp[0] + g6*f1;
1347 vout[kipy] = vect[kipy] + g4*vect[kipy] + g5*hxp[1] + g6*f2;
1348 vout[kipz] = vect[kipz] + g4*vect[kipz] + g5*hxp[2] + g6*f3;
1353 //___________________________________________________________
1354 void AliMUONTrackExtrap::GetField(Double_t *Position, Double_t *Field)
1356 /// interface for arguments in double precision (Why ? ChF)
1359 x[0] = Position[0]; x[1] = Position[1]; x[2] = Position[2];
1361 if (fgkField) fgkField->Field(x,b);
1363 cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl;
1367 Field[0] = b[0]; Field[1] = b[1]; Field[2] = b[2];