ATLAS Offline Software
Volume.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // Volume.cxx, (c) ATLAS Detector software
8 
9 // Trk
10 #include "TrkVolumes/Volume.h"
13 //CxxUtils
14 #include "CxxUtils/inline_hints.h"
15 // Gaudi
16 #include "GaudiKernel/MsgStream.h"
17 // STD
18 #include <iostream>
19 
20 
21 // constructor with Amg::Transform3D
22 Trk::Volume::Volume(std::unique_ptr<Amg::Transform3D> htrans,
23  std::shared_ptr<Trk::VolumeBounds> volbounds)
24  : m_transform(std::move(htrans))
25  , m_center(m_transform ? m_transform->translation() : Trk::s_origin)
26  , m_volumeBounds(std::move(volbounds))
27 {}
28 
29 // copy constructor
31  : m_transform(vol.m_transform
32  ? std::make_unique<Amg::Transform3D>(*(vol.m_transform))
33  : nullptr),
34  m_center(vol.m_center),
35  m_volumeBounds(vol.m_volumeBounds) {}
36 
37 // copy constructor with shift
39  : m_transform(vol.m_transform ? std::make_unique<Amg::Transform3D>(
40  shift * (*(vol.m_transform)))
41  : std::make_unique<Amg::Transform3D>(shift)),
42  m_center(shift * vol.m_center),
43  m_volumeBounds(vol.m_volumeBounds) {}
44 
45 // assignment operator
48 {
49  if (this != &vol) {
50  m_transform = vol.m_transform
51  ? std::make_unique<Amg::Transform3D>(*vol.m_transform)
52  : nullptr;
53  m_center = vol.m_center;
54  m_volumeBounds = vol.m_volumeBounds;
55  }
56  return *this;
57 }
58 
61 {
62  return new Trk::Volume(*this);
63 }
64 
65 // We compile this package with optimization, even in debug builds; otherwise,
66 // the heavy use of Eigen makes it too slow. However, from here we may call
67 // to out-of-line Eigen code that is linked from other DSOs; in that case,
68 // it would not be optimized. Avoid this by forcing all Eigen code
69 // to be inlined here if possible.
71 bool
72 Trk::Volume::inside(const Amg::Vector3D& gp, double tol) const
73 {
74  if (!m_transform) {
75  return (volumeBounds()).inside(gp, tol);
76  }
77  Amg::Vector3D posInVolFrame((transform().inverse()) * gp);
78  return (volumeBounds()).inside(posInVolFrame, tol);
79 }
80 
83  const Amg::Vector3D& gp,
84  const Amg::Vector3D& dir,
85  bool forceInside) const
86 {
87  if (!m_transform) {
88  return Trk::ObjectAccessor(
89  volumeBounds().boundarySurfaceAccessor(gp, dir, forceInside));
90  }
91  return Trk::ObjectAccessor(volumeBounds().boundarySurfaceAccessor(
92  transform().inverse() * gp, dir, forceInside));
93 }
94 
97 MsgStream&
98 Trk::operator<<(MsgStream& sl, const Trk::Volume& vol)
99 {
100  sl << "Trk::Volume with VolumeBounds :" << vol.volumeBounds() << endmsg;
101  return sl;
102 }
103 
104 std::ostream&
105 Trk::operator<<(std::ostream& sl, const Trk::Volume& vol)
106 {
107  sl << "Trk::Volume with VolumeBounds :" << vol.volumeBounds() << std::endl;
108  return sl;
109 }
110 
inline_hints.h
ObjectAccessor.h
Trk::Volume::inside
bool inside(const Amg::Vector3D &gp, double tol=0.) const
Inside() method for checks.
Definition: Volume.cxx:72
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
Trk::Volume::m_volumeBounds
std::shared_ptr< VolumeBounds > m_volumeBounds
the volumeBounds
Definition: Volume.h:80
VolumeBounds.h
Volume.h
Trk::Volume::Volume
Volume()=default
Defaults copies are special due ot unique ptr data member
ATH_FLATTEN
#define ATH_FLATTEN
Definition: inline_hints.h:52
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
MuonR4::inverse
CalibratedSpacePoint::Covariance_t inverse(const CalibratedSpacePoint::Covariance_t &mat)
Inverts the parsed matrix.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/UtilFunctions.cxx:65
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::Volume::clone
virtual Volume * clone() const
polymorpic deep copy
Definition: Volume.cxx:60
Trk::Volume::boundarySurfaceAccessor
ObjectAccessor boundarySurfaceAccessor(const Amg::Vector3D &gp, const Amg::Vector3D &mom, bool forceInside=false) const
Provide accessor for BoundarySurfaces.
Definition: Volume.cxx:82
beamspotman.dir
string dir
Definition: beamspotman.py:621
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::Volume::operator=
Volume & operator=(Volume &&)=default
Trk::ObjectAccessor
Definition: ObjectAccessor.h:15
Trk::operator<<
MsgStream & operator<<(MsgStream &sl, const AlignModule &alignModule)
overload of << operator for MsgStream for debug output
Definition: AlignModule.cxx:204
Trk::Volume::volumeBounds
const VolumeBounds & volumeBounds() const
returns the volumeBounds()
Definition: Volume.h:96
Trk::Volume::m_transform
std::unique_ptr< Amg::Transform3D > m_transform
Transform3D (optional)
Definition: Volume.h:78
Trk::Volume
Definition: Volume.h:36
Trk::Volume::m_center
Amg::Vector3D m_center
center position of the surface
Definition: Volume.h:79