17#include "GaudiKernel/MsgStream.h"
18#include "GaudiKernel/SystemOfUnits.h"
34 std::vector<std::pair<float, float>> xyVtx,
44 m_xyVtx.assign(xyVtx.begin(), xyVtx.end());
49 std::vector<std::pair<double, double>> xyVtx,
59 m_xyVtx.assign(xyVtx.begin(), xyVtx.end());
97std::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>(
116 retsf.push_back(std::move(xymPlane));
119 for (
unsigned int iv = 0; iv <
m_xyVtx.size(); iv++) {
121 retsf.push_back(
sideSurf(transform, iv, iv + 1));
123 retsf.push_back(
sideSurf(transform, iv, 0));
130std::unique_ptr<Trk::PlaneSurface>
134 unsigned int iv2)
const
136 std::unique_ptr<Trk::PlaneSurface> plane =
nullptr;
140 double xsize = sqrt(xdif * xdif + ydif * ydif);
142 double ori =
ordering() > 0 ? 1. : -1.;
148 double phi = ori * ydif < 0 ?
M_PI / 2 : -
M_PI / 2;
149 if (ori > 0 && ydif > 0)
151 if (std::abs(xdif) > 1e-6) {
152 phi = atan(ydif / xdif);
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)
205std::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++)
225 int tmp_ordering = 1;
231 double ph2 = yd2 < 0 ? -
M_PI / 2 :
M_PI / 2;
232 if (std::abs(xd2) > 1e-6) {
233 ph2 = atan(yd2 / xd2);
237 double ph0 = yd0 < 0 ? -
M_PI / 2 :
M_PI / 2;
238 if (std::abs(xd0) > 1e-6) {
239 ph0 = atan(yd0 / xd0);
248 if ((ph0 > ph2 && ph0 - ph2 <
M_PI) || (ph2 - ph0) >
M_PI)
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 <<
")";
Bounds for the transcript of triangular prism.
PrismVolumeBounds & operator=(const PrismVolumeBounds &bobo)
Assignment operator.
std::vector< std::pair< double, double > > mirror_xyVtx() const
mirror the input vertices for down-side boundary
double m_halfZ
halflength in z
virtual ~PrismVolumeBounds()
Destructor.
Trk::EightObjectsAccessor m_objectAccessor
There's only one single object Acessor for the moment has to be implemented if Cuboids are used more ...
PrismVolumeBounds()
Default Constructor.
CxxUtils::CachedValue< int > m_ordering
cache vertex ordering
std::vector< std::pair< double, double > > m_xyVtx
generating xy vertices
Trk::TriangleBounds * m_baseBounds
base xy bounds
int ordering() const
assess ordering of vertices
MsgStream & dump(MsgStream &sl) const override final
Output Method for MsgStream.
virtual std::vector< std::unique_ptr< Trk::Surface > > decomposeToSurfaces(const Amg::Transform3D &transform) override final
Method to decompose the Bounds into Surfaces.
bool inside(const Amg::Vector3D &, double tol=0.) const override final
This method checks if position in the 3D volume frame is inside the volume.
std::unique_ptr< Trk::PlaneSurface > sideSurf(const Amg::Transform3D &, unsigned int, unsigned int) const
method to construct side boundary planes
Bounds for a triangular, planar surface.
VolumeBounds()
Default Constructor.
Eigen::AngleAxisd AngleAxis3D
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D