6 #include "CLHEP/Units/SystemOfUnits.h"
15 constexpr
double Binomial(
int n,
int k) {
17 if (
n < 0 ||
k < 0 ||
n <
k) {
18 return std::numeric_limits<double>::signaling_NaN();
20 if (
k == 0 ||
n ==
k) {
27 for (
double i = k1;
i > 1.; --
i) {
33 constexpr
int PolyDegree = 20;
34 constexpr
int PolyNCoeff = PolyDegree + 1;
36 constexpr std::array<double, PolyNCoeff> BinomialCache() {
37 constexpr
double b0 = Binomial(20, 0);
38 constexpr
double b1 = Binomial(20, 1);
39 constexpr
double b2 = Binomial(20, 2);
40 constexpr
double b3 = Binomial(20, 3);
41 constexpr
double b4 = Binomial(20, 4);
42 constexpr
double b5 = Binomial(20, 5);
43 constexpr
double b6 = Binomial(20, 6);
44 constexpr
double b7 = Binomial(20, 7);
45 constexpr
double b8 = Binomial(20, 8);
46 constexpr
double b9 = Binomial(20, 9);
47 constexpr
double b10 = Binomial(20, 10);
49 std::array<double, PolyNCoeff>
res = {b0, b1, b2, b3, b4, b5, b6,
50 b7, b8, b9, b10, b9, b8, b7,
51 b6, b5, b4, b3, b2, b1, b0};
58 constexpr std::array<double, PolyNCoeff> s_binomialCache = BinomialCache();
61 double bernstein_grundpolynom(
const double t,
const int i) {
62 static_assert(s_binomialCache.size() >
N,
63 " Binomial cache must be larger than N");
68 double bernstein_bezier(
const double u,
const double v,
const float *
P) {
72 std::array<double,PolyNCoeff> bernstein_grundpolynomU{};
73 std::array<double,PolyNCoeff> bernstein_grundpolynomV{};
74 for (
int i = 0;
i < PolyNCoeff; ++
i) {
75 bernstein_grundpolynomU[
i] = bernstein_grundpolynom<PolyDegree>(
u,
i);
76 bernstein_grundpolynomV[
i] = bernstein_grundpolynom<PolyDegree>(
v,
i);
79 for (
int i = 0;
i < PolyNCoeff; ++
i) {
82 const double bernstein_grundpolynom_i = bernstein_grundpolynomU[
i];
84 for (
int j = 0; j < PolyNCoeff; ++j) {
86 const int k = (
i * (PolyDegree + 1)) + j;
92 const double bernstein_grundpolynom_j = bernstein_grundpolynomV[j];
93 r += bernstein_grundpolynom_i * bernstein_grundpolynom_j *
P[
k];
103 else distosize = 441;
109 std::vector<float> map(distosize, 0.0);
121 double localphi = locpos[0];
122 double localeta = locpos[1];
124 const unsigned long long ull_id =
getId(hashID);
127 if (ull_id == 0 &&
m_version > 1) {
return nullCorrection; }
136 double invtanphi = direction.x()/direction.z();
137 double invtaneta = direction.y()/direction.z();
138 if (sqrt(invtanphi*invtanphi+invtaneta*invtaneta)>100.0) {
return nullCorrection; }
146 localZ =
getSurveyZ(localeta, localphi, map.data());
148 localZ =
getSurveyZ(localeta, localphi, map.data());
150 float modEtaSize, modPhiSize;
153 if (ull_id >= 0x200000000000000 && ull_id <= 0x20d980000000000) {
166 localZ =
getInSituZ(localeta, modEtaSize, localphi, modPhiSize, map.data());
169 double localetaCor = -localZ * invtaneta;
170 double localphiCor = -localZ * invtanphi;
175 if (
getVersion()==0) { localphiCor = -localphiCor; }
182 newlocpos +=
correction(hashID, locpos, direction);
188 newlocpos -=
correction(hashID, locpos, direction);
194 double etaHalfRangeBB = eta_size * 10. / 21.;
195 double phiHalfRangeBB = phi_size * 10. / 21.;
196 double etaRangeBB = eta_size * 20. / 21.;
197 double phiRangeBB = phi_size * 20. / 21.;
202 if (std::abs(localeta) - etaHalfRangeBB > 0) {
204 eta = (localeta + etaHalfRangeBB) / etaRangeBB;
206 eta = 1. + (localeta - etaHalfRangeBB) / etaRangeBB;
208 eta = localeta / etaRangeBB + 0.5;
210 if (std::abs(localphi) - phiHalfRangeBB > 0) {
212 phi = (localphi + phiHalfRangeBB) / phiRangeBB;
214 phi = 1. + (localphi - phiHalfRangeBB) / phiRangeBB;
216 phi = localphi / phiRangeBB + 0.5;
218 return bernstein_bezier(
eta,
phi, disto);
230 double twist1 = -
data2;
231 double twist2 =
data2;
232 double b1 = sqrt((1. + twist1*twist1) * (1. + twist1*twist1) * (1. + twist1*twist1));
233 double b2 = sqrt((1. + twist2*twist2) * (1. + twist2*twist2) * (1. + twist2*twist2));
234 double z1 = localeta * twist1 - 0.5 * b1 * localeta*localeta *
data1;
235 double z2 = localeta * twist2 - 0.5 * b2 * localeta*localeta * data0;
236 double zoff1 = (b1 * yFE*yFE *
data1) / 24.;
237 double zoff2 = (b2 * yFE*yFE * data0) / 24.;
241 return z1 + ((z2 - z1) / xFE) * (localphi + xFE / 2.);
247 if (ull_id < 0x240000000000000)
return false;
256 if (ull_id >= 0x200000000000000 && ull_id <= 0x200180000000000)
return true;
257 if (ull_id >= 0x200800000000000 && ull_id <= 0x200980000000000)
return true;
260 if (ull_id >= 0x201000000000000 && ull_id <= 0x201180000000000)
return true;
261 if (ull_id >= 0x201800000000000 && ull_id <= 0x201980000000000)
return true;
264 if (ull_id >= 0x202000000000000 && ull_id <= 0x202180000000000)
return true;
265 if (ull_id >= 0x202800000000000 && ull_id <= 0x202980000000000)
return true;
268 if (ull_id >= 0x203000000000000 && ull_id <= 0x203180000000000)
return true;
269 if (ull_id >= 0x203800000000000 && ull_id <= 0x203980000000000)
return true;
272 if (ull_id >= 0x204000000000000 && ull_id <= 0x204180000000000)
return true;
273 if (ull_id >= 0x204800000000000 && ull_id <= 0x204980000000000)
return true;
276 if (ull_id >= 0x205000000000000 && ull_id <= 0x205180000000000)
return true;
277 if (ull_id >= 0x205800000000000 && ull_id <= 0x205980000000000)
return true;
280 if (ull_id >= 0x206000000000000 && ull_id <= 0x206180000000000)
return true;
281 if (ull_id >= 0x206800000000000 && ull_id <= 0x206980000000000)
return true;
284 if (ull_id >= 0x207000000000000 && ull_id <= 0x207180000000000)
return true;
285 if (ull_id >= 0x207800000000000 && ull_id <= 0x207980000000000)
return true;
288 if (ull_id >= 0x208000000000000 && ull_id <= 0x208180000000000)
return true;
289 if (ull_id >= 0x208800000000000 && ull_id <= 0x208980000000000)
return true;
292 if (ull_id >= 0x209000000000000 && ull_id <= 0x209180000000000)
return true;
293 if (ull_id >= 0x209800000000000 && ull_id <= 0x209980000000000)
return true;
296 if (ull_id >= 0x20a000000000000 && ull_id <= 0x20a180000000000)
return true;
297 if (ull_id >= 0x20a800000000000 && ull_id <= 0x20a980000000000)
return true;
300 if (ull_id >= 0x20b000000000000 && ull_id <= 0x20b180000000000)
return true;
301 if (ull_id >= 0x20b800000000000 && ull_id <= 0x20b980000000000)
return true;
304 if (ull_id >= 0x20c000000000000 && ull_id <= 0x20c180000000000)
return true;
305 if (ull_id >= 0x20c800000000000 && ull_id <= 0x20c980000000000)
return true;
308 if (ull_id >= 0x20d000000000000 && ull_id <= 0x20d180000000000)
return true;
309 if (ull_id >= 0x20d800000000000 && ull_id <= 0x20d980000000000)
return true;