]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTrackParam.cxx
Code from MUON-dev joined
[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$
18Revision 1.1.2.3 2000/06/09 21:03:09 morsch
19Make includes consistent with new file structure.
20
21Revision 1.1.2.2 2000/06/09 12:58:05 gosset
22Removed comment beginnings in Log sections of .cxx files
23Suppressed most violations of coding rules
24
25Revision 1.1.2.1 2000/06/07 14:44:53 gosset
26Addition of files for track reconstruction in C++
27*/
28
29//__________________________________________________________________________
30//
31// Track parameters in ALICE dimuon spectrometer
32//__________________________________________________________________________
33
34#include <iostream.h>
35
36#include "AliCallf77.h"
37#include "AliMUON.h"
38#include "AliMUONHitForRec.h"
39#include "AliMUONSegment.h"
40#include "AliMUONTrackParam.h"
41#include "AliMUONChamber.h"
42#include "AliRun.h"
43
44ClassImp(AliMUONTrackParam) // Class implementation in ROOT context
45
46#ifndef WIN32
47# define reco_ghelix reco_ghelix_
48#else
49# define reco_ghelix RECO_GHELIX
50#endif
51
52extern "C"
53{
54void type_of_call reco_ghelix(Double_t &Charge, Double_t &StepLength, Double_t *VGeant3, Double_t *VGeant3New);
55}
56
57// Inline functions for Get and Set: inline removed because it does not work !!!!
58Double_t AliMUONTrackParam::GetInverseBendingMomentum(void) {
59 // Get fInverseBendingMomentum
60 return fInverseBendingMomentum;}
61void AliMUONTrackParam::SetInverseBendingMomentum(Double_t InverseBendingMomentum) {
62 // Set fInverseBendingMomentum
63 fInverseBendingMomentum = InverseBendingMomentum;}
64Double_t AliMUONTrackParam::GetBendingSlope(void) {
65 // Get fBendingSlope
66 return fBendingSlope;}
67void AliMUONTrackParam::SetBendingSlope(Double_t BendingSlope) {
68 // Set fBendingSlope
69 fBendingSlope = BendingSlope;}
70Double_t AliMUONTrackParam::GetNonBendingSlope(void) {
71 // Get fNonBendingSlope
72 return fNonBendingSlope;}
73void AliMUONTrackParam::SetNonBendingSlope(Double_t NonBendingSlope) {
74 // Set fNonBendingSlope
75 fNonBendingSlope = NonBendingSlope;}
76Double_t AliMUONTrackParam::GetZ(void) {
77 // Get fZ
78 return fZ;}
79void AliMUONTrackParam::SetZ(Double_t Z) {
80 // Set fZ
81 fZ = Z;}
82Double_t AliMUONTrackParam::GetBendingCoor(void) {
83 // Get fBendingCoor
84 return fBendingCoor;}
85void AliMUONTrackParam::SetBendingCoor(Double_t BendingCoor) {
86 // Set fBendingCoor
87 fBendingCoor = BendingCoor;}
88Double_t AliMUONTrackParam::GetNonBendingCoor(void) {
89 // Get fNonBendingCoor
90 return fNonBendingCoor;}
91void AliMUONTrackParam::SetNonBendingCoor(Double_t NonBendingCoor) {
92 // Set fNonBendingCoor
93 fNonBendingCoor = NonBendingCoor;}
94
95 //__________________________________________________________________________
96void AliMUONTrackParam::ExtrapToZ(Double_t Z)
97{
98 // Track parameter extrapolation to the plane at "Z".
99 // On return, the track parameters resulting from the extrapolation
100 // replace the current track parameters.
101 // Use "reco_ghelix" which should be replaced by something else !!!!
102 if (this->fZ == Z) return; // nothing to be done if same Z
103 Double_t forwardBackward; // +1 if forward, -1 if backward
104 if (Z > this->fZ) forwardBackward = 1.0;
105 else forwardBackward = -1.0;
106 Double_t temp, vGeant3[7], vGeant3New[7]; // 7 in parameter ????
107 Int_t iGeant3, stepNumber;
108 Int_t maxStepNumber = 5000; // in parameter ????
109 // For safety: return kTRUE or kFALSE ????
110 // Parameter vector for calling GHELIX in Geant3
111 SetGeant3Parameters(vGeant3, forwardBackward);
112 // For use of reco_ghelix...: invert X and Y, PX/PTOT and PY/PTOT !!!!
113 temp = vGeant3[0]; vGeant3[0] = vGeant3[1]; vGeant3[1] = temp;
114 temp = vGeant3[3]; vGeant3[3] = vGeant3[4]; vGeant3[4] = temp;
115 // charge must be changed with momentum for backward motion
116 Double_t charge =
117 forwardBackward * TMath::Sign(Double_t(1.0), this->fInverseBendingMomentum);
118 Double_t stepLength = 6.0; // in parameter ????
119 // Extrapolation loop
120 stepNumber = 0;
121 while (((forwardBackward * (vGeant3[2] - Z)) <= 0.0) &&
122 (stepNumber < maxStepNumber)) {
123 stepNumber++;
124 // call Geant3 "ghelix" subroutine through a copy in "reco_muon.F":
125 // the true function should be called, but how ???? and remove prototyping ...
126 reco_ghelix(charge, stepLength, vGeant3, vGeant3New);
127 if ((forwardBackward * (vGeant3New[2] - Z)) > 0.0) break; // one is beyond Z
128 // better use TArray ????
129 for (iGeant3 = 0; iGeant3 < 7; iGeant3++)
130 {vGeant3[iGeant3] = vGeant3New[iGeant3];}
131 }
132 // check maxStepNumber ????
133 // For use of reco_ghelix...:
134 // invert back X and Y, PX/PTOT and PY/PTOT, both for vGeant3 and vGeant3New !!!!
135 temp = vGeant3[0]; vGeant3[0] = vGeant3[1]; vGeant3[1] = temp;
136 temp = vGeant3New[0]; vGeant3New[0] = vGeant3New[1]; vGeant3New[1] = temp;
137 temp = vGeant3[3]; vGeant3[3] = vGeant3[4]; vGeant3[4] = temp;
138 temp = vGeant3New[3]; vGeant3New[3] = vGeant3New[4]; vGeant3New[4] = temp;
139 // Interpolation back to exact Z (2nd order)
140 // should be in function ???? using TArray ????
141 Double_t dZ12 = vGeant3New[2] - vGeant3[2]; // 1->2
142 Double_t dZ1i = Z - vGeant3[2]; // 1-i
143 Double_t dZi2 = vGeant3New[2] - Z; // i->2
144 Double_t xPrime = (vGeant3New[0] - vGeant3[0]) / dZ12;
145 Double_t xSecond =
146 ((vGeant3New[3] / vGeant3New[5]) - (vGeant3[3] / vGeant3[5])) / dZ12;
147 Double_t yPrime = (vGeant3New[1] - vGeant3[1]) / dZ12;
148 Double_t ySecond =
149 ((vGeant3New[4] / vGeant3New[5]) - (vGeant3[4] / vGeant3[5])) / dZ12;
150 vGeant3[0] = vGeant3[0] + xPrime * dZ1i - 0.5 * xSecond * dZ1i * dZi2; // X
151 vGeant3[1] = vGeant3[1] + yPrime * dZ1i - 0.5 * ySecond * dZ1i * dZi2; // Y
152 vGeant3[2] = Z; // Z
153 Double_t xPrimeI = xPrime - 0.5 * xSecond * (dZi2 - dZ1i);
154 Double_t yPrimeI = yPrime - 0.5 * ySecond * (dZi2 - dZ1i);
155 vGeant3[5] =
156 1.0 / TMath::Sqrt(1.0 + xPrimeI * xPrimeI + yPrimeI * yPrimeI); // PZ/PTOT
157 vGeant3[3] = xPrimeI * vGeant3[5]; // PX/PTOT
158 vGeant3[4] = yPrimeI * vGeant3[5]; // PY/PTOT
159 // Track parameters from Geant3 parameters
160 GetFromGeant3Parameters(vGeant3, charge);
161}
162
163 //__________________________________________________________________________
164void AliMUONTrackParam::SetGeant3Parameters(Double_t *VGeant3, Double_t ForwardBackward)
165{
166 // Set vector of Geant3 parameters pointed to by "VGeant3"
167 // from track parameters in current AliMUONTrackParam.
168 // Since AliMUONTrackParam is only geometry, one uses "ForwardBackward"
169 // to know whether the particle is going forward (+1) or backward (-1).
170 VGeant3[0] = this->fNonBendingCoor; // X
171 VGeant3[1] = this->fBendingCoor; // Y
172 VGeant3[2] = this->fZ; // Z
173 Double_t pYZ = TMath::Abs(1.0 / this->fInverseBendingMomentum);
174 Double_t pZ =
175 pYZ / TMath::Sqrt(1.0 + this->fBendingSlope * this->fBendingSlope);
176 VGeant3[6] =
177 TMath::Sqrt(pYZ * pYZ +
178 pZ * pZ * this->fNonBendingSlope * this->fNonBendingSlope); // PTOT
179 VGeant3[5] = ForwardBackward * pZ / VGeant3[6]; // PZ/PTOT
180 VGeant3[3] = this->fNonBendingSlope * VGeant3[5]; // PX/PTOT
181 VGeant3[4] = this->fBendingSlope * VGeant3[5]; // PY/PTOT
182}
183
184 //__________________________________________________________________________
185void AliMUONTrackParam::GetFromGeant3Parameters(Double_t *VGeant3, Double_t Charge)
186{
187 // Get track parameters in current AliMUONTrackParam
188 // from Geant3 parameters pointed to by "VGeant3".
189 // "InverseBendingMomentum" is signed with "Charge".
190 this->fNonBendingCoor = VGeant3[0]; // X
191 this->fBendingCoor = VGeant3[1]; // Y
192 this->fZ = VGeant3[2]; // Z
193 Double_t pYZ = VGeant3[6] * TMath::Sqrt(1.0 - VGeant3[3] * VGeant3[3]);
194 this->fInverseBendingMomentum = Charge / pYZ;
195 this->fBendingSlope = VGeant3[4] / VGeant3[5];
196 this->fNonBendingSlope = VGeant3[3] / VGeant3[5];
197}
198
199 //__________________________________________________________________________
200void AliMUONTrackParam::ExtrapToStation(Int_t Station, AliMUONTrackParam *TrackParam)
201{
202 // Track parameters extrapolated from current track parameters ("this")
203 // to both chambers of the station(0..) "Station"
204 // are returned in the array (dimension 2) of track parameters
205 // pointed to by "TrackParam" (index 0 and 1 for first and second chambers).
206 Double_t extZ[2], z1, z2;
207 Int_t i1, i2;
208 AliMUON *pMUON = (AliMUON*) gAlice->GetModule("MUON"); // necessary ????
209 // range of Station to be checked ????
210 z1 = (&(pMUON->Chamber(2 * Station)))->Z(); // Z of first chamber
211 z2 = (&(pMUON->Chamber(2 * Station + 1)))->Z(); // Z of second chamber
212 // First and second Z to extrapolate at
213 if ((z1 > this->fZ) && (z2 > this->fZ)) {i1 = 0; i2 = 1;}
214 else if ((z1 < this->fZ) && (z2 < this->fZ)) {i1 = 1; i2 = 0;}
215 else {
216 cout << "ERROR in AliMUONTrackParam::CreateExtrapSegmentInStation" << endl;
217 cout << "Starting Z (" << this->fZ << ") in between z1 (" << z1 <<
218 ") and z2 (" << z2 << ") of station(0..) " << Station << endl;
219 }
220 extZ[i1] = z1;
221 extZ[i2] = z2;
222 // copy of track parameters
223 TrackParam[i1] = *this;
224 // first extrapolation
225 (&(TrackParam[i1]))->ExtrapToZ(extZ[0]);
226 TrackParam[i2] = TrackParam[i1];
227 // second extrapolation
228 (&(TrackParam[i2]))->ExtrapToZ(extZ[1]);
229 return;
230}
231