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

The TransformStore provides a central place to outsource the alignable transforms of the sensitive detector elements and the alignable volumes. More...

#include <TransformStore.h>

Collaboration diagram for ActsTrk::detail::TransformStore:

Public Types

enum class  Mode : std::uint8_t { LazyFill , Block }
 Enum describing the operation mode of the cache. More...

Public Member Functions

 TransformStore (const DetectorType detType, const Mode m)
 Constructor.
 TransformStore (TransformStore &&other) noexcept=default
 Define the move constructor.
TransformStoreoperator= (TransformStore &&other) noexcept=default
 Define the move assignment operator.
 TransformStore (const TransformStore &other) noexcept
 Define the copy constructor.
TransformStoreoperator= (const TransformStore &other) noexcept
 Define the copy assignment operator.
const Amg::Transform3DgetTransform (const unsigned ticketNo) const
 Returns the pointer to the transfomation cached in the store (Might be a nullptr if LazyFill is used).
const Amg::Transform3DsetTransform (const unsigned int ticketNo, Amg::Transform3D &&trf) const
 Stores a transform at the index of the passed ticket number.
const Amg::Transform3DsetTransform (const unsigned int ticketNo, Amg::Transform3D &&trf)
 Stores a transform at the index of the passed ticket number.
Mode mode () const
 Returns the mode with which the store has been instantiated.
DetectorType detectorType () const
 Returns the detector type.
std::size_t size () const
 Return the size (maximum capacity) of the current store.
std::size_t filled () const
 Returns the number of filled transforms.

Static Public Member Functions

static std::string toString (const Mode m)
 Define the to string operator.

Private Types

using LazyStorage_t = std::vector<CxxUtils::CachedUniquePtr<Amg::Transform3D>>
 Abrivation of the backend in the lazy filling mode.
using TrfVec_t = std::vector<Amg::Transform3D>
 Abrivate the transform vector.
using CheckVec_t = std::vector<char>
 Abrivate the char vector.
using BlockStorage_t = std::pair<TrfVec_t, CheckVec_t>
 Abrivation of the continous vector storage.
using Storage_t = std::variant<LazyStorage_t, BlockStorage_t>
 Use the std::variant to dynamically switch between the two types.

Private Member Functions

std::ostream & print (std::ostream &ostr) const

Static Private Member Functions

static Storage_t initStorage (const DetectorType dType, const Mode mode) noexcept
 Helper method to instantiate the storage for a given detector type.

Private Attributes

Storage_t m_storage {}
DetectorType m_detType {ActsTrk::DetectorType::UnDefined}
 The associated detector type.

Friends

std::ostream & operator<< (std::ostream &ostr, const Mode m)
std::ostream & operator<< (std::ostream &ostr, const TransformStore &store)
 Define the to string ostream operator.

Detailed Description

The TransformStore provides a central place to outsource the alignable transforms of the sensitive detector elements and the alignable volumes.

For each subdetector, a cache of size N is provided (C.f. the TrfStoreTicketCounter how the cache size is managed). The transform store can be operated either in a LazyFilling mode where the memory is only assigned if the cache slot is actually needed. In this mode, the setTransform mehtod can be called on a const instance. Alternatively, the Store can be operated in Block mode, where tne the memory for N Transforms is allocated at instantiation and can only be filled if a non-const reference is passed

Definition at line 27 of file TransformStore.h.

Member Typedef Documentation

◆ BlockStorage_t

Abrivation of the continous vector storage.

Definition at line 89 of file TransformStore.h.

◆ CheckVec_t

using ActsTrk::detail::TransformStore::CheckVec_t = std::vector<char>
private

Abrivate the char vector.

Definition at line 87 of file TransformStore.h.

◆ LazyStorage_t

Abrivation of the backend in the lazy filling mode.

Definition at line 83 of file TransformStore.h.

◆ Storage_t

Use the std::variant to dynamically switch between the two types.

Definition at line 91 of file TransformStore.h.

◆ TrfVec_t

Abrivate the transform vector.

Definition at line 85 of file TransformStore.h.

Member Enumeration Documentation

◆ Mode

enum class ActsTrk::detail::TransformStore::Mode : std::uint8_t
strong

Enum describing the operation mode of the cache.

Enumerator
LazyFill 
Block 

Transforms can be set later during the event processing.

Transforms can only be set if the Store is created and non-const.

Definition at line 30 of file TransformStore.h.

30 : std::uint8_t {
31 LazyFill,
32 Block
34 };

Constructor & Destructor Documentation

◆ TransformStore() [1/3]

ActsTrk::detail::TransformStore::TransformStore ( const DetectorType detType,
const Mode m )

Constructor.

Parameters
detTypeSub detector type to retrieve the information about how much memory needs to be allocated
mStorage mode

Definition at line 47 of file TransformStore.cxx.

