40{
41 const int MAX_STATION = 4;
43
44 int nit;
45 const int nitmx=10;
48
49 double c0,
c1,
c2,
c3,c22,c33,
e2,
e3,c2q,c3q,
d,da,
db,
a,
b,
dx,
dy;
52 double x0 = 0., y0 = 0.,
x1 = 0.,
y1 = 0.,
x2 = 0.,
y2 = 0., x3 = 0., y3 = 0.;
53 double tm = 0.;
54 double xn = 0.;
55 const double eps = 0.005;
56
57 TrigL2MuonSA::SuperPoint* superPoints[4] = {};
58
59 for (int i_station=0; i_station<MAX_STATION; i_station++) {
60
61 int chamberID = -1;
68 return StatusCode::FAILURE;
69 }
70 superPoints[i_station] = &(trackPattern.
superPoints[chamberID]);
71
74 if ( i_station != 3 ){
75 phim = superPoints[i_station]->
Phim;
76 }
77 }
78 }
79
81
83 y0 = 4230.;
84
86 x2 = superPoints[1]->
Z;
87 y2 = superPoints[1]->
R;
88 x3 = superPoints[2]->
Z;
89 y3 = superPoints[2]->
R;
91 x2 = superPoints[0]->
Z;
92 y2 = superPoints[0]->
R;
93 x3 = superPoints[2]->
Z;
94 y3 = superPoints[2]->
R;
96 x2 = superPoints[0]->
Z;
97 y2 = superPoints[0]->
R;
98 x3 = superPoints[1]->
Z;
99 y3 = superPoints[1]->
R;
100 }
101
105 throw std::runtime_error("y2 is zero in setSagittaRadius");
106 }
108
111 c1 = -
dy*(
y2*y3-y0*y0)+ y3*x2*x2 - y2*x3*x3;
112 c0 = y0*
x2*x3*
dx + y0*
x2*(y3-y0)*(y3-y0) - y0*x3*(
y2-y0)*(y2-y0);
115
116 nit = 1;
117 while((nit++)<=nitmx&&std::abs(x0-xn)>=eps) {
118 xn = x0 -
f(x0,c0,c1,c2,c3)/
fp(x0,c33,c22,c1);
119 x0 = xn;
120 }
122
125
127 theta = std::atan2(superPoints[0]->R,std::abs(superPoints[0]->Z));
128 signZ = (std::abs(superPoints[0]->Z) >
ZERO_LIMIT)? superPoints[0]->Z/std::abs(superPoints[0]->Z): 1.;
129 } else {
130 theta = std::atan2(y1,std::abs(x1));
131 signZ = (std::abs(x1) >
ZERO_LIMIT)? x1/std::abs(x1): 1.;
132 }
133
134 trackPattern.
etaMap = (-std::log(std::tan(
theta/2.)))*signZ;
136 one = (std::cos(rpcFitResult.
phi)>0)? 1: -1;
137 } else {
138 one = (std::cos(p_roids->
phi())>0)? 1: -1;
139 }
141
142 if(phim>=
M_PI+0.1) phim = phim - 2*
M_PI;
143
144 if(phim>=0) trackPattern.
phiMap = (
phi>=0.)?
phi - phim : phim -std::abs(
phi);
146
148
156 da = -c2q*
e3 + c3q*
e2;
160
165 if(
a<=0.) trackPattern.
charge = 1;
166
167 }
else if (
count==3) {
168
169 theta = std::atan2(superPoints[0]->R,std::abs(superPoints[0]->Z));
170 signZ = (std::abs(superPoints[0]->Z) >
ZERO_LIMIT)? superPoints[0]->Z/std::abs(superPoints[0]->Z): 1.;
171
172 trackPattern.
etaMap = (-std::log(std::tan(
theta/2.)))*signZ;
173
175 one = (std::cos(rpcFitResult.
phi)>0)? 1: -1;
176 } else {
177 one = (std::cos(p_roids->
phi())>0)? 1: -1;
178 }
180 if(phim>=
M_PI+0.1) phim = phim - 2*
M_PI;
181
182 if(phim>=0) trackPattern.
phiMap = (
phi>=0.)?
phi - phim : phim -std::abs(
phi);
184
186
187
189
190 if ( !m_alignmentBarrelLUT ) {
191 ATH_MSG_ERROR("Alignment correction service is not prepared");
192 return StatusCode::FAILURE;
193 }
194
195 double dZ = (*m_alignmentBarrelLUT)->GetDeltaZ(trackPattern.
s_address,
199 superPoints[0]->R);
200 superPoints[1]->Z += 10*dZ;
201 }
202
203 m = ( superPoints[2]->
Z - superPoints[0]->
Z ) / ( superPoints[2]->R - superPoints[0]->R );
204
205 trackPattern.
barrelSagitta = superPoints[1]->
Z - superPoints[1]->
R*
m - superPoints[0]->
Z + superPoints[0]->
R*
m;
206
207 cost = std::cos(std::atan(m));
208 x2 = superPoints[1]->
R - superPoints[0]->
R;
209 y2 = superPoints[1]->
Z - superPoints[0]->
Z;
210 x3 = superPoints[2]->
R - superPoints[0]->
R;
211 y3 = superPoints[2]->
Z - superPoints[0]->
Z;
212
216
217 tm = x3;
218 x3 = ( x3 + y3*
m)*
cost;
219 y3 = (-tm*
m + y3 )*
cost;
220
221 x0 = x3/2.;
223
226
227 }
229 y0 = 4230.;
230
232 x2 = superPoints[0]->
Z;
233 y2 = superPoints[0]->
R;
234 x3 = superPoints[3]->
Z;
235 y3 = superPoints[3]->
R;
237 x2 = superPoints[3]->
Z;
238 y2 = superPoints[3]->
R;
239 x3 = superPoints[1]->
Z;
240 y3 = superPoints[1]->
R;
242 x2 = superPoints[3]->
Z;
243 y2 = superPoints[3]->
R;
244 x3 = superPoints[2]->
Z;
245 y3 = superPoints[2]->
R;
246 }
247
250
252
255 c1 = -
dy*(
y2*y3-y0*y0)+ y3*x2*x2 - y2*x3*x3;
256 c0 = y0*
x2*x3*
dx + y0*
x2*(y3-y0)*(y3-y0) - y0*x3*(
y2-y0)*(y2-y0);
259
260 nit = 1;
261 while((nit++)<=nitmx&&std::abs(x0-xn)>=eps) {
262 xn = x0 -
f(x0,c0,c1,c2,c3)/
fp(x0,c33,c22,c1);
263 x0 = xn;
264 }
266
269
271 rad = superPoints[0]->
R;
272 theta = std::atan2(rad,std::abs(superPoints[0]->Z));
273 signZ = (std::abs(superPoints[0]->Z) >
ZERO_LIMIT)? superPoints[0]->Z/std::abs(superPoints[0]->Z): 1.;
274 } else {
276 theta = std::atan2(rad,std::abs(x1));
277 signZ = (std::abs(x1) >
ZERO_LIMIT)? x1/std::abs(x1): 1.;
278 }
279
280 trackPattern.
etaMap = (-std::log(std::tan(
theta/2.)))*signZ;
282
283 one = (std::cos(rpcFitResult.
phi)>0)? 1: -1;
284 } else {
285 one = (std::cos(p_roids->
phi())>0)? 1: -1;
286 }
288
289 if(phim>=
M_PI+0.1) phim = phim - 2*
M_PI;
290
291 if(phim>=0) trackPattern.
phiMap = (
phi>=0.)?
phi - phim : phim -std::abs(
phi);
293
295
303 da = -c2q*
e3 + c3q*
e2;
307
313 if(
a<=0.) trackPattern.
charge = 1;
314 }
315
316 ATH_MSG_DEBUG(
"... count/trackPattern.barrelSagitta/barrelRadius/charge/s_address/phi="
319 << trackPattern.
phiMS);
320
321 return StatusCode::SUCCESS;
322}
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
virtual double phi() const override final
Methods to retrieve data members.
float f(float x, float c0, float c1, float c2, float c3) const
float fp(float x, float c33, float c22, float c1) const
TrigL2MuonSA::SuperPoint superPoints[s_NCHAMBER]
int cost(std::vector< std::string > &files, node &n, const std::string &directory="", bool deleteref=false, bool relocate=false)
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
double e2(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 2nd sampling
@ BarrelInner
Inner station in the barrel spectrometer.
@ BarrelMiddle
Middle station in the barrel spectrometer.
@ BarrelOuter
Outer station in the barrel spectrometer.
@ EndcapInner
Inner station in the endcap spectrometer.
setSAddress setEtaMS setDirPhiMS setDirZMS barrelRadius