ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::PrismVolumeBounds Class Referencefinal

Bounds for the transcript of triangular prism. More...

#include <PrismVolumeBounds.h>

Inheritance diagram for Trk::PrismVolumeBounds:
Collaboration diagram for Trk::PrismVolumeBounds:

Public Member Functions

 PrismVolumeBounds ()
 Default Constructor.
 PrismVolumeBounds (std::vector< std::pair< float, float > > xyvtx, float hlengthz)
 Constructor - generic case (from float)
 PrismVolumeBounds (std::vector< std::pair< double, double > > xyvtx, double hlengthz)
 Constructor - generic case from (double)
 PrismVolumeBounds (const PrismVolumeBounds &bobo)
 Copy Constructor.
virtual ~PrismVolumeBounds ()
 Destructor.
PrismVolumeBoundsoperator= (const PrismVolumeBounds &bobo)
 Assignment operator.
PrismVolumeBoundsclone () const override final
 Virtual constructor.
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.
virtual std::vector< std::unique_ptr< Trk::Surface > > decomposeToSurfaces (const Amg::Transform3D &transform) override final
 Method to decompose the Bounds into Surfaces.
ObjectAccessor boundarySurfaceAccessor (const Amg::Vector3D &gp, const Amg::Vector3D &dir, bool forceInside=false) const override final
 Provide accessor for BoundarySurfaces.
const std::vector< std::pair< double, double > > & xyVertices () const
 This method returns the set of xy generating vertices.
double halflengthZ () const
 This method returns the halflength in local z.
MsgStream & dump (MsgStream &sl) const override final
 Output Method for MsgStream.
std::ostream & dump (std::ostream &sl) const override final
 Output Method for std::ostream.

Private Member Functions

std::unique_ptr< Trk::PlaneSurfacesideSurf (const Amg::Transform3D &, unsigned int, unsigned int) const
 method to construct side boundary planes
std::vector< std::pair< double, double > > mirror_xyVtx () const
 mirror the input vertices for down-side boundary
int ordering () const
 assess ordering of vertices

Private Attributes

std::vector< std::pair< double, double > > m_xyVtx
 generating xy vertices
double m_halfZ
 halflength in z
Trk::TriangleBoundsm_baseBounds
 base xy bounds
CxxUtils::CachedValue< int > m_ordering
 cache vertex ordering
Trk::EightObjectsAccessor m_objectAccessor
 There's only one single object Acessor for the moment has to be implemented if Cuboids are used more widely.

Detailed Description

Bounds for the transcript of triangular prism.

BoundarySurfaceFace [index]:

- negativeFaceXY     [0] : Triangular Trk::PlaneSurface,
                           parallel to \f$ xy \f$ plane at negative \f$ z

\( - positiveFaceXY [1] : Triangular Trk::PlaneSurface, parallel to \) xy \( plane at positive \) z

Definition at line 44 of file PrismVolumeBounds.h.

Constructor & Destructor Documentation

◆ PrismVolumeBounds() [1/4]

Trk::PrismVolumeBounds::PrismVolumeBounds ( )

Default Constructor.

Definition at line 24 of file PrismVolumeBounds.cxx.

25 : VolumeBounds()
26 , m_halfZ()
27 , m_baseBounds(nullptr)
28 , m_ordering()
29 , // invalid cache
31{}
double m_halfZ
halflength in z
Trk::EightObjectsAccessor m_objectAccessor
There's only one single object Acessor for the moment has to be implemented if Cuboids are used more ...
CxxUtils::CachedValue< int > m_ordering
cache vertex ordering
Trk::TriangleBounds * m_baseBounds
base xy bounds
VolumeBounds()
Default Constructor.

◆ PrismVolumeBounds() [2/4]

Trk::PrismVolumeBounds::PrismVolumeBounds ( std::vector< std::pair< float, float > > xyvtx,
float hlengthz )

Constructor - generic case (from float)

Definition at line 33 of file PrismVolumeBounds.cxx.

36 : VolumeBounds()
37 , m_halfZ(halez)
38 , m_baseBounds(nullptr)
39 , m_ordering()
40 , // invalid cache
42{
43 m_xyVtx.resize(xyVtx.size());
44 m_xyVtx.assign(xyVtx.begin(), xyVtx.end());
45 m_baseBounds = new Trk::TriangleBounds(m_xyVtx);
46}
std::vector< std::pair< double, double > > m_xyVtx
generating xy vertices

