10 template <
typename external_spacepo
int_t>
14 auto extractFunction =
16 -> std::array<float, 6> {
17 std::array<float, 6>
output{obj.x(), obj.y(), obj.z(),
18 obj.radius(), obj.varianceR(), obj.varianceZ()};
22 return transformCoordinates<InternalSpacePoint<external_spacepoint_t>>(
23 sp, spM, bottom,
std::move(extractFunction));
26 template <
typename external_spacepo
int_t,
typename callable_t>
28 const external_spacepoint_t& spM,
30 callable_t&& extractFunction) {
36 auto [xM, yM, zM, rM, varianceRM, varianceZM] = extractFunction(spM);
37 auto [xSP, ySP, zSP, rSP, varianceRSP, varianceZSP] = extractFunction(sp);
39 float cosPhiM = xM / rM;
40 float sinPhiM = yM / rM;
41 float deltaX = xSP - xM;
42 float deltaY = ySP - yM;
43 float deltaZ = zSP - zM;
44 float xNewFrame = deltaX * cosPhiM + deltaY * sinPhiM;
45 float yNewFrame = deltaY * cosPhiM - deltaX * sinPhiM;
46 float deltaR2 = (xNewFrame * xNewFrame + yNewFrame * yNewFrame);
47 float iDeltaR2 = 1. / (deltaX * deltaX + deltaY * deltaY);
48 float iDeltaR = std::sqrt(iDeltaR2);
49 int bottomFactor = bottom ? -1 : 1;
50 float cotTheta = deltaZ * iDeltaR * bottomFactor;
56 const float U = xNewFrame * iDeltaR2;
57 const float V = yNewFrame * iDeltaR2;
60 const float Er = ((varianceZM + varianceZSP) +
61 (cotTheta * cotTheta) * (varianceRM + varianceRSP)) *
64 sp.setDeltaR(std::sqrt(deltaR2 + (deltaZ * deltaZ)));
65 return LinCircle(cotTheta, iDeltaR, Er, U, V, xNewFrame, yNewFrame);
68 template <
typename external_spacepo
int_t>
73 std::vector<LinCircle>& linCircleVec) {
74 auto extractFunction =
76 -> std::array<float, 6> {
77 std::array<float, 6>
output{obj.x(), obj.y(), obj.z(),
78 obj.radius(), obj.varianceR(), obj.varianceZ()};
82 transformCoordinates<InternalSpacePoint<external_spacepoint_t>>(
83 spacePointData,
vec, spM, bottom, linCircleVec,
87 template <
typename external_spacepo
int_t,
typename callable_t>
89 const std::vector<external_spacepoint_t*>&
vec,
90 const external_spacepoint_t& spM,
bool bottom,
91 std::vector<LinCircle>& linCircleVec,
92 callable_t&& extractFunction) {
93 auto [xM, yM, zM, rM, varianceRM, varianceZM] = extractFunction(spM);
96 linCircleVec.resize(vec.size());
98 float cosPhiM = xM / rM;
99 float sinPhiM = yM / rM;
101 int bottomFactor = bottom ? -1 : 1;
103 for (std::size_t
idx(0);
idx < vec.size(); ++
idx) {
105 auto [xSP, ySP, zSP, rSP, varianceRSP, varianceZSP] = extractFunction(*sp);
107 float deltaX = xSP - xM;
108 float deltaY = ySP - yM;
109 float deltaZ = zSP - zM;
114 float xNewFrame = deltaX * cosPhiM + deltaY * sinPhiM;
115 float yNewFrame = deltaY * cosPhiM - deltaX * sinPhiM;
117 float deltaR2 = (xNewFrame * xNewFrame + yNewFrame * yNewFrame);
118 float iDeltaR2 = 1. / deltaR2;
119 float iDeltaR = std::sqrt(iDeltaR2);
122 float cotTheta = deltaZ * iDeltaR * bottomFactor;
129 float U = xNewFrame * iDeltaR2;
130 float V = yNewFrame * iDeltaR2;
132 float Er = ((varianceZM + varianceZSP) +
133 (cotTheta * cotTheta) * (varianceRM + varianceRSP)) *
137 linCircleVec[
idx].cotTheta = cotTheta;
138 linCircleVec[
idx].iDeltaR = iDeltaR;
139 linCircleVec[
idx].Er = Er;
140 linCircleVec[
idx].U = U;
141 linCircleVec[
idx].V = V;
142 linCircleVec[
idx].x = xNewFrame;
143 linCircleVec[
idx].y = yNewFrame;
146 std::sqrt(deltaR2 + (deltaZ * deltaZ)));
150 template <
typename external_spacepo
int_t>
155 const double* spacepointPosition,
double* outputCoordinates) {
159 if (not hasValueStored) {
172 const double xTopStripVector = topStripVector[0];
173 const double yTopStripVector = topStripVector[1];
174 const double zTopStripVector = topStripVector[2];
175 const double xBottomStripVector = bottomStripVector[0];
176 const double yBottomStripVector = bottomStripVector[1];
177 const double zBottomStripVector = bottomStripVector[2];
180 double d1[3] = {yTopStripVector * spacepointPosition[2] -
181 zTopStripVector * spacepointPosition[1],
182 zTopStripVector * spacepointPosition[0] -
183 xTopStripVector * spacepointPosition[2],
184 xTopStripVector * spacepointPosition[1] -
185 yTopStripVector * spacepointPosition[0]};
188 double bd1 = xBottomStripVector * d1[0] + yBottomStripVector * d1[1] +
189 zBottomStripVector * d1[2];
193 double s1 = (stripCenterDistance[0] * d1[0] + stripCenterDistance[1] * d1[1] +
194 stripCenterDistance[2] * d1[2]);
200 double d0[3] = {yBottomStripVector * spacepointPosition[2] -
201 zBottomStripVector * spacepointPosition[1],
202 zBottomStripVector * spacepointPosition[0] -
203 xBottomStripVector * spacepointPosition[2],
204 xBottomStripVector * spacepointPosition[1] -
205 yBottomStripVector * spacepointPosition[0]};
209 double s0 = (stripCenterDistance[0] * d0[0] + stripCenterDistance[1] * d0[1] +
210 stripCenterDistance[2] * d0[2]);
224 outputCoordinates[0] = topStripCenterPosition[0] + xTopStripVector * s0;
225 outputCoordinates[1] = topStripCenterPosition[1] + yTopStripVector * s0;
226 outputCoordinates[2] = topStripCenterPosition[2] + zTopStripVector * s0;