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