ATLAS Offline Software
Loading...
Searching...
No Matches
ActsTrk::VolumePlacement Class Reference

Implementation to make a (tracking) volume alignable. More...

#include <VolumePlacement.h>

Inheritance diagram for ActsTrk::VolumePlacement:
Collaboration diagram for ActsTrk::VolumePlacement:

Classes

class  AlignedCache
 Auxiliary class to store the aligned transforms of the volume and of the associated portals. More...

Public Types

using AlignableNode_t = GeoIntrusivePtr<GeoAlignableTransform>
 Abrivation of an alignable GeoTransform.
using Parent_t
 Abrivation of the parent input types that are connected to the alignment system --> A direct alignable transform --> A detector element base following the alignment --> Another alignable volume element.

Public Member Functions

 VolumePlacement (const DetectorType detType, const AlignableNode_t parentNode, std::optional< Amg::Transform3D > addShift=std::nullopt)
 Constructor taking an Alignable transform from the geometry tree.
 VolumePlacement (const IDetectorElementBase &parentElement, std::optional< Amg::Transform3D > addShift=std::nullopt)
 Constructor taking the reference to a Detector element.
 VolumePlacement (const VolumePlacement &parentPlacement, std::optional< Amg::Transform3D > addShift=std::nullopt)
 Constructor taking the reference to another placement The life time of the object must be ensured to exceed the Placement's lifetime.
void addChild (std::unique_ptr< VolumePlacement > &&child)
 Add a child volume placement to this placement.
void connectCenterSurface (std::shared_ptr< Acts::RegularSurface > surface)
 Connect an external surface and place it into the volume center.
DetectorType detectorType () const override final
unsigned storeAlignedTransforms (const DetectorAlignStore &store) const override final
void makePortalsAlignable (const Acts::GeometryContext &gctx, const std::vector< std::shared_ptr< Acts::RegularSurface > > &portalsToAlign) override final
const Acts::Transform3 & localToGlobalTransform (const Acts::GeometryContext &gctx) const override final
const Amg::Transform3DlocalToGlobalTransform (const GeometryContext &gctx) const
const Acts::Transform3 & globalToLocalTransform (const Acts::GeometryContext &gctx) const override final
const Amg::Transform3DglobalToLocalTransform (const GeometryContext &gctx) const
const Acts::Transform3 & portalLocalToGlobal (const Acts::GeometryContext &gctx, const std::size_t portalIdx) const override final

Private Member Functions

Amg::Transform3D localToGlobalTransform (const DetectorAlignStore *store) const
 Constructs the local -> global transform of the volume.

Private Attributes

Parent_t m_parent {}
 Parent element which is following the alignment.
GeoIntrusivePtr< GeoTransform > m_refShift {}
 Additional shift on top of the parent position.
std::unique_ptr< AlignedCachem_locToGlobCache {}
 Cache to handle the local -> global transform of the volume.
std::unique_ptr< AlignedCachem_globToLocCache {}
 Cache to handle the global -> local transform of the volume.
std::vector< std::unique_ptr< AlignedCache > > m_portalCaches {}
 Cache to handle the local -> global transforms of the associated portals.
std::vector< std::unique_ptr< VolumePlacement > > m_children {}
 Children spawning from this VolumePlacement.
std::unique_ptr< Acts::detail::PortalPlacement > m_surfacePlacement {}
 Pipe the local -> global transform to a surface.

Detailed Description

Implementation to make a (tracking) volume alignable.

The placement is coupled to the alignment system either via a reference IDetectorElement, an alignable node in the geometry tree or another VolumePlacement.

Definition at line 22 of file VolumePlacement.h.

Member Typedef Documentation

◆ AlignableNode_t

using ActsTrk::VolumePlacement::AlignableNode_t = GeoIntrusivePtr<GeoAlignableTransform>

Abrivation of an alignable GeoTransform.

Definition at line 25 of file VolumePlacement.h.

◆ Parent_t

Initial value:
std::variant<AlignableNode_t,
base class interface providing the bare minimal interface extension.
GeoIntrusivePtr< GeoAlignableTransform > AlignableNode_t
Abrivation of an alignable GeoTransform.
VolumePlacement(const DetectorType detType, const AlignableNode_t parentNode, std::optional< Amg::Transform3D > addShift=std::nullopt)
Constructor taking an Alignable transform from the geometry tree.

