]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTrackParam.cxx
Cleaning of the code :
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackParam.cxx
CommitLineData
a9e2aefa 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/*
17$Log$
ecfa008b 18Revision 1.6 2000/09/19 09:49:50 gosset
19AliMUONEventReconstructor package
20* track extrapolation independent from reco_muon.F, use of AliMagF...
21* possibility to use new magnetic field (automatic from generated root file)
22
a6f03ddb 23Revision 1.5 2000/07/18 16:04:06 gosset
24AliMUONEventReconstructor package:
25* a few minor modifications and more comments
26* a few corrections
27 * right sign for Z of raw clusters
28 * right loop over chambers inside station
29 * symmetrized covariance matrix for measurements (TrackChi2MCS)
30 * right sign of charge in extrapolation (ExtrapToZ)
31 * right zEndAbsorber for Branson correction below 3 degrees
32* use of TVirtualFitter instead of TMinuit for AliMUONTrack::Fit
33* no parameter for AliMUONTrack::Fit() but more fit parameters in Track object
34
956019b6 35Revision 1.4 2000/07/03 07:53:31 morsch
36Double declaration problem on HP solved.
37
88962f0c 38Revision 1.3 2000/06/30 10:15:48 gosset
39Changes to EventReconstructor...:
40precision fit with multiple Coulomb scattering;
41extrapolation to vertex with Branson correction in absorber (JPC)
42
04b5ea16 43Revision 1.2 2000/06/15 07:58:49 morsch
44Code from MUON-dev joined
45
a9e2aefa 46Revision 1.1.2.3 2000/06/09 21:03:09 morsch
47Make includes consistent with new file structure.
48
49Revision 1.1.2.2 2000/06/09 12:58:05 gosset
50Removed comment beginnings in Log sections of .cxx files
51Suppressed most violations of coding rules
52
53Revision 1.1.2.1 2000/06/07 14:44:53 gosset
54Addition of files for track reconstruction in C++
55*/
56
57//__________________________________________________________________________
58//
59// Track parameters in ALICE dimuon spectrometer
60//__________________________________________________________________________
61
62#include <iostream.h>
63
64#include "AliCallf77.h"
65#include "AliMUON.h"
66#include "AliMUONHitForRec.h"
67#include "AliMUONSegment.h"
68#include "AliMUONTrackParam.h"
69#include "AliMUONChamber.h"
70#include "AliRun.h"
71
72ClassImp(AliMUONTrackParam) // Class implementation in ROOT context
73
a6f03ddb 74 // A few calls in Fortran or from Fortran (extrap.F).
75 // Needed, instead of calls to Geant subroutines,
76 // because double precision is necessary for track fit converging with Minuit.
77 // The "extrap" functions should be translated into C++ ????
a9e2aefa 78#ifndef WIN32
a6f03ddb 79# define extrap_onestep_helix extrap_onestep_helix_
80# define extrap_onestep_helix3 extrap_onestep_helix3_
81# define extrap_onestep_rungekutta extrap_onestep_rungekutta_
82# define gufld_double gufld_double_
a9e2aefa 83#else
a6f03ddb 84# define extrap_onestep_helix EXTRAP_ONESTEP_HELIX
85# define extrap_onestep_helix3 EXTRAP_ONESTEP_HELIX3
86# define extrap_onestep_rungekutta EXTRAP_ONESTEP_RUNGEKUTTA
87# define gufld_double GUFLD_DOUBLE
a9e2aefa 88#endif
89
a6f03ddb 90extern "C" {
91 void type_of_call extrap_onestep_helix
92 (Double_t &Charge, Double_t &StepLength, Double_t *VGeant3, Double_t *VGeant3New);
93
94 void type_of_call extrap_onestep_helix3
95 (Double_t &Field, Double_t &StepLength, Double_t *VGeant3, Double_t *VGeant3New);
96
97 void type_of_call extrap_onestep_rungekutta
98 (Double_t &Charge, Double_t &StepLength, Double_t *VGeant3, Double_t *VGeant3New);
99
100 void type_of_call gufld_double(Double_t *Position, Double_t *Field) {
101 // interface to "gAlice->Field()->Field" for arguments in double precision
102 Float_t x[3], b[3];
103 x[0] = Position[0]; x[1] = Position[1]; x[2] = Position[2];
104 gAlice->Field()->Field(x, b);
105 Field[0] = b[0]; Field[1] = b[1]; Field[2] = b[2];
106 }
a9e2aefa 107}
108
109// Inline functions for Get and Set: inline removed because it does not work !!!!
110Double_t AliMUONTrackParam::GetInverseBendingMomentum(void) {
111 // Get fInverseBendingMomentum
112 return fInverseBendingMomentum;}
113void AliMUONTrackParam::SetInverseBendingMomentum(Double_t InverseBendingMomentum) {
114 // Set fInverseBendingMomentum
115 fInverseBendingMomentum = InverseBendingMomentum;}
116Double_t AliMUONTrackParam::GetBendingSlope(void) {
117 // Get fBendingSlope
118 return fBendingSlope;}
119void AliMUONTrackParam::SetBendingSlope(Double_t BendingSlope) {
120 // Set fBendingSlope
121 fBendingSlope = BendingSlope;}
122Double_t AliMUONTrackParam::GetNonBendingSlope(void) {
123 // Get fNonBendingSlope
124 return fNonBendingSlope;}
125void AliMUONTrackParam::SetNonBendingSlope(Double_t NonBendingSlope) {
126 // Set fNonBendingSlope
127 fNonBendingSlope = NonBendingSlope;}
128Double_t AliMUONTrackParam::GetZ(void) {
129 // Get fZ
130 return fZ;}
131void AliMUONTrackParam::SetZ(Double_t Z) {
132 // Set fZ
133 fZ = Z;}
134Double_t AliMUONTrackParam::GetBendingCoor(void) {
135 // Get fBendingCoor
136 return fBendingCoor;}
137void AliMUONTrackParam::SetBendingCoor(Double_t BendingCoor) {
138 // Set fBendingCoor
139 fBendingCoor = BendingCoor;}
140Double_t AliMUONTrackParam::GetNonBendingCoor(void) {
141 // Get fNonBendingCoor
142 return fNonBendingCoor;}
143void AliMUONTrackParam::SetNonBendingCoor(Double_t NonBendingCoor) {
144 // Set fNonBendingCoor
145 fNonBendingCoor = NonBendingCoor;}
146
147 //__________________________________________________________________________
148void AliMUONTrackParam::ExtrapToZ(Double_t Z)
149{
150 // Track parameter extrapolation to the plane at "Z".
151 // On return, the track parameters resulting from the extrapolation
152 // replace the current track parameters.
a9e2aefa 153 if (this->fZ == Z) return; // nothing to be done if same Z
154 Double_t forwardBackward; // +1 if forward, -1 if backward
155 if (Z > this->fZ) forwardBackward = 1.0;
156 else forwardBackward = -1.0;
a6f03ddb 157 Double_t vGeant3[7], vGeant3New[7]; // 7 in parameter ????
a9e2aefa 158 Int_t iGeant3, stepNumber;
159 Int_t maxStepNumber = 5000; // in parameter ????
160 // For safety: return kTRUE or kFALSE ????
a6f03ddb 161 // Parameter vector for calling EXTRAP_ONESTEP
a9e2aefa 162 SetGeant3Parameters(vGeant3, forwardBackward);
956019b6 163 // sign of charge (sign of fInverseBendingMomentum if forward motion)
a6f03ddb 164 // must be changed if backward extrapolation
956019b6 165 Double_t chargeExtrap = forwardBackward *
166 TMath::Sign(Double_t(1.0), this->fInverseBendingMomentum);
a9e2aefa 167 Double_t stepLength = 6.0; // in parameter ????
168 // Extrapolation loop
169 stepNumber = 0;
170 while (((forwardBackward * (vGeant3[2] - Z)) <= 0.0) &&
171 (stepNumber < maxStepNumber)) {
172 stepNumber++;
a6f03ddb 173 // Option for switching between helix and Runge-Kutta ????
174 // extrap_onestep_rungekutta(chargeExtrap, stepLength, vGeant3, vGeant3New);
175 extrap_onestep_helix(chargeExtrap, stepLength, vGeant3, vGeant3New);
a9e2aefa 176 if ((forwardBackward * (vGeant3New[2] - Z)) > 0.0) break; // one is beyond Z
177 // better use TArray ????
178 for (iGeant3 = 0; iGeant3 < 7; iGeant3++)
179 {vGeant3[iGeant3] = vGeant3New[iGeant3];}
180 }
181 // check maxStepNumber ????
a9e2aefa 182 // Interpolation back to exact Z (2nd order)
183 // should be in function ???? using TArray ????
184 Double_t dZ12 = vGeant3New[2] - vGeant3[2]; // 1->2
185 Double_t dZ1i = Z - vGeant3[2]; // 1-i
186 Double_t dZi2 = vGeant3New[2] - Z; // i->2
187 Double_t xPrime = (vGeant3New[0] - vGeant3[0]) / dZ12;
188 Double_t xSecond =
189 ((vGeant3New[3] / vGeant3New[5]) - (vGeant3[3] / vGeant3[5])) / dZ12;
190 Double_t yPrime = (vGeant3New[1] - vGeant3[1]) / dZ12;
191 Double_t ySecond =
192 ((vGeant3New[4] / vGeant3New[5]) - (vGeant3[4] / vGeant3[5])) / dZ12;
193 vGeant3[0] = vGeant3[0] + xPrime * dZ1i - 0.5 * xSecond * dZ1i * dZi2; // X
194 vGeant3[1] = vGeant3[1] + yPrime * dZ1i - 0.5 * ySecond * dZ1i * dZi2; // Y
195 vGeant3[2] = Z; // Z
196 Double_t xPrimeI = xPrime - 0.5 * xSecond * (dZi2 - dZ1i);
197 Double_t yPrimeI = yPrime - 0.5 * ySecond * (dZi2 - dZ1i);
956019b6 198 // (PX, PY, PZ)/PTOT assuming forward motion
a9e2aefa 199 vGeant3[5] =
200 1.0 / TMath::Sqrt(1.0 + xPrimeI * xPrimeI + yPrimeI * yPrimeI); // PZ/PTOT
201 vGeant3[3] = xPrimeI * vGeant3[5]; // PX/PTOT
202 vGeant3[4] = yPrimeI * vGeant3[5]; // PY/PTOT
956019b6 203 // Track parameters from Geant3 parameters,
204 // with charge back for forward motion
205 GetFromGeant3Parameters(vGeant3, chargeExtrap * forwardBackward);
a9e2aefa 206}
207
208 //__________________________________________________________________________
209void AliMUONTrackParam::SetGeant3Parameters(Double_t *VGeant3, Double_t ForwardBackward)
210{
211 // Set vector of Geant3 parameters pointed to by "VGeant3"
212 // from track parameters in current AliMUONTrackParam.
213 // Since AliMUONTrackParam is only geometry, one uses "ForwardBackward"
214 // to know whether the particle is going forward (+1) or backward (-1).
215 VGeant3[0] = this->fNonBendingCoor; // X
216 VGeant3[1] = this->fBendingCoor; // Y
217 VGeant3[2] = this->fZ; // Z
218 Double_t pYZ = TMath::Abs(1.0 / this->fInverseBendingMomentum);
219 Double_t pZ =
220 pYZ / TMath::Sqrt(1.0 + this->fBendingSlope * this->fBendingSlope);
221 VGeant3[6] =
222 TMath::Sqrt(pYZ * pYZ +
223 pZ * pZ * this->fNonBendingSlope * this->fNonBendingSlope); // PTOT
224 VGeant3[5] = ForwardBackward * pZ / VGeant3[6]; // PZ/PTOT
225 VGeant3[3] = this->fNonBendingSlope * VGeant3[5]; // PX/PTOT
226 VGeant3[4] = this->fBendingSlope * VGeant3[5]; // PY/PTOT
227}
228
229 //__________________________________________________________________________
230void AliMUONTrackParam::GetFromGeant3Parameters(Double_t *VGeant3, Double_t Charge)
231{
232 // Get track parameters in current AliMUONTrackParam
956019b6 233 // from Geant3 parameters pointed to by "VGeant3",
234 // assumed to be calculated for forward motion in Z.
a9e2aefa 235 // "InverseBendingMomentum" is signed with "Charge".
236 this->fNonBendingCoor = VGeant3[0]; // X
237 this->fBendingCoor = VGeant3[1]; // Y
238 this->fZ = VGeant3[2]; // Z
239 Double_t pYZ = VGeant3[6] * TMath::Sqrt(1.0 - VGeant3[3] * VGeant3[3]);
240 this->fInverseBendingMomentum = Charge / pYZ;
241 this->fBendingSlope = VGeant3[4] / VGeant3[5];
242 this->fNonBendingSlope = VGeant3[3] / VGeant3[5];
243}
244
245 //__________________________________________________________________________
246void AliMUONTrackParam::ExtrapToStation(Int_t Station, AliMUONTrackParam *TrackParam)
247{
248 // Track parameters extrapolated from current track parameters ("this")
249 // to both chambers of the station(0..) "Station"
250 // are returned in the array (dimension 2) of track parameters
251 // pointed to by "TrackParam" (index 0 and 1 for first and second chambers).
252 Double_t extZ[2], z1, z2;
ecfa008b 253 Int_t i1 = -1, i2 = -1; // = -1 to avoid compilation warnings
a9e2aefa 254 AliMUON *pMUON = (AliMUON*) gAlice->GetModule("MUON"); // necessary ????
255 // range of Station to be checked ????
256 z1 = (&(pMUON->Chamber(2 * Station)))->Z(); // Z of first chamber
257 z2 = (&(pMUON->Chamber(2 * Station + 1)))->Z(); // Z of second chamber
258 // First and second Z to extrapolate at
259 if ((z1 > this->fZ) && (z2 > this->fZ)) {i1 = 0; i2 = 1;}
260 else if ((z1 < this->fZ) && (z2 < this->fZ)) {i1 = 1; i2 = 0;}
261 else {
262 cout << "ERROR in AliMUONTrackParam::CreateExtrapSegmentInStation" << endl;
263 cout << "Starting Z (" << this->fZ << ") in between z1 (" << z1 <<
264 ") and z2 (" << z2 << ") of station(0..) " << Station << endl;
265 }
266 extZ[i1] = z1;
267 extZ[i2] = z2;
268 // copy of track parameters
269 TrackParam[i1] = *this;
270 // first extrapolation
271 (&(TrackParam[i1]))->ExtrapToZ(extZ[0]);
272 TrackParam[i2] = TrackParam[i1];
273 // second extrapolation
274 (&(TrackParam[i2]))->ExtrapToZ(extZ[1]);
275 return;
276}
277
04b5ea16 278 //__________________________________________________________________________
279void AliMUONTrackParam::ExtrapToVertex()
280{
281 // Extrapolation to the vertex.
282 // Returns the track parameters resulting from the extrapolation,
283 // in the current TrackParam.
956019b6 284 // Changes parameters according to Branson correction through the absorber
04b5ea16 285
286 Double_t zAbsorber = 503.0; // to be coherent with the Geant absorber geometry !!!!
287 // Extrapolates track parameters upstream to the "Z" end of the front absorber
288 ExtrapToZ(zAbsorber);
289 // Makes Branson correction (multiple scattering + energy loss)
290 BransonCorrection();
291}
292
293 //__________________________________________________________________________
294void AliMUONTrackParam::BransonCorrection()
295{
296 // Branson correction of track parameters
297 // the entry parameters have to be calculated at the end of the absorber
298 Double_t zEndAbsorber, zBP, xBP, yBP;
299 Double_t pYZ, pX, pY, pZ, pTotal, xEndAbsorber, yEndAbsorber, radiusEndAbsorber2, pT, theta;
300 Int_t sign;
301 // Would it be possible to calculate all that from Geant configuration ????
956019b6 302 // and to get the Branson parameters from a function in ABSO module ????
303 // with an eventual contribution from other detectors like START ????
04b5ea16 304 // Radiation lengths outer part theta > 3 degres
305 static Double_t x01[9] = { 18.8, // C (cm)
306 10.397, // Concrete (cm)
307 0.56, // Plomb (cm)
308 47.26, // Polyethylene (cm)
309 0.56, // Plomb (cm)
310 47.26, // Polyethylene (cm)
311 0.56, // Plomb (cm)
312 47.26, // Polyethylene (cm)
313 0.56 }; // Plomb (cm)
314 // inner part theta < 3 degres
315 static Double_t x02[3] = { 18.8, // C (cm)
316 10.397, // Concrete (cm)
317 0.35 }; // W (cm)
318 // z positions of the materials inside the absober outer part theta > 3 degres
319 static Double_t z1[10] = { 90, 315, 467, 472, 477, 482, 487, 492, 497, 502 };
320 // inner part theta < 3 degres
321 static Double_t z2[4] = { 90, 315, 467, 503 };
322 static Bool_t first = kTRUE;
323 static Double_t zBP1, zBP2, rLimit;
324 // Calculates z positions of the Branson's planes: zBP1 for outer part and zBP2 for inner part (only at the first call)
325 if (first) {
326 first = kFALSE;
327 Double_t aNBP = 0.0;
328 Double_t aDBP = 0.0;
88962f0c 329 Int_t iBound;
330
331 for (iBound = 0; iBound < 9; iBound++) {
04b5ea16 332 aNBP = aNBP +
333 (z1[iBound+1] * z1[iBound+1] * z1[iBound+1] -
334 z1[iBound] * z1[iBound] * z1[iBound] ) / x01[iBound];
335 aDBP = aDBP +
336 (z1[iBound+1] * z1[iBound+1] - z1[iBound] * z1[iBound] ) / x01[iBound];
337 }
338 zBP1 = (2.0 * aNBP) / (3.0 * aDBP);
339 aNBP = 0.0;
340 aDBP = 0.0;
88962f0c 341 for (iBound = 0; iBound < 3; iBound++) {
04b5ea16 342 aNBP = aNBP +
343 (z2[iBound+1] * z2[iBound+1] * z2[iBound+1] -
344 z2[iBound] * z2[iBound ] * z2[iBound] ) / x02[iBound];
345 aDBP = aDBP +
346 (z2[iBound+1] * z2[iBound+1] - z2[iBound] * z2[iBound]) / x02[iBound];
347 }
348 zBP2 = (2.0 * aNBP) / (3.0 * aDBP);
349 rLimit = z2[3] * TMath::Tan(3.0 * (TMath::Pi()) / 180.);
350 }
351
352 pYZ = TMath::Abs(1.0 / fInverseBendingMomentum);
353 sign = 1;
354 if (fInverseBendingMomentum < 0) sign = -1;
355 pZ = pYZ / (TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope));
356 pX = pZ * fNonBendingSlope;
357 pY = pZ * fBendingSlope;
358 pTotal = TMath::Sqrt(pYZ *pYZ + pX * pX);
359 xEndAbsorber = fNonBendingCoor;
360 yEndAbsorber = fBendingCoor;
361 radiusEndAbsorber2 = xEndAbsorber * xEndAbsorber + yEndAbsorber * yEndAbsorber;
362
363 if (radiusEndAbsorber2 > rLimit*rLimit) {
364 zEndAbsorber = z1[9];
365 zBP = zBP1;
366 } else {
956019b6 367 zEndAbsorber = z2[3];
04b5ea16 368 zBP = zBP2;
369 }
370
371 xBP = xEndAbsorber - (pX / pZ) * (zEndAbsorber - zBP);
372 yBP = yEndAbsorber - (pY / pZ) * (zEndAbsorber - zBP);
373
374 // new parameters after Branson and energy loss corrections
375 pZ = pTotal * zBP / TMath::Sqrt(xBP * xBP + yBP * yBP + zBP * zBP);
376 pX = pZ * xBP / zBP;
377 pY = pZ * yBP / zBP;
378 fBendingSlope = pY / pZ;
379 fNonBendingSlope = pX / pZ;
380
381 pT = TMath::Sqrt(pX * pX + pY * pY);
382 theta = TMath::ATan2(pT, pZ);
383 pTotal =
384 TotalMomentumEnergyLoss(rLimit, pTotal, theta, xEndAbsorber, yEndAbsorber);
385
386 fInverseBendingMomentum = (sign / pTotal) *
387 TMath::Sqrt(1.0 +
388 fBendingSlope * fBendingSlope +
389 fNonBendingSlope * fNonBendingSlope) /
390 TMath::Sqrt(1.0 + fBendingSlope * fBendingSlope);
391
392 // vertex position at (0,0,0)
393 // should be taken from vertex measurement ???
394 fBendingCoor = 0.0;
395 fNonBendingCoor = 0;
396 fZ= 0;
397}
398
399 //__________________________________________________________________________
400Double_t AliMUONTrackParam::TotalMomentumEnergyLoss(Double_t rLimit, Double_t pTotal, Double_t theta, Double_t xEndAbsorber, Double_t yEndAbsorber)
401{
402 // Returns the total momentum corrected from energy loss in the front absorber
403 Double_t deltaP, pTotalCorrected;
404
405 Double_t radiusEndAbsorber2 =
406 xEndAbsorber *xEndAbsorber + yEndAbsorber * yEndAbsorber;
407 // Parametrization to be redone according to change of absorber material ????
956019b6 408 // See remark in function BransonCorrection !!!!
04b5ea16 409 // The name is not so good, and there are many arguments !!!!
410 if (radiusEndAbsorber2 < rLimit * rLimit) {
411 if (pTotal < 15) {
412 deltaP = 2.737 + 0.0494 * pTotal - 0.001123 * pTotal * pTotal;
413 } else {
414 deltaP = 3.0643 + 0.01346 *pTotal;
415 }
416 } else {
417 if (pTotal < 15) {
418 deltaP = 2.1380 + 0.0351 * pTotal - 0.000853 * pTotal * pTotal;
419 } else {
420 deltaP = 2.407 + 0.00702 * pTotal;
421 }
422 }
423 pTotalCorrected = pTotal + deltaP / TMath::Cos(theta);
424 return pTotalCorrected;
425}
426