48 :
49 m_storage{initStorage(detType, m)},
50 m_detType{detType} {}
static Storage_t initStorage(const DetectorType dType, const Mode mode) noexcept
Helper method to instantiate the storage for a given detector type.
DetectorType m_detType
The associated detector type.

◆ TransformStore() [2/3]

ActsTrk::detail::TransformStore::TransformStore ( TransformStore && other)
defaultnoexcept

Define the move constructor.

◆ TransformStore() [3/3]

ActsTrk::detail::TransformStore::TransformStore ( const TransformStore & other)
noexcept

Define the copy constructor.

Definition at line 51 of file TransformStore.cxx.

51 :
52 m_storage{initStorage(other.detectorType(), other.mode())},
53 m_detType{other.detectorType()} {
54 if (mode() == Mode::Block){
55 for (std::size_t t = 0; t < size(); ++t) {
56 if (const Amg::Transform3D* copyMe = other.getTransform(t); copyMe != nullptr) {
57 setTransform(t, Amg::Transform3D{*copyMe});
58 }
59 }
60 }
61 }
const Amg::Transform3D & setTransform(const unsigned int ticketNo, Amg::Transform3D &&trf) const
Stores a transform at the index of the passed ticket number.
@ Block
Transforms can be set later during the event processing.
Mode mode() const
Returns the mode with which the store has been instantiated.
std::size_t size() const
Return the size (maximum capacity) of the current store.
Eigen::Affine3d Transform3D

Member Function Documentation

◆ detectorType()

DetectorType ActsTrk::detail::TransformStore::detectorType ( ) const

Returns the detector type.

Definition at line 78 of file TransformStore.cxx.

78{ return m_detType; }

◆ filled()

std::size_t ActsTrk::detail::TransformStore::filled ( ) const

Returns the number of filled transforms.

Definition at line 131 of file TransformStore.cxx.

131 {
132 return std::visit([](const auto& store) {
133 using Store_t = std::decay_t<decltype(store)>;
134 if constexpr(std::is_same_v<Store_t, LazyStorage_t>) {
135 return std::count_if(store.begin(), store.end(), [](const auto& trf){
136 return trf.get() != nullptr;
137 });
138 } else if constexpr(std::is_same_v<Store_t, BlockStorage_t>) {
139 return std::count_if(store.second.begin(), store.second.end(), [](const char filled){
140 return filled;
141 });
142 }
143 }, m_storage);
144 }
std::size_t filled() const
Returns the number of filled transforms.
StoreGateSvc * Store_t
TestStore store
Definition TestStore.cxx:23

◆ getTransform()

const Amg::Transform3D * ActsTrk::detail::TransformStore::getTransform ( const unsigned ticketNo) const
inline

Returns the pointer to the transfomation cached in the store (Might be a nullptr if LazyFill is used).

Parameters
ticketNoUnique ticket number drawn by the client indicating the index inside the storegae vector

Definition at line 139 of file TransformStore.h.

139 {
140 return std::visit([&](auto& store) -> const Amg::Transform3D* {
141 using Store_t = std::decay_t<decltype(store)>;
142 if constexpr(std::is_same_v<Store_t, LazyStorage_t>) {
143 assert(ticketNo < store.size());
144 return store[ticketNo].get();
145 } else if constexpr(std::is_same_v<Store_t, BlockStorage_t>) {
146 assert(ticketNo < store.first.size());
147 return store.second[ticketNo] ? &store.first[ticketNo] : nullptr;
148 } else {
149 return nullptr;
150 }
151 }, m_storage);
152 }

◆ initStorage()

TransformStore::Storage_t ActsTrk::detail::TransformStore::initStorage ( const DetectorType dType,
const Mode mode )
staticprivatenoexcept

Helper method to instantiate the storage for a given detector type.

Parameters
dTypeSubdetector system for which the transform storage needs to be instantiated
modeThe mode in which the storage shall be instantiated

Definition at line 31 of file TransformStore.cxx.

32 {
33 const unsigned size = TrfStoreTicketCounter::distributedTickets(dType);
34 switch (mode) {
35 using enum Mode;
36 case LazyFill: {
38 return store;
39 } case Block: {
40 TrfVec_t trfStore(size, Amg::Transform3D::Identity());
41 CheckVec_t isSet(size, 0);
42 return std::make_pair(std::move(trfStore), std::move(isSet));
43 }
44 }
45 return Storage_t{};
46 }
std::variant< LazyStorage_t, BlockStorage_t > Storage_t
Use the std::variant to dynamically switch between the two types.
Mode
Enum describing the operation mode of the cache.
std::vector< CxxUtils::CachedUniquePtr< Amg::Transform3D > > LazyStorage_t
Abrivation of the backend in the lazy filling mode.
std::vector< char > CheckVec_t
Abrivate the char vector.
std::vector< Amg::Transform3D > TrfVec_t
Abrivate the transform vector.
static unsigned int distributedTickets(const DetectorType detType)
Returns the number of all distributed tickets.

