11 std::ifstream ifin3(global_coords_filename_.fullPath());
15 <<
"GlobalCoordsObtainer::GlobalCoordsObtainer() - Cannot find " << global_coords_filename_.fullPath();
25 while (ifin3.good()) {
26 ifin3 >> wh >> st >> se >> sl >>
perp >> x_phi0;
30 sl1_constants.
x_phi0 = x_phi0;
33 sl3_constants.
x_phi0 = x_phi0;
36 global_constants.push_back({
ChId.rawId(), sl1_constants, sl3_constants});
48 if (
ChId.wheel() > 0 || (
ChId.wheel() == 0 &&
ChId.sector() % 4 > 1)) {
52 auto phi1 = calc_atan_lut(12,
63 auto phi3 = calc_atan_lut(12,
79 auto phic = calc_atan_lut(12,
90 auto phib = calc_atan_lut(9, 6, 1. / 4096, 0., 4. /
std::pow(2, 13), 10, 3, 10, 16,
sgn);
120 long int a_min = -
std::pow(2, (a_size - 1));
121 long int a_max =
std::pow(2, (a_size - 1)) - 1;
122 long int b_min = -
std::pow(2, (b_size - 1));
123 long int b_max =
std::pow(2, (b_size - 1)) - 1;
125 std::map<int, lut_value> lut;
127 for (
long int x_msb = -(
long int)
std::pow(2, msb_num - 1); x_msb < (
long int)
std::pow(2, msb_num - 1); x_msb++) {
128 int x1 = ((x_msb) << lsb_num);
129 int x2 = ((x_msb + 1) << lsb_num) - 1;
131 double t1 =
x1 * in_res - abscissa_0;
132 double t2 =
x2 * in_res - abscissa_0;
134 double phi1 =
sgn * atan(
t1);
135 double phi2 =
sgn * atan(
t2);
137 double y1 = phi1 / out_res;
138 double y2 = phi2 / out_res;
152 double t_max_err =
sqrt(
sgn * in_res / out_res /
a - 1);
157 double x_max_err = (t_max_err + abscissa_0) / in_res;
158 double phi_max_err =
sgn * atan(t_max_err);
159 double y_max_err = phi_max_err / out_res;
166 double b = (
y1 + y_max_err -
a * (x_max_err -
x1)) / 2;
173 long int a_int = (
long int)(round(
a * (
pow(2, a_extra_bits))));
174 long int b_int = (
long int)(round(
b * (
pow(2, b_extra_bits))));
177 std::vector<long int> as = {a_min, a_int, a_max};
178 std::vector<long int>
bs = {b_min, b_int, b_max};
191 int index = to_two_comp(x_msb, msb_num);
192 lut[
index] = {a_int, b_int};
201 auto phi_lut = &luts[chid].phic;
203 phi_lut = &luts[chid].phi1;
204 }
else if (sl == 3) {
205 phi_lut = &luts[chid].phi3;
208 auto phib_lut = &luts[chid].phib;
211 x = to_two_comp(x,
X_SIZE);
242 auto phi_lut_a = phi_lut_q.a;
243 auto phi_lut_b = phi_lut_q.b;
244 auto phib_lut_a = phib_lut_q.a;
245 auto phib_lut_b = phib_lut_q.b;
250 int phi_uncut = (phi_lut_b <<
PHI_B_SHL_BITS) + x_lsb * phi_lut_a;
251 int psi_uncut = (phib_lut_b <<
PHIB_B_SHL_BITS) + tanpsi_lsb * phib_lut_a;