17 #include "GaudiKernel/MsgStream.h"
18 #include "GaudiKernel/SystemOfUnits.h"
27 , m_baseBounds(nullptr)
34 std::vector<std::pair<float, float>> xyVtx,
38 , m_baseBounds(nullptr)
44 m_xyVtx.assign(xyVtx.begin(), xyVtx.end());
49 std::vector<std::pair<double, double>> xyVtx,
53 , m_baseBounds(nullptr)
59 m_xyVtx.assign(xyVtx.begin(), xyVtx.end());
65 , m_halfZ(trabo.m_halfZ)
66 , m_baseBounds(nullptr)
67 , m_ordering(trabo.m_ordering)
69 m_objectAccessor(trabo.m_objectAccessor)
87 m_xyVtx.resize(trabo.
m_xyVtx.size());
97 std::vector<std::unique_ptr<Trk::Surface>>
101 auto retsf = std::vector<std::unique_ptr<Trk::Surface>>();
105 auto xyPlane = std::make_unique<Trk::PlaneSurface>(
108 std::make_shared<Trk::TriangleBounds>(m_xyVtx));
109 retsf.push_back(std::move(xyPlane));
111 auto xymPlane = std::make_unique<Trk::PlaneSurface>(
115 std::make_shared<Trk::TriangleBounds>(mirror_xyVtx()));
116 retsf.push_back(std::move(xymPlane));
119 for (
unsigned int iv = 0; iv < m_xyVtx.size(); iv++) {
120 if (iv != m_xyVtx.size() - 1)
121 retsf.push_back(sideSurf(
transform, iv, iv + 1));
123 retsf.push_back(sideSurf(
transform, iv, 0));
130 std::unique_ptr<Trk::PlaneSurface>
134 unsigned int iv2)
const
136 std::unique_ptr<Trk::PlaneSurface> plane =
nullptr;
138 double xdif = m_xyVtx[iv2].first - m_xyVtx[iv1].first;
139 double ydif = m_xyVtx[iv2].second - m_xyVtx[iv1].second;
140 double xsize = sqrt(xdif * xdif + ydif * ydif);
142 double ori =
ordering() > 0 ? 1. : -1.;
145 0.5 * (m_xyVtx[iv1].
first + m_xyVtx[iv2].
first),
148 double phi = ori * ydif < 0 ?
M_PI / 2 : -
M_PI / 2;
149 if (ori > 0 && ydif > 0)
151 if (std::abs(xdif) > 1
e-6) {
161 plane = std::make_unique<Trk::PlaneSurface>(tr, std::make_shared<Trk::RectangleBounds>(0.5 * xsize, m_halfZ));
173 int ivr = (iv1 == 0 || iv2 == 0) ? 1 : 0;
174 if (ivr == 1 && (iv1 == 1 || iv2 == 1))
177 double ox = m_xyVtx[ivr].first -
pos[0];
178 double oy = m_xyVtx[ivr].second -
pos[1];
182 if (
d.dot(plane->
normal()) > 0.) {
189 std::make_unique<Trk::PlaneSurface>(tr, std::make_shared<Trk::RectangleBounds>(0.5 * xsize, m_halfZ));
198 if (std::abs(
pos.z()) > m_halfZ + tol)
202 return (m_baseBounds->inside(locp, tol, tol));
205 std::vector<std::pair<double, double>>
208 std::vector<std::pair<double, double>> mirrored;
209 mirrored.resize(m_xyVtx.size());
211 for (
unsigned int i = 0;
i < m_xyVtx.size();
i++)
213 std::pair<double, double>(m_xyVtx[
i].
first, -m_xyVtx[
i].
second);
221 if (m_ordering.isValid()) {
222 return *(m_ordering.ptr());
225 int tmp_ordering = 1;
227 double yd2 = m_xyVtx[2].second - m_xyVtx[1].second;
228 double yd0 = m_xyVtx[0].second - m_xyVtx[1].second;
229 double xd2 = m_xyVtx[2].first - m_xyVtx[1].first;
230 double xd0 = m_xyVtx[0].first - m_xyVtx[1].first;
231 double ph2 = yd2 < 0 ? -
M_PI / 2 :
M_PI / 2;
232 if (std::abs(xd2) > 1
e-6) {
233 ph2 =
atan(yd2 / xd2);
237 double ph0 = yd0 < 0 ? -
M_PI / 2 :
M_PI / 2;
238 if (std::abs(xd0) > 1
e-6) {
239 ph0 =
atan(yd0 / xd0);
248 if ((ph0 > ph2 && ph0 - ph2 <
M_PI) || (ph2 - ph0) >
M_PI)
251 m_ordering.set(tmp_ordering);
252 return *(m_ordering.ptr());
259 std::stringstream temp_sl;
260 temp_sl << std::setiosflags(std::ios::fixed);
261 temp_sl << std::setprecision(7);
262 temp_sl <<
"Trk::PrismVolumeBounds: (halfZ, generating vtx) = ";
263 temp_sl <<
"( " << m_halfZ <<
")";
264 for (
const auto & myVtx : m_xyVtx)
265 temp_sl <<
"(" << myVtx.first <<
"," << myVtx.second <<
")";
274 std::stringstream temp_sl;
275 temp_sl << std::setiosflags(std::ios::fixed);
276 temp_sl << std::setprecision(7);
277 temp_sl <<
"Trk::PrismVolumeBounds: (halfZ, generating vtx) = ";
278 temp_sl <<
"( " << m_halfZ <<
")";
279 for (
const auto & myVtx : m_xyVtx)
280 temp_sl <<
"(" << myVtx.first <<
"," << myVtx.second <<
")";