◆ PrismVolumeBounds() [3/4]

Trk::PrismVolumeBounds::PrismVolumeBounds ( std::vector< std::pair< double, double > > xyvtx,
double hlengthz )

Constructor - generic case from (double)

Definition at line 48 of file PrismVolumeBounds.cxx.

51 : VolumeBounds()
52 , m_halfZ(halez)
53 , m_baseBounds(nullptr)
54 , m_ordering()
55 , // invalid cache
57{
58 m_xyVtx.resize(xyVtx.size());
59 m_xyVtx.assign(xyVtx.begin(), xyVtx.end());
60 m_baseBounds = new Trk::TriangleBounds(m_xyVtx);
61}

◆ PrismVolumeBounds() [4/4]

Trk::PrismVolumeBounds::PrismVolumeBounds ( const PrismVolumeBounds & bobo)

Copy Constructor.

Definition at line 63 of file PrismVolumeBounds.cxx.

64 : VolumeBounds()
65 , m_halfZ(trabo.m_halfZ)
66 , m_baseBounds(nullptr)
67 , m_ordering(trabo.m_ordering)
68 , // ordering cache will be valid if trabo/other cache is valid
69 m_objectAccessor(trabo.m_objectAccessor)
70{
71 m_xyVtx.resize(trabo.m_xyVtx.size());
72 m_xyVtx.assign(trabo.m_xyVtx.begin(), trabo.m_xyVtx.end());
73 m_baseBounds = new Trk::TriangleBounds(m_xyVtx);
74}

◆ ~PrismVolumeBounds()

Trk::PrismVolumeBounds::~PrismVolumeBounds ( )
virtual

Destructor.

Definition at line 76 of file PrismVolumeBounds.cxx.

77{
78 delete m_baseBounds;
79}

Member Function Documentation

◆ boundarySurfaceAccessor()

ObjectAccessor Trk::PrismVolumeBounds::boundarySurfaceAccessor ( const Amg::Vector3D & gp,
const Amg::Vector3D & dir,
bool forceInside = false ) const
inlinefinaloverridevirtual

Provide accessor for BoundarySurfaces.

Implements Trk::VolumeBounds.

Definition at line 127 of file PrismVolumeBounds.h.

128 {
129 return Trk::ObjectAccessor(m_objectAccessor);
130}

◆ clone()

PrismVolumeBounds * Trk::PrismVolumeBounds::clone ( ) const
inlinefinaloverridevirtual

Virtual constructor.

Implements Trk::VolumeBounds.

Definition at line 116 of file PrismVolumeBounds.h.

116 {
117 return new PrismVolumeBounds(*this);
118}
PrismVolumeBounds()
Default Constructor.

◆ decomposeToSurfaces()

std::vector< std::unique_ptr< Trk::Surface > > Trk::PrismVolumeBounds::decomposeToSurfaces ( const Amg::Transform3D & transform)
finaloverridevirtual

Method to decompose the Bounds into Surfaces.

Implements Trk::VolumeBounds.

Definition at line 98 of file PrismVolumeBounds.cxx.

100{
101 auto retsf = std::vector<std::unique_ptr<Trk::Surface>>();
102
103 // face surfaces xy
104 // (1) - at positive local z
105 auto xyPlane = std::make_unique<Trk::PlaneSurface>(
107 transform * Amg::Translation3D(Amg::Vector3D(0., 0., m_halfZ))),
108 std::make_shared<Trk::TriangleBounds>(m_xyVtx));
109 retsf.push_back(std::move(xyPlane));
110 // (2) - at negative local z
111 auto xymPlane = std::make_unique<Trk::PlaneSurface>(
113 transform * Amg::Translation3D(Amg::Vector3D(0., 0., -m_halfZ)) *
114 Amg::AngleAxis3D(180 * Gaudi::Units::deg, Amg::Vector3D(1., 0., 0.))),
115 std::make_shared<Trk::TriangleBounds>(mirror_xyVtx()));
116 retsf.push_back(std::move(xymPlane));
117 // loop over xy vertices
118 // (3)
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));
122 else
123 retsf.push_back(sideSurf(transform, iv, 0));
124 }
125
126 return retsf;
127}
std::vector< std::pair< double, double > > mirror_xyVtx() const
mirror the input vertices for down-side boundary
std::unique_ptr< Trk::PlaneSurface > sideSurf(const Amg::Transform3D &, unsigned int, unsigned int) const
method to construct side boundary planes
Eigen::AngleAxisd AngleAxis3D
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D

