ATLAS Offline Software
DoubleTrapezoidVolumeBounds.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // DoubleTrapezoidVolumeBounds.cxx, (c) ATLAS Detector software
8 
9 // Trk
11 // TrkSurfaces
15 // Gaudi
16 #include "GaudiKernel/MsgStream.h"
17 #include "GaudiKernel/SystemOfUnits.h"
18 // STD
19 #include <cmath>
20 #include <iomanip>
21 #include <iostream>
22 
24  : VolumeBounds()
25  , m_minHalfX(0.)
26  , m_medHalfX(0.)
27  , m_maxHalfX(0.)
28  , m_halfY1(0.)
29  , m_halfY2(0.)
30  , m_halfZ(0.)
31  , m_alpha1(0.)
32  , m_alpha2(0.)
33  , m_objectAccessor()
34 {}
35 
37  double minhalex,
38  double medhalex,
39  double maxhalex,
40  double haley1,
41  double haley2,
42  double halez)
43  : VolumeBounds()
44  , m_minHalfX(minhalex)
45  , m_medHalfX(medhalex)
46  , m_maxHalfX(maxhalex)
47  , m_halfY1(haley1)
48  , m_halfY2(haley2)
49  , m_halfZ(halez)
50  , m_alpha1(0.)
51  , m_alpha2(0.)
52  , m_objectAccessor()
53 {
54  m_alpha1 = atan2(m_medHalfX - m_minHalfX, 2. * m_halfY1);
55  m_alpha2 = atan2(m_medHalfX - m_maxHalfX, 2. * m_halfY2);
56 }
57 
60  : VolumeBounds()
61  , m_minHalfX(trabo.m_minHalfX)
62  , m_medHalfX(trabo.m_medHalfX)
63  , m_maxHalfX(trabo.m_maxHalfX)
64  , m_halfY1(trabo.m_halfY1)
65  , m_halfY2(trabo.m_halfY2)
66  , m_halfZ(trabo.m_halfZ)
67  , m_alpha1(trabo.m_alpha1)
68  , m_alpha2(trabo.m_alpha2)
69  , m_objectAccessor(trabo.m_objectAccessor)
70 {}
71 
73 
77 {
78  if (this != &trabo) {
79  m_minHalfX = trabo.m_minHalfX;
80  m_medHalfX = trabo.m_medHalfX;
81  m_maxHalfX = trabo.m_maxHalfX;
82  m_halfY1 = trabo.m_halfY1;
83  m_halfY2 = trabo.m_halfY2;
84  m_halfZ = trabo.m_halfZ;
85  m_alpha1 = trabo.m_alpha1;
86  m_alpha2 = trabo.m_alpha2;
87  m_objectAccessor = trabo.m_objectAccessor;
88  }
89  return *this;
90 }
91 
92 const std::vector<const Trk::Surface*>*
94  (const Amg::Transform3D& transform)
95 {
96  std::vector<const Trk::Surface*>* retsf =
97  new std::vector<const Trk::Surface*>;
98 
99  // face surfaces xy
100  Amg::RotationMatrix3D diamondRotation(transform.rotation());
101  Amg::Vector3D diamondX(diamondRotation.col(0));
102  Amg::Vector3D diamondY(diamondRotation.col(1));
103  Amg::Vector3D diamondZ(diamondRotation.col(2));
104  Amg::Vector3D diamondCenter(transform.translation());
105 
106  // (1) - at negative local z
107  retsf->push_back(new Trk::PlaneSurface(
109  transform *
110  Amg::AngleAxis3D(180 * Gaudi::Units::deg, Amg::Vector3D(0., 1., 0.)) *
111  Amg::Translation3D(Amg::Vector3D(0., 0., this->halflengthZ()))),
112  this->faceXYDiamondBounds()));
113  // (2) - at positive local z
114  retsf->push_back(new Trk::PlaneSurface(
116  transform *
117  Amg::Translation3D(Amg::Vector3D(0., 0., this->halflengthZ()))),
118  this->faceXYDiamondBounds()));
119  // face surfaces yz
120  // transmute cyclical
121  // (3) - at point A, attached to alpha opening angle
122  Amg::Vector3D A(
123  diamondCenter - this->minHalflengthX() * diamondX -
124  2 * this->halflengthY1() * diamondY);
125  Amg::AngleAxis3D alpha1ZRotation(this->alpha1(), Amg::Vector3D(0., 0., 1.));
126  Amg::RotationMatrix3D alpha1Rotation(
127  diamondRotation * alpha1ZRotation *
128  Amg::AngleAxis3D(-90 * Gaudi::Units::deg, Amg::Vector3D(0., 1., 0.)) *
130  RectangleBounds* faceAlpha1Bounds = this->faceAlpha1RectangleBounds();
131  Amg::Vector3D faceAlpha1Position(
132  A + alpha1Rotation.col(0) * faceAlpha1Bounds->halflengthX());
133  retsf->push_back(new Trk::PlaneSurface(
135  alpha1Rotation * Amg::Translation3D(faceAlpha1Position)),
136  faceAlpha1Bounds));
137  // (4) - at point B, attached to beta opening angle
138  Amg::Vector3D B(
139  diamondCenter + this->minHalflengthX() * diamondX -
140  2 * this->halflengthY1() * diamondY);
141  Amg::AngleAxis3D beta1ZRotation(-this->alpha1(), Amg::Vector3D(0., 0., 1.));
142  Amg::RotationMatrix3D beta1Rotation(
143  diamondRotation * beta1ZRotation *
146  RectangleBounds* faceBeta1Bounds = this->faceBeta1RectangleBounds();
147  Amg::Vector3D faceBeta1Position(
148  B + beta1Rotation.col(0) * faceBeta1Bounds->halflengthX());
149  retsf->push_back(new Trk::PlaneSurface(
150  Amg::Transform3D(beta1Rotation * Amg::Translation3D(faceBeta1Position)),
151  faceBeta1Bounds));
152  // face surfaces yz
153  // transmute cyclical
154  // (5) - at point A', attached to alpha opening angle
155  Amg::Vector3D AA(
156  diamondCenter - this->maxHalflengthX() * diamondX +
157  2 * this->halflengthY2() * diamondY);
158  Amg::AngleAxis3D alpha2ZRotation(-this->alpha2(), Amg::Vector3D(0., 0., 1.));
159  Amg::RotationMatrix3D alpha2Rotation(
160  diamondRotation * alpha2ZRotation *
161  Amg::AngleAxis3D(-90 * Gaudi::Units::deg, Amg::Vector3D(0., 1., 0.)) *
162  Amg::AngleAxis3D(-90 * Gaudi::Units::deg, Amg::Vector3D(0., 0., 1.)));
163  RectangleBounds* faceAlpha2Bounds = this->faceAlpha2RectangleBounds();
164  Amg::Vector3D faceAlpha2Position(
165  AA + alpha2Rotation.col(0) * faceAlpha2Bounds->halflengthX());
166  retsf->push_back(new Trk::PlaneSurface(
168  alpha2Rotation * Amg::Translation3D(faceAlpha2Position)),
169  faceAlpha2Bounds));
170  // (6) - at point B', attached to beta opening angle
171  Amg::Vector3D BB(
172  diamondCenter + this->maxHalflengthX() * diamondX +
173  2 * this->halflengthY2() * diamondY);
174  Amg::AngleAxis3D beta2ZRotation(this->alpha2(), Amg::Vector3D(0., 0., 1.));
175  Amg::RotationMatrix3D beta2Rotation(
176  diamondRotation * beta2ZRotation *
178  Amg::AngleAxis3D(-90 * Gaudi::Units::deg, Amg::Vector3D(0., 0., 1.)));
179  RectangleBounds* faceBeta2Bounds = this->faceBeta2RectangleBounds();
180  Amg::Vector3D faceBeta2Position(
181  BB + beta2Rotation.col(0) * faceBeta2Bounds->halflengthX());
182  retsf->push_back(new Trk::PlaneSurface(
183  Amg::Transform3D(beta2Rotation * Amg::Translation3D(faceBeta2Position)),
184  faceBeta2Bounds));
185  // face surfaces zx
186  // (7) - at negative local y
187  retsf->push_back(new Trk::PlaneSurface(
189  transform *
190  Amg::AngleAxis3D(180. * Gaudi::Units::deg, Amg::Vector3D(1., 0., 0.)) *
191  Amg::Translation3D(Amg::Vector3D(0., 2 * this->halflengthY1(), 0.)) *
192  Amg::AngleAxis3D(-90 * Gaudi::Units::deg, Amg::Vector3D(0., 1., 0.)) *
193  Amg::AngleAxis3D(-90. * Gaudi::Units::deg, Amg::Vector3D(1., 0., 0.))),
194  this->faceZXRectangleBoundsBottom()));
195  // (8) - at positive local y
196  retsf->push_back(new Trk::PlaneSurface(
198  transform *
199  Amg::Translation3D(Amg::Vector3D(0., this->halflengthY2(), 0.)) *
200  Amg::AngleAxis3D(-90 * Gaudi::Units::deg, Amg::Vector3D(0., 1., 0.)) *
201  Amg::AngleAxis3D(-90. * Gaudi::Units::deg, Amg::Vector3D(1., 0., 0.))),
202  this->faceZXRectangleBoundsTop()));
203 
204  return retsf;
205 }
206 
207 // faces in xy
210 {
211  return new Trk::DiamondBounds(
212  m_minHalfX, m_medHalfX, m_maxHalfX, m_halfY1, m_halfY2);
213 }
214 
217 {
218  return new Trk::RectangleBounds(m_halfY1 / cos(m_alpha1), m_halfZ);
219 }
220 
223 {
224  return new Trk::RectangleBounds(m_halfY2 / cos(m_alpha2), m_halfZ);
225 }
226 
229 {
230  return new Trk::RectangleBounds(m_halfY1 / cos(m_alpha1), m_halfZ);
231 }
232 
235 {
236  return new Trk::RectangleBounds(m_halfY2 / cos(m_alpha2), m_halfZ);
237 }
238 
241 {
242  return new Trk::RectangleBounds(m_halfZ, m_minHalfX);
243 }
244 
247 {
248  return new Trk::RectangleBounds(m_halfZ, m_maxHalfX);
249 }
250 
251 // Trk::RectangleBounds*
252 // Trk::DoubleTrapezoidVolumeBounds::faceZXRectangleBoundsTop() const
253 //{
254 // double delta = (m_alpha < m_beta) ? m_alpha - M_PI/2. : m_beta - M_PI/2.;
255 // return new Trk::RectangleBounds(m_halfZ,
256 // 0.5*(m_minHalfX+m_minHalfX+2.*m_halfY/cos(delta)));
257 //}
258 
259 bool
261  const
262 {
263  if (std::abs(pos.z()) > m_halfZ + tol)
264  return false;
265  if (pos.y() < -2 * m_halfY1 - tol)
266  return false;
267  if (pos.y() > 2 * m_halfY2 - tol)
268  return false;
269  Trk::DiamondBounds* faceXYBounds = this->faceXYDiamondBounds();
270  Amg::Vector2D locp(pos.x(), pos.y());
271  bool inside(faceXYBounds->inside(locp, tol));
272  delete faceXYBounds;
273  return inside;
274 }
275 
276 // ostream operator overload
277 MsgStream&
279 {
280  std::stringstream temp_sl;
281  temp_sl << std::setiosflags(std::ios::fixed);
282  temp_sl << std::setprecision(7);
283  temp_sl << "Trk::DoubleTrapezoidVolumeBounds: (minhalfX, medhalfX, maxhalfX, "
284  "halfY1, halfY2, halfZ) = ";
285  temp_sl << "(" << m_minHalfX << ", " << m_medHalfX << ", " << m_maxHalfX;
286  temp_sl << ", " << m_halfY1 << ", " << m_halfY2 << ", " << m_halfZ << ")";
287  sl << temp_sl.str();
288  return sl;
289 }
290 
291 std::ostream&
293 {
294  std::stringstream temp_sl;
295  temp_sl << std::setiosflags(std::ios::fixed);
296  temp_sl << std::setprecision(7);
297  temp_sl << "Trk::DoubleTrapezoidVolumeBounds: ) =(minhalfX, medhalfX, "
298  "maxhalfX, halfY1, halfY2, halfZ) ";
299  temp_sl << "(" << m_minHalfX << ", " << m_medHalfX << ", " << m_maxHalfX;
300  temp_sl << ", " << m_halfY1 << ", " << m_halfY2 << ", " << m_halfZ << ")";
301  sl << temp_sl.str();
302  return sl;
303 }
304 
Trk::DoubleTrapezoidVolumeBounds::m_alpha2
double m_alpha2
opening angle alpha (in point A')
Definition: DoubleTrapezoidVolumeBounds.h:166
Trk::RectangleBounds
Definition: RectangleBounds.h:38
Trk::DoubleTrapezoidVolumeBounds::m_halfY1
double m_halfY1
halflength in y
Definition: DoubleTrapezoidVolumeBounds.h:161
Trk::DoubleTrapezoidVolumeBounds::m_objectAccessor
Trk::EightObjectsAccessor m_objectAccessor
There's only one single object Acessor for the moment has to be implemented if Cuboids are used more ...
Definition: DoubleTrapezoidVolumeBounds.h:173
Trk::DoubleTrapezoidVolumeBounds::m_halfZ
double m_halfZ
halflength in z
Definition: DoubleTrapezoidVolumeBounds.h:163
Trk::DoubleTrapezoidVolumeBounds::m_minHalfX
double m_minHalfX
minimal Y halflength in x
Definition: DoubleTrapezoidVolumeBounds.h:158
Trk::DoubleTrapezoidVolumeBounds::faceXYDiamondBounds
DiamondBounds * faceXYDiamondBounds() const
This method returns the associated DoubleTrapezoidBounds of the face PlaneSurface parallel to local x...
Definition: DoubleTrapezoidVolumeBounds.cxx:209
RectangleBounds.h
Trk::DoubleTrapezoidVolumeBounds::m_alpha1
double m_alpha1
opening angle alpha (in point A)
Definition: DoubleTrapezoidVolumeBounds.h:165
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
Trk::DoubleTrapezoidVolumeBounds::inside
bool inside(const Amg::Vector3D &, double tol=0.) const override final
This method checks if position in the 3D volume frame is inside the cylinder.
Definition: DoubleTrapezoidVolumeBounds.cxx:260
Trk::DoubleTrapezoidVolumeBounds::operator=
DoubleTrapezoidVolumeBounds & operator=(const DoubleTrapezoidVolumeBounds &bobo)
Assignment operator.
Definition: DoubleTrapezoidVolumeBounds.cxx:75
Trk::DoubleTrapezoidVolumeBounds::~DoubleTrapezoidVolumeBounds
virtual ~DoubleTrapezoidVolumeBounds()
Destructor.
deg
#define deg
Definition: SbPolyhedron.cxx:17
Trk::DoubleTrapezoidVolumeBounds::DoubleTrapezoidVolumeBounds
DoubleTrapezoidVolumeBounds()
Default Constructor.
Definition: DoubleTrapezoidVolumeBounds.cxx:23
Trk::DoubleTrapezoidVolumeBounds::m_halfY2
double m_halfY2
halflength in y
Definition: DoubleTrapezoidVolumeBounds.h:162
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
Trk::DiamondBounds::inside
virtual bool inside(const Amg::Vector2D &locpo, double tol1=0., double tol2=0.) const override final
The orientation of the Diamond is according to the figure.
Definition: DiamondBounds.cxx:61
Trk::DoubleTrapezoidVolumeBounds::faceAlpha2RectangleBounds
RectangleBounds * faceAlpha2RectangleBounds() const
Definition: DoubleTrapezoidVolumeBounds.cxx:222
DiamondBounds.h
Trk::VolumeBounds
Definition: VolumeBounds.h:45
Trk::DoubleTrapezoidVolumeBounds::dump
MsgStream & dump(MsgStream &sl) const override final
Output Method for MsgStream.
Definition: DoubleTrapezoidVolumeBounds.cxx:278
Trk::DiamondBounds
Definition: DiamondBounds.h:37
Trk::RectangleBounds::halflengthX
double halflengthX() const
for consistant naming
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
Trk::DoubleTrapezoidVolumeBounds::faceBeta2RectangleBounds
RectangleBounds * faceBeta2RectangleBounds() const
Definition: DoubleTrapezoidVolumeBounds.cxx:234
DoubleTrapezoidVolumeBounds.h
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::DoubleTrapezoidVolumeBounds::decomposeToSurfaces
const std::vector< const Trk::Surface * > * decomposeToSurfaces(const Amg::Transform3D &transform) override final
Method to decompose the Bounds into Surfaces.
Definition: DoubleTrapezoidVolumeBounds.cxx:94
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Trk::inside
@ inside
Definition: PropDirection.h:29
Trk::DoubleTrapezoidVolumeBounds::faceZXRectangleBoundsTop
RectangleBounds * faceZXRectangleBoundsTop() const
This method returns the associated RecantleBounds of the face PlaneSurface parallel to local zx plane...
Definition: DoubleTrapezoidVolumeBounds.cxx:246
Trk::DoubleTrapezoidVolumeBounds::faceAlpha1RectangleBounds
RectangleBounds * faceAlpha1RectangleBounds() const
This method returns the associated RecantleBounds of the face PlaneSurface attached to alpha (negativ...
Definition: DoubleTrapezoidVolumeBounds.cxx:216
Trk::PlaneSurface
Definition: PlaneSurface.h:64
Amg::RotationMatrix3D
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Definition: GeoPrimitives.h:49
PlaneSurface.h
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
Trk::DoubleTrapezoidVolumeBounds
Definition: DoubleTrapezoidVolumeBounds.h:66
Trk::DoubleTrapezoidVolumeBounds::faceZXRectangleBoundsBottom
RectangleBounds * faceZXRectangleBoundsBottom() const
This method returns the associated RecantleBounds of the face PlaneSurface parallel to local zx plane...
Definition: DoubleTrapezoidVolumeBounds.cxx:240
Trk::DoubleTrapezoidVolumeBounds::m_maxHalfX
double m_maxHalfX
maximal Y halflength in x
Definition: DoubleTrapezoidVolumeBounds.h:160
Amg::AngleAxis3D
Eigen::AngleAxisd AngleAxis3D
Definition: GeoPrimitives.h:45
Trk::DoubleTrapezoidVolumeBounds::faceBeta1RectangleBounds
RectangleBounds * faceBeta1RectangleBounds() const
This method returns the associated RecantleBounds of the face PlaneSurface attached to beta (positive...
Definition: DoubleTrapezoidVolumeBounds.cxx:228
Trk::DoubleTrapezoidVolumeBounds::m_medHalfX
double m_medHalfX
maximal halflength in x
Definition: DoubleTrapezoidVolumeBounds.h:159