1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ///////////////////////////////////////////////////
26 ///////////////////////////////////////////////////
28 #include <Riostream.h>
30 #include "AliCallf77.h"
32 #include "AliMUONTrackParam.h"
33 #include "AliMUONChamber.h"
37 ClassImp(AliMUONTrackParam) // Class implementation in ROOT context
39 // A few calls in Fortran or from Fortran (extrap.F).
40 // Needed, instead of calls to Geant subroutines,
41 // because double precision is necessary for track fit converging with Minuit.
42 // The "extrap" functions should be translated into C++ ????
44 # define extrap_onestep_helix extrap_onestep_helix_
45 # define extrap_onestep_helix3 extrap_onestep_helix3_
46 # define extrap_onestep_rungekutta extrap_onestep_rungekutta_
47 # define gufld_double gufld_double_
49 # define extrap_onestep_helix EXTRAP_ONESTEP_HELIX
50 # define extrap_onestep_helix3 EXTRAP_ONESTEP_HELIX3
51 # define extrap_onestep_rungekutta EXTRAP_ONESTEP_RUNGEKUTTA
52 # define gufld_double GUFLD_DOUBLE
56 void type_of_call extrap_onestep_helix
57 (Double_t &Charge, Double_t &StepLength, Double_t *VGeant3, Double_t *VGeant3New);
59 void type_of_call extrap_onestep_helix3
60 (Double_t &Field, Double_t &StepLength, Double_t *VGeant3, Double_t *VGeant3New);
62 void type_of_call extrap_onestep_rungekutta
63 (Double_t &Charge, Double_t &StepLength, Double_t *VGeant3, Double_t *VGeant3New);
65 void type_of_call gufld_double(Double_t *Position, Double_t *Field) {
66 // interface to "gAlice->Field()->Field" for arguments in double precision
68 x[0] = Position[0]; x[1] = Position[1]; x[2] = Position[2];
69 gAlice->Field()->Field(x, b);
70 Field[0] = b[0]; Field[1] = b[1]; Field[2] = b[2];
73 //_________________________________________________________________________
75 AliMUONTrackParam& AliMUONTrackParam::operator=(const AliMUONTrackParam& MUONTrackParam)
77 if (this == &MUONTrackParam)
80 fInverseBendingMomentum = MUONTrackParam.fInverseBendingMomentum;
81 fBendingSlope = MUONTrackParam.fBendingSlope;
82 fNonBendingSlope = MUONTrackParam.fNonBendingSlope;
83 fZ = MUONTrackParam.fZ;
84 fBendingCoor = MUONTrackParam.fBendingCoor;
85 fNonBendingCoor = MUONTrackParam.fNonBendingCoor;
89 //_________________________________________________________________________
90 AliMUONTrackParam::AliMUONTrackParam(const AliMUONTrackParam& MUONTrackParam):TObject(MUONTrackParam)
92 fInverseBendingMomentum = MUONTrackParam.fInverseBendingMomentum;
93 fBendingSlope = MUONTrackParam.fBendingSlope;
94 fNonBendingSlope = MUONTrackParam.fNonBendingSlope;
95 fZ = MUONTrackParam.fZ;
96 fBendingCoor = MUONTrackParam.fBendingCoor;
97 fNonBendingCoor = MUONTrackParam.fNonBendingCoor;
100 //__________________________________________________________________________
101 void AliMUONTrackParam::ExtrapToZ(Double_t Z)
103 // Track parameter extrapolation to the plane at "Z".
104 // On return, the track parameters resulting from the extrapolation
105 // replace the current track parameters.
106 if (this->fZ == Z) return; // nothing to be done if same Z
107 Double_t forwardBackward; // +1 if forward, -1 if backward
108 if (Z < this->fZ) forwardBackward = 1.0; // spectro. z<0
109 else forwardBackward = -1.0;
110 Double_t vGeant3[7], vGeant3New[7]; // 7 in parameter ????
111 Int_t iGeant3, stepNumber;
112 Int_t maxStepNumber = 5000; // in parameter ????
113 // For safety: return kTRUE or kFALSE ????
114 // Parameter vector for calling EXTRAP_ONESTEP
115 SetGeant3Parameters(vGeant3, forwardBackward);
116 // sign of charge (sign of fInverseBendingMomentum if forward motion)
117 // must be changed if backward extrapolation
118 Double_t chargeExtrap = forwardBackward *
119 TMath::Sign(Double_t(1.0), this->fInverseBendingMomentum);
120 Double_t stepLength = 6.0; // in parameter ????
121 // Extrapolation loop
123 while (((-forwardBackward * (vGeant3[2] - Z)) <= 0.0) && // spectro. z<0
124 (stepNumber < maxStepNumber)) {
126 // Option for switching between helix and Runge-Kutta ????
127 // extrap_onestep_rungekutta(chargeExtrap, stepLength, vGeant3, vGeant3New);
128 extrap_onestep_helix(chargeExtrap, stepLength, vGeant3, vGeant3New);
129 if ((-forwardBackward * (vGeant3New[2] - Z)) > 0.0) break; // one is beyond Z spectro. z<0
130 // better use TArray ????
131 for (iGeant3 = 0; iGeant3 < 7; iGeant3++)
132 {vGeant3[iGeant3] = vGeant3New[iGeant3];}
134 // check maxStepNumber ????
135 // Interpolation back to exact Z (2nd order)
136 // should be in function ???? using TArray ????
137 Double_t dZ12 = vGeant3New[2] - vGeant3[2]; // 1->2
138 Double_t dZ1i = Z - vGeant3[2]; // 1-i
139 Double_t dZi2 = vGeant3New[2] - Z; // i->2
140 Double_t xPrime = (vGeant3New[0] - vGeant3[0]) / dZ12;
142 ((vGeant3New[3] / vGeant3New[5]) - (vGeant3[3] / vGeant3[5])) / dZ12;
143 Double_t yPrime = (vGeant3New[1] - vGeant3[1]) / dZ12;
145 ((vGeant3New[4] / vGeant3New[5]) - (vGeant3[4] / vGeant3[5])) / dZ12;
146 vGeant3[0] = vGeant3[0] + xPrime * dZ1i - 0.5 * xSecond * dZ1i * dZi2; // X
147 vGeant3[1] = vGeant3[1] + yPrime * dZ1i - 0.5 * ySecond * dZ1i * dZi2; // Y
149 Double_t xPrimeI = xPrime - 0.5 * xSecond * (dZi2 - dZ1i);
150 Double_t yPrimeI = yPrime - 0.5 * ySecond * (dZi2 - dZ1i);
151 // (PX, PY, PZ)/PTOT assuming forward motion
153 1.0 / TMath::Sqrt(1.0 + xPrimeI * xPrimeI + yPrimeI * yPrimeI); // PZ/PTOT
154 vGeant3[3] = xPrimeI * vGeant3[5]; // PX/PTOT
155 vGeant3[4] = yPrimeI * vGeant3[5]; // PY/PTOT
156 // Track parameters from Geant3 parameters,
157 // with charge back for forward motion
158 GetFromGeant3Parameters(vGeant3, chargeExtrap * forwardBackward);
161 //__________________________________________________________________________
162 void AliMUONTrackParam::SetGeant3Parameters(Double_t *VGeant3, Double_t ForwardBackward)
164 // Set vector of Geant3 parameters pointed to by "VGeant3"
165 // from track parameters in current AliMUONTrackParam.
166 // Since AliMUONTrackParam is only geometry, one uses "ForwardBackward"
167 // to know whether the particle is going forward (+1) or backward (-1).
168 VGeant3[0] = this->fNonBendingCoor; // X
169 VGeant3[1] = this->fBendingCoor; // Y
170 VGeant3[2] = this->fZ; // Z
171 Double_t pYZ = TMath::Abs(1.0 / this->fInverseBendingMomentum);
173 pYZ / TMath::Sqrt(1.0 + this->fBendingSlope * this->fBendingSlope);
175 TMath::Sqrt(pYZ * pYZ +
176 pZ * pZ * this->fNonBendingSlope * this->fNonBendingSlope); // PTOT
177 VGeant3[5] = -ForwardBackward * pZ / VGeant3[6]; // PZ/PTOT spectro. z<0
178 VGeant3[3] = this->fNonBendingSlope * VGeant3[5]; // PX/PTOT
179 VGeant3[4] = this->fBendingSlope * VGeant3[5]; // PY/PTOT
182 //__________________________________________________________________________
183 void AliMUONTrackParam::GetFromGeant3Parameters(Double_t *VGeant3, Double_t Charge)
185 // Get track parameters in current AliMUONTrackParam
186 // from Geant3 parameters pointed to by "VGeant3",
187 // assumed to be calculated for forward motion in Z.
188 // "InverseBendingMomentum" is signed with "Charge".
189 this->fNonBendingCoor = VGeant3[0]; // X
190 this->fBendingCoor = VGeant3[1]; // Y
191 this->fZ = VGeant3[2]; // Z
192 Double_t pYZ = VGeant3[6] * TMath::Sqrt(1.0 - VGeant3[3] * VGeant3[3]);
193 this->fInverseBendingMomentum = Charge / pYZ;
194 this->fBendingSlope = VGeant3[4] / VGeant3[5];
195 this->fNonBendingSlope = VGeant3[3] / VGeant3[5];
198 //__________________________________________________________________________
199 void AliMUONTrackParam::ExtrapToStation(Int_t Station, AliMUONTrackParam *TrackParam)
201 // Track parameters extrapolated from current track parameters ("this")
202 // to both chambers of the station(0..) "Station"
203 // are returned in the array (dimension 2) of track parameters
204 // pointed to by "TrackParam" (index 0 and 1 for first and second chambers).
205 Double_t extZ[2], z1, z2;
206 Int_t i1 = -1, i2 = -1; // = -1 to avoid compilation warnings
207 AliMUON *pMUON = (AliMUON*) gAlice->GetModule("MUON"); // necessary ????
208 // range of Station to be checked ????
209 z1 = (&(pMUON->Chamber(2 * Station)))->Z(); // Z of first chamber
210 z2 = (&(pMUON->Chamber(2 * Station + 1)))->Z(); // Z of second chamber
211 // First and second Z to extrapolate at
212 if ((z1 > this->fZ) && (z2 > this->fZ)) {i1 = 0; i2 = 1;}
213 else if ((z1 < this->fZ) && (z2 < this->fZ)) {i1 = 1; i2 = 0;}
215 cout << "ERROR in AliMUONTrackParam::CreateExtrapSegmentInStation" << endl;
216 cout << "Starting Z (" << this->fZ << ") in between z1 (" << z1 <<
217 ") and z2 (" << z2 << ") of station(0..) " << Station << endl;
221 // copy of track parameters
222 TrackParam[i1] = *this;
223 // first extrapolation
224 (&(TrackParam[i1]))->ExtrapToZ(extZ[0]);
225 TrackParam[i2] = TrackParam[i1];
226 // second extrapolation
227 (&(TrackParam[i2]))->ExtrapToZ(extZ[1]);
231 //__________________________________________________________________________
232 void AliMUONTrackParam::ExtrapToVertex()
234 // Extrapolation to the vertex.
235 // Returns the track parameters resulting from the extrapolation,
236 // in the current TrackParam.
237 // Changes parameters according to Branson correction through the absorber
239 Double_t zAbsorber = -503.0; // to be coherent with the Geant absorber geometry !!!!
241 // Extrapolates track parameters upstream to the "Z" end of the front absorber
242 ExtrapToZ(zAbsorber); // !!!
243 // Makes Branson correction (multiple scattering + energy loss)
245 // Makes a simple magnetic field correction through the absorber
246 FieldCorrection(zAbsorber);
250 // Keep this version for future developments
251 //__________________________________________________________________________
252 // void AliMUONTrackParam::BransonCorrection()
254 // // Branson correction of track parameters
255 // // the entry parameters have to be calculated at the end of the absorber
256 // Double_t zEndAbsorber, zBP, xBP, yBP;
257 // Double_t pYZ, pX, pY, pZ, pTotal, xEndAbsorber, yEndAbsorber, radiusEndAbsorber2, pT, theta;
259 // // Would it be possible to calculate all that from Geant configuration ????
260 // // and to get the Branson parameters from a function in ABSO module ????
261 // // with an eventual contribution from other detectors like START ????
262 // // Radiation lengths outer part theta > 3 degres
263 // static Double_t x01[9] = { 18.8, // C (cm)
264 // 10.397, // Concrete (cm)
265 // 0.56, // Plomb (cm)
266 // 47.26, // Polyethylene (cm)
267 // 0.56, // Plomb (cm)
268 // 47.26, // Polyethylene (cm)
269 // 0.56, // Plomb (cm)
270 // 47.26, // Polyethylene (cm)
271 // 0.56 }; // Plomb (cm)
272 // // inner part theta < 3 degres
273 // static Double_t x02[3] = { 18.8, // C (cm)
274 // 10.397, // Concrete (cm)
276 // // z positions of the materials inside the absober outer part theta > 3 degres
277 // static Double_t z1[10] = { 90, 315, 467, 472, 477, 482, 487, 492, 497, 502 };
278 // // inner part theta < 3 degres
279 // static Double_t z2[4] = { 90, 315, 467, 503 };
280 // static Bool_t first = kTRUE;
281 // static Double_t zBP1, zBP2, rLimit;
282 // // Calculates z positions of the Branson's planes: zBP1 for outer part and zBP2 for inner part (only at the first call)
285 // Double_t aNBP = 0.0;
286 // Double_t aDBP = 0.0;
289 // for (iBound = 0; iBound < 9; iBound++) {
291 // (z1[iBound+1] * z1[iBound+1] * z1[iBound+1] -
292 // z1[iBound] * z1[iBound] * z1[iBound] ) / x01[iBound];
294 // (z1[iBound+1] * z1[iBound+1] - z1[iBound] * z1[iBound] ) / x01[iBound];
296 // zBP1 = (2.0 * aNBP) / (3.0 * aDBP);
299 // for (iBound = 0; iBound < 3; iBound++) {
301 // (z2[iBound+1] * z2[iBound+1] * z2[iBound+1] -
302 // z2[iBound] * z2[iBound ] * z2[iBound] ) / x02[iBound];
304 // (z2[iBound+1] * z2[iBound+1] - z2[iBound] * z2[iBound]) / x02[iBound];
306 // zBP2 = (2.0 * aNBP) / (3.0 * aDBP);
307 // rLimit = z2[3] * TMath::Tan(3.0 * (TMath::Pi()) / 180.);
310 // pYZ = TMath::Abs(1.0 / fInverseBendingMomentum);
312 // if (fInverseBendingMomentum < 0) sign = -1;
313 // pZ = pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope));
314 // pX = pZ * fNonBendingSlope;
315 // pY = pZ * fBendingSlope;
316 // pTotal = TMath::Sqrt(pYZ *pYZ + pX * pX);
317 // xEndAbsorber = fNonBendingCoor;
318 // yEndAbsorber = fBendingCoor;
319 // radiusEndAbsorber2 = xEndAbsorber * xEndAbsorber + yEndAbsorber * yEndAbsorber;
321 // if (radiusEndAbsorber2 > rLimit*rLimit) {
322 // zEndAbsorber = z1[9];
325 // zEndAbsorber = z2[3];
329 // xBP = xEndAbsorber - (pX / pZ) * (zEndAbsorber - zBP);
330 // yBP = yEndAbsorber - (pY / pZ) * (zEndAbsorber - zBP);
332 // // new parameters after Branson and energy loss corrections
333 // pZ = pTotal * zBP / TMath::Sqrt(xBP * xBP + yBP * yBP + zBP * zBP);
334 // pX = pZ * xBP / zBP;
335 // pY = pZ * yBP / zBP;
336 // fBendingSlope = pY / pZ;
337 // fNonBendingSlope = pX / pZ;
339 // pT = TMath::Sqrt(pX * pX + pY * pY);
340 // theta = TMath::ATan2(pT, pZ);
342 // TotalMomentumEnergyLoss(rLimit, pTotal, theta, xEndAbsorber, yEndAbsorber);
344 // fInverseBendingMomentum = (sign / pTotal) *
346 // fBendingSlope * fBendingSlope +
347 // fNonBendingSlope * fNonBendingSlope) /
348 // TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope);
350 // // vertex position at (0,0,0)
351 // // should be taken from vertex measurement ???
352 // fBendingCoor = 0.0;
353 // fNonBendingCoor = 0;
357 void AliMUONTrackParam::BransonCorrection()
359 // Branson correction of track parameters
360 // the entry parameters have to be calculated at the end of the absorber
361 // simplified version: the z positions of Branson's planes are no longer calculated
362 // but are given as inputs. One can use the macros MUONTestAbso.C and DrawTestAbso.C
363 // to test this correction.
364 // Would it be possible to calculate all that from Geant configuration ????
365 // and to get the Branson parameters from a function in ABSO module ????
366 // with an eventual contribution from other detectors like START ????
367 Double_t zBP, xBP, yBP;
368 Double_t pYZ, pX, pY, pZ, pTotal, xEndAbsorber, yEndAbsorber, radiusEndAbsorber2, pT, theta;
370 static Bool_t first = kTRUE;
371 static Double_t zBP1, zBP2, rLimit, thetaLimit, zEndAbsorber;
372 // zBP1 for outer part and zBP2 for inner part (only at the first call)
376 zEndAbsorber = -503; // spectro (z<0)
377 thetaLimit = 3.0 * (TMath::Pi()) / 180.;
378 rLimit = TMath::Abs(zEndAbsorber) * TMath::Tan(thetaLimit);
379 zBP1 = -450; // values close to those calculated with EvalAbso.C
383 pYZ = TMath::Abs(1.0 / fInverseBendingMomentum);
385 if (fInverseBendingMomentum < 0) sign = -1;
386 pZ = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro (z<0)
387 pX = pZ * fNonBendingSlope;
388 pY = pZ * fBendingSlope;
389 pTotal = TMath::Sqrt(pYZ *pYZ + pX * pX);
390 xEndAbsorber = fNonBendingCoor;
391 yEndAbsorber = fBendingCoor;
392 radiusEndAbsorber2 = xEndAbsorber * xEndAbsorber + yEndAbsorber * yEndAbsorber;
394 if (radiusEndAbsorber2 > rLimit*rLimit) {
400 xBP = xEndAbsorber - (pX / pZ) * (zEndAbsorber - zBP);
401 yBP = yEndAbsorber - (pY / pZ) * (zEndAbsorber - zBP);
403 // new parameters after Branson and energy loss corrections
404 // Float_t zSmear = zBP - gRandom->Gaus(0.,2.); // !!! possible smearing of Z vertex position
405 Float_t zSmear = zBP;
407 pZ = pTotal * zSmear / TMath::Sqrt(xBP * xBP + yBP * yBP + zSmear * zSmear);
408 pX = pZ * xBP / zSmear;
409 pY = pZ * yBP / zSmear;
410 fBendingSlope = pY / pZ;
411 fNonBendingSlope = pX / pZ;
414 pT = TMath::Sqrt(pX * pX + pY * pY);
415 theta = TMath::ATan2(pT, TMath::Abs(pZ));
416 pTotal = TotalMomentumEnergyLoss(thetaLimit, pTotal, theta);
418 fInverseBendingMomentum = (sign / pTotal) *
420 fBendingSlope * fBendingSlope +
421 fNonBendingSlope * fNonBendingSlope) /
422 TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope);
424 // vertex position at (0,0,0)
425 // should be taken from vertex measurement ???
431 //__________________________________________________________________________
432 Double_t AliMUONTrackParam::TotalMomentumEnergyLoss(Double_t thetaLimit, Double_t pTotal, Double_t theta)
434 // Returns the total momentum corrected from energy loss in the front absorber
435 // One can use the macros MUONTestAbso.C and DrawTestAbso.C
436 // to test this correction.
437 // Momentum energy loss behaviour evaluated with the simulation of single muons (april 2002)
438 Double_t deltaP, pTotalCorrected;
440 // Parametrization to be redone according to change of absorber material ????
441 // See remark in function BransonCorrection !!!!
442 // The name is not so good, and there are many arguments !!!!
443 if (theta < thetaLimit ) {
445 deltaP = 2.5938 + 0.0570 * pTotal - 0.001151 * pTotal * pTotal;
447 deltaP = 3.0714 + 0.011767 *pTotal;
451 deltaP = 2.1207 + 0.05478 * pTotal - 0.00145079 * pTotal * pTotal;
453 deltaP = 2.6069 + 0.0051705 * pTotal;
456 pTotalCorrected = pTotal + deltaP / TMath::Cos(theta);
457 return pTotalCorrected;
460 //__________________________________________________________________________
461 void AliMUONTrackParam::FieldCorrection(Double_t Z)
464 // Correction of the effect of the magnetic field in the absorber
465 // Assume a constant field along Z axis.
469 Double_t pYZ,pX,pY,pZ,pT;
470 Double_t pXNew,pYNew;
473 pYZ = TMath::Abs(1.0 / fInverseBendingMomentum);
474 c = TMath::Sign(1.0,fInverseBendingMomentum); // particle charge
476 pZ = -pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope)); // spectro. (z<0)
477 pX = pZ * fNonBendingSlope;
478 pY = pZ * fBendingSlope;
479 pT = TMath::Sqrt(pX*pX+pY*pY);
481 if (TMath::Abs(pZ) <= 0) return;
483 x[0] = x[2]*fNonBendingSlope;
484 x[1] = x[2]*fBendingSlope;
486 // Take magn. field value at position x.
487 gAlice->Field()->Field(x, b);
490 // Transverse momentum rotation
491 // Parameterized with the study of DeltaPhi = phiReco - phiGen as a function of pZ.
492 Double_t phiShift = c*0.436*0.0003*bZ*Z/pZ;
493 // Rotate momentum around Z axis.
494 pXNew = pX*TMath::Cos(phiShift) - pY*TMath::Sin(phiShift);
495 pYNew = pX*TMath::Sin(phiShift) + pY*TMath::Cos(phiShift);
497 fBendingSlope = pYNew / pZ;
498 fNonBendingSlope = pXNew / pZ;
500 fInverseBendingMomentum = c / TMath::Sqrt(pYNew*pYNew+pZ*pZ);