Abrivation of the parent input types that are connected to the alignment system --> A direct alignable transform --> A detector element base following the alignment --> Another alignable volume element.

Definition at line 31 of file VolumePlacement.h.

Constructor & Destructor Documentation

◆ VolumePlacement() [1/3]

ActsTrk::VolumePlacement::VolumePlacement ( const DetectorType detType,
const AlignableNode_t parentNode,
std::optional< Amg::Transform3D > addShift = std::nullopt )
explicit

Constructor taking an Alignable transform from the geometry tree.

Parameters
detTypeDetectortype of the alignment store into which the transforms are written
parentNodePointer to the alignable transform
addShiftAdditional optional shift to be applied on top of the alignable reference

Definition at line 39 of file VolumePlacement.cxx.

41 :
42 m_parent{parentNode},
43 m_locToGlobCache{std::make_unique<AlignedCache>(AlignedCache::CacheFlags::volumeLocToGlob, detType, this)},
44 m_globToLocCache{std::make_unique<AlignedCache>(AlignedCache::CacheFlags::volumeGlobToLoc, detType, this)} {
45 if (!addShift) {
46 return;
47 }
48 m_refShift = GeoDeDuplicator{}.makeTransform(*addShift);
49 }
std::unique_ptr< AlignedCache > m_globToLocCache
Cache to handle the global -> local transform of the volume.
Parent_t m_parent
Parent element which is following the alignment.
GeoIntrusivePtr< GeoTransform > m_refShift
Additional shift on top of the parent position.
std::unique_ptr< AlignedCache > m_locToGlobCache
Cache to handle the local -> global transform of the volume.

◆ VolumePlacement() [2/3]

ActsTrk::VolumePlacement::VolumePlacement ( const IDetectorElementBase & parentElement,
std::optional< Amg::Transform3D > addShift = std::nullopt )
explicit

Constructor taking the reference to a Detector element.

The life time of the detector element must be ensured to exceed the Placement's lifetime

Parameters
parentElementThe detector element which alignment the volume is following
addShiftAdditional optional shift to be applied on top of the alignable reference

Definition at line 55 of file VolumePlacement.cxx.

56 :
57 m_parent{&parentElement},
58 m_globToLocCache{std::make_unique<AlignedCache>(AlignedCache::CacheFlags::volumeGlobToLoc,
59 parentElement.detectorType(), this)} {
60 if (!addShift) {
61 return;
62 }
63 m_locToGlobCache = std::make_unique<AlignedCache>(AlignedCache::CacheFlags::volumeLocToGlob,
64 parentElement.detectorType(), this);
65 m_refShift = GeoDeDuplicator{}.makeTransform(*addShift);
66
67 }

◆ VolumePlacement() [3/3]

ActsTrk::VolumePlacement::VolumePlacement ( const VolumePlacement & parentPlacement,
std::optional< Amg::Transform3D > addShift = std::nullopt )
explicit

Constructor taking the reference to another placement The life time of the object must be ensured to exceed the Placement's lifetime.

Parameters
parentPlacementThe parent placement moving according to the alignment
addShiftAdditional optional shift to be applied on top of the alignable reference

Definition at line 69 of file VolumePlacement.cxx.

70 :
71 m_parent{&parentPlacement}{
72 if (!addShift) {
73 return;
74 }
75 m_locToGlobCache = std::make_unique<AlignedCache>(AlignedCache::CacheFlags::volumeLocToGlob,
76 parentPlacement.detectorType(), this);
77 m_globToLocCache = std::make_unique<AlignedCache>(AlignedCache::CacheFlags::volumeGlobToLoc,
78 parentPlacement.detectorType(), this);
79 m_refShift = GeoDeDuplicator{}.makeTransform(*addShift);
80
81 }

Member Function Documentation

◆ addChild()

void ActsTrk::VolumePlacement::addChild ( std::unique_ptr< VolumePlacement > && child)

Add a child volume placement to this placement.

The object takes ownership and fills the alignment cache

Parameters
childThe child to be appended

Definition at line 50 of file VolumePlacement.cxx.

50 {
51 assert(child.get() != this);
52 assert(child != nullptr);
53 m_children.push_back(std::move(child));
54 }
std::vector< std::unique_ptr< VolumePlacement > > m_children
Children spawning from this VolumePlacement.

◆ connectCenterSurface()