◆ dump() [1/2]

MsgStream & Trk::PrismVolumeBounds::dump ( MsgStream & sl) const
finaloverridevirtual

Output Method for MsgStream.

Implements Trk::VolumeBounds.

Definition at line 257 of file PrismVolumeBounds.cxx.

258{
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 << ")";
266 sl << temp_sl.str();
267
268 return sl;
269}

◆ dump() [2/2]

std::ostream & Trk::PrismVolumeBounds::dump ( std::ostream & sl) const
finaloverridevirtual

Output Method for std::ostream.

Implements Trk::VolumeBounds.

Definition at line 272 of file PrismVolumeBounds.cxx.

273{
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 << ")";
281 sl << temp_sl.str();
282
283 return sl;
284}

◆ halflengthZ()

double Trk::PrismVolumeBounds::halflengthZ ( ) const
inline

This method returns the halflength in local z.

Definition at line 125 of file PrismVolumeBounds.h.

125{ return m_halfZ; }

◆ inside()

bool Trk::PrismVolumeBounds::inside ( const Amg::Vector3D & pos,
double tol = 0. ) const
finaloverridevirtual

This method checks if position in the 3D volume frame is inside the volume.

Implements Trk::VolumeBounds.

Definition at line 196 of file PrismVolumeBounds.cxx.

197{
198 if (std::abs(pos.z()) > m_halfZ + tol)
199 return false;
200 // xy plane
201 Amg::Vector2D locp(pos.x(), pos.y());
202 return (m_baseBounds->inside(locp, tol, tol));
203}
Eigen::Matrix< double, 2, 1 > Vector2D

◆ mirror_xyVtx()

std::vector< std::pair< double, double > > Trk::PrismVolumeBounds::mirror_xyVtx ( ) const
private

mirror the input vertices for down-side boundary

Definition at line 206 of file PrismVolumeBounds.cxx.

207{
208 std::vector<std::pair<double, double>> mirrored;
209 mirrored.resize(m_xyVtx.size());
210
211 for (unsigned int i = 0; i < m_xyVtx.size(); i++)
212 mirrored[i] =
213 std::pair<double, double>(m_xyVtx[i].first, -m_xyVtx[i].second);
214
215 return mirrored;
216}

◆ operator=()

Trk::PrismVolumeBounds & Trk::PrismVolumeBounds::operator= ( const PrismVolumeBounds & bobo)

Assignment operator.

Definition at line 82 of file PrismVolumeBounds.cxx.

83{
84 if (this != &trabo) {
85 m_halfZ = trabo.m_halfZ;
86 m_objectAccessor = trabo.m_objectAccessor;
87 m_xyVtx.resize(trabo.m_xyVtx.size());
88 m_xyVtx.assign(trabo.m_xyVtx.begin(), trabo.m_xyVtx.end());
89 delete m_baseBounds;
90 m_baseBounds = new Trk::TriangleBounds(m_xyVtx);
92 trabo.m_ordering; // ordering cache will be valid if trabo cache is valid
93 }
94 return *this;
95}

◆ ordering()

int Trk::PrismVolumeBounds::ordering ( ) const
private

assess ordering of vertices

Definition at line 219 of file PrismVolumeBounds.cxx.

220{
221 if (m_ordering.isValid()) {
222 return *(m_ordering.ptr());
223 }
224
225 int tmp_ordering = 1;
226
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) > 1e-6) {
233 ph2 = atan(yd2 / xd2);
234 if (xd2 < 0)
235 ph2 += M_PI;
236 }
237 double ph0 = yd0 < 0 ? -M_PI / 2 : M_PI / 2;
238 if (std::abs(xd0) > 1e-6) {
239 ph0 = atan(yd0 / xd0);
240 if (xd0 < 0)
241 ph0 += M_PI;
242 }
243 if (ph0 < 0)
244 ph0 += 2 * M_PI;
245 if (ph2 < 0)
246 ph2 += 2 * M_PI;
247
248 if ((ph0 > ph2 && ph0 - ph2 < M_PI) || (ph2 - ph0) > M_PI)
249 tmp_ordering = 0;
250
251 m_ordering.set(tmp_ordering);
252 return *(m_ordering.ptr());
253}
#define M_PI

◆ sideSurf()

std::unique_ptr< Trk::PlaneSurface > Trk::PrismVolumeBounds::sideSurf ( const Amg::Transform3D & transform,
unsigned int iv1,
unsigned int iv2 ) const
private

