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 // Default constructor
22  : m_transform(nullptr)
23  , m_center(nullptr)
24  , m_volumeBounds()
25 {}
26 
27 // constructor with HepGeom::Transform3D
29  : m_transform(htrans)
30  , m_center(nullptr)
31  , m_volumeBounds(volbounds)
32 {}
33 
34 // copy constructor - will up to now not copy the sub structure!
36  : m_transform(
37  vol.m_transform ? std::make_unique<Amg::Transform3D>(*(vol.m_transform))
38  : nullptr)
39  , m_center(
40  (vol.m_center) ? std::make_unique<Amg::Vector3D>(*(vol.m_center))
41  : nullptr)
42  , m_volumeBounds(vol.m_volumeBounds)
43 {}
44 
45 // copy constructor with shift
47  : m_transform(
48  vol.m_transform
49  ? std::make_unique<Amg::Transform3D>(shift * (*(vol.m_transform)))
50  : std::make_unique<Amg::Transform3D>(shift))
51  , m_center(
52  (vol.m_center)
53  ? std::make_unique<Amg::Vector3D>(shift * (*(vol.m_center)))
54  : nullptr)
55  , m_volumeBounds(vol.m_volumeBounds)
56 {}
57 
58 // destructor
59 Trk::Volume::~Volume() = default;
60 
61 // assignment operator
64 {
65  if (this != &vol) {
66  m_transform = vol.m_transform
67  ? std::make_unique<Amg::Transform3D>(*vol.m_transform)
68  : nullptr;
69  m_center = vol.m_center
70  ? std::make_unique<const Amg::Vector3D>(*(vol.m_center))
71  : nullptr;
72  m_volumeBounds = vol.m_volumeBounds;
73  }
74  return *this;
75 }
76 
79 {
80  return new Trk::Volume(*this);
81 }
82 
83 // We compile this package with optimization, even in debug builds; otherwise,
84 // the heavy use of Eigen makes it too slow. However, from here we may call
85 // to out-of-line Eigen code that is linked from other DSOs; in that case,
86 // it would not be optimized. Avoid this by forcing all Eigen code
87 // to be inlined here if possible.
89 bool
90 Trk::Volume::inside(const Amg::Vector3D& gp, double tol) const
91 {
92  if (!m_transform) {
93  return (volumeBounds()).inside(gp, tol);
94  }
95  Amg::Vector3D posInVolFrame((transform().inverse()) * gp);
96  return (volumeBounds()).inside(posInVolFrame, tol);
97 }
98 
101  const Amg::Vector3D& gp,
102  const Amg::Vector3D& dir,
103  bool forceInside) const
104 {
105  if (!m_transform) {
106  return Trk::ObjectAccessor(
107  volumeBounds().boundarySurfaceAccessor(gp, dir, forceInside));
108  }
109  return Trk::ObjectAccessor(volumeBounds().boundarySurfaceAccessor(
110  transform().inverse() * gp, dir, forceInside));
111 }
112 
115 MsgStream&
116 Trk::operator<<(MsgStream& sl, const Trk::Volume& vol)
117 {
118  sl << "Trk::Volume with VolumeBounds :" << vol.volumeBounds() << endmsg;
119  return sl;
120 }
121 
122 std::ostream&
123 Trk::operator<<(std::ostream& sl, const Trk::Volume& vol)
124 {
125  sl << "Trk::Volume with VolumeBounds :" << vol.volumeBounds() << std::endl;
126  return sl;
127 }
128 
Trk::Volume::operator=
Volume & operator=(const Volume &vol)
Assignment operator.
Definition: Volume.cxx:63
Trk::Volume::Volume
Volume()
Default constructor.
Definition: Volume.cxx:21
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:90
Trk::Volume::m_center
CxxUtils::CachedUniquePtr< Amg::Vector3D > m_center
center position of the surface
Definition: Volume.h:77
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
VolumeBounds.h
Trk::VolumeBounds
Definition: VolumeBounds.h:45
Volume.h
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
Pseudo-constructor.
Definition: Volume.cxx:78
Trk::Volume::boundarySurfaceAccessor
ObjectAccessor boundarySurfaceAccessor(const Amg::Vector3D &gp, const Amg::Vector3D &mom, bool forceInside=false) const
Provide accessor for BoundarySurfaces.
Definition: Volume.cxx:100
beamspotman.dir
string dir
Definition: beamspotman.py:623
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
Trk::Volume::~Volume
virtual ~Volume()
Destructor.
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
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:97
Trk::Volume::m_transform
std::unique_ptr< Amg::Transform3D > m_transform
HepGeom::Transform3D.
Definition: Volume.h:76
Trk::Volume::m_volumeBounds
SharedObject< VolumeBounds > m_volumeBounds
the volumeBounds
Definition: Volume.h:78
Trk::Volume
Definition: Volume.h:35