]>
Commit | Line | Data |
---|---|---|
c04e3238 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
56316147 | 18 | //----------------------------------------------------------------------------- |
19 | // Class AliMUONTrackExtrap | |
20 | // ------------------------ | |
21 | // Tools for track extrapolation in ALICE dimuon spectrometer | |
22 | // Author: Philippe Pillot | |
23 | //----------------------------------------------------------------------------- | |
c04e3238 | 24 | |
c04e3238 | 25 | #include "AliMUONTrackExtrap.h" |
26 | #include "AliMUONTrackParam.h" | |
27 | #include "AliMUONConstants.h" | |
0e894e58 | 28 | #include "AliMUONReconstructor.h" |
8cde4af5 | 29 | |
c04e3238 | 30 | #include "AliMagF.h" |
8cde4af5 | 31 | |
8cde4af5 | 32 | #include <TMath.h> |
8cde4af5 | 33 | #include <TGeoManager.h> |
c04e3238 | 34 | |
ea94c18b | 35 | #include <Riostream.h> |
36 | ||
78649106 | 37 | /// \cond CLASSIMP |
c04e3238 | 38 | ClassImp(AliMUONTrackExtrap) // Class implementation in ROOT context |
78649106 | 39 | /// \endcond |
c04e3238 | 40 | |
41 | const AliMagF* AliMUONTrackExtrap::fgkField = 0x0; | |
9f093251 | 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; | |
4284483e | 46 | const Bool_t AliMUONTrackExtrap::fgkUseHelix = kFALSE; |
208f139e | 47 | const Int_t AliMUONTrackExtrap::fgkMaxStepNumber = 5000; |
4284483e | 48 | const Double_t AliMUONTrackExtrap::fgkHelixStepLength = 6.; |
49 | const Double_t AliMUONTrackExtrap::fgkRungeKuttaMaxResidue = 0.002; | |
208f139e | 50 | |
9f093251 | 51 | //__________________________________________________________________________ |
52 | void AliMUONTrackExtrap::SetField(const AliMagF* magField) | |
53 | { | |
54 | /// set magnetic field | |
55 | ||
56 | // set field map | |
57 | fgkField = magField; | |
58 | if (!fgkField) { | |
59 | cout<<"E-AliMUONTrackExtrap::SetField: fgkField = 0x0"<<endl; | |
60 | return; | |
61 | } | |
62 | ||
63 | // set field on/off flag | |
64 | fgFieldON = (fgkField->Factor() == 0.) ? kFALSE : kTRUE; | |
65 | ||
66 | // set field at the centre of the dipole | |
67 | if (fgFieldON) { | |
68 | Float_t b[3] = {0.,0.,0.}, x[3] = {50.,50.,(Float_t) fgkSimpleBPosition}; | |
69 | fgkField->Field(x,b); | |
70 | fgSimpleBValue = (Double_t) b[0]; | |
71 | } else fgSimpleBValue = 0.; | |
72 | ||
73 | } | |
74 | ||
690d2205 | 75 | //__________________________________________________________________________ |
208f139e | 76 | Double_t AliMUONTrackExtrap::GetImpactParamFromBendingMomentum(Double_t bendingMomentum) |
77 | { | |
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. | |
82 | ||
83 | if (bendingMomentum == 0.) return 1.e10; | |
84 | ||
9f093251 | 85 | if (!fgkField) { |
208f139e | 86 | cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl; |
87 | exit(-1); | |
88 | } | |
208f139e | 89 | |
9f093251 | 90 | const Double_t kCorrectionFactor = 0.9; // impact parameter is 10% overestimated |
91 | ||
92 | return kCorrectionFactor * (-0.0003 * fgSimpleBValue * fgkSimpleBLength * fgkSimpleBPosition / bendingMomentum); | |
208f139e | 93 | } |
94 | ||
690d2205 | 95 | //__________________________________________________________________________ |
9bdbee64 | 96 | Double_t |
97 | AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(Double_t impactParam) | |
208f139e | 98 | { |
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. | |
103 | ||
104 | if (impactParam == 0.) return 1.e10; | |
105 | ||
9f093251 | 106 | if (!fgkField) { |
208f139e | 107 | cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl; |
108 | exit(-1); | |
109 | } | |
208f139e | 110 | |
9f093251 | 111 | const Double_t kCorrectionFactor = 1.1; // bending momentum is 10% underestimated |
112 | ||
9bdbee64 | 113 | if (fgFieldON) |
114 | { | |
115 | return kCorrectionFactor * (-0.0003 * fgSimpleBValue * fgkSimpleBLength * fgkSimpleBPosition / impactParam); | |
116 | } | |
117 | else | |
118 | { | |
119 | return AliMUONConstants::GetMostProbBendingMomentum(); | |
120 | } | |
019df241 | 121 | } |
122 | ||
690d2205 | 123 | //__________________________________________________________________________ |
9f093251 | 124 | void AliMUONTrackExtrap::LinearExtrapToZ(AliMUONTrackParam* trackParam, Double_t zEnd, Bool_t updatePropagator) |
019df241 | 125 | { |
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. | |
128 | ||
129 | if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z | |
130 | ||
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); | |
136 | ||
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); | |
9f093251 | 147 | |
148 | // Update the propagator if required | |
149 | if (updatePropagator) { | |
150 | TMatrixD jacob(5,5); | |
151 | jacob.UnitMatrix(); | |
152 | jacob(0,1) = dZ; | |
153 | jacob(2,3) = dZ; | |
154 | trackParam->UpdatePropagator(jacob); | |
155 | } | |
156 | ||
019df241 | 157 | } |
158 | ||
208f139e | 159 | } |
c04e3238 | 160 | |
690d2205 | 161 | //__________________________________________________________________________ |
c04e3238 | 162 | void AliMUONTrackExtrap::ExtrapToZ(AliMUONTrackParam* trackParam, Double_t zEnd) |
163 | { | |
4284483e | 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. | |
9f093251 | 166 | if (!fgFieldON) AliMUONTrackExtrap::LinearExtrapToZ(trackParam,zEnd); |
167 | else if (fgkUseHelix) AliMUONTrackExtrap::ExtrapToZHelix(trackParam,zEnd); | |
4284483e | 168 | else AliMUONTrackExtrap::ExtrapToZRungekutta(trackParam,zEnd); |
169 | } | |
170 | ||
690d2205 | 171 | //__________________________________________________________________________ |
4284483e | 172 | void AliMUONTrackExtrap::ExtrapToZHelix(AliMUONTrackParam* trackParam, Double_t zEnd) |
173 | { | |
174 | /// Track parameter extrapolation to the plane at "Z" using Helix algorithm. | |
c04e3238 | 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; | |
dade8580 | 180 | Double_t v3[7], v3New[7]; // 7 in parameter ???? |
181 | Int_t i3, stepNumber; | |
c04e3238 | 182 | // For safety: return kTRUE or kFALSE ???? |
183 | // Parameter vector for calling EXTRAP_ONESTEP | |
4284483e | 184 | ConvertTrackParamForExtrap(trackParam, forwardBackward, v3); |
c04e3238 | 185 | // sign of charge (sign of fInverseBendingMomentum if forward motion) |
186 | // must be changed if backward extrapolation | |
208f139e | 187 | Double_t chargeExtrap = forwardBackward * TMath::Sign(Double_t(1.0), trackParam->GetInverseBendingMomentum()); |
c04e3238 | 188 | // Extrapolation loop |
189 | stepNumber = 0; | |
208f139e | 190 | while (((-forwardBackward * (v3[2] - zEnd)) <= 0.0) && (stepNumber < fgkMaxStepNumber)) { // spectro. z<0 |
c04e3238 | 191 | stepNumber++; |
4284483e | 192 | ExtrapOneStepHelix(chargeExtrap, fgkHelixStepLength, v3, v3New); |
dade8580 | 193 | if ((-forwardBackward * (v3New[2] - zEnd)) > 0.0) break; // one is beyond Z spectro. z<0 |
690d2205 | 194 | // better use TArray ???? |
208f139e | 195 | for (i3 = 0; i3 < 7; i3++) {v3[i3] = v3New[i3];} |
c04e3238 | 196 | } |
208f139e | 197 | // check fgkMaxStepNumber ???? |
c04e3238 | 198 | // Interpolation back to exact Z (2nd order) |
199 | // should be in function ???? using TArray ???? | |
dade8580 | 200 | Double_t dZ12 = v3New[2] - v3[2]; // 1->2 |
c04e3238 | 201 | if (TMath::Abs(dZ12) > 0) { |
dade8580 | 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 | |
210 | v3[2] = zEnd; // Z | |
c04e3238 | 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 | |
208f139e | 214 | v3[5] = 1.0 / TMath::Sqrt(1.0 + xPrimeI * xPrimeI + yPrimeI * yPrimeI); // PZ/PTOT |
dade8580 | 215 | v3[3] = xPrimeI * v3[5]; // PX/PTOT |
216 | v3[4] = yPrimeI * v3[5]; // PY/PTOT | |
c04e3238 | 217 | } else { |
4284483e | 218 | cout<<"W-AliMUONTrackExtrap::ExtrapToZHelix: Extrap. to Z not reached, Z = "<<zEnd<<endl; |
c04e3238 | 219 | } |
4284483e | 220 | // Recover track parameters (charge back for forward motion) |
dade8580 | 221 | RecoverTrackParam(v3, chargeExtrap * forwardBackward, trackParam); |
c04e3238 | 222 | } |
223 | ||
690d2205 | 224 | //__________________________________________________________________________ |
4284483e | 225 | void AliMUONTrackExtrap::ExtrapToZRungekutta(AliMUONTrackParam* trackParam, Double_t zEnd) |
226 | { | |
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]; | |
237 | Double_t dZ, step; | |
238 | Int_t stepNumber = 0; | |
239 | ||
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() + | |
690d2205 | 246 | trackParam->GetNonBendingSlope()*trackParam->GetNonBendingSlope()); |
4284483e | 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; | |
251 | break; | |
252 | } | |
253 | stepNumber ++; | |
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); | |
260 | } | |
261 | ||
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); | |
266 | } | |
267 | ||
690d2205 | 268 | //__________________________________________________________________________ |
4284483e | 269 | void AliMUONTrackExtrap::ConvertTrackParamForExtrap(AliMUONTrackParam* trackParam, Double_t forwardBackward, Double_t *v3) |
c04e3238 | 270 | { |
dade8580 | 271 | /// Set vector of Geant3 parameters pointed to by "v3" from track parameters in trackParam. |
c04e3238 | 272 | /// Since AliMUONTrackParam is only geometry, one uses "forwardBackward" |
273 | /// to know whether the particle is going forward (+1) or backward (-1). | |
dade8580 | 274 | v3[0] = trackParam->GetNonBendingCoor(); // X |
275 | v3[1] = trackParam->GetBendingCoor(); // Y | |
276 | v3[2] = trackParam->GetZ(); // Z | |
c04e3238 | 277 | Double_t pYZ = TMath::Abs(1.0 / trackParam->GetInverseBendingMomentum()); |
278 | Double_t pZ = pYZ / TMath::Sqrt(1.0 + trackParam->GetBendingSlope() * trackParam->GetBendingSlope()); | |
dade8580 | 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 | |
c04e3238 | 283 | } |
284 | ||
690d2205 | 285 | //__________________________________________________________________________ |
dade8580 | 286 | void AliMUONTrackExtrap::RecoverTrackParam(Double_t *v3, Double_t charge, AliMUONTrackParam* trackParam) |
c04e3238 | 287 | { |
dade8580 | 288 | /// Set track parameters in trackParam from Geant3 parameters pointed to by "v3", |
c04e3238 | 289 | /// assumed to be calculated for forward motion in Z. |
290 | /// "InverseBendingMomentum" is signed with "charge". | |
dade8580 | 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]); | |
c04e3238 | 295 | trackParam->SetInverseBendingMomentum(charge/pYZ); |
dade8580 | 296 | trackParam->SetBendingSlope(v3[4]/v3[5]); |
297 | trackParam->SetNonBendingSlope(v3[3]/v3[5]); | |
208f139e | 298 | } |
299 | ||
690d2205 | 300 | //__________________________________________________________________________ |
ea94c18b | 301 | void AliMUONTrackExtrap::ExtrapToZCov(AliMUONTrackParam* trackParam, Double_t zEnd, Bool_t updatePropagator) |
208f139e | 302 | { |
303 | /// Track parameters and their covariances extrapolated to the plane at "zEnd". | |
304 | /// On return, results from the extrapolation are updated in trackParam. | |
305 | ||
306 | if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z | |
307 | ||
9f093251 | 308 | if (!fgFieldON) { // linear extrapolation if no magnetic field |
309 | AliMUONTrackExtrap::LinearExtrapToZ(trackParam,zEnd,updatePropagator); | |
310 | return; | |
311 | } | |
312 | ||
ea94c18b | 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); | |
318 | return; | |
319 | } | |
320 | ||
208f139e | 321 | // Save the actual track parameters |
322 | AliMUONTrackParam trackParamSave(*trackParam); | |
ea94c18b | 323 | TMatrixD paramSave(trackParamSave.GetParameters()); |
324 | Double_t zBegin = trackParamSave.GetZ(); | |
325 | ||
326 | // Get reference to the parameter covariance matrix | |
327 | const TMatrixD& kParamCov = trackParam->GetCovariances(); | |
9bf6860b | 328 | |
208f139e | 329 | // Extrapolate track parameters to "zEnd" |
330 | ExtrapToZ(trackParam,zEnd); | |
208f139e | 331 | |
ea94c18b | 332 | // Get reference to the extrapolated parameters |
333 | const TMatrixD& extrapParam = trackParam->GetParameters(); | |
208f139e | 334 | |
335 | // Calculate the jacobian related to the track parameters extrapolation to "zEnd" | |
336 | TMatrixD jacob(5,5); | |
ea94c18b | 337 | jacob.Zero(); |
338 | TMatrixD dParam(5,1); | |
208f139e | 339 | for (Int_t i=0; i<5; i++) { |
340 | // Skip jacobian calculation for parameters with no associated error | |
18abc511 | 341 | if (kParamCov(i,i) <= 0.) continue; |
ea94c18b | 342 | |
208f139e | 343 | // Small variation of parameter i only |
344 | for (Int_t j=0; j<5; j++) { | |
345 | if (j==i) { | |
ea94c18b | 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.; | |
208f139e | 349 | } |
ea94c18b | 350 | |
208f139e | 351 | // Set new parameters |
ea94c18b | 352 | trackParamSave.SetParameters(paramSave); |
353 | trackParamSave.AddParameters(dParam); | |
354 | trackParamSave.SetZ(zBegin); | |
355 | ||
208f139e | 356 | // Extrapolate new track parameters to "zEnd" |
357 | ExtrapToZ(&trackParamSave,zEnd); | |
ea94c18b | 358 | |
208f139e | 359 | // Calculate the jacobian |
ea94c18b | 360 | TMatrixD jacobji(trackParamSave.GetParameters(),TMatrixD::kMinus,extrapParam); |
361 | jacobji *= 1. / dParam(i,0); | |
362 | jacob.SetSub(0,i,jacobji); | |
208f139e | 363 | } |
364 | ||
365 | // Extrapolate track parameter covariances to "zEnd" | |
ea94c18b | 366 | TMatrixD tmp(kParamCov,TMatrixD::kMultTranspose,jacob); |
367 | TMatrixD tmp2(jacob,TMatrixD::kMult,tmp); | |
368 | trackParam->SetCovariances(tmp2); | |
369 | ||
370 | // Update the propagator if required | |
371 | if (updatePropagator) trackParam->UpdatePropagator(jacob); | |
208f139e | 372 | } |
373 | ||
690d2205 | 374 | //__________________________________________________________________________ |
8cde4af5 | 375 | void AliMUONTrackExtrap::AddMCSEffectInAbsorber(AliMUONTrackParam* param, Double_t pathLength, Double_t f0, Double_t f1, Double_t f2) |
376 | { | |
377 | /// Add to the track parameter covariances the effects of multiple Coulomb scattering | |
690d2205 | 378 | /// The absorber correction parameters are supposed to be calculated at the current track z-position |
8cde4af5 | 379 | |
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) / | |
690d2205 | 385 | (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope); // velocity = 1 |
8cde4af5 | 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; | |
389 | ||
690d2205 | 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); | |
394 | ||
395 | // Set MCS covariance matrix | |
ea94c18b | 396 | TMatrixD newParamCov(param->GetCovariances()); |
8cde4af5 | 397 | // Non bending plane |
ea94c18b | 398 | newParamCov(0,0) += varCoor; newParamCov(0,1) += covCorrSlope; |
399 | newParamCov(1,0) += covCorrSlope; newParamCov(1,1) += varSlop; | |
8cde4af5 | 400 | // Bending plane |
ea94c18b | 401 | newParamCov(2,2) += varCoor; newParamCov(2,3) += covCorrSlope; |
402 | newParamCov(3,2) += covCorrSlope; newParamCov(3,3) += varSlop; | |
690d2205 | 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; | |
ea94c18b | 409 | |
410 | // Set new covariances | |
411 | param->SetCovariances(newParamCov); | |
690d2205 | 412 | } |
413 | ||
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) | |
419 | { | |
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 | |
424 | ||
425 | // Position of the Branson plane (spectro. (z<0)) | |
426 | Double_t zB = (f1>0.) ? absZBeg - f2/f1 : 0.; | |
427 | ||
428 | // Add MCS effects to current parameter covariances | |
429 | AddMCSEffectInAbsorber(param, pathLength, f0, f1, f2); | |
430 | ||
431 | // Get track parameters and covariances in the Branson plane corrected for magnetic field effect | |
432 | ExtrapToZCov(param,zVtx); | |
433 | LinearExtrapToZ(param,zB); | |
434 | ||
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)); | |
444 | ||
445 | // Get covariances in (X, SlopeX, Y, SlopeY, q*PTot) coordinate system | |
446 | TMatrixD paramCovP(param->GetCovariances()); | |
447 | Cov2CovP(param->GetParameters(),paramCovP); | |
448 | ||
449 | // Get the covariance matrix in the (XVtx, X, YVtx, Y, q*PTot) coordinate system | |
450 | TMatrixD paramCovVtx(5,5); | |
451 | paramCovVtx.Zero(); | |
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); | |
463 | ||
464 | // Jacobian of the transformation (XVtx, X, YVtx, Y, q*PTot) -> (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q*PTotVtx) | |
465 | TMatrixD jacob(5,5); | |
466 | jacob.UnitMatrix(); | |
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); | |
8cde4af5 | 471 | |
690d2205 | 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); | |
475 | ||
476 | // Compute covariances at vertex in the (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q/PyzVtx) coordinate system | |
477 | CovP2Cov(newParam,newParamCov); | |
478 | ||
479 | // Set parameters and covariances at vertex | |
480 | param->SetParameters(newParam); | |
481 | param->SetZ(zVtx); | |
482 | param->SetCovariances(newParamCov); | |
8cde4af5 | 483 | } |
484 | ||
690d2205 | 485 | //__________________________________________________________________________ |
486 | void AliMUONTrackExtrap::CorrectELossEffectInAbsorber(AliMUONTrackParam* param, Double_t eLoss, Double_t sigmaELoss2) | |
487 | { | |
488 | /// Correct parameters for energy loss and add energy loss fluctuation effect to covariances | |
489 | ||
490 | // Get parameter covariances in (X, SlopeX, Y, SlopeY, q*PTot) coordinate system | |
491 | TMatrixD newParamCov(param->GetCovariances()); | |
492 | Cov2CovP(param->GetParameters(),newParamCov); | |
493 | ||
494 | // Add effects of energy loss fluctuation to covariances | |
495 | newParamCov(4,4) += sigmaELoss2; | |
496 | ||
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)); | |
503 | ||
504 | // Get new parameter covariances in (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system | |
505 | CovP2Cov(param->GetParameters(),newParamCov); | |
506 | ||
507 | // Set new parameter covariances | |
508 | param->SetCovariances(newParamCov); | |
509 | } | |
510 | ||
511 | //__________________________________________________________________________ | |
18abc511 | 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) | |
8cde4af5 | 515 | { |
516 | /// Parameters used to correct for Multiple Coulomb Scattering and energy loss in absorber | |
690d2205 | 517 | /// Calculated assuming a linear propagation from trackXYZIn to trackXYZOut (order is important) |
8cde4af5 | 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) | |
84f061ef | 523 | // totalELoss: total energy loss in absorber |
8cde4af5 | 524 | |
525 | // Reset absorber's parameters | |
526 | pathLength = 0.; | |
527 | f0 = 0.; | |
528 | f1 = 0.; | |
529 | f2 = 0.; | |
530 | meanRho = 0.; | |
84f061ef | 531 | totalELoss = 0.; |
690d2205 | 532 | sigmaELoss2 = 0.; |
8cde4af5 | 533 | |
534 | // Check whether the geometry is available | |
535 | if (!gGeoManager) { | |
536 | cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: no TGeo"<<endl; | |
18abc511 | 537 | return kFALSE; |
8cde4af5 | 538 | } |
539 | ||
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])); | |
18abc511 | 544 | if (pathLength < TGeoShape::Tolerance()) return kFALSE; |
8cde4af5 | 545 | Double_t b[3]; |
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); | |
550 | if (!currentnode) { | |
551 | cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: start point out of geometry"<<endl; | |
18abc511 | 552 | return kFALSE; |
8cde4af5 | 553 | } |
554 | ||
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) | |
84f061ef | 558 | Double_t atomicA = 0.; // A of material |
559 | Double_t atomicZ = 0.; // Z of material | |
8cde4af5 | 560 | Double_t localPathLength = 0; |
561 | Double_t remainingPathLength = pathLength; | |
562 | Double_t zB = trackXYZIn[2]; | |
563 | Double_t zE, dzB, dzE; | |
564 | do { | |
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 | |
84f061ef | 570 | atomicA = material->GetA(); |
571 | atomicZ = material->GetZ(); | |
8cde4af5 | 572 | |
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; | |
578 | else { | |
579 | currentnode = gGeoManager->Step(); | |
580 | if (!currentnode) { | |
581 | cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: navigation failed"<<endl; | |
18abc511 | 582 | f0 = f1 = f2 = meanRho = totalELoss = sigmaELoss2 = 0.; |
583 | return kFALSE; | |
8cde4af5 | 584 | } |
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; | |
18abc511 | 591 | f0 = f1 = f2 = meanRho = totalELoss = sigmaELoss2 = 0.; |
592 | return kFALSE; | |
8cde4af5 | 593 | } |
594 | localPathLength += 0.001; | |
595 | } | |
596 | } | |
597 | ||
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; | |
84f061ef | 606 | totalELoss += BetheBloch(pTotal, localPathLength, rho, atomicA, atomicZ); |
690d2205 | 607 | sigmaELoss2 += EnergyLossFluctuation2(pTotal, localPathLength, rho, atomicA, atomicZ); |
8cde4af5 | 608 | |
609 | // prepare next step | |
610 | zB = zE; | |
611 | remainingPathLength -= localPathLength; | |
612 | } while (remainingPathLength > TGeoShape::Tolerance()); | |
613 | ||
614 | meanRho /= pathLength; | |
18abc511 | 615 | |
616 | return kTRUE; | |
8cde4af5 | 617 | } |
618 | ||
690d2205 | 619 | //__________________________________________________________________________ |
ea94c18b | 620 | Double_t AliMUONTrackExtrap::GetMCSAngle2(const AliMUONTrackParam& param, Double_t dZ, Double_t x0) |
621 | { | |
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. | |
625 | ||
626 | Double_t bendingSlope = param.GetBendingSlope(); | |
627 | Double_t nonBendingSlope = param.GetNonBendingSlope(); | |
628 | Double_t inverseTotalMomentum2 = param.GetInverseBendingMomentum() * param.GetInverseBendingMomentum() * | |
690d2205 | 629 | (1.0 + bendingSlope * bendingSlope) / |
630 | (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope); | |
ea94c18b | 631 | // Path length in the material |
632 | Double_t pathLength = TMath::Abs(dZ) * TMath::Sqrt(1.0 + bendingSlope*bendingSlope + nonBendingSlope*nonBendingSlope); | |
633 | // relativistic velocity | |
634 | Double_t velo = 1.; | |
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)); | |
637 | ||
638 | return theta02 * theta02 * inverseTotalMomentum2 * pathLength / x0; | |
639 | } | |
640 | ||
690d2205 | 641 | //__________________________________________________________________________ |
8cde4af5 | 642 | void AliMUONTrackExtrap::AddMCSEffect(AliMUONTrackParam *param, Double_t dZ, Double_t x0) |
208f139e | 643 | { |
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. | |
647 | ||
648 | Double_t bendingSlope = param->GetBendingSlope(); | |
649 | Double_t nonBendingSlope = param->GetNonBendingSlope(); | |
690d2205 | 650 | Double_t inverseBendingMomentum = param->GetInverseBendingMomentum(); |
651 | Double_t inverseTotalMomentum2 = inverseBendingMomentum * inverseBendingMomentum * | |
652 | (1.0 + bendingSlope * bendingSlope) / | |
653 | (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope); | |
208f139e | 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 | |
658 | Double_t velo = 1.; | |
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; | |
662 | ||
208f139e | 663 | Double_t varCoor = pathLength2 * theta02 / 3.; |
664 | Double_t varSlop = theta02; | |
665 | Double_t covCorrSlope = pathLength * theta02 / 2.; | |
ea94c18b | 666 | |
690d2205 | 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); | |
671 | ||
672 | // Set MCS covariance matrix | |
ea94c18b | 673 | TMatrixD newParamCov(param->GetCovariances()); |
208f139e | 674 | // Non bending plane |
ea94c18b | 675 | newParamCov(0,0) += varCoor; newParamCov(0,1) += covCorrSlope; |
676 | newParamCov(1,0) += covCorrSlope; newParamCov(1,1) += varSlop; | |
208f139e | 677 | // Bending plane |
ea94c18b | 678 | newParamCov(2,2) += varCoor; newParamCov(2,3) += covCorrSlope; |
679 | newParamCov(3,2) += covCorrSlope; newParamCov(3,3) += varSlop; | |
690d2205 | 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; | |
208f139e | 686 | |
ea94c18b | 687 | // Set new covariances |
688 | param->SetCovariances(newParamCov); | |
c04e3238 | 689 | } |
690 | ||
690d2205 | 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) | |
c04e3238 | 696 | { |
690d2205 | 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 | |
c04e3238 | 704 | |
8cde4af5 | 705 | if (trackParam->GetZ() == zVtx) return; // nothing to be done if already at vertex |
c04e3238 | 706 | |
8cde4af5 | 707 | if (trackParam->GetZ() > zVtx) { // spectro. (z<0) |
690d2205 | 708 | cout<<"E-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ() |
709 | <<") upstream the vertex (zVtx = "<<zVtx<<")"<<endl; | |
fac70e25 | 710 | return; |
711 | } | |
712 | ||
8cde4af5 | 713 | // Check the vertex position relatively to the absorber |
ea94c18b | 714 | if (zVtx < AliMUONConstants::AbsZBeg() && zVtx > AliMUONConstants::AbsZEnd()) { // spectro. (z<0) |
8cde4af5 | 715 | cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Ending Z ("<<zVtx |
690d2205 | 716 | <<") inside the front absorber ("<<AliMUONConstants::AbsZBeg()<<","<<AliMUONConstants::AbsZEnd()<<")"<<endl; |
ea94c18b | 717 | } else if (zVtx < AliMUONConstants::AbsZEnd() ) { // spectro. (z<0) |
8cde4af5 | 718 | cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Ending Z ("<<zVtx |
690d2205 | 719 | <<") downstream the front absorber (zAbsorberEnd = "<<AliMUONConstants::AbsZEnd()<<")"<<endl; |
720 | if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx); | |
721 | else ExtrapToZ(trackParam,zVtx); | |
8cde4af5 | 722 | return; |
723 | } | |
724 | ||
725 | // Check the track position relatively to the absorber and extrapolate track parameters to the end of the absorber if needed | |
ea94c18b | 726 | if (trackParam->GetZ() > AliMUONConstants::AbsZBeg()) { // spectro. (z<0) |
8cde4af5 | 727 | cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ() |
690d2205 | 728 | <<") upstream the front absorber (zAbsorberBegin = "<<AliMUONConstants::AbsZBeg()<<")"<<endl; |
729 | if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx); | |
730 | else ExtrapToZ(trackParam,zVtx); | |
8cde4af5 | 731 | return; |
ea94c18b | 732 | } else if (trackParam->GetZ() > AliMUONConstants::AbsZEnd()) { // spectro. (z<0) |
8cde4af5 | 733 | cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ() |
690d2205 | 734 | <<") inside the front absorber ("<<AliMUONConstants::AbsZBeg()<<","<<AliMUONConstants::AbsZEnd()<<")"<<endl; |
c04e3238 | 735 | } else { |
690d2205 | 736 | if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,AliMUONConstants::AbsZEnd()); |
737 | else ExtrapToZ(trackParam,AliMUONConstants::AbsZEnd()); | |
c04e3238 | 738 | } |
c04e3238 | 739 | |
690d2205 | 740 | // Get absorber correction parameters assuming linear propagation in absorber |
8cde4af5 | 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]; | |
690d2205 | 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]); | |
750 | } else { | |
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(); | |
756 | } | |
84f061ef | 757 | Double_t pTot = trackParam->P(); |
18abc511 | 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); | |
763 | return; | |
764 | } | |
8cde4af5 | 765 | |
690d2205 | 766 | // Compute track parameters and covariances at vertex according to correctForMCS and correctForEnergyLoss flags |
767 | if (correctForMCS) { | |
fac70e25 | 768 | |
690d2205 | 769 | if (correctForEnergyLoss) { |
770 | ||
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); | |
776 | ||
777 | } else { | |
778 | ||
779 | // Correct for multiple scattering | |
780 | CorrectMCSEffectInAbsorber(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx, | |
781 | trackXYZIn[2], pathLength, f0, f1, f2); | |
782 | } | |
fac70e25 | 783 | |
fac70e25 | 784 | } else { |
690d2205 | 785 | |
786 | if (correctForEnergyLoss) { | |
787 | ||
18abc511 | 788 | // Correct for energy loss add multiple scattering dispersion in covariance matrix |
690d2205 | 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); | |
794 | ||
795 | } else { | |
796 | ||
18abc511 | 797 | // add multiple scattering dispersion in covariance matrix |
690d2205 | 798 | AddMCSEffectInAbsorber(trackParam, pathLength, f0, f1, f2); |
799 | ExtrapToZCov(trackParam, zVtx); | |
800 | ||
801 | } | |
802 | ||
fac70e25 | 803 | } |
8cde4af5 | 804 | |
fac70e25 | 805 | } |
806 | ||
690d2205 | 807 | //__________________________________________________________________________ |
808 | void AliMUONTrackExtrap::ExtrapToVertex(AliMUONTrackParam* trackParam, | |
809 | Double_t xVtx, Double_t yVtx, Double_t zVtx, | |
810 | Double_t errXVtx, Double_t errYVtx) | |
811 | { | |
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); | |
815 | } | |
816 | ||
817 | //__________________________________________________________________________ | |
818 | void AliMUONTrackExtrap::ExtrapToVertexWithoutELoss(AliMUONTrackParam* trackParam, | |
819 | Double_t xVtx, Double_t yVtx, Double_t zVtx, | |
820 | Double_t errXVtx, Double_t errYVtx) | |
821 | { | |
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); | |
825 | } | |
826 | ||
827 | //__________________________________________________________________________ | |
828 | void AliMUONTrackExtrap::ExtrapToVertexWithoutBranson(AliMUONTrackParam* trackParam, Double_t zVtx) | |
829 | { | |
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); | |
833 | } | |
834 | ||
835 | //__________________________________________________________________________ | |
836 | void AliMUONTrackExtrap::ExtrapToVertexUncorrected(AliMUONTrackParam* trackParam, Double_t zVtx) | |
837 | { | |
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); | |
841 | } | |
842 | ||
843 | //__________________________________________________________________________ | |
fac70e25 | 844 | Double_t AliMUONTrackExtrap::TotalMomentumEnergyLoss(AliMUONTrackParam* trackParam, Double_t xVtx, Double_t yVtx, Double_t zVtx) |
845 | { | |
846 | /// Calculate the total momentum energy loss in-between the track position and the vertex assuming a linear propagation | |
847 | ||
848 | if (trackParam->GetZ() == zVtx) return 0.; // nothing to be done if already at vertex | |
8cde4af5 | 849 | |
fac70e25 | 850 | // Check whether the geometry is available |
851 | if (!gGeoManager) { | |
852 | cout<<"E-AliMUONTrackExtrap::TotalMomentumEnergyLoss: no TGeo"<<endl; | |
853 | return 0.; | |
854 | } | |
855 | ||
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; | |
84f061ef | 865 | Double_t pTot = trackParam->P(); |
18abc511 | 866 | Double_t pathLength, f0, f1, f2, meanRho, totalELoss, sigmaELoss2; |
690d2205 | 867 | GetAbsorberCorrectionParam(trackXYZIn,trackXYZOut,pTot,pathLength,f0,f1,f2,meanRho,totalELoss,sigmaELoss2); |
fac70e25 | 868 | |
84f061ef | 869 | return totalELoss; |
c04e3238 | 870 | } |
871 | ||
690d2205 | 872 | //__________________________________________________________________________ |
84f061ef | 873 | Double_t AliMUONTrackExtrap::BetheBloch(Double_t pTotal, Double_t pathLength, Double_t rho, Double_t atomicA, Double_t atomicZ) |
c04e3238 | 874 | { |
84f061ef | 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) | |
8cde4af5 | 881 | Double_t p2=pTotal*pTotal; |
882 | Double_t beta2=p2/(p2 + muMass*muMass); | |
8cde4af5 | 883 | |
84f061ef | 884 | Double_t w = k * rho * pathLength * atomicZ / atomicA / beta2; |
885 | ||
8cde4af5 | 886 | if (beta2/(1-beta2)>3.5*3.5) |
690d2205 | 887 | return w * (log(2.*eMass*3.5/(i*atomicZ)) + 0.5*log(beta2/(1-beta2)) - beta2); |
888 | ||
84f061ef | 889 | return w * (log(2.*eMass*beta2/(1-beta2)/(i*atomicZ)) - beta2); |
c04e3238 | 890 | } |
891 | ||
690d2205 | 892 | //__________________________________________________________________________ |
893 | Double_t AliMUONTrackExtrap::EnergyLossFluctuation2(Double_t pTotal, Double_t pathLength, Double_t rho, Double_t atomicA, Double_t atomicZ) | |
894 | { | |
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); | |
902 | ||
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) | |
905 | ||
906 | //sigma2 = k * rho * pathLength * atomicZ / atomicA * eMass; // sigma2 of the energy loss gaussian distribution | |
907 | ||
908 | return sigma2; | |
909 | } | |
910 | ||
911 | //__________________________________________________________________________ | |
912 | void AliMUONTrackExtrap::Cov2CovP(const TMatrixD ¶m, TMatrixD &cov) | |
913 | { | |
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 | |
916 | ||
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); | |
920 | ||
921 | // Jacobian of the opposite transformation | |
922 | TMatrixD jacob(5,5); | |
923 | jacob.UnitMatrix(); | |
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); | |
928 | ||
929 | // compute covariances in new coordinate system | |
930 | TMatrixD tmp(cov,TMatrixD::kMultTranspose,jacob); | |
931 | cov.Mult(jacob,tmp); | |
932 | } | |
933 | ||
934 | //__________________________________________________________________________ | |
935 | void AliMUONTrackExtrap::CovP2Cov(const TMatrixD ¶m, TMatrixD &covP) | |
936 | { | |
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 | |
939 | ||
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); | |
943 | ||
944 | // Jacobian of the transformation | |
945 | TMatrixD jacob(5,5); | |
946 | jacob.UnitMatrix(); | |
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; | |
951 | ||
952 | // compute covariances in new coordinate system | |
953 | TMatrixD tmp(covP,TMatrixD::kMultTranspose,jacob); | |
954 | covP.Mult(jacob,tmp); | |
955 | } | |
956 | ||
c04e3238 | 957 | //__________________________________________________________________________ |
958 | void AliMUONTrackExtrap::ExtrapOneStepHelix(Double_t charge, Double_t step, Double_t *vect, Double_t *vout) | |
959 | { | |
71a2d3aa | 960 | /// <pre> |
c04e3238 | 961 | /// ****************************************************************** |
962 | /// * * | |
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. * | |
966 | /// * Parameters: * | |
967 | /// * input * | |
968 | /// * STEP =arc length of the step asked * | |
969 | /// * VECT =input vector (position,direction cos and momentum) * | |
970 | /// * CHARGE= electric charge of the particle * | |
971 | /// * output * | |
972 | /// * VOUT = same as VECT after completion of the step * | |
973 | /// * * | |
2060b217 | 974 | /// * ==>Called by : USER, GUSWIM * |
c04e3238 | 975 | /// * Author m.hansroul ********* * |
976 | /// * modified s.egli, s.v.levonian * | |
977 | /// * modified v.perevoztchikov | |
978 | /// * * | |
979 | /// ****************************************************************** | |
71a2d3aa | 980 | /// </pre> |
c04e3238 | 981 | |
982 | // modif: everything in double precision | |
983 | ||
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; | |
988 | ||
989 | const Int_t kix = 0; | |
990 | const Int_t kiy = 1; | |
991 | const Int_t kiz = 2; | |
992 | const Int_t kipx = 3; | |
993 | const Int_t kipy = 4; | |
994 | const Int_t kipz = 5; | |
995 | const Int_t kipp = 6; | |
996 | ||
997 | const Double_t kec = 2.9979251e-4; | |
998 | // | |
999 | // ------------------------------------------------------------------ | |
1000 | // | |
1001 | // units are kgauss,centimeters,gev/c | |
1002 | // | |
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]; | |
1008 | } | |
1009 | return; | |
1010 | } | |
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]; | |
1014 | ||
1015 | //cmodif: call gufld (xyz, h) changed into: | |
1016 | GetField (xyz, h); | |
1017 | ||
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]; | |
1024 | } | |
1025 | return; | |
1026 | } | |
1027 | if (h2xy < 1.e-12*h[3]) { | |
1028 | ExtrapOneStepHelix3(charge*h[2], step, vect, vout); | |
1029 | return; | |
1030 | } | |
1031 | h[3] = TMath::Sqrt(h[3]); | |
1032 | h[0] /= h[3]; | |
1033 | h[1] /= h[3]; | |
1034 | h[2] /= h[3]; | |
1035 | h[3] *= kec; | |
1036 | ||
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]; | |
1040 | ||
1041 | hp = h[0]*vect[kipx] + h[1]*vect[kipy] + h[2]*vect[kipz]; | |
1042 | ||
1043 | rho = -charge*h[3]/vect[kipp]; | |
1044 | tet = rho * step; | |
1045 | ||
1046 | if (TMath::Abs(tet) > 0.15) { | |
1047 | sint = TMath::Sin(tet); | |
1048 | sintt = (sint/tet); | |
1049 | tsint = (tet-sint)/tet; | |
1050 | cos1t = 2.*(TMath::Sin(0.5*tet))*(TMath::Sin(0.5*tet))/tet; | |
1051 | } else { | |
1052 | tsint = tet*tet/36.; | |
1053 | sintt = (1. - tsint); | |
1054 | sint = tet*sintt; | |
1055 | cos1t = 0.5*tet; | |
1056 | } | |
1057 | ||
1058 | f1 = step * sintt; | |
1059 | f2 = step * cos1t; | |
1060 | f3 = step * tsint * hp; | |
1061 | f4 = -tet*cos1t; | |
1062 | f5 = sint; | |
1063 | f6 = tet * cos1t * hp; | |
1064 | ||
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]; | |
1068 | ||
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]; | |
1072 | ||
1073 | return; | |
1074 | } | |
1075 | ||
1076 | //__________________________________________________________________________ | |
1077 | void AliMUONTrackExtrap::ExtrapOneStepHelix3(Double_t field, Double_t step, Double_t *vect, Double_t *vout) | |
1078 | { | |
71a2d3aa | 1079 | /// <pre> |
c04e3238 | 1080 | /// ****************************************************************** |
1081 | /// * * | |
1082 | /// * Tracking routine in a constant field oriented * | |
1083 | /// * along axis 3 * | |
1084 | /// * Tracking is performed with a conventional * | |
1085 | /// * helix step method * | |
1086 | /// * * | |
2060b217 | 1087 | /// * ==>Called by : USER, GUSWIM * |
c04e3238 | 1088 | /// * Authors R.Brun, M.Hansroul ********* * |
1089 | /// * Rewritten V.Perevoztchikov | |
1090 | /// * * | |
1091 | /// ****************************************************************** | |
71a2d3aa | 1092 | /// </pre> |
c04e3238 | 1093 | |
1094 | Double_t hxp[3]; | |
1095 | Double_t h4, hp, rho, tet; | |
1096 | Double_t sint, sintt, tsint, cos1t; | |
1097 | Double_t f1, f2, f3, f4, f5, f6; | |
1098 | ||
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; | |
1106 | ||
1107 | const Double_t kec = 2.9979251e-4; | |
1108 | ||
1109 | // | |
1110 | // ------------------------------------------------------------------ | |
1111 | // | |
1112 | // units are kgauss,centimeters,gev/c | |
1113 | // | |
1114 | vout[kipp] = vect[kipp]; | |
1115 | h4 = field * kec; | |
1116 | ||
1117 | hxp[0] = - vect[kipy]; | |
1118 | hxp[1] = + vect[kipx]; | |
1119 | ||
1120 | hp = vect[kipz]; | |
1121 | ||
1122 | rho = -h4/vect[kipp]; | |
1123 | tet = rho * step; | |
1124 | if (TMath::Abs(tet) > 0.15) { | |
1125 | sint = TMath::Sin(tet); | |
1126 | sintt = (sint/tet); | |
1127 | tsint = (tet-sint)/tet; | |
1128 | cos1t = 2.* TMath::Sin(0.5*tet) * TMath::Sin(0.5*tet)/tet; | |
1129 | } else { | |
1130 | tsint = tet*tet/36.; | |
1131 | sintt = (1. - tsint); | |
1132 | sint = tet*sintt; | |
1133 | cos1t = 0.5*tet; | |
1134 | } | |
1135 | ||
1136 | f1 = step * sintt; | |
1137 | f2 = step * cos1t; | |
1138 | f3 = step * tsint * hp; | |
1139 | f4 = -tet*cos1t; | |
1140 | f5 = sint; | |
1141 | f6 = tet * cos1t * hp; | |
1142 | ||
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; | |
1146 | ||
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; | |
1150 | ||
1151 | return; | |
1152 | } | |
8cde4af5 | 1153 | |
c04e3238 | 1154 | //__________________________________________________________________________ |
1155 | void AliMUONTrackExtrap::ExtrapOneStepRungekutta(Double_t charge, Double_t step, Double_t* vect, Double_t* vout) | |
1156 | { | |
71a2d3aa | 1157 | /// <pre> |
c04e3238 | 1158 | /// ****************************************************************** |
1159 | /// * * | |
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) * | |
1163 | /// * * | |
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) * | |
1172 | /// * * | |
2060b217 | 1173 | /// * ==>Called by : USER, GUSWIM * |
c04e3238 | 1174 | /// * Authors R.Brun, M.Hansroul ********* * |
1175 | /// * V.Perevoztchikov (CUT STEP implementation) * | |
1176 | /// * * | |
1177 | /// * * | |
1178 | /// ****************************************************************** | |
71a2d3aa | 1179 | /// </pre> |
c04e3238 | 1180 | |
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; | |
1187 | ||
1188 | Double_t x; | |
1189 | Double_t y; | |
1190 | Double_t z; | |
1191 | ||
1192 | Double_t xt; | |
1193 | Double_t yt; | |
1194 | Double_t zt; | |
1195 | ||
1196 | Double_t maxit = 1992; | |
1197 | Double_t maxcut = 11; | |
1198 | ||
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; | |
1204 | ||
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; | |
1212 | ||
1213 | // *. | |
1214 | // *. ------------------------------------------------------------------ | |
1215 | // *. | |
1216 | // * this constant is for units cm,gev/c and kgauss | |
1217 | // * | |
1218 | Int_t iter = 0; | |
1219 | Int_t ncut = 0; | |
1220 | for(Int_t j = 0; j < 7; j++) | |
1221 | vout[j] = vect[j]; | |
1222 | ||
1223 | Double_t pinv = kec * charge / vect[6]; | |
1224 | Double_t tl = 0.; | |
1225 | Double_t h = step; | |
1226 | Double_t rest; | |
1227 | ||
1228 | ||
1229 | do { | |
1230 | rest = step - tl; | |
1231 | if (TMath::Abs(h) > TMath::Abs(rest)) h = rest; | |
1232 | //cmodif: call gufld(vout,f) changed into: | |
1233 | ||
1234 | GetField(vout,f); | |
1235 | ||
1236 | // * | |
1237 | // * start of integration | |
1238 | // * | |
1239 | x = vout[0]; | |
1240 | y = vout[1]; | |
1241 | z = vout[2]; | |
1242 | a = vout[3]; | |
1243 | b = vout[4]; | |
1244 | c = vout[5]; | |
1245 | ||
1246 | h2 = khalf * h; | |
1247 | h4 = khalf * h2; | |
1248 | ph = pinv * h; | |
1249 | ph2 = khalf * ph; | |
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; | |
1255 | ||
1256 | dxt = h2 * a + h4 * secxs[0]; | |
1257 | dyt = h2 * b + h4 * secys[0]; | |
1258 | dzt = h2 * c + h4 * seczs[0]; | |
1259 | xt = x + dxt; | |
1260 | yt = y + dyt; | |
1261 | zt = z + dzt; | |
1262 | // * | |
1263 | // * second intermediate point | |
1264 | // * | |
1265 | ||
1266 | est = TMath::Abs(dxt) + TMath::Abs(dyt) + TMath::Abs(dzt); | |
1267 | if (est > h) { | |
1268 | if (ncut++ > maxcut) break; | |
1269 | h *= khalf; | |
1270 | continue; | |
1271 | } | |
1272 | ||
1273 | xyzt[0] = xt; | |
1274 | xyzt[1] = yt; | |
1275 | xyzt[2] = zt; | |
1276 | ||
1277 | //cmodif: call gufld(xyzt,f) changed into: | |
1278 | GetField(xyzt,f); | |
1279 | ||
1280 | at = a + secxs[0]; | |
1281 | bt = b + secys[0]; | |
1282 | ct = c + seczs[0]; | |
1283 | ||
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; | |
1287 | at = a + secxs[1]; | |
1288 | bt = b + secys[1]; | |
1289 | ct = c + seczs[1]; | |
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]); | |
1296 | xt = x + dxt; | |
1297 | yt = y + dyt; | |
1298 | zt = z + dzt; | |
1299 | at = a + 2.*secxs[2]; | |
1300 | bt = b + 2.*secys[2]; | |
1301 | ct = c + 2.*seczs[2]; | |
1302 | ||
1303 | est = TMath::Abs(dxt)+TMath::Abs(dyt)+TMath::Abs(dzt); | |
1304 | if (est > 2.*TMath::Abs(h)) { | |
1305 | if (ncut++ > maxcut) break; | |
1306 | h *= khalf; | |
1307 | continue; | |
1308 | } | |
1309 | ||
1310 | xyzt[0] = xt; | |
1311 | xyzt[1] = yt; | |
1312 | xyzt[2] = zt; | |
1313 | ||
1314 | //cmodif: call gufld(xyzt,f) changed into: | |
1315 | GetField(xyzt,f); | |
1316 | ||
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; | |
1320 | ||
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; | |
1327 | ||
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])); | |
1331 | ||
1332 | if (est > kdlt && TMath::Abs(h) > 1.e-4) { | |
1333 | if (ncut++ > maxcut) break; | |
1334 | h *= khalf; | |
1335 | continue; | |
1336 | } | |
1337 | ||
1338 | ncut = 0; | |
1339 | // * if too many iterations, go to helix | |
1340 | if (iter++ > maxit) break; | |
1341 | ||
1342 | tl += h; | |
1343 | if (est < kdlt32) | |
1344 | h *= 2.; | |
1345 | cba = 1./ TMath::Sqrt(a*a + b*b + c*c); | |
1346 | vout[0] = x; | |
1347 | vout[1] = y; | |
1348 | vout[2] = z; | |
1349 | vout[3] = cba*a; | |
1350 | vout[4] = cba*b; | |
1351 | vout[5] = cba*c; | |
1352 | rest = step - tl; | |
1353 | if (step < 0.) rest = -rest; | |
1354 | if (rest < 1.e-5*TMath::Abs(step)) return; | |
1355 | ||
1356 | } while(1); | |
1357 | ||
1358 | // angle too big, use helix | |
1359 | ||
1360 | f1 = f[0]; | |
1361 | f2 = f[1]; | |
1362 | f3 = f[2]; | |
1363 | f4 = TMath::Sqrt(f1*f1+f2*f2+f3*f3); | |
1364 | rho = -f4*pinv; | |
1365 | tet = rho * step; | |
1366 | ||
1367 | hnorm = 1./f4; | |
1368 | f1 = f1*hnorm; | |
1369 | f2 = f2*hnorm; | |
1370 | f3 = f3*hnorm; | |
1371 | ||
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]; | |
1375 | ||
1376 | hp = f1*vect[kipx] + f2*vect[kipy] + f3*vect[kipz]; | |
1377 | ||
1378 | rho1 = 1./rho; | |
1379 | sint = TMath::Sin(tet); | |
1380 | cost = 2.*TMath::Sin(khalf*tet)*TMath::Sin(khalf*tet); | |
1381 | ||
1382 | g1 = sint*rho1; | |
1383 | g2 = cost*rho1; | |
1384 | g3 = (tet-sint) * hp*rho1; | |
1385 | g4 = -cost; | |
1386 | g5 = sint; | |
1387 | g6 = cost * hp; | |
1388 | ||
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; | |
1392 | ||
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; | |
1396 | ||
1397 | return; | |
1398 | } | |
8cde4af5 | 1399 | |
c04e3238 | 1400 | //___________________________________________________________ |
690d2205 | 1401 | void AliMUONTrackExtrap::GetField(Double_t *Position, Double_t *Field) |
c04e3238 | 1402 | { |
1403 | /// interface for arguments in double precision (Why ? ChF) | |
1404 | Float_t x[3], b[3]; | |
690d2205 | 1405 | |
c04e3238 | 1406 | x[0] = Position[0]; x[1] = Position[1]; x[2] = Position[2]; |
690d2205 | 1407 | |
c04e3238 | 1408 | if (fgkField) fgkField->Field(x,b); |
1409 | else { | |
1410 | cout<<"F-AliMUONTrackExtrap::GetField: fgkField = 0x0"<<endl; | |
1411 | exit(-1); | |
1412 | } | |
1413 | ||
1414 | Field[0] = b[0]; Field[1] = b[1]; Field[2] = b[2]; | |
690d2205 | 1415 | |
c04e3238 | 1416 | return; |
1417 | } |