◆ mode()

TransformStore::Mode ActsTrk::detail::TransformStore::mode ( ) const

Returns the mode with which the store has been instantiated.

Definition at line 120 of file TransformStore.cxx.

120 {
121 return std::visit([&](const auto& store) {
122 using Store_t = std::decay_t<decltype(store)>;
123 if constexpr(std::is_same_v<Store_t, LazyStorage_t>) {
124 return Mode::LazyFill;
125 } else if constexpr(std::is_same_v<Store_t, BlockStorage_t>) {
126 return Mode::Block;
127 }
128 }, m_storage);
129 }

◆ operator=() [1/2]

TransformStore & ActsTrk::detail::TransformStore::operator= ( const TransformStore & other)
noexcept

Define the copy assignment operator.

Definition at line 63 of file TransformStore.cxx.

63 {
64 if (&other != this) {
65 m_storage = initStorage(other.detectorType(), other.mode());
66 m_detType = other.detectorType();
67 if (mode() == Mode::Block){
68 for (std::size_t t = 0; t < size(); ++t) {
69 if (const Amg::Transform3D* copyMe = other.getTransform(t);
70 copyMe != nullptr) {
71 setTransform(t, Amg::Transform3D{*copyMe});
72 }
73 }
74 }
75 }
76 return (*this);
77 }

◆ operator=() [2/2]

TransformStore & ActsTrk::detail::TransformStore::operator= ( TransformStore && other)
defaultnoexcept

Define the move assignment operator.

◆ print()

std::ostream & ActsTrk::detail::TransformStore::print ( std::ostream & ostr) const
private

Definition at line 23 of file TransformStore.cxx.

23 {
24 const auto f = filled();
25 const auto s = size();
26 ostr<<detectorType()<<" transform store in mode: "<<mode()
27 <<", size: "<<s<<", (un)allocated: ("<<(s- f)<<")"<<f;
28 return ostr;
29 }
DetectorType detectorType() const
Returns the detector type.

◆ setTransform() [1/2]

const Amg::Transform3D & ActsTrk::detail::TransformStore::setTransform ( const unsigned int ticketNo,
Amg::Transform3D && trf )

Stores a transform at the index of the passed ticket number.

Parameters
ticketNoNumber of the ticket under which the transform should be cached
trfTransform object to be stored
Returns
The reference to the transform to which the passed transform was assigned to

◆ setTransform() [2/2]

const Amg::Transform3D & ActsTrk::detail::TransformStore::setTransform ( const unsigned int ticketNo,
Amg::Transform3D && trf ) const

Stores a transform at the index of the passed ticket number.

(Only works if the LazyFill mode option is activated)

Parameters
ticketNoNumber of the ticket under which the transform should be cached
trfTransform object to be stored
Returns
The reference to the transform to which the passed transform was assigned to

◆ size()

std::size_t ActsTrk::detail::TransformStore::size ( ) const

Return the size (maximum capacity) of the current store.

Definition at line 94 of file TransformStore.cxx.

94 {
95 return std::visit([](const auto& store){
96 using Store_t = std::decay_t<decltype(store)>;
97 if constexpr(std::is_same_v<Store_t, LazyStorage_t>) {
98 return store.size();
99 } else {
100 return store.first.size();
101 }
102 }, m_storage);
103 }

◆ toString()

std::string ActsTrk::detail::TransformStore::toString ( const Mode m)
static

Define the to string operator.

Definition at line 15 of file TransformStore.cxx.

15 {
16 switch (m) {
17 using enum Mode;
18 case LazyFill: return "LazyFill";
19 case Block: return "Block";
20 }
21 return "";
22 }

◆ operator<< [1/2]

std::ostream & operator<< ( std::ostream & ostr,
const Mode m )
friend

Definition at line 37 of file TransformStore.h.

37 {
38 return ostr<<toString(m);
39 }
static std::string toString(const Mode m)
Define the to string operator.

◆ operator<< [2/2]

std::ostream & operator<< ( std::ostream & ostr,
const TransformStore & store )
friend

Define the to string ostream operator.

Definition at line 41 of file TransformStore.h.

41 {
42 return store.print(ostr);
43 }

Member Data Documentation

◆ m_detType

DetectorType ActsTrk::detail::TransformStore::m_detType {ActsTrk::DetectorType::UnDefined}
private

The associated detector type.

Definition at line 94 of file TransformStore.h.

@ UnDefined
Small Thing Gap chambers (NSW).

◆ m_storage

Storage_t ActsTrk::detail::TransformStore::m_storage {}
private

Definition at line 92 of file TransformStore.h.

92{};

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