]>
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 | |
ecdf58c4 | 30 | #include "AliMagF.h" |
31 | #include "AliExternalTrackParam.h" | |
8cde4af5 | 32 | |
f7a1cc68 | 33 | #include <TGeoGlobalMagField.h> |
8cde4af5 | 34 | #include <TGeoManager.h> |
f7a1cc68 | 35 | #include <TMath.h> |
ecdf58c4 | 36 | #include <TDatabasePDG.h> |
c04e3238 | 37 | |
ea94c18b | 38 | #include <Riostream.h> |
39 | ||
cdd730d0 | 40 | using std::endl; |
41 | using std::cout; | |
78649106 | 42 | /// \cond CLASSIMP |
c04e3238 | 43 | ClassImp(AliMUONTrackExtrap) // Class implementation in ROOT context |
78649106 | 44 | /// \endcond |
c04e3238 | 45 | |
9f093251 | 46 | const Double_t AliMUONTrackExtrap::fgkSimpleBPosition = 0.5 * (AliMUONConstants::CoilZ() + AliMUONConstants::YokeZ()); |
47 | const Double_t AliMUONTrackExtrap::fgkSimpleBLength = 0.5 * (AliMUONConstants::CoilL() + AliMUONConstants::YokeL()); | |
48 | Double_t AliMUONTrackExtrap::fgSimpleBValue = 0.; | |
49 | Bool_t AliMUONTrackExtrap::fgFieldON = kFALSE; | |
4284483e | 50 | const Bool_t AliMUONTrackExtrap::fgkUseHelix = kFALSE; |
208f139e | 51 | const Int_t AliMUONTrackExtrap::fgkMaxStepNumber = 5000; |
4284483e | 52 | const Double_t AliMUONTrackExtrap::fgkHelixStepLength = 6.; |
53 | const Double_t AliMUONTrackExtrap::fgkRungeKuttaMaxResidue = 0.002; | |
208f139e | 54 | |
9f093251 | 55 | //__________________________________________________________________________ |
f7a1cc68 | 56 | void AliMUONTrackExtrap::SetField() |
9f093251 | 57 | { |
cddcc1f3 | 58 | /// set field on/off flag; |
59 | /// set field at the centre of the dipole | |
f7a1cc68 | 60 | const Double_t x[3] = {50.,50.,fgkSimpleBPosition}; |
61 | Double_t b[3] = {0.,0.,0.}; | |
62 | TGeoGlobalMagField::Instance()->Field(x,b); | |
63 | fgSimpleBValue = b[0]; | |
ade4e6f9 | 64 | fgFieldON = (TMath::Abs(fgSimpleBValue) > 1.e-10) ? kTRUE : kFALSE; |
9f093251 | 65 | |
66 | } | |
67 | ||
690d2205 | 68 | //__________________________________________________________________________ |
208f139e | 69 | Double_t AliMUONTrackExtrap::GetImpactParamFromBendingMomentum(Double_t bendingMomentum) |
70 | { | |
71 | /// Returns impact parameter at vertex in bending plane (cm), | |
72 | /// from the signed bending momentum "BendingMomentum" in bending plane (GeV/c), | |
73 | /// using simple values for dipole magnetic field. | |
74 | /// The sign of "BendingMomentum" is the sign of the charge. | |
75 | ||
76 | if (bendingMomentum == 0.) return 1.e10; | |
77 | ||
6b191dea | 78 | const Double_t kCorrectionFactor = 1.1; // impact parameter is 10% underestimated |
9f093251 | 79 | |
80 | return kCorrectionFactor * (-0.0003 * fgSimpleBValue * fgkSimpleBLength * fgkSimpleBPosition / bendingMomentum); | |
208f139e | 81 | } |
82 | ||
690d2205 | 83 | //__________________________________________________________________________ |
9bdbee64 | 84 | Double_t |
85 | AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(Double_t impactParam) | |
208f139e | 86 | { |
87 | /// Returns signed bending momentum in bending plane (GeV/c), | |
88 | /// the sign being the sign of the charge for particles moving forward in Z, | |
89 | /// from the impact parameter "ImpactParam" at vertex in bending plane (cm), | |
90 | /// using simple values for dipole magnetic field. | |
91 | ||
92 | if (impactParam == 0.) return 1.e10; | |
93 | ||
9f093251 | 94 | const Double_t kCorrectionFactor = 1.1; // bending momentum is 10% underestimated |
95 | ||
9bdbee64 | 96 | if (fgFieldON) |
97 | { | |
98 | return kCorrectionFactor * (-0.0003 * fgSimpleBValue * fgkSimpleBLength * fgkSimpleBPosition / impactParam); | |
99 | } | |
100 | else | |
101 | { | |
102 | return AliMUONConstants::GetMostProbBendingMomentum(); | |
103 | } | |
019df241 | 104 | } |
105 | ||
690d2205 | 106 | //__________________________________________________________________________ |
3fe6651e | 107 | void AliMUONTrackExtrap::LinearExtrapToZ(AliMUONTrackParam* trackParam, Double_t zEnd) |
019df241 | 108 | { |
3fe6651e | 109 | /// Track parameters linearly extrapolated to the plane at "zEnd". |
019df241 | 110 | /// On return, results from the extrapolation are updated in trackParam. |
111 | ||
112 | if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z | |
113 | ||
114 | // Compute track parameters | |
115 | Double_t dZ = zEnd - trackParam->GetZ(); | |
116 | trackParam->SetNonBendingCoor(trackParam->GetNonBendingCoor() + trackParam->GetNonBendingSlope() * dZ); | |
117 | trackParam->SetBendingCoor(trackParam->GetBendingCoor() + trackParam->GetBendingSlope() * dZ); | |
118 | trackParam->SetZ(zEnd); | |
3fe6651e | 119 | } |
120 | ||
121 | //__________________________________________________________________________ | |
122 | void AliMUONTrackExtrap::LinearExtrapToZCov(AliMUONTrackParam* trackParam, Double_t zEnd, Bool_t updatePropagator) | |
123 | { | |
124 | /// Track parameters and their covariances linearly extrapolated to the plane at "zEnd". | |
125 | /// On return, results from the extrapolation are updated in trackParam. | |
019df241 | 126 | |
3fe6651e | 127 | if (trackParam->GetZ() == zEnd) return; // nothing to be done if same z |
128 | ||
129 | // No need to propagate the covariance matrix if it does not exist | |
130 | if (!trackParam->CovariancesExist()) { | |
131 | cout<<"W-AliMUONTrackExtrap::LinearExtrapToZCov: Covariance matrix does not exist"<<endl; | |
132 | // Extrapolate linearly track parameters to "zEnd" | |
133 | LinearExtrapToZ(trackParam,zEnd); | |
134 | return; | |
019df241 | 135 | } |
136 | ||
3fe6651e | 137 | // Compute track parameters |
138 | Double_t dZ = zEnd - trackParam->GetZ(); | |
139 | trackParam->SetNonBendingCoor(trackParam->GetNonBendingCoor() + trackParam->GetNonBendingSlope() * dZ); | |
140 | trackParam->SetBendingCoor(trackParam->GetBendingCoor() + trackParam->GetBendingSlope() * dZ); | |
141 | trackParam->SetZ(zEnd); | |
142 | ||
143 | // Calculate the jacobian related to the track parameters linear extrapolation to "zEnd" | |
144 | TMatrixD jacob(5,5); | |
145 | jacob.UnitMatrix(); | |
146 | jacob(0,1) = dZ; | |
147 | jacob(2,3) = dZ; | |
148 | ||
149 | // Extrapolate track parameter covariances to "zEnd" | |
150 | TMatrixD tmp(trackParam->GetCovariances(),TMatrixD::kMultTranspose,jacob); | |
151 | TMatrixD tmp2(jacob,TMatrixD::kMult,tmp); | |
152 | trackParam->SetCovariances(tmp2); | |
153 | ||
154 | // Update the propagator if required | |
155 | if (updatePropagator) trackParam->UpdatePropagator(jacob); | |
208f139e | 156 | } |
c04e3238 | 157 | |
690d2205 | 158 | //__________________________________________________________________________ |
4ea3f013 | 159 | Bool_t AliMUONTrackExtrap::ExtrapToZ(AliMUONTrackParam* trackParam, Double_t zEnd) |
c04e3238 | 160 | { |
4284483e | 161 | /// Interface to track parameter extrapolation to the plane at "Z" using Helix or Rungekutta algorithm. |
162 | /// On return, the track parameters resulting from the extrapolation are updated in trackParam. | |
4ea3f013 | 163 | if (!fgFieldON) { |
164 | AliMUONTrackExtrap::LinearExtrapToZ(trackParam,zEnd); | |
165 | return kTRUE; | |
166 | } | |
167 | else if (fgkUseHelix) return AliMUONTrackExtrap::ExtrapToZHelix(trackParam,zEnd); | |
168 | else return AliMUONTrackExtrap::ExtrapToZRungekutta(trackParam,zEnd); | |
4284483e | 169 | } |
170 | ||
690d2205 | 171 | //__________________________________________________________________________ |
4ea3f013 | 172 | Bool_t AliMUONTrackExtrap::ExtrapToZHelix(AliMUONTrackParam* trackParam, Double_t zEnd) |
4284483e | 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. |
4ea3f013 | 176 | if (trackParam->GetZ() == zEnd) return kTRUE; // nothing to be done if same Z |
c04e3238 | 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); |
4ea3f013 | 222 | return kTRUE; |
c04e3238 | 223 | } |
224 | ||
690d2205 | 225 | //__________________________________________________________________________ |
4ea3f013 | 226 | Bool_t AliMUONTrackExtrap::ExtrapToZRungekutta(AliMUONTrackParam* trackParam, Double_t zEnd) |
4284483e | 227 | { |
228 | /// Track parameter extrapolation to the plane at "Z" using Rungekutta algorithm. | |
229 | /// On return, the track parameters resulting from the extrapolation are updated in trackParam. | |
4ea3f013 | 230 | if (trackParam->GetZ() == zEnd) return kTRUE; // nothing to be done if same Z |
4284483e | 231 | Double_t forwardBackward; // +1 if forward, -1 if backward |
232 | if (zEnd < trackParam->GetZ()) forwardBackward = 1.0; // spectro. z<0 | |
233 | else forwardBackward = -1.0; | |
234 | // sign of charge (sign of fInverseBendingMomentum if forward motion) | |
235 | // must be changed if backward extrapolation | |
236 | Double_t chargeExtrap = forwardBackward * TMath::Sign(Double_t(1.0), trackParam->GetInverseBendingMomentum()); | |
237 | Double_t v3[7], v3New[7]; | |
238 | Double_t dZ, step; | |
239 | Int_t stepNumber = 0; | |
240 | ||
4ea3f013 | 241 | // Extrapolation loop (until within tolerance or the track turn around) |
4284483e | 242 | Double_t residue = zEnd - trackParam->GetZ(); |
4ea3f013 | 243 | Bool_t uturn = kFALSE; |
ade4e6f9 | 244 | Bool_t trackingFailed = kFALSE; |
4ea3f013 | 245 | Bool_t tooManyStep = kFALSE; |
4284483e | 246 | while (TMath::Abs(residue) > fgkRungeKuttaMaxResidue && stepNumber <= fgkMaxStepNumber) { |
4ea3f013 | 247 | |
4284483e | 248 | dZ = zEnd - trackParam->GetZ(); |
249 | // step lenght assuming linear trajectory | |
250 | step = dZ * TMath::Sqrt(1.0 + trackParam->GetBendingSlope()*trackParam->GetBendingSlope() + | |
690d2205 | 251 | trackParam->GetNonBendingSlope()*trackParam->GetNonBendingSlope()); |
4284483e | 252 | ConvertTrackParamForExtrap(trackParam, forwardBackward, v3); |
4ea3f013 | 253 | |
4284483e | 254 | do { // reduce step lenght while zEnd oversteped |
255 | if (stepNumber > fgkMaxStepNumber) { | |
256 | cout<<"W-AliMUONTrackExtrap::ExtrapToZRungekutta: Too many trials: "<<stepNumber<<endl; | |
4ea3f013 | 257 | tooManyStep = kTRUE; |
4284483e | 258 | break; |
259 | } | |
260 | stepNumber ++; | |
261 | step = TMath::Abs(step); | |
ade4e6f9 | 262 | if (!AliMUONTrackExtrap::ExtrapOneStepRungekutta(chargeExtrap,step,v3,v3New)) { |
263 | trackingFailed = kTRUE; | |
264 | break; | |
265 | } | |
4284483e | 266 | residue = zEnd - v3New[2]; |
267 | step *= dZ/(v3New[2]-trackParam->GetZ()); | |
268 | } while (residue*dZ < 0 && TMath::Abs(residue) > fgkRungeKuttaMaxResidue); | |
4ea3f013 | 269 | |
ade4e6f9 | 270 | if (trackingFailed) break; |
271 | else if (v3New[5]*v3[5] < 0) { // the track turned around | |
4ea3f013 | 272 | cout<<"W-AliMUONTrackExtrap::ExtrapToZRungekutta: The track turned around"<<endl; |
273 | uturn = kTRUE; | |
274 | break; | |
275 | } else RecoverTrackParam(v3New, chargeExtrap * forwardBackward, trackParam); | |
276 | ||
4284483e | 277 | } |
278 | ||
279 | // terminate the extropolation with a straight line up to the exact "zEnd" value | |
ade4e6f9 | 280 | if (trackingFailed || uturn) { |
4ea3f013 | 281 | |
282 | // track ends +-100 meters away in the bending direction | |
283 | dZ = zEnd - v3[2]; | |
284 | Double_t bendingSlope = TMath::Sign(1.e4,-fgSimpleBValue*trackParam->GetInverseBendingMomentum()) / dZ; | |
285 | Double_t pZ = TMath::Abs(1. / trackParam->GetInverseBendingMomentum()) / TMath::Sqrt(1.0 + bendingSlope * bendingSlope); | |
286 | Double_t nonBendingSlope = TMath::Sign(TMath::Abs(v3[3]) * v3[6] / pZ, trackParam->GetNonBendingSlope()); | |
287 | trackParam->SetNonBendingCoor(trackParam->GetNonBendingCoor() + dZ * nonBendingSlope); | |
288 | trackParam->SetNonBendingSlope(nonBendingSlope); | |
289 | trackParam->SetBendingCoor(trackParam->GetBendingCoor() + dZ * bendingSlope); | |
290 | trackParam->SetBendingSlope(bendingSlope); | |
291 | trackParam->SetZ(zEnd); | |
292 | ||
293 | return kFALSE; | |
294 | ||
295 | } else { | |
296 | ||
297 | // track extrapolated normally | |
298 | trackParam->SetNonBendingCoor(trackParam->GetNonBendingCoor() + residue * trackParam->GetNonBendingSlope()); | |
299 | trackParam->SetBendingCoor(trackParam->GetBendingCoor() + residue * trackParam->GetBendingSlope()); | |
300 | trackParam->SetZ(zEnd); | |
301 | ||
302 | return !tooManyStep; | |
303 | ||
304 | } | |
305 | ||
4284483e | 306 | } |
307 | ||
690d2205 | 308 | //__________________________________________________________________________ |
4284483e | 309 | void AliMUONTrackExtrap::ConvertTrackParamForExtrap(AliMUONTrackParam* trackParam, Double_t forwardBackward, Double_t *v3) |
c04e3238 | 310 | { |
dade8580 | 311 | /// Set vector of Geant3 parameters pointed to by "v3" from track parameters in trackParam. |
c04e3238 | 312 | /// Since AliMUONTrackParam is only geometry, one uses "forwardBackward" |
313 | /// to know whether the particle is going forward (+1) or backward (-1). | |
dade8580 | 314 | v3[0] = trackParam->GetNonBendingCoor(); // X |
315 | v3[1] = trackParam->GetBendingCoor(); // Y | |
316 | v3[2] = trackParam->GetZ(); // Z | |
c04e3238 | 317 | Double_t pYZ = TMath::Abs(1.0 / trackParam->GetInverseBendingMomentum()); |
318 | Double_t pZ = pYZ / TMath::Sqrt(1.0 + trackParam->GetBendingSlope() * trackParam->GetBendingSlope()); | |
dade8580 | 319 | v3[6] = TMath::Sqrt(pYZ * pYZ + pZ * pZ * trackParam->GetNonBendingSlope() * trackParam->GetNonBendingSlope()); // PTOT |
320 | v3[5] = -forwardBackward * pZ / v3[6]; // PZ/PTOT spectro. z<0 | |
321 | v3[3] = trackParam->GetNonBendingSlope() * v3[5]; // PX/PTOT | |
322 | v3[4] = trackParam->GetBendingSlope() * v3[5]; // PY/PTOT | |
c04e3238 | 323 | } |
324 | ||
690d2205 | 325 | //__________________________________________________________________________ |
dade8580 | 326 | void AliMUONTrackExtrap::RecoverTrackParam(Double_t *v3, Double_t charge, AliMUONTrackParam* trackParam) |
c04e3238 | 327 | { |
dade8580 | 328 | /// Set track parameters in trackParam from Geant3 parameters pointed to by "v3", |
c04e3238 | 329 | /// assumed to be calculated for forward motion in Z. |
330 | /// "InverseBendingMomentum" is signed with "charge". | |
dade8580 | 331 | trackParam->SetNonBendingCoor(v3[0]); // X |
332 | trackParam->SetBendingCoor(v3[1]); // Y | |
333 | trackParam->SetZ(v3[2]); // Z | |
60e55aee | 334 | Double_t pYZ = v3[6] * TMath::Sqrt((1.-v3[3])*(1.+v3[3])); |
c04e3238 | 335 | trackParam->SetInverseBendingMomentum(charge/pYZ); |
dade8580 | 336 | trackParam->SetBendingSlope(v3[4]/v3[5]); |
337 | trackParam->SetNonBendingSlope(v3[3]/v3[5]); | |
208f139e | 338 | } |
339 | ||
690d2205 | 340 | //__________________________________________________________________________ |
4ea3f013 | 341 | Bool_t AliMUONTrackExtrap::ExtrapToZCov(AliMUONTrackParam* trackParam, Double_t zEnd, Bool_t updatePropagator) |
208f139e | 342 | { |
343 | /// Track parameters and their covariances extrapolated to the plane at "zEnd". | |
344 | /// On return, results from the extrapolation are updated in trackParam. | |
345 | ||
4ea3f013 | 346 | if (trackParam->GetZ() == zEnd) return kTRUE; // nothing to be done if same z |
208f139e | 347 | |
9f093251 | 348 | if (!fgFieldON) { // linear extrapolation if no magnetic field |
3fe6651e | 349 | AliMUONTrackExtrap::LinearExtrapToZCov(trackParam,zEnd,updatePropagator); |
4ea3f013 | 350 | return kTRUE; |
9f093251 | 351 | } |
352 | ||
ea94c18b | 353 | // No need to propagate the covariance matrix if it does not exist |
354 | if (!trackParam->CovariancesExist()) { | |
355 | cout<<"W-AliMUONTrackExtrap::ExtrapToZCov: Covariance matrix does not exist"<<endl; | |
356 | // Extrapolate track parameters to "zEnd" | |
4ea3f013 | 357 | return ExtrapToZ(trackParam,zEnd); |
ea94c18b | 358 | } |
359 | ||
208f139e | 360 | // Save the actual track parameters |
361 | AliMUONTrackParam trackParamSave(*trackParam); | |
ea94c18b | 362 | TMatrixD paramSave(trackParamSave.GetParameters()); |
363 | Double_t zBegin = trackParamSave.GetZ(); | |
364 | ||
365 | // Get reference to the parameter covariance matrix | |
366 | const TMatrixD& kParamCov = trackParam->GetCovariances(); | |
9bf6860b | 367 | |
208f139e | 368 | // Extrapolate track parameters to "zEnd" |
4ea3f013 | 369 | // Do not update the covariance matrix if the extrapolation failed |
370 | if (!ExtrapToZ(trackParam,zEnd)) return kFALSE; | |
208f139e | 371 | |
ea94c18b | 372 | // Get reference to the extrapolated parameters |
373 | const TMatrixD& extrapParam = trackParam->GetParameters(); | |
208f139e | 374 | |
375 | // Calculate the jacobian related to the track parameters extrapolation to "zEnd" | |
4ea3f013 | 376 | Bool_t extrapStatus = kTRUE; |
208f139e | 377 | TMatrixD jacob(5,5); |
ea94c18b | 378 | jacob.Zero(); |
379 | TMatrixD dParam(5,1); | |
6b191dea | 380 | Double_t direction[5] = {-1.,-1.,1.,1.,-1.}; |
208f139e | 381 | for (Int_t i=0; i<5; i++) { |
382 | // Skip jacobian calculation for parameters with no associated error | |
18abc511 | 383 | if (kParamCov(i,i) <= 0.) continue; |
ea94c18b | 384 | |
208f139e | 385 | // Small variation of parameter i only |
386 | for (Int_t j=0; j<5; j++) { | |
387 | if (j==i) { | |
ea94c18b | 388 | dParam(j,0) = TMath::Sqrt(kParamCov(i,i)); |
6b191dea | 389 | dParam(j,0) *= TMath::Sign(1.,direction[j]*paramSave(j,0)); // variation always in the same direction |
ea94c18b | 390 | } else dParam(j,0) = 0.; |
208f139e | 391 | } |
ea94c18b | 392 | |
208f139e | 393 | // Set new parameters |
ea94c18b | 394 | trackParamSave.SetParameters(paramSave); |
395 | trackParamSave.AddParameters(dParam); | |
396 | trackParamSave.SetZ(zBegin); | |
397 | ||
208f139e | 398 | // Extrapolate new track parameters to "zEnd" |
4ea3f013 | 399 | if (!ExtrapToZ(&trackParamSave,zEnd)) { |
400 | cout<<"W-AliMUONTrackExtrap::ExtrapToZCov: Bad covariance matrix"<<endl; | |
401 | extrapStatus = kFALSE; | |
402 | } | |
ea94c18b | 403 | |
208f139e | 404 | // Calculate the jacobian |
ea94c18b | 405 | TMatrixD jacobji(trackParamSave.GetParameters(),TMatrixD::kMinus,extrapParam); |
406 | jacobji *= 1. / dParam(i,0); | |
407 | jacob.SetSub(0,i,jacobji); | |
208f139e | 408 | } |
409 | ||
410 | // Extrapolate track parameter covariances to "zEnd" | |
ea94c18b | 411 | TMatrixD tmp(kParamCov,TMatrixD::kMultTranspose,jacob); |
412 | TMatrixD tmp2(jacob,TMatrixD::kMult,tmp); | |
413 | trackParam->SetCovariances(tmp2); | |
414 | ||
415 | // Update the propagator if required | |
416 | if (updatePropagator) trackParam->UpdatePropagator(jacob); | |
4ea3f013 | 417 | |
418 | return extrapStatus; | |
208f139e | 419 | } |
420 | ||
690d2205 | 421 | //__________________________________________________________________________ |
37a615ac | 422 | void AliMUONTrackExtrap::AddMCSEffectInAbsorber(AliMUONTrackParam* param, Double_t signedPathLength, Double_t f0, Double_t f1, Double_t f2) |
8cde4af5 | 423 | { |
424 | /// Add to the track parameter covariances the effects of multiple Coulomb scattering | |
37a615ac | 425 | /// signedPathLength must have the sign of (zOut - zIn) where all other parameters are assumed to be given at zOut. |
8cde4af5 | 426 | |
427 | // absorber related covariance parameters | |
428 | Double_t bendingSlope = param->GetBendingSlope(); | |
429 | Double_t nonBendingSlope = param->GetNonBendingSlope(); | |
430 | Double_t inverseBendingMomentum = param->GetInverseBendingMomentum(); | |
431 | Double_t alpha2 = 0.0136 * 0.0136 * inverseBendingMomentum * inverseBendingMomentum * (1.0 + bendingSlope * bendingSlope) / | |
690d2205 | 432 | (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope); // velocity = 1 |
37a615ac | 433 | Double_t pathLength = TMath::Abs(signedPathLength); |
8cde4af5 | 434 | Double_t varCoor = alpha2 * (pathLength * pathLength * f0 - 2. * pathLength * f1 + f2); |
37a615ac | 435 | Double_t covCorrSlope = TMath::Sign(1.,signedPathLength) * alpha2 * (pathLength * f0 - f1); |
8cde4af5 | 436 | Double_t varSlop = alpha2 * f0; |
437 | ||
690d2205 | 438 | // Set MCS covariance matrix |
ea94c18b | 439 | TMatrixD newParamCov(param->GetCovariances()); |
8cde4af5 | 440 | // Non bending plane |
ea94c18b | 441 | newParamCov(0,0) += varCoor; newParamCov(0,1) += covCorrSlope; |
442 | newParamCov(1,0) += covCorrSlope; newParamCov(1,1) += varSlop; | |
8cde4af5 | 443 | // Bending plane |
ea94c18b | 444 | newParamCov(2,2) += varCoor; newParamCov(2,3) += covCorrSlope; |
445 | newParamCov(3,2) += covCorrSlope; newParamCov(3,3) += varSlop; | |
c24543a2 | 446 | |
447 | // Set momentum related covariances if B!=0 | |
448 | if (fgFieldON) { | |
449 | // compute derivative d(q/Pxy) / dSlopeX and d(q/Pxy) / dSlopeY | |
450 | Double_t dqPxydSlopeX = inverseBendingMomentum * nonBendingSlope / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope); | |
451 | Double_t dqPxydSlopeY = - inverseBendingMomentum * nonBendingSlope*nonBendingSlope * bendingSlope / | |
452 | (1. + bendingSlope*bendingSlope) / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope); | |
453 | // Inverse bending momentum (due to dependences with bending and non bending slopes) | |
454 | newParamCov(4,0) += dqPxydSlopeX * covCorrSlope; newParamCov(0,4) += dqPxydSlopeX * covCorrSlope; | |
455 | newParamCov(4,1) += dqPxydSlopeX * varSlop; newParamCov(1,4) += dqPxydSlopeX * varSlop; | |
456 | newParamCov(4,2) += dqPxydSlopeY * covCorrSlope; newParamCov(2,4) += dqPxydSlopeY * covCorrSlope; | |
457 | newParamCov(4,3) += dqPxydSlopeY * varSlop; newParamCov(3,4) += dqPxydSlopeY * varSlop; | |
458 | newParamCov(4,4) += (dqPxydSlopeX*dqPxydSlopeX + dqPxydSlopeY*dqPxydSlopeY) * varSlop; | |
459 | } | |
ea94c18b | 460 | |
461 | // Set new covariances | |
462 | param->SetCovariances(newParamCov); | |
690d2205 | 463 | } |
464 | ||
465 | //__________________________________________________________________________ | |
466 | void AliMUONTrackExtrap::CorrectMCSEffectInAbsorber(AliMUONTrackParam* param, | |
467 | Double_t xVtx, Double_t yVtx, Double_t zVtx, | |
468 | Double_t errXVtx, Double_t errYVtx, | |
469 | Double_t absZBeg, Double_t pathLength, Double_t f0, Double_t f1, Double_t f2) | |
470 | { | |
471 | /// Correct parameters and corresponding covariances using Branson correction | |
472 | /// - input param are parameters and covariances at the end of absorber | |
473 | /// - output param are parameters and covariances at vertex | |
474 | /// Absorber correction parameters are supposed to be calculated at the current track z-position | |
475 | ||
476 | // Position of the Branson plane (spectro. (z<0)) | |
477 | Double_t zB = (f1>0.) ? absZBeg - f2/f1 : 0.; | |
478 | ||
37a615ac | 479 | // Add MCS effects to current parameter covariances (spectro. (z<0)) |
480 | AddMCSEffectInAbsorber(param, -pathLength, f0, f1, f2); | |
690d2205 | 481 | |
482 | // Get track parameters and covariances in the Branson plane corrected for magnetic field effect | |
483 | ExtrapToZCov(param,zVtx); | |
3fe6651e | 484 | LinearExtrapToZCov(param,zB); |
690d2205 | 485 | |
486 | // compute track parameters at vertex | |
487 | TMatrixD newParam(5,1); | |
488 | newParam(0,0) = xVtx; | |
489 | newParam(1,0) = (param->GetNonBendingCoor() - xVtx) / (zB - zVtx); | |
490 | newParam(2,0) = yVtx; | |
491 | newParam(3,0) = (param->GetBendingCoor() - yVtx) / (zB - zVtx); | |
492 | newParam(4,0) = param->GetCharge() / param->P() * | |
493 | TMath::Sqrt(1.0 + newParam(1,0)*newParam(1,0) + newParam(3,0)*newParam(3,0)) / | |
494 | TMath::Sqrt(1.0 + newParam(3,0)*newParam(3,0)); | |
495 | ||
496 | // Get covariances in (X, SlopeX, Y, SlopeY, q*PTot) coordinate system | |
497 | TMatrixD paramCovP(param->GetCovariances()); | |
498 | Cov2CovP(param->GetParameters(),paramCovP); | |
499 | ||
500 | // Get the covariance matrix in the (XVtx, X, YVtx, Y, q*PTot) coordinate system | |
501 | TMatrixD paramCovVtx(5,5); | |
502 | paramCovVtx.Zero(); | |
503 | paramCovVtx(0,0) = errXVtx * errXVtx; | |
504 | paramCovVtx(1,1) = paramCovP(0,0); | |
505 | paramCovVtx(2,2) = errYVtx * errYVtx; | |
506 | paramCovVtx(3,3) = paramCovP(2,2); | |
507 | paramCovVtx(4,4) = paramCovP(4,4); | |
508 | paramCovVtx(1,3) = paramCovP(0,2); | |
509 | paramCovVtx(3,1) = paramCovP(2,0); | |
510 | paramCovVtx(1,4) = paramCovP(0,4); | |
511 | paramCovVtx(4,1) = paramCovP(4,0); | |
512 | paramCovVtx(3,4) = paramCovP(2,4); | |
513 | paramCovVtx(4,3) = paramCovP(4,2); | |
514 | ||
515 | // Jacobian of the transformation (XVtx, X, YVtx, Y, q*PTot) -> (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q*PTotVtx) | |
516 | TMatrixD jacob(5,5); | |
517 | jacob.UnitMatrix(); | |
518 | jacob(1,0) = - 1. / (zB - zVtx); | |
519 | jacob(1,1) = 1. / (zB - zVtx); | |
520 | jacob(3,2) = - 1. / (zB - zVtx); | |
521 | jacob(3,3) = 1. / (zB - zVtx); | |
8cde4af5 | 522 | |
690d2205 | 523 | // Compute covariances at vertex in the (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q*PTotVtx) coordinate system |
524 | TMatrixD tmp(paramCovVtx,TMatrixD::kMultTranspose,jacob); | |
525 | TMatrixD newParamCov(jacob,TMatrixD::kMult,tmp); | |
526 | ||
527 | // Compute covariances at vertex in the (XVtx, SlopeXVtx, YVtx, SlopeYVtx, q/PyzVtx) coordinate system | |
528 | CovP2Cov(newParam,newParamCov); | |
529 | ||
530 | // Set parameters and covariances at vertex | |
531 | param->SetParameters(newParam); | |
532 | param->SetZ(zVtx); | |
533 | param->SetCovariances(newParamCov); | |
8cde4af5 | 534 | } |
535 | ||
690d2205 | 536 | //__________________________________________________________________________ |
537 | void AliMUONTrackExtrap::CorrectELossEffectInAbsorber(AliMUONTrackParam* param, Double_t eLoss, Double_t sigmaELoss2) | |
538 | { | |
539 | /// Correct parameters for energy loss and add energy loss fluctuation effect to covariances | |
540 | ||
541 | // Get parameter covariances in (X, SlopeX, Y, SlopeY, q*PTot) coordinate system | |
542 | TMatrixD newParamCov(param->GetCovariances()); | |
543 | Cov2CovP(param->GetParameters(),newParamCov); | |
544 | ||
690d2205 | 545 | // Compute new parameters corrected for energy loss |
ecdf58c4 | 546 | Double_t muMass = TDatabasePDG::Instance()->GetParticle("mu-")->Mass(); // GeV |
547 | Double_t p = param->P(); | |
548 | Double_t e = TMath::Sqrt(p*p + muMass*muMass); | |
549 | Double_t eCorr = e + eLoss; | |
550 | Double_t pCorr = TMath::Sqrt(eCorr*eCorr - muMass*muMass); | |
690d2205 | 551 | Double_t nonBendingSlope = param->GetNonBendingSlope(); |
552 | Double_t bendingSlope = param->GetBendingSlope(); | |
ecdf58c4 | 553 | param->SetInverseBendingMomentum(param->GetCharge() / pCorr * |
690d2205 | 554 | TMath::Sqrt(1.0 + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope) / |
555 | TMath::Sqrt(1.0 + bendingSlope*bendingSlope)); | |
556 | ||
ecdf58c4 | 557 | // Add effects of energy loss fluctuation to covariances |
558 | newParamCov(4,4) += eCorr * eCorr / pCorr / pCorr * sigmaELoss2; | |
559 | ||
690d2205 | 560 | // Get new parameter covariances in (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system |
561 | CovP2Cov(param->GetParameters(),newParamCov); | |
562 | ||
563 | // Set new parameter covariances | |
564 | param->SetCovariances(newParamCov); | |
565 | } | |
566 | ||
567 | //__________________________________________________________________________ | |
18abc511 | 568 | Bool_t AliMUONTrackExtrap::GetAbsorberCorrectionParam(Double_t trackXYZIn[3], Double_t trackXYZOut[3], Double_t pTotal, |
569 | Double_t &pathLength, Double_t &f0, Double_t &f1, Double_t &f2, | |
570 | Double_t &meanRho, Double_t &totalELoss, Double_t &sigmaELoss2) | |
8cde4af5 | 571 | { |
572 | /// Parameters used to correct for Multiple Coulomb Scattering and energy loss in absorber | |
690d2205 | 573 | /// Calculated assuming a linear propagation from trackXYZIn to trackXYZOut (order is important) |
8cde4af5 | 574 | // pathLength: path length between trackXYZIn and trackXYZOut (cm) |
575 | // f0: 0th moment of z calculated with the inverse radiation-length distribution | |
576 | // f1: 1st moment of z calculated with the inverse radiation-length distribution | |
577 | // f2: 2nd moment of z calculated with the inverse radiation-length distribution | |
578 | // meanRho: average density of crossed material (g/cm3) | |
84f061ef | 579 | // totalELoss: total energy loss in absorber |
8cde4af5 | 580 | |
581 | // Reset absorber's parameters | |
582 | pathLength = 0.; | |
583 | f0 = 0.; | |
584 | f1 = 0.; | |
585 | f2 = 0.; | |
586 | meanRho = 0.; | |
84f061ef | 587 | totalELoss = 0.; |
690d2205 | 588 | sigmaELoss2 = 0.; |
8cde4af5 | 589 | |
590 | // Check whether the geometry is available | |
591 | if (!gGeoManager) { | |
592 | cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: no TGeo"<<endl; | |
18abc511 | 593 | return kFALSE; |
8cde4af5 | 594 | } |
595 | ||
596 | // Initialize starting point and direction | |
597 | pathLength = TMath::Sqrt((trackXYZOut[0] - trackXYZIn[0])*(trackXYZOut[0] - trackXYZIn[0])+ | |
598 | (trackXYZOut[1] - trackXYZIn[1])*(trackXYZOut[1] - trackXYZIn[1])+ | |
599 | (trackXYZOut[2] - trackXYZIn[2])*(trackXYZOut[2] - trackXYZIn[2])); | |
18abc511 | 600 | if (pathLength < TGeoShape::Tolerance()) return kFALSE; |
8cde4af5 | 601 | Double_t b[3]; |
602 | b[0] = (trackXYZOut[0] - trackXYZIn[0]) / pathLength; | |
603 | b[1] = (trackXYZOut[1] - trackXYZIn[1]) / pathLength; | |
604 | b[2] = (trackXYZOut[2] - trackXYZIn[2]) / pathLength; | |
605 | TGeoNode *currentnode = gGeoManager->InitTrack(trackXYZIn, b); | |
606 | if (!currentnode) { | |
607 | cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: start point out of geometry"<<endl; | |
18abc511 | 608 | return kFALSE; |
8cde4af5 | 609 | } |
610 | ||
611 | // loop over absorber slices and calculate absorber's parameters | |
612 | Double_t rho = 0.; // material density (g/cm3) | |
613 | Double_t x0 = 0.; // radiation-length (cm-1) | |
84f061ef | 614 | Double_t atomicA = 0.; // A of material |
615 | Double_t atomicZ = 0.; // Z of material | |
fa5e35be | 616 | Double_t atomicZoverA = 0.; // Z/A of material |
8cde4af5 | 617 | Double_t localPathLength = 0; |
618 | Double_t remainingPathLength = pathLength; | |
619 | Double_t zB = trackXYZIn[2]; | |
620 | Double_t zE, dzB, dzE; | |
621 | do { | |
622 | // Get material properties | |
623 | TGeoMaterial *material = currentnode->GetVolume()->GetMedium()->GetMaterial(); | |
624 | rho = material->GetDensity(); | |
625 | x0 = material->GetRadLen(); | |
84f061ef | 626 | atomicA = material->GetA(); |
627 | atomicZ = material->GetZ(); | |
fa5e35be | 628 | if(material->IsMixture()){ |
629 | TGeoMixture * mixture = (TGeoMixture*)material; | |
630 | atomicZoverA = 0.; | |
631 | Double_t sum = 0.; | |
632 | for (Int_t iel=0;iel<mixture->GetNelements();iel++){ | |
633 | sum += mixture->GetWmixt()[iel]; | |
634 | atomicZoverA += mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel]; | |
635 | } | |
636 | atomicZoverA/=sum; | |
637 | } | |
638 | else atomicZoverA = atomicZ/atomicA; | |
8cde4af5 | 639 | |
640 | // Get path length within this material | |
641 | gGeoManager->FindNextBoundary(remainingPathLength); | |
642 | localPathLength = gGeoManager->GetStep() + 1.e-6; | |
643 | // Check if boundary within remaining path length. If so, make sure to cross the boundary to prepare the next step | |
644 | if (localPathLength >= remainingPathLength) localPathLength = remainingPathLength; | |
645 | else { | |
646 | currentnode = gGeoManager->Step(); | |
647 | if (!currentnode) { | |
648 | cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: navigation failed"<<endl; | |
18abc511 | 649 | f0 = f1 = f2 = meanRho = totalELoss = sigmaELoss2 = 0.; |
650 | return kFALSE; | |
8cde4af5 | 651 | } |
652 | if (!gGeoManager->IsEntering()) { | |
653 | // make another small step to try to enter in new absorber slice | |
654 | gGeoManager->SetStep(0.001); | |
655 | currentnode = gGeoManager->Step(); | |
656 | if (!gGeoManager->IsEntering() || !currentnode) { | |
657 | cout<<"E-AliMUONTrackExtrap::GetAbsorberCorrectionParam: navigation failed"<<endl; | |
18abc511 | 658 | f0 = f1 = f2 = meanRho = totalELoss = sigmaELoss2 = 0.; |
659 | return kFALSE; | |
8cde4af5 | 660 | } |
661 | localPathLength += 0.001; | |
662 | } | |
663 | } | |
664 | ||
665 | // calculate absorber's parameters | |
666 | zE = b[2] * localPathLength + zB; | |
667 | dzB = zB - trackXYZIn[2]; | |
668 | dzE = zE - trackXYZIn[2]; | |
669 | f0 += localPathLength / x0; | |
670 | f1 += (dzE*dzE - dzB*dzB) / b[2] / b[2] / x0 / 2.; | |
671 | f2 += (dzE*dzE*dzE - dzB*dzB*dzB) / b[2] / b[2] / b[2] / x0 / 3.; | |
672 | meanRho += localPathLength * rho; | |
fa5e35be | 673 | totalELoss += BetheBloch(pTotal, localPathLength, rho, atomicZ, atomicZoverA); |
674 | sigmaELoss2 += EnergyLossFluctuation2(pTotal, localPathLength, rho, atomicZoverA); | |
8cde4af5 | 675 | |
676 | // prepare next step | |
677 | zB = zE; | |
678 | remainingPathLength -= localPathLength; | |
679 | } while (remainingPathLength > TGeoShape::Tolerance()); | |
680 | ||
681 | meanRho /= pathLength; | |
18abc511 | 682 | |
683 | return kTRUE; | |
8cde4af5 | 684 | } |
685 | ||
690d2205 | 686 | //__________________________________________________________________________ |
ea94c18b | 687 | Double_t AliMUONTrackExtrap::GetMCSAngle2(const AliMUONTrackParam& param, Double_t dZ, Double_t x0) |
688 | { | |
689 | /// Return the angular dispersion square due to multiple Coulomb scattering | |
690 | /// through a material of thickness "dZ" and of radiation length "x0" | |
691 | /// assuming linear propagation and using the small angle approximation. | |
692 | ||
693 | Double_t bendingSlope = param.GetBendingSlope(); | |
694 | Double_t nonBendingSlope = param.GetNonBendingSlope(); | |
695 | Double_t inverseTotalMomentum2 = param.GetInverseBendingMomentum() * param.GetInverseBendingMomentum() * | |
690d2205 | 696 | (1.0 + bendingSlope * bendingSlope) / |
697 | (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope); | |
ea94c18b | 698 | // Path length in the material |
699 | Double_t pathLength = TMath::Abs(dZ) * TMath::Sqrt(1.0 + bendingSlope*bendingSlope + nonBendingSlope*nonBendingSlope); | |
700 | // relativistic velocity | |
701 | Double_t velo = 1.; | |
702 | // Angular dispersion square of the track (variance) in a plane perpendicular to the trajectory | |
703 | Double_t theta02 = 0.0136 / velo * (1 + 0.038 * TMath::Log(pathLength/x0)); | |
704 | ||
705 | return theta02 * theta02 * inverseTotalMomentum2 * pathLength / x0; | |
706 | } | |
707 | ||
690d2205 | 708 | //__________________________________________________________________________ |
8cde4af5 | 709 | void AliMUONTrackExtrap::AddMCSEffect(AliMUONTrackParam *param, Double_t dZ, Double_t x0) |
208f139e | 710 | { |
711 | /// Add to the track parameter covariances the effects of multiple Coulomb scattering | |
37a615ac | 712 | /// through a material of thickness "Abs(dZ)" and of radiation length "x0" |
208f139e | 713 | /// assuming linear propagation and using the small angle approximation. |
37a615ac | 714 | /// dZ = zOut - zIn (sign is important) and "param" is assumed to be given zOut. |
715 | /// If x0 <= 0., assume dZ = pathLength/x0 and consider the material thickness as negligible. | |
208f139e | 716 | |
717 | Double_t bendingSlope = param->GetBendingSlope(); | |
718 | Double_t nonBendingSlope = param->GetNonBendingSlope(); | |
690d2205 | 719 | Double_t inverseBendingMomentum = param->GetInverseBendingMomentum(); |
720 | Double_t inverseTotalMomentum2 = inverseBendingMomentum * inverseBendingMomentum * | |
721 | (1.0 + bendingSlope * bendingSlope) / | |
722 | (1.0 + bendingSlope *bendingSlope + nonBendingSlope * nonBendingSlope); | |
208f139e | 723 | // Path length in the material |
37a615ac | 724 | Double_t signedPathLength = dZ * TMath::Sqrt(1.0 + bendingSlope*bendingSlope + nonBendingSlope*nonBendingSlope); |
725 | Double_t pathLengthOverX0 = (x0 > 0.) ? TMath::Abs(signedPathLength) / x0 : TMath::Abs(signedPathLength); | |
208f139e | 726 | // relativistic velocity |
727 | Double_t velo = 1.; | |
728 | // Angular dispersion square of the track (variance) in a plane perpendicular to the trajectory | |
37a615ac | 729 | Double_t theta02 = 0.0136 / velo * (1 + 0.038 * TMath::Log(pathLengthOverX0)); |
730 | theta02 *= theta02 * inverseTotalMomentum2 * pathLengthOverX0; | |
208f139e | 731 | |
37a615ac | 732 | Double_t varCoor = (x0 > 0.) ? signedPathLength * signedPathLength * theta02 / 3. : 0.; |
208f139e | 733 | Double_t varSlop = theta02; |
37a615ac | 734 | Double_t covCorrSlope = (x0 > 0.) ? signedPathLength * theta02 / 2. : 0.; |
ea94c18b | 735 | |
690d2205 | 736 | // Set MCS covariance matrix |
ea94c18b | 737 | TMatrixD newParamCov(param->GetCovariances()); |
208f139e | 738 | // Non bending plane |
ea94c18b | 739 | newParamCov(0,0) += varCoor; newParamCov(0,1) += covCorrSlope; |
740 | newParamCov(1,0) += covCorrSlope; newParamCov(1,1) += varSlop; | |
208f139e | 741 | // Bending plane |
ea94c18b | 742 | newParamCov(2,2) += varCoor; newParamCov(2,3) += covCorrSlope; |
743 | newParamCov(3,2) += covCorrSlope; newParamCov(3,3) += varSlop; | |
c24543a2 | 744 | |
745 | // Set momentum related covariances if B!=0 | |
746 | if (fgFieldON) { | |
747 | // compute derivative d(q/Pxy) / dSlopeX and d(q/Pxy) / dSlopeY | |
748 | Double_t dqPxydSlopeX = inverseBendingMomentum * nonBendingSlope / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope); | |
749 | Double_t dqPxydSlopeY = - inverseBendingMomentum * nonBendingSlope*nonBendingSlope * bendingSlope / | |
750 | (1. + bendingSlope*bendingSlope) / (1. + nonBendingSlope*nonBendingSlope + bendingSlope*bendingSlope); | |
751 | // Inverse bending momentum (due to dependences with bending and non bending slopes) | |
752 | newParamCov(4,0) += dqPxydSlopeX * covCorrSlope; newParamCov(0,4) += dqPxydSlopeX * covCorrSlope; | |
753 | newParamCov(4,1) += dqPxydSlopeX * varSlop; newParamCov(1,4) += dqPxydSlopeX * varSlop; | |
754 | newParamCov(4,2) += dqPxydSlopeY * covCorrSlope; newParamCov(2,4) += dqPxydSlopeY * covCorrSlope; | |
755 | newParamCov(4,3) += dqPxydSlopeY * varSlop; newParamCov(3,4) += dqPxydSlopeY * varSlop; | |
756 | newParamCov(4,4) += (dqPxydSlopeX*dqPxydSlopeX + dqPxydSlopeY*dqPxydSlopeY) * varSlop; | |
757 | } | |
208f139e | 758 | |
ea94c18b | 759 | // Set new covariances |
760 | param->SetCovariances(newParamCov); | |
c04e3238 | 761 | } |
762 | ||
690d2205 | 763 | //__________________________________________________________________________ |
764 | void AliMUONTrackExtrap::ExtrapToVertex(AliMUONTrackParam* trackParam, | |
765 | Double_t xVtx, Double_t yVtx, Double_t zVtx, | |
766 | Double_t errXVtx, Double_t errYVtx, | |
767 | Bool_t correctForMCS, Bool_t correctForEnergyLoss) | |
c04e3238 | 768 | { |
690d2205 | 769 | /// Main method for extrapolation to the vertex: |
770 | /// Returns the track parameters and covariances resulting from the extrapolation of the current trackParam | |
771 | /// Changes parameters and covariances according to multiple scattering and energy loss corrections: | |
772 | /// if correctForMCS=kTRUE: compute parameters using Branson correction and add correction resolution to covariances | |
773 | /// if correctForMCS=kFALSE: add parameter dispersion due to MCS in parameter covariances | |
774 | /// if correctForEnergyLoss=kTRUE: correct parameters for energy loss and add energy loss fluctuation to covariances | |
775 | /// if correctForEnergyLoss=kFALSE: do nothing about energy loss | |
c04e3238 | 776 | |
8cde4af5 | 777 | if (trackParam->GetZ() == zVtx) return; // nothing to be done if already at vertex |
c04e3238 | 778 | |
8cde4af5 | 779 | if (trackParam->GetZ() > zVtx) { // spectro. (z<0) |
690d2205 | 780 | cout<<"E-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ() |
781 | <<") upstream the vertex (zVtx = "<<zVtx<<")"<<endl; | |
fac70e25 | 782 | return; |
783 | } | |
784 | ||
8cde4af5 | 785 | // Check the vertex position relatively to the absorber |
ea94c18b | 786 | if (zVtx < AliMUONConstants::AbsZBeg() && zVtx > AliMUONConstants::AbsZEnd()) { // spectro. (z<0) |
8cde4af5 | 787 | cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Ending Z ("<<zVtx |
690d2205 | 788 | <<") inside the front absorber ("<<AliMUONConstants::AbsZBeg()<<","<<AliMUONConstants::AbsZEnd()<<")"<<endl; |
ea94c18b | 789 | } else if (zVtx < AliMUONConstants::AbsZEnd() ) { // spectro. (z<0) |
8cde4af5 | 790 | cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Ending Z ("<<zVtx |
690d2205 | 791 | <<") downstream the front absorber (zAbsorberEnd = "<<AliMUONConstants::AbsZEnd()<<")"<<endl; |
792 | if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx); | |
793 | else ExtrapToZ(trackParam,zVtx); | |
8cde4af5 | 794 | return; |
795 | } | |
796 | ||
797 | // Check the track position relatively to the absorber and extrapolate track parameters to the end of the absorber if needed | |
ea94c18b | 798 | if (trackParam->GetZ() > AliMUONConstants::AbsZBeg()) { // spectro. (z<0) |
8cde4af5 | 799 | cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ() |
690d2205 | 800 | <<") upstream the front absorber (zAbsorberBegin = "<<AliMUONConstants::AbsZBeg()<<")"<<endl; |
801 | if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx); | |
802 | else ExtrapToZ(trackParam,zVtx); | |
8cde4af5 | 803 | return; |
ea94c18b | 804 | } else if (trackParam->GetZ() > AliMUONConstants::AbsZEnd()) { // spectro. (z<0) |
8cde4af5 | 805 | cout<<"W-AliMUONTrackExtrap::ExtrapToVertex: Starting Z ("<<trackParam->GetZ() |
690d2205 | 806 | <<") inside the front absorber ("<<AliMUONConstants::AbsZBeg()<<","<<AliMUONConstants::AbsZEnd()<<")"<<endl; |
c04e3238 | 807 | } else { |
690d2205 | 808 | if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,AliMUONConstants::AbsZEnd()); |
809 | else ExtrapToZ(trackParam,AliMUONConstants::AbsZEnd()); | |
c04e3238 | 810 | } |
c04e3238 | 811 | |
690d2205 | 812 | // Get absorber correction parameters assuming linear propagation in absorber |
8cde4af5 | 813 | Double_t trackXYZOut[3]; |
814 | trackXYZOut[0] = trackParam->GetNonBendingCoor(); | |
815 | trackXYZOut[1] = trackParam->GetBendingCoor(); | |
816 | trackXYZOut[2] = trackParam->GetZ(); | |
817 | Double_t trackXYZIn[3]; | |
690d2205 | 818 | if (correctForMCS) { // assume linear propagation until the vertex |
819 | trackXYZIn[2] = TMath::Min(zVtx, AliMUONConstants::AbsZBeg()); // spectro. (z<0) | |
820 | trackXYZIn[0] = trackXYZOut[0] + (xVtx - trackXYZOut[0]) / (zVtx - trackXYZOut[2]) * (trackXYZIn[2] - trackXYZOut[2]); | |
821 | trackXYZIn[1] = trackXYZOut[1] + (yVtx - trackXYZOut[1]) / (zVtx - trackXYZOut[2]) * (trackXYZIn[2] - trackXYZOut[2]); | |
822 | } else { | |
823 | AliMUONTrackParam trackParamIn(*trackParam); | |
824 | ExtrapToZ(&trackParamIn, TMath::Min(zVtx, AliMUONConstants::AbsZBeg())); | |
825 | trackXYZIn[0] = trackParamIn.GetNonBendingCoor(); | |
826 | trackXYZIn[1] = trackParamIn.GetBendingCoor(); | |
827 | trackXYZIn[2] = trackParamIn.GetZ(); | |
828 | } | |
84f061ef | 829 | Double_t pTot = trackParam->P(); |
ecdf58c4 | 830 | Double_t pathLength, f0, f1, f2, meanRho, totalELoss, sigmaELoss2; |
831 | if (!GetAbsorberCorrectionParam(trackXYZIn,trackXYZOut,pTot,pathLength,f0,f1,f2,meanRho,totalELoss,sigmaELoss2)) { | |
18abc511 | 832 | cout<<"E-AliMUONTrackExtrap::ExtrapToVertex: Unable to take into account the absorber effects"<<endl; |
833 | if (trackParam->CovariancesExist()) ExtrapToZCov(trackParam,zVtx); | |
834 | else ExtrapToZ(trackParam,zVtx); | |
835 | return; | |
836 | } | |
8cde4af5 | 837 | |
690d2205 | 838 | // Compute track parameters and covariances at vertex according to correctForMCS and correctForEnergyLoss flags |
839 | if (correctForMCS) { | |
fac70e25 | 840 | |
690d2205 | 841 | if (correctForEnergyLoss) { |
842 | ||
843 | // Correct for multiple scattering and energy loss | |
ecdf58c4 | 844 | CorrectELossEffectInAbsorber(trackParam, 0.5*totalELoss, 0.5*sigmaELoss2); |
690d2205 | 845 | CorrectMCSEffectInAbsorber(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx, |
846 | trackXYZIn[2], pathLength, f0, f1, f2); | |
ecdf58c4 | 847 | CorrectELossEffectInAbsorber(trackParam, 0.5*totalELoss, 0.5*sigmaELoss2); |
690d2205 | 848 | |
849 | } else { | |
850 | ||
851 | // Correct for multiple scattering | |
852 | CorrectMCSEffectInAbsorber(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx, | |
853 | trackXYZIn[2], pathLength, f0, f1, f2); | |
854 | } | |
fac70e25 | 855 | |
fac70e25 | 856 | } else { |
690d2205 | 857 | |
858 | if (correctForEnergyLoss) { | |
859 | ||
18abc511 | 860 | // Correct for energy loss add multiple scattering dispersion in covariance matrix |
ecdf58c4 | 861 | CorrectELossEffectInAbsorber(trackParam, 0.5*totalELoss, 0.5*sigmaELoss2); |
37a615ac | 862 | AddMCSEffectInAbsorber(trackParam, -pathLength, f0, f1, f2); // (spectro. (z<0)) |
690d2205 | 863 | ExtrapToZCov(trackParam, trackXYZIn[2]); |
ecdf58c4 | 864 | CorrectELossEffectInAbsorber(trackParam, 0.5*totalELoss, 0.5*sigmaELoss2); |
690d2205 | 865 | ExtrapToZCov(trackParam, zVtx); |
866 | ||
867 | } else { | |
868 | ||
18abc511 | 869 | // add multiple scattering dispersion in covariance matrix |
37a615ac | 870 | AddMCSEffectInAbsorber(trackParam, -pathLength, f0, f1, f2); // (spectro. (z<0)) |
690d2205 | 871 | ExtrapToZCov(trackParam, zVtx); |
872 | ||
873 | } | |
874 | ||
fac70e25 | 875 | } |
8cde4af5 | 876 | |
fac70e25 | 877 | } |
878 | ||
690d2205 | 879 | //__________________________________________________________________________ |
880 | void AliMUONTrackExtrap::ExtrapToVertex(AliMUONTrackParam* trackParam, | |
881 | Double_t xVtx, Double_t yVtx, Double_t zVtx, | |
882 | Double_t errXVtx, Double_t errYVtx) | |
883 | { | |
884 | /// Extrapolate track parameters to vertex, corrected for multiple scattering and energy loss effects | |
885 | /// Add branson correction resolution and energy loss fluctuation to parameter covariances | |
886 | ExtrapToVertex(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx, kTRUE, kTRUE); | |
887 | } | |
888 | ||
889 | //__________________________________________________________________________ | |
890 | void AliMUONTrackExtrap::ExtrapToVertexWithoutELoss(AliMUONTrackParam* trackParam, | |
891 | Double_t xVtx, Double_t yVtx, Double_t zVtx, | |
892 | Double_t errXVtx, Double_t errYVtx) | |
893 | { | |
894 | /// Extrapolate track parameters to vertex, corrected for multiple scattering effects only | |
895 | /// Add branson correction resolution to parameter covariances | |
896 | ExtrapToVertex(trackParam, xVtx, yVtx, zVtx, errXVtx, errYVtx, kTRUE, kFALSE); | |
897 | } | |
898 | ||
899 | //__________________________________________________________________________ | |
900 | void AliMUONTrackExtrap::ExtrapToVertexWithoutBranson(AliMUONTrackParam* trackParam, Double_t zVtx) | |
901 | { | |
902 | /// Extrapolate track parameters to vertex, corrected for energy loss effects only | |
903 | /// Add dispersion due to multiple scattering and energy loss fluctuation to parameter covariances | |
904 | ExtrapToVertex(trackParam, 0., 0., zVtx, 0., 0., kFALSE, kTRUE); | |
905 | } | |
906 | ||
907 | //__________________________________________________________________________ | |
908 | void AliMUONTrackExtrap::ExtrapToVertexUncorrected(AliMUONTrackParam* trackParam, Double_t zVtx) | |
909 | { | |
910 | /// Extrapolate track parameters to vertex without multiple scattering and energy loss corrections | |
911 | /// Add dispersion due to multiple scattering to parameter covariances | |
912 | ExtrapToVertex(trackParam, 0., 0., zVtx, 0., 0., kFALSE, kFALSE); | |
913 | } | |
914 | ||
915 | //__________________________________________________________________________ | |
fac70e25 | 916 | Double_t AliMUONTrackExtrap::TotalMomentumEnergyLoss(AliMUONTrackParam* trackParam, Double_t xVtx, Double_t yVtx, Double_t zVtx) |
917 | { | |
918 | /// Calculate the total momentum energy loss in-between the track position and the vertex assuming a linear propagation | |
919 | ||
920 | if (trackParam->GetZ() == zVtx) return 0.; // nothing to be done if already at vertex | |
8cde4af5 | 921 | |
fac70e25 | 922 | // Check whether the geometry is available |
923 | if (!gGeoManager) { | |
924 | cout<<"E-AliMUONTrackExtrap::TotalMomentumEnergyLoss: no TGeo"<<endl; | |
925 | return 0.; | |
926 | } | |
927 | ||
928 | // Get encountered material correction parameters assuming linear propagation from vertex to the track position | |
929 | Double_t trackXYZOut[3]; | |
930 | trackXYZOut[0] = trackParam->GetNonBendingCoor(); | |
931 | trackXYZOut[1] = trackParam->GetBendingCoor(); | |
932 | trackXYZOut[2] = trackParam->GetZ(); | |
933 | Double_t trackXYZIn[3]; | |
934 | trackXYZIn[0] = xVtx; | |
935 | trackXYZIn[1] = yVtx; | |
936 | trackXYZIn[2] = zVtx; | |
84f061ef | 937 | Double_t pTot = trackParam->P(); |
18abc511 | 938 | Double_t pathLength, f0, f1, f2, meanRho, totalELoss, sigmaELoss2; |
690d2205 | 939 | GetAbsorberCorrectionParam(trackXYZIn,trackXYZOut,pTot,pathLength,f0,f1,f2,meanRho,totalELoss,sigmaELoss2); |
fac70e25 | 940 | |
ecdf58c4 | 941 | // total momentum corrected for energy loss |
942 | Double_t muMass = TDatabasePDG::Instance()->GetParticle("mu-")->Mass(); // GeV | |
943 | Double_t e = TMath::Sqrt(pTot*pTot + muMass*muMass); | |
944 | Double_t eCorr = e + totalELoss; | |
945 | Double_t pTotCorr = TMath::Sqrt(eCorr*eCorr - muMass*muMass); | |
946 | ||
947 | return pTotCorr - pTot; | |
c04e3238 | 948 | } |
949 | ||
690d2205 | 950 | //__________________________________________________________________________ |
fa5e35be | 951 | Double_t AliMUONTrackExtrap::BetheBloch(Double_t pTotal, Double_t pathLength, Double_t rho, Double_t atomicZ, Double_t atomicZoverA) |
c04e3238 | 952 | { |
84f061ef | 953 | /// Returns the mean total momentum energy loss of muon with total momentum='pTotal' |
954 | /// in the absorber layer of lenght='pathLength', density='rho', A='atomicA' and Z='atomicZ' | |
ecdf58c4 | 955 | Double_t muMass = TDatabasePDG::Instance()->GetParticle("mu-")->Mass(); // GeV |
84f061ef | 956 | |
ecdf58c4 | 957 | // mean exitation energy (GeV) |
958 | Double_t i; | |
959 | if (atomicZ < 13) i = (12. * atomicZ + 7.) * 1.e-9; | |
960 | else i = (9.76 * atomicZ + 58.8 * TMath::Power(atomicZ,-0.19)) * 1.e-9; | |
690d2205 | 961 | |
fa5e35be | 962 | return pathLength * rho * AliExternalTrackParam::BetheBlochGeant(pTotal/muMass, rho, 0.20, 3.00, i, atomicZoverA); |
c04e3238 | 963 | } |
964 | ||
690d2205 | 965 | //__________________________________________________________________________ |
fa5e35be | 966 | Double_t AliMUONTrackExtrap::EnergyLossFluctuation2(Double_t pTotal, Double_t pathLength, Double_t rho, Double_t atomicZoverA) |
690d2205 | 967 | { |
968 | /// Returns the total momentum energy loss fluctuation of muon with total momentum='pTotal' | |
969 | /// in the absorber layer of lenght='pathLength', density='rho', A='atomicA' and Z='atomicZ' | |
ecdf58c4 | 970 | Double_t muMass = TDatabasePDG::Instance()->GetParticle("mu-")->Mass(); // GeV |
690d2205 | 971 | //Double_t eMass = 0.510998918e-3; // GeV |
972 | Double_t k = 0.307075e-3; // GeV.g^-1.cm^2 | |
973 | Double_t p2=pTotal*pTotal; | |
974 | Double_t beta2=p2/(p2 + muMass*muMass); | |
975 | ||
fa5e35be | 976 | Double_t fwhm = 2. * k * rho * pathLength * atomicZoverA / beta2; // FWHM of the energy loss Landau distribution |
690d2205 | 977 | Double_t sigma2 = fwhm * fwhm / (8.*log(2.)); // gaussian: fwmh = 2 * srqt(2*ln(2)) * sigma (i.e. fwmh = 2.35 * sigma) |
978 | ||
979 | //sigma2 = k * rho * pathLength * atomicZ / atomicA * eMass; // sigma2 of the energy loss gaussian distribution | |
980 | ||
981 | return sigma2; | |
982 | } | |
983 | ||
984 | //__________________________________________________________________________ | |
985 | void AliMUONTrackExtrap::Cov2CovP(const TMatrixD ¶m, TMatrixD &cov) | |
986 | { | |
987 | /// change coordinate system: (X, SlopeX, Y, SlopeY, q/Pyz) -> (X, SlopeX, Y, SlopeY, q*PTot) | |
988 | /// parameters (param) are given in the (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system | |
989 | ||
990 | // charge * total momentum | |
991 | Double_t qPTot = TMath::Sqrt(1. + param(1,0)*param(1,0) + param(3,0)*param(3,0)) / | |
992 | TMath::Sqrt(1. + param(3,0)*param(3,0)) / param(4,0); | |
993 | ||
994 | // Jacobian of the opposite transformation | |
995 | TMatrixD jacob(5,5); | |
996 | jacob.UnitMatrix(); | |
997 | jacob(4,1) = qPTot * param(1,0) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0)); | |
998 | jacob(4,3) = - qPTot * param(1,0) * param(1,0) * param(3,0) / | |
999 | (1. + param(3,0)*param(3,0)) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0)); | |
1000 | jacob(4,4) = - qPTot / param(4,0); | |
1001 | ||
1002 | // compute covariances in new coordinate system | |
1003 | TMatrixD tmp(cov,TMatrixD::kMultTranspose,jacob); | |
1004 | cov.Mult(jacob,tmp); | |
1005 | } | |
1006 | ||
1007 | //__________________________________________________________________________ | |
1008 | void AliMUONTrackExtrap::CovP2Cov(const TMatrixD ¶m, TMatrixD &covP) | |
1009 | { | |
1010 | /// change coordinate system: (X, SlopeX, Y, SlopeY, q*PTot) -> (X, SlopeX, Y, SlopeY, q/Pyz) | |
1011 | /// parameters (param) are given in the (X, SlopeX, Y, SlopeY, q/Pyz) coordinate system | |
1012 | ||
1013 | // charge * total momentum | |
1014 | Double_t qPTot = TMath::Sqrt(1. + param(1,0)*param(1,0) + param(3,0)*param(3,0)) / | |
1015 | TMath::Sqrt(1. + param(3,0)*param(3,0)) / param(4,0); | |
1016 | ||
1017 | // Jacobian of the transformation | |
1018 | TMatrixD jacob(5,5); | |
1019 | jacob.UnitMatrix(); | |
1020 | jacob(4,1) = param(4,0) * param(1,0) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0)); | |
1021 | jacob(4,3) = - param(4,0) * param(1,0) * param(1,0) * param(3,0) / | |
1022 | (1. + param(3,0)*param(3,0)) / (1. + param(1,0)*param(1,0) + param(3,0)*param(3,0)); | |
1023 | jacob(4,4) = - param(4,0) / qPTot; | |
1024 | ||
1025 | // compute covariances in new coordinate system | |
1026 | TMatrixD tmp(covP,TMatrixD::kMultTranspose,jacob); | |
1027 | covP.Mult(jacob,tmp); | |
1028 | } | |
1029 | ||
c04e3238 | 1030 | //__________________________________________________________________________ |
57e2ad1a | 1031 | void AliMUONTrackExtrap::ExtrapOneStepHelix(Double_t charge, Double_t step, const Double_t *vect, Double_t *vout) |
c04e3238 | 1032 | { |
71a2d3aa | 1033 | /// <pre> |
c04e3238 | 1034 | /// ****************************************************************** |
1035 | /// * * | |
1036 | /// * Performs the tracking of one step in a magnetic field * | |
1037 | /// * The trajectory is assumed to be a helix in a constant field * | |
1038 | /// * taken at the mid point of the step. * | |
1039 | /// * Parameters: * | |
1040 | /// * input * | |
1041 | /// * STEP =arc length of the step asked * | |
1042 | /// * VECT =input vector (position,direction cos and momentum) * | |
1043 | /// * CHARGE= electric charge of the particle * | |
1044 | /// * output * | |
1045 | /// * VOUT = same as VECT after completion of the step * | |
1046 | /// * * | |
2060b217 | 1047 | /// * ==>Called by : USER, GUSWIM * |
c04e3238 | 1048 | /// * Author m.hansroul ********* * |
1049 | /// * modified s.egli, s.v.levonian * | |
1050 | /// * modified v.perevoztchikov | |
1051 | /// * * | |
1052 | /// ****************************************************************** | |
71a2d3aa | 1053 | /// </pre> |
c04e3238 | 1054 | |
1055 | // modif: everything in double precision | |
1056 | ||
1057 | Double_t xyz[3], h[4], hxp[3]; | |
1058 | Double_t h2xy, hp, rho, tet; | |
1059 | Double_t sint, sintt, tsint, cos1t; | |
1060 | Double_t f1, f2, f3, f4, f5, f6; | |
1061 | ||
1062 | const Int_t kix = 0; | |
1063 | const Int_t kiy = 1; | |
1064 | const Int_t kiz = 2; | |
1065 | const Int_t kipx = 3; | |
1066 | const Int_t kipy = 4; | |
1067 | const Int_t kipz = 5; | |
1068 | const Int_t kipp = 6; | |
1069 | ||
1070 | const Double_t kec = 2.9979251e-4; | |
1071 | // | |
1072 | // ------------------------------------------------------------------ | |
1073 | // | |
1074 | // units are kgauss,centimeters,gev/c | |
1075 | // | |
1076 | vout[kipp] = vect[kipp]; | |
1077 | if (TMath::Abs(charge) < 0.00001) { | |
1078 | for (Int_t i = 0; i < 3; i++) { | |
1079 | vout[i] = vect[i] + step * vect[i+3]; | |
1080 | vout[i+3] = vect[i+3]; | |
1081 | } | |
1082 | return; | |
1083 | } | |
1084 | xyz[0] = vect[kix] + 0.5 * step * vect[kipx]; | |
1085 | xyz[1] = vect[kiy] + 0.5 * step * vect[kipy]; | |
1086 | xyz[2] = vect[kiz] + 0.5 * step * vect[kipz]; | |
1087 | ||
1088 | //cmodif: call gufld (xyz, h) changed into: | |
f7a1cc68 | 1089 | TGeoGlobalMagField::Instance()->Field(xyz,h); |
c04e3238 | 1090 | |
1091 | h2xy = h[0]*h[0] + h[1]*h[1]; | |
1092 | h[3] = h[2]*h[2]+ h2xy; | |
1093 | if (h[3] < 1.e-12) { | |
1094 | for (Int_t i = 0; i < 3; i++) { | |
1095 | vout[i] = vect[i] + step * vect[i+3]; | |
1096 | vout[i+3] = vect[i+3]; | |
1097 | } | |
1098 | return; | |
1099 | } | |
1100 | if (h2xy < 1.e-12*h[3]) { | |
1101 | ExtrapOneStepHelix3(charge*h[2], step, vect, vout); | |
1102 | return; | |
1103 | } | |
1104 | h[3] = TMath::Sqrt(h[3]); | |
1105 | h[0] /= h[3]; | |
1106 | h[1] /= h[3]; | |
1107 | h[2] /= h[3]; | |
1108 | h[3] *= kec; | |
1109 | ||
1110 | hxp[0] = h[1]*vect[kipz] - h[2]*vect[kipy]; | |
1111 | hxp[1] = h[2]*vect[kipx] - h[0]*vect[kipz]; | |
1112 | hxp[2] = h[0]*vect[kipy] - h[1]*vect[kipx]; | |
1113 | ||
1114 | hp = h[0]*vect[kipx] + h[1]*vect[kipy] + h[2]*vect[kipz]; | |
1115 | ||
1116 | rho = -charge*h[3]/vect[kipp]; | |
1117 | tet = rho * step; | |
1118 | ||
1119 | if (TMath::Abs(tet) > 0.15) { | |
1120 | sint = TMath::Sin(tet); | |
1121 | sintt = (sint/tet); | |
1122 | tsint = (tet-sint)/tet; | |
1123 | cos1t = 2.*(TMath::Sin(0.5*tet))*(TMath::Sin(0.5*tet))/tet; | |
1124 | } else { | |
1125 | tsint = tet*tet/36.; | |
1126 | sintt = (1. - tsint); | |
1127 | sint = tet*sintt; | |
1128 | cos1t = 0.5*tet; | |
1129 | } | |
1130 | ||
1131 | f1 = step * sintt; | |
1132 | f2 = step * cos1t; | |
1133 | f3 = step * tsint * hp; | |
1134 | f4 = -tet*cos1t; | |
1135 | f5 = sint; | |
1136 | f6 = tet * cos1t * hp; | |
1137 | ||
1138 | vout[kix] = vect[kix] + f1*vect[kipx] + f2*hxp[0] + f3*h[0]; | |
1139 | vout[kiy] = vect[kiy] + f1*vect[kipy] + f2*hxp[1] + f3*h[1]; | |
1140 | vout[kiz] = vect[kiz] + f1*vect[kipz] + f2*hxp[2] + f3*h[2]; | |
1141 | ||
1142 | vout[kipx] = vect[kipx] + f4*vect[kipx] + f5*hxp[0] + f6*h[0]; | |
1143 | vout[kipy] = vect[kipy] + f4*vect[kipy] + f5*hxp[1] + f6*h[1]; | |
1144 | vout[kipz] = vect[kipz] + f4*vect[kipz] + f5*hxp[2] + f6*h[2]; | |
1145 | ||
1146 | return; | |
1147 | } | |
1148 | ||
1149 | //__________________________________________________________________________ | |
57e2ad1a | 1150 | void AliMUONTrackExtrap::ExtrapOneStepHelix3(Double_t field, Double_t step, const Double_t *vect, Double_t *vout) |
c04e3238 | 1151 | { |
71a2d3aa | 1152 | /// <pre> |
c04e3238 | 1153 | /// ****************************************************************** |
1154 | /// * * | |
1155 | /// * Tracking routine in a constant field oriented * | |
1156 | /// * along axis 3 * | |
1157 | /// * Tracking is performed with a conventional * | |
1158 | /// * helix step method * | |
1159 | /// * * | |
2060b217 | 1160 | /// * ==>Called by : USER, GUSWIM * |
c04e3238 | 1161 | /// * Authors R.Brun, M.Hansroul ********* * |
1162 | /// * Rewritten V.Perevoztchikov | |
1163 | /// * * | |
1164 | /// ****************************************************************** | |
71a2d3aa | 1165 | /// </pre> |
c04e3238 | 1166 | |
1167 | Double_t hxp[3]; | |
1168 | Double_t h4, hp, rho, tet; | |
1169 | Double_t sint, sintt, tsint, cos1t; | |
1170 | Double_t f1, f2, f3, f4, f5, f6; | |
1171 | ||
1172 | const Int_t kix = 0; | |
1173 | const Int_t kiy = 1; | |
1174 | const Int_t kiz = 2; | |
1175 | const Int_t kipx = 3; | |
1176 | const Int_t kipy = 4; | |
1177 | const Int_t kipz = 5; | |
1178 | const Int_t kipp = 6; | |
1179 | ||
1180 | const Double_t kec = 2.9979251e-4; | |
1181 | ||
1182 | // | |
1183 | // ------------------------------------------------------------------ | |
1184 | // | |
1185 | // units are kgauss,centimeters,gev/c | |
1186 | // | |
1187 | vout[kipp] = vect[kipp]; | |
1188 | h4 = field * kec; | |
1189 | ||
1190 | hxp[0] = - vect[kipy]; | |
1191 | hxp[1] = + vect[kipx]; | |
1192 | ||
1193 | hp = vect[kipz]; | |
1194 | ||
1195 | rho = -h4/vect[kipp]; | |
1196 | tet = rho * step; | |
1197 | if (TMath::Abs(tet) > 0.15) { | |
1198 | sint = TMath::Sin(tet); | |
1199 | sintt = (sint/tet); | |
1200 | tsint = (tet-sint)/tet; | |
1201 | cos1t = 2.* TMath::Sin(0.5*tet) * TMath::Sin(0.5*tet)/tet; | |
1202 | } else { | |
1203 | tsint = tet*tet/36.; | |
1204 | sintt = (1. - tsint); | |
1205 | sint = tet*sintt; | |
1206 | cos1t = 0.5*tet; | |
1207 | } | |
1208 | ||
1209 | f1 = step * sintt; | |
1210 | f2 = step * cos1t; | |
1211 | f3 = step * tsint * hp; | |
1212 | f4 = -tet*cos1t; | |
1213 | f5 = sint; | |
1214 | f6 = tet * cos1t * hp; | |
1215 | ||
1216 | vout[kix] = vect[kix] + f1*vect[kipx] + f2*hxp[0]; | |
1217 | vout[kiy] = vect[kiy] + f1*vect[kipy] + f2*hxp[1]; | |
1218 | vout[kiz] = vect[kiz] + f1*vect[kipz] + f3; | |
1219 | ||
1220 | vout[kipx] = vect[kipx] + f4*vect[kipx] + f5*hxp[0]; | |
1221 | vout[kipy] = vect[kipy] + f4*vect[kipy] + f5*hxp[1]; | |
1222 | vout[kipz] = vect[kipz] + f4*vect[kipz] + f6; | |
1223 | ||
1224 | return; | |
1225 | } | |
8cde4af5 | 1226 | |
c04e3238 | 1227 | //__________________________________________________________________________ |
57e2ad1a | 1228 | Bool_t AliMUONTrackExtrap::ExtrapOneStepRungekutta(Double_t charge, Double_t step, const Double_t* vect, Double_t* vout) |
c04e3238 | 1229 | { |
71a2d3aa | 1230 | /// <pre> |
c04e3238 | 1231 | /// ****************************************************************** |
1232 | /// * * | |
1233 | /// * Runge-Kutta method for tracking a particle through a magnetic * | |
1234 | /// * field. Uses Nystroem algorithm (See Handbook Nat. Bur. of * | |
1235 | /// * Standards, procedure 25.5.20) * | |
1236 | /// * * | |
1237 | /// * Input parameters * | |
1238 | /// * CHARGE Particle charge * | |
1239 | /// * STEP Step size * | |
1240 | /// * VECT Initial co-ords,direction cosines,momentum * | |
1241 | /// * Output parameters * | |
1242 | /// * VOUT Output co-ords,direction cosines,momentum * | |
1243 | /// * User routine called * | |
1244 | /// * CALL GUFLD(X,F) * | |
1245 | /// * * | |
2060b217 | 1246 | /// * ==>Called by : USER, GUSWIM * |
c04e3238 | 1247 | /// * Authors R.Brun, M.Hansroul ********* * |
1248 | /// * V.Perevoztchikov (CUT STEP implementation) * | |
1249 | /// * * | |
1250 | /// * * | |
1251 | /// ****************************************************************** | |
71a2d3aa | 1252 | /// </pre> |
c04e3238 | 1253 | |
1254 | Double_t h2, h4, f[4]; | |
d373bcbe | 1255 | Double_t xyzt[3] = {FLT_MAX, FLT_MAX, FLT_MAX}; |
1256 | Double_t a, b, c, ph,ph2; | |
c04e3238 | 1257 | Double_t secxs[4],secys[4],seczs[4],hxp[3]; |
1258 | Double_t g1, g2, g3, g4, g5, g6, ang2, dxt, dyt, dzt; | |
1259 | Double_t est, at, bt, ct, cba; | |
1260 | Double_t f1, f2, f3, f4, rho, tet, hnorm, hp, rho1, sint, cost; | |
1261 | ||
1262 | Double_t x; | |
1263 | Double_t y; | |
1264 | Double_t z; | |
1265 | ||
1266 | Double_t xt; | |
1267 | Double_t yt; | |
1268 | Double_t zt; | |
1269 | ||
1270 | Double_t maxit = 1992; | |
1271 | Double_t maxcut = 11; | |
1272 | ||
1273 | const Double_t kdlt = 1e-4; | |
1274 | const Double_t kdlt32 = kdlt/32.; | |
1275 | const Double_t kthird = 1./3.; | |
1276 | const Double_t khalf = 0.5; | |
1277 | const Double_t kec = 2.9979251e-4; | |
1278 | ||
1279 | const Double_t kpisqua = 9.86960440109; | |
1280 | const Int_t kix = 0; | |
1281 | const Int_t kiy = 1; | |
1282 | const Int_t kiz = 2; | |
1283 | const Int_t kipx = 3; | |
1284 | const Int_t kipy = 4; | |
1285 | const Int_t kipz = 5; | |
1286 | ||
1287 | // *. | |
1288 | // *. ------------------------------------------------------------------ | |
1289 | // *. | |
1290 | // * this constant is for units cm,gev/c and kgauss | |
1291 | // * | |
1292 | Int_t iter = 0; | |
1293 | Int_t ncut = 0; | |
1294 | for(Int_t j = 0; j < 7; j++) | |
1295 | vout[j] = vect[j]; | |
1296 | ||
1297 | Double_t pinv = kec * charge / vect[6]; | |
1298 | Double_t tl = 0.; | |
1299 | Double_t h = step; | |
1300 | Double_t rest; | |
1301 | ||
1302 | ||
1303 | do { | |
1304 | rest = step - tl; | |
1305 | if (TMath::Abs(h) > TMath::Abs(rest)) h = rest; | |
1306 | //cmodif: call gufld(vout,f) changed into: | |
f7a1cc68 | 1307 | TGeoGlobalMagField::Instance()->Field(vout,f); |
c04e3238 | 1308 | |
1309 | // * | |
1310 | // * start of integration | |
1311 | // * | |
1312 | x = vout[0]; | |
1313 | y = vout[1]; | |
1314 | z = vout[2]; | |
1315 | a = vout[3]; | |
1316 | b = vout[4]; | |
1317 | c = vout[5]; | |
1318 | ||
1319 | h2 = khalf * h; | |
1320 | h4 = khalf * h2; | |
1321 | ph = pinv * h; | |
1322 | ph2 = khalf * ph; | |
1323 | secxs[0] = (b * f[2] - c * f[1]) * ph2; | |
1324 | secys[0] = (c * f[0] - a * f[2]) * ph2; | |
1325 | seczs[0] = (a * f[1] - b * f[0]) * ph2; | |
1326 | ang2 = (secxs[0]*secxs[0] + secys[0]*secys[0] + seczs[0]*seczs[0]); | |
1327 | if (ang2 > kpisqua) break; | |
1328 | ||
1329 | dxt = h2 * a + h4 * secxs[0]; | |
1330 | dyt = h2 * b + h4 * secys[0]; | |
1331 | dzt = h2 * c + h4 * seczs[0]; | |
1332 | xt = x + dxt; | |
1333 | yt = y + dyt; | |
1334 | zt = z + dzt; | |
1335 | // * | |
1336 | // * second intermediate point | |
1337 | // * | |
1338 | ||
1339 | est = TMath::Abs(dxt) + TMath::Abs(dyt) + TMath::Abs(dzt); | |
1340 | if (est > h) { | |
1341 | if (ncut++ > maxcut) break; | |
1342 | h *= khalf; | |
1343 | continue; | |
1344 | } | |
1345 | ||
1346 | xyzt[0] = xt; | |
1347 | xyzt[1] = yt; | |
1348 | xyzt[2] = zt; | |
1349 | ||
1350 | //cmodif: call gufld(xyzt,f) changed into: | |
f7a1cc68 | 1351 | TGeoGlobalMagField::Instance()->Field(xyzt,f); |
c04e3238 | 1352 | |
1353 | at = a + secxs[0]; | |
1354 | bt = b + secys[0]; | |
1355 | ct = c + seczs[0]; | |
1356 | ||
1357 | secxs[1] = (bt * f[2] - ct * f[1]) * ph2; | |
1358 | secys[1] = (ct * f[0] - at * f[2]) * ph2; | |
1359 | seczs[1] = (at * f[1] - bt * f[0]) * ph2; | |
1360 | at = a + secxs[1]; | |
1361 | bt = b + secys[1]; | |
1362 | ct = c + seczs[1]; | |
1363 | secxs[2] = (bt * f[2] - ct * f[1]) * ph2; | |
1364 | secys[2] = (ct * f[0] - at * f[2]) * ph2; | |
1365 | seczs[2] = (at * f[1] - bt * f[0]) * ph2; | |
1366 | dxt = h * (a + secxs[2]); | |
1367 | dyt = h * (b + secys[2]); | |
1368 | dzt = h * (c + seczs[2]); | |
1369 | xt = x + dxt; | |
1370 | yt = y + dyt; | |
1371 | zt = z + dzt; | |
1372 | at = a + 2.*secxs[2]; | |
1373 | bt = b + 2.*secys[2]; | |
1374 | ct = c + 2.*seczs[2]; | |
1375 | ||
1376 | est = TMath::Abs(dxt)+TMath::Abs(dyt)+TMath::Abs(dzt); | |
1377 | if (est > 2.*TMath::Abs(h)) { | |
1378 | if (ncut++ > maxcut) break; | |
1379 | h *= khalf; | |
1380 | continue; | |
1381 | } | |
1382 | ||
1383 | xyzt[0] = xt; | |
1384 | xyzt[1] = yt; | |
1385 | xyzt[2] = zt; | |
1386 | ||
1387 | //cmodif: call gufld(xyzt,f) changed into: | |
f7a1cc68 | 1388 | TGeoGlobalMagField::Instance()->Field(xyzt,f); |
c04e3238 | 1389 | |
1390 | z = z + (c + (seczs[0] + seczs[1] + seczs[2]) * kthird) * h; | |
1391 | y = y + (b + (secys[0] + secys[1] + secys[2]) * kthird) * h; | |
1392 | x = x + (a + (secxs[0] + secxs[1] + secxs[2]) * kthird) * h; | |
1393 | ||
1394 | secxs[3] = (bt*f[2] - ct*f[1])* ph2; | |
1395 | secys[3] = (ct*f[0] - at*f[2])* ph2; | |
1396 | seczs[3] = (at*f[1] - bt*f[0])* ph2; | |
1397 | a = a+(secxs[0]+secxs[3]+2. * (secxs[1]+secxs[2])) * kthird; | |
1398 | b = b+(secys[0]+secys[3]+2. * (secys[1]+secys[2])) * kthird; | |
1399 | c = c+(seczs[0]+seczs[3]+2. * (seczs[1]+seczs[2])) * kthird; | |
1400 | ||
1401 | est = TMath::Abs(secxs[0]+secxs[3] - (secxs[1]+secxs[2])) | |
1402 | + TMath::Abs(secys[0]+secys[3] - (secys[1]+secys[2])) | |
1403 | + TMath::Abs(seczs[0]+seczs[3] - (seczs[1]+seczs[2])); | |
1404 | ||
1405 | if (est > kdlt && TMath::Abs(h) > 1.e-4) { | |
1406 | if (ncut++ > maxcut) break; | |
1407 | h *= khalf; | |
1408 | continue; | |
1409 | } | |
1410 | ||
1411 | ncut = 0; | |
1412 | // * if too many iterations, go to helix | |
1413 | if (iter++ > maxit) break; | |
1414 | ||
1415 | tl += h; | |
1416 | if (est < kdlt32) | |
1417 | h *= 2.; | |
1418 | cba = 1./ TMath::Sqrt(a*a + b*b + c*c); | |
1419 | vout[0] = x; | |
1420 | vout[1] = y; | |
1421 | vout[2] = z; | |
1422 | vout[3] = cba*a; | |
1423 | vout[4] = cba*b; | |
1424 | vout[5] = cba*c; | |
1425 | rest = step - tl; | |
1426 | if (step < 0.) rest = -rest; | |
ade4e6f9 | 1427 | if (rest < 1.e-5*TMath::Abs(step)) return kTRUE; |
c04e3238 | 1428 | |
1429 | } while(1); | |
1430 | ||
1431 | // angle too big, use helix | |
ade4e6f9 | 1432 | cout<<"W-AliMUONTrackExtrap::ExtrapOneStepRungekutta: Ruge-Kutta failed: switch to helix"<<endl; |
c04e3238 | 1433 | |
1434 | f1 = f[0]; | |
1435 | f2 = f[1]; | |
1436 | f3 = f[2]; | |
1437 | f4 = TMath::Sqrt(f1*f1+f2*f2+f3*f3); | |
ade4e6f9 | 1438 | if (f4 < 1.e-10) { |
1439 | cout<<"E-AliMUONTrackExtrap::ExtrapOneStepRungekutta: magnetic field at ("; | |
1440 | cout<<xyzt[0]<<", "<<xyzt[1]<<", "<<xyzt[2]<<") = "<<f4<<": giving up"<<endl; | |
1441 | return kFALSE; | |
1442 | } | |
c04e3238 | 1443 | rho = -f4*pinv; |
1444 | tet = rho * step; | |
1445 | ||
1446 | hnorm = 1./f4; | |
1447 | f1 = f1*hnorm; | |
1448 | f2 = f2*hnorm; | |
1449 | f3 = f3*hnorm; | |
1450 | ||
1451 | hxp[0] = f2*vect[kipz] - f3*vect[kipy]; | |
1452 | hxp[1] = f3*vect[kipx] - f1*vect[kipz]; | |
1453 | hxp[2] = f1*vect[kipy] - f2*vect[kipx]; | |
1454 | ||
1455 | hp = f1*vect[kipx] + f2*vect[kipy] + f3*vect[kipz]; | |
1456 | ||
1457 | rho1 = 1./rho; | |
1458 | sint = TMath::Sin(tet); | |
1459 | cost = 2.*TMath::Sin(khalf*tet)*TMath::Sin(khalf*tet); | |
1460 | ||
1461 | g1 = sint*rho1; | |
1462 | g2 = cost*rho1; | |
1463 | g3 = (tet-sint) * hp*rho1; | |
1464 | g4 = -cost; | |
1465 | g5 = sint; | |
1466 | g6 = cost * hp; | |
1467 | ||
1468 | vout[kix] = vect[kix] + g1*vect[kipx] + g2*hxp[0] + g3*f1; | |
1469 | vout[kiy] = vect[kiy] + g1*vect[kipy] + g2*hxp[1] + g3*f2; | |
1470 | vout[kiz] = vect[kiz] + g1*vect[kipz] + g2*hxp[2] + g3*f3; | |
1471 | ||
1472 | vout[kipx] = vect[kipx] + g4*vect[kipx] + g5*hxp[0] + g6*f1; | |
1473 | vout[kipy] = vect[kipy] + g4*vect[kipy] + g5*hxp[1] + g6*f2; | |
1474 | vout[kipz] = vect[kipz] + g4*vect[kipz] + g5*hxp[2] + g6*f3; | |
1475 | ||
ade4e6f9 | 1476 | return kTRUE; |
c04e3238 | 1477 | } |
8cde4af5 | 1478 |