method to construct side boundary planes

Definition at line 131 of file PrismVolumeBounds.cxx.

135{
136 std::unique_ptr<Trk::PlaneSurface> plane = nullptr;
137
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);
141
142 double ori = ordering() > 0 ? 1. : -1.;
143
145 0.5 * (m_xyVtx[iv1].first + m_xyVtx[iv2].first),
146 0.5 * (m_xyVtx[iv1].second + m_xyVtx[iv2].second),
147 0.);
148 double phi = ori * ydif < 0 ? M_PI / 2 : -M_PI / 2;
149 if (ori > 0 && ydif > 0)
150 phi = M_PI / 2;
151 if (std::abs(xdif) > 1e-6) {
152 phi = atan(ydif / xdif);
153 if (xdif < 0)
154 phi += M_PI;
155 }
156
158 transform * Amg::Translation3D(pos) *
159 Amg::AngleAxis3D(phi, Amg::Vector3D(0., 0., 1.)) *
160 Amg::AngleAxis3D(-ori * 90 * Gaudi::Units::deg, Amg::Vector3D(1., 0., 0.)));
161 plane = std::make_unique<Trk::PlaneSurface>(tr, std::make_shared<Trk::RectangleBounds>(0.5 * xsize, m_halfZ));
162
163 // verify position of vertices - uncomment for debugging
164 // if
165 // (!plane->isOnSurface(Trk::GlobalPosition(m_xyVtx[iv1].first,m_xyVtx[iv1].second,m_halfZ),true,0.001,0.001)
166 // ||
167 // !plane->isOnSurface(Trk::GlobalPosition(m_xyVtx[iv2].first,m_xyVtx[iv2].second,-m_halfZ),true,0.001,0.001)
168 // )
169 // std::cout << "ERROR in PRISM side boundary:vertices out of plane"<<
170 // std::endl;
171
172 // orientation
173 int ivr = (iv1 == 0 || iv2 == 0) ? 1 : 0;
174 if (ivr == 1 && (iv1 == 1 || iv2 == 1))
175 ivr = 2;
176
177 double ox = m_xyVtx[ivr].first - pos[0];
178 double oy = m_xyVtx[ivr].second - pos[1];
179 Amg::Vector3D d(ox, oy, 0.);
180
181 // protect against wrong orientation
182 if (d.dot(plane->normal()) > 0.) {
183 tr = Amg::Transform3D(
184 transform * Amg::Translation3D(pos) *
185 Amg::AngleAxis3D(phi + M_PI, Amg::Vector3D(0., 0., 1.)) *
187 -ori * 90 * Gaudi::Units::deg, Amg::Vector3D(1., 0., 0.)));
188 plane =
189 std::make_unique<Trk::PlaneSurface>(tr, std::make_shared<Trk::RectangleBounds>(0.5 * xsize, m_halfZ));
190 }
191
192 return plane;
193}
int ordering() const
assess ordering of vertices
@ phi
Definition ParamDefs.h:75

◆ xyVertices()

const std::vector< std::pair< double, double > > & Trk::PrismVolumeBounds::xyVertices ( ) const
inline

This method returns the set of xy generating vertices.

Definition at line 120 of file PrismVolumeBounds.h.

121 {
122 return m_xyVtx;
123}

Member Data Documentation

◆ m_baseBounds

Trk::TriangleBounds* Trk::PrismVolumeBounds::m_baseBounds
private

base xy bounds

Definition at line 107 of file PrismVolumeBounds.h.

◆ m_halfZ

double Trk::PrismVolumeBounds::m_halfZ
private

halflength in z

Definition at line 106 of file PrismVolumeBounds.h.

◆ m_objectAccessor

Trk::EightObjectsAccessor Trk::PrismVolumeBounds::m_objectAccessor
private

There's only one single object Acessor for the moment has to be implemented if Cuboids are used more widely.

this is a real relict,can we get rid of it ?

Definition at line 113 of file PrismVolumeBounds.h.

◆ m_ordering

CxxUtils::CachedValue<int> Trk::PrismVolumeBounds::m_ordering
private

cache vertex ordering

Definition at line 108 of file PrismVolumeBounds.h.

◆ m_xyVtx

std::vector<std::pair<double, double> > Trk::PrismVolumeBounds::m_xyVtx
private

generating xy vertices

Definition at line 105 of file PrismVolumeBounds.h.


The documentation for this class was generated from the following files: