41 const int MAX_STATION = 4;
47 double theta,rad,
phi,one,phim=0,signZ;
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.;
55 const double eps = 0.005;
59 for (
int i_station=0; i_station<MAX_STATION; i_station++) {
68 return StatusCode::FAILURE;
70 superPoints[i_station] = &(trackPattern.
superPoints[chamberID]);
74 if ( i_station != 3 ){
75 phim = superPoints[i_station]->
Phim;
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;
105 throw std::runtime_error(
"y2 is zero in setSagittaRadius");
110 c2 = -y0*dx + 2.*(y2*x3-y3*x2);
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);
117 while((nit++)<=nitmx&&std::abs(x0-xn)>=eps) {
118 xn = x0 -
f(x0,c0,c1,c2,c3)/
fp(x0,c33,c22,c1);
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.;
130 theta = std::atan2(y1,std::abs(x1));
131 signZ = (std::abs(x1) >
ZERO_LIMIT)? x1/std::abs(x1): 1.;
134 trackPattern.
etaMap = (-std::log(std::tan(
theta/2.)))*signZ;
136 one = (std::cos(rpcFitResult.
phi)>0)? 1: -1;
138 one = (std::cos(p_roids->
phi())>0)? 1: -1;
142 if(phim>=
M_PI+0.1) phim = phim - 2*
M_PI;
144 if(phim>=0) trackPattern.
phiMap = (
phi>=0.)?
phi - phim : phim -std::abs(
phi);
156 da = -c2q*e3 + c3q*e2;
157 db = -c2*c3q + c3*c2q;
165 if(
a<=0.) trackPattern.
charge = 1;
167 }
else if (
count==3) {
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.;
172 trackPattern.
etaMap = (-std::log(std::tan(
theta/2.)))*signZ;
175 one = (std::cos(rpcFitResult.
phi)>0)? 1: -1;
177 one = (std::cos(p_roids->
phi())>0)? 1: -1;
180 if(phim>=
M_PI+0.1) phim = phim - 2*
M_PI;
182 if(phim>=0) trackPattern.
phiMap = (
phi>=0.)?
phi - phim : phim -std::abs(
phi);
191 ATH_MSG_ERROR(
"Alignment correction service is not prepared");
192 return StatusCode::FAILURE;
195 double dZ = (*m_alignmentBarrelLUT)->GetDeltaZ(trackPattern.
s_address,
200 superPoints[1]->
Z += 10*dZ;
203 m = ( superPoints[2]->
Z - superPoints[0]->
Z ) / ( superPoints[2]->R - superPoints[0]->R );
205 trackPattern.
barrelSagitta = superPoints[1]->
Z - superPoints[1]->
R*m - superPoints[0]->
Z + superPoints[0]->
R*m;
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;
214 x2 = ( x2 + y2*m)*
cost;
215 y2 = (-tm*m + y2 )*
cost;
218 x3 = ( x3 + y3*m)*
cost;
219 y3 = (-tm*m + y3 )*
cost;
222 y0 = (y2*y2 + x2*x2 -x2*x3)/(2*y2);
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;
254 c2 = -y0*dx + 2.*(y2*x3-y3*x2);
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);
261 while((nit++)<=nitmx&&std::abs(x0-xn)>=eps) {
262 xn = x0 -
f(x0,c0,c1,c2,c3)/
fp(x0,c33,c22,c1);
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.;
276 theta = std::atan2(rad,std::abs(x1));
277 signZ = (std::abs(x1) >
ZERO_LIMIT)? x1/std::abs(x1): 1.;
280 trackPattern.
etaMap = (-std::log(std::tan(
theta/2.)))*signZ;
283 one = (std::cos(rpcFitResult.
phi)>0)? 1: -1;
285 one = (std::cos(p_roids->
phi())>0)? 1: -1;
289 if(phim>=
M_PI+0.1) phim = phim - 2*
M_PI;
291 if(phim>=0) trackPattern.
phiMap = (
phi>=0.)?
phi - phim : phim -std::abs(
phi);
303 da = -c2q*e3 + c3q*e2;
304 db = -c2*c3q + c3*c2q;
310 double barrelRadius = std::sqrt(x0*x0 + y0*y0);
313 if(
a<=0.) trackPattern.
charge = 1;
316 ATH_MSG_DEBUG(
"... count/trackPattern.barrelSagitta/barrelRadius/charge/s_address/phi="
319 << trackPattern.
phiMS);
321 return StatusCode::SUCCESS;