void ActsTrk::VolumePlacement::connectCenterSurface ( std::shared_ptr< Acts::RegularSurface > surface)

Connect an external surface and place it into the volume center.

Parameters
surfacepointer to the surface that is connected to the placement

Definition at line 122 of file VolumePlacement.cxx.

122 {
123 if (m_surfacePlacement) {
124 THROW_EXCEPTION("Center surface already defined");
125 }
126 m_surfacePlacement = std::make_unique<Acts::detail::PortalPlacement>(std::numeric_limits<std::size_t>::max(),
127 Amg::Transform3D::Identity(), this,
128 surface);
129 }
std::unique_ptr< Acts::detail::PortalPlacement > m_surfacePlacement
Pipe the local -> global transform to a surface.
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10

◆ detectorType()

DetectorType ActsTrk::VolumePlacement::detectorType ( ) const
finaloverridevirtual

Implements ActsTrk::IVolumePlacement.

Definition at line 130 of file VolumePlacement.cxx.

130 {
131 if (m_locToGlobCache){
132 return m_locToGlobCache->detectorType();
133 }
134 return std::visit([](const auto& parent) {
135 using visit_t = std::decay_t<decltype(parent)>;
136 if constexpr(!std::is_same_v<visit_t, AlignableNode_t>) {
137 return parent->detectorType();
138 }
140 }, m_parent);
141 }
@ UnDefined
Small Thing Gap chambers (NSW)

◆ globalToLocalTransform() [1/2]

const Acts::Transform3 & ActsTrk::VolumePlacement::globalToLocalTransform ( const Acts::GeometryContext & gctx) const
finaloverride

Definition at line 106 of file VolumePlacement.cxx.

106 {
107 // The only configuration without glob -> loc cache is a parent volume placement
108 if (!m_globToLocCache) {
109 return std::get<const VolumePlacement*>(m_parent)->globalToLocalTransform(gctx);
110 }
111 return m_globToLocCache->getTransform(gctx);
112 }

◆ globalToLocalTransform() [2/2]

const Amg::Transform3D & ActsTrk::VolumePlacement::globalToLocalTransform ( const GeometryContext & gctx) const

Definition at line 113 of file VolumePlacement.cxx.

113 {
114 return globalToLocalTransform(gctx.context());
115 }
const Acts::Transform3 & globalToLocalTransform(const Acts::GeometryContext &gctx) const override final

◆ localToGlobalTransform() [1/3]

const Acts::Transform3 & ActsTrk::VolumePlacement::localToGlobalTransform ( const Acts::GeometryContext & gctx) const
finaloverride

Definition at line 91 of file VolumePlacement.cxx.

91 {
92 if (!m_locToGlobCache) {
93 if (std::holds_alternative<const IDetectorElementBase*>(m_parent)){
94 return std::get<const IDetectorElementBase*>(m_parent)->localToGlobalTransform(gctx);
95 } else if (std::holds_alternative<const VolumePlacement*>(m_parent)) {
96 return std::get<const VolumePlacement*>(m_parent)->localToGlobalTransform(gctx);
97 } else {
98 THROW_EXCEPTION("A VolumePlacement without cache && alignable trf should never happen");
99 }
100 }
101 return m_locToGlobCache->getTransform(gctx);
102 }

◆ localToGlobalTransform() [2/3]

Amg::Transform3D ActsTrk::VolumePlacement::localToGlobalTransform ( const DetectorAlignStore * store) const
private

Constructs the local -> global transform of the volume.

The request is forwarded to the parent and an optional shift is applied on top

Parameters
storeFrom which the alignment information is grepped and to which the final transform is written

Definition at line 143 of file VolumePlacement.cxx.

143 {
144 return std::visit([&](const auto& parent) -> Amg::Transform3D {
145 using visit_t = std::decay_t<decltype(parent)>;
146 if constexpr(std::is_same_v<visit_t, AlignableNode_t>) {
147 return parent->getTransform(store ? store->geoModelAlignment.get() : nullptr);
148 } else {
149 return parent->localToGlobalTransform(store);
150 }
151 return Amg::Transform3D::Identity();
152 }, m_parent) * (m_refShift ? m_refShift->getDefTransform()
153 : Amg::Transform3D::Identity());
154 }
Eigen::Affine3d Transform3D
TestStore store
Definition TestStore.cxx:23

◆ localToGlobalTransform() [3/3]

