ATLAS Offline Software
Loading...
Searching...
No Matches
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
15// Gaudi
16#include "GaudiKernel/MsgStream.h"
17// STD
18#include <iostream>
19
20
21// constructor with Amg::Transform3D
22Trk::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
32 ? std::make_unique<Amg::Transform3D>(*(vol.m_transform))
33 : nullptr),
34 m_center(vol.m_center),
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),
44
45// assignment operator
48{
49 if (this != &vol) {
51 ? std::make_unique<Amg::Transform3D>(*vol.m_transform)
52 : nullptr;
53 m_center = vol.m_center;
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.
71bool
72Trk::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) {
89 volumeBounds().boundarySurfaceAccessor(gp, dir, forceInside));
90 }
92 transform().inverse() * gp, dir, forceInside));
93}
94
97MsgStream&
98Trk::operator<<(MsgStream& sl, const Trk::Volume& vol)
99{
100 sl << "Trk::Volume with VolumeBounds :" << vol.volumeBounds() << endmsg;
101 return sl;
102}
103
104std::ostream&
105Trk::operator<<(std::ostream& sl, const Trk::Volume& vol)
106{
107 sl << "Trk::Volume with VolumeBounds :" << vol.volumeBounds() << std::endl;
108 return sl;
109}
110
#define endmsg
Eigen::Affine3d Transform3D
Base class for all volumes inside the tracking realm, it defines the interface for inherited Volume c...
Definition Volume.h:36
Volume()=default
Defaults copies are special due ot unique ptr data member.
Volume & operator=(Volume &&)=default
const Amg::Transform3D & transform() const
Return methods for geometry transform.
Definition Volume.h:83
const VolumeBounds & volumeBounds() const
returns the volumeBounds()
Definition Volume.h:96
Amg::Vector3D m_center
center position of the surface
Definition Volume.h:79
std::unique_ptr< Amg::Transform3D > m_transform
Transform3D (optional)
Definition Volume.h:78
std::shared_ptr< VolumeBounds > m_volumeBounds
the volumeBounds
Definition Volume.h:80
ObjectAccessor boundarySurfaceAccessor(const Amg::Vector3D &gp, const Amg::Vector3D &mom, bool forceInside=false) const
Provide accessor for BoundarySurfaces.
Definition Volume.cxx:82
virtual Volume * clone() const
polymorpic deep copy
Definition Volume.cxx:60
bool inside(const Amg::Vector3D &gp, double tol=0.) const
Inside() method for checks.
Definition Volume.cxx:72
#define ATH_FLATTEN
Definition of ATLAS Math & Geometry primitives (Amg)
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
MsgStream & operator<<(MsgStream &sl, const AlignModule &alignModule)
overload of << operator for MsgStream for debug output
static const Amg::Vector3D s_origin(0, 0, 0)
origin position
STL namespace.