const Amg::Transform3D & ActsTrk::VolumePlacement::localToGlobalTransform ( const GeometryContext & gctx) const

Definition at line 103 of file VolumePlacement.cxx.

103 {
104 return localToGlobalTransform(gctx.context());
105 }
const Acts::Transform3 & localToGlobalTransform(const Acts::GeometryContext &gctx) const override final

◆ makePortalsAlignable()

void ActsTrk::VolumePlacement::makePortalsAlignable ( const Acts::GeometryContext & gctx,
const std::vector< std::shared_ptr< Acts::RegularSurface > > & portalsToAlign )
finaloverride

Definition at line 83 of file VolumePlacement.cxx.

84 {
85 Acts::VolumePlacementBase::makePortalsAlignable(gctx, portalsToAlign);
86 for (std::size_t p = 0ul; p < portalsToAlign.size(); ++p) {
87 m_portalCaches.emplace_back(std::make_unique<AlignedCache>(this, p));
88 }
89 }
std::vector< std::unique_ptr< AlignedCache > > m_portalCaches
Cache to handle the local -> global transforms of the associated portals.

◆ portalLocalToGlobal()

const Acts::Transform3 & ActsTrk::VolumePlacement::portalLocalToGlobal ( const Acts::GeometryContext & gctx,
const std::size_t portalIdx ) const
finaloverride

Definition at line 117 of file VolumePlacement.cxx.

118 {
119 return portalIdx < m_portalCaches.size() ?
120 m_portalCaches.at(portalIdx)->getTransform(gctx) : localToGlobalTransform(gctx);
121 }

◆ storeAlignedTransforms()

unsigned ActsTrk::VolumePlacement::storeAlignedTransforms ( const DetectorAlignStore & store) const
finaloverridevirtual

Implements ActsTrk::IVolumePlacement.

Definition at line 156 of file VolumePlacement.cxx.

156 {
157 unsigned n{0};
158 for (const std::unique_ptr<VolumePlacement>& child : m_children) {
159 n+=child->storeAlignedTransforms(store);
160 }
161 if (store.detType != detectorType()) {
162 return n;
163 }
164 for (const AlignedCache* volCache : {m_locToGlobCache.get(), m_globToLocCache.get()}) {
165 if (!volCache) {
166 continue;
167 }
168 volCache->getTransform(&store);
169 ++n;
170 }
171 for (const std::unique_ptr<AlignedCache>& cache: m_portalCaches) {
172 cache->getTransform(&store);
173 ++n;
174 }
175 return n;
176 }
Auxiliary class to store the aligned transforms of the volume and of the associated portals.
DetectorType detectorType() const override final

Member Data Documentation

◆ m_children

std::vector<std::unique_ptr<VolumePlacement> > ActsTrk::VolumePlacement::m_children {}
private

Children spawning from this VolumePlacement.

Definition at line 128 of file VolumePlacement.h.

128{};

◆ m_globToLocCache

std::unique_ptr<AlignedCache> ActsTrk::VolumePlacement::m_globToLocCache {}
private

Cache to handle the global -> local transform of the volume.

Definition at line 124 of file VolumePlacement.h.

124{};

◆ m_locToGlobCache

std::unique_ptr<AlignedCache> ActsTrk::VolumePlacement::m_locToGlobCache {}
private

Cache to handle the local -> global transform of the volume.

Definition at line 122 of file VolumePlacement.h.

122{};

◆ m_parent

Parent_t ActsTrk::VolumePlacement::m_parent {}
private

Parent element which is following the alignment.

Definition at line 118 of file VolumePlacement.h.

118{};

◆ m_portalCaches

std::vector<std::unique_ptr<AlignedCache> > ActsTrk::VolumePlacement::m_portalCaches {}
private

Cache to handle the local -> global transforms of the associated portals.

Definition at line 126 of file VolumePlacement.h.

126{};

◆ m_refShift

GeoIntrusivePtr<GeoTransform> ActsTrk::VolumePlacement::m_refShift {}
private

Additional shift on top of the parent position.

Definition at line 120 of file VolumePlacement.h.

120{};

◆ m_surfacePlacement

std::unique_ptr<Acts::detail::PortalPlacement> ActsTrk::VolumePlacement::m_surfacePlacement {}
private

Pipe the local -> global transform to a surface.

Definition at line 130 of file VolumePlacement.h.

130{};

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