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

#include <AtlasUncalibSourceLinkAccessor.h>

Inheritance diagram for ActsTrk::detail::AtlasMeasurementContainerList:
Collaboration diagram for ActsTrk::detail::AtlasMeasurementContainerList:

Public Types

using Base
using measurement_container_variant_t

Public Member Functions

unsigned int getDimension (const xAOD::PixelClusterContainer &container)
std::size_t size () const
const measurement_container_variant_tat (std::size_t container_index) const
const std::vector< measurement_container_variant_t > & containerList () const
void setContainer (std::size_t container_index, const container_t &container)

Static Public Member Functions

template<std::size_t DIM>
static bool isDimension (const SG::AuxVectorBase &container)
static constexpr std::size_t getMeasurementDimMax ()
static void dumpVariantTypes ()

Protected Member Functions

const AtlasMeasurementContainerListderived () const

Static Protected Member Functions

static void dumpVariantTypes (std::ostream &out)
static constexpr T lvalue (T &&a)
static constexpr std::size_t dimMax (std::size_t max_dim=0ul)
static constexpr bool isSameContainer ()
static constexpr unsigned int countVariants ()
static unsigned int countDerivedVariants (const container_t &a)
static void throwContainerNotInVariant (const char *a)
static measurement_container_variant_t getContainerWithDimensionNoAmbiguities (const container_t &a, unsigned int dimension=0)
static unsigned int getDimensionOfDerivedVariantOption (const container_t &a)
static measurement_container_variant_t getContainerWithDimension (const container_t &a)

Private Attributes

std::vector< measurement_container_variant_tm_containerList

Detailed Description

Definition at line 227 of file AtlasUncalibSourceLinkAccessor.h.

Member Typedef Documentation

◆ Base

◆ measurement_container_variant_t

using MeasurementContainerListWithDimension< AtlasMeasurementContainerList, T_Container >::measurement_container_variant_t
inherited

Definition at line 264 of file MeasurementContainerWithDimension.h.

Member Function Documentation

◆ at()

◆ containerList()

const std::vector< measurement_container_variant_t > & MeasurementContainerListWithDimension< AtlasMeasurementContainerList, T_Container >::containerList ( ) const
inlineinherited

Definition at line 283 of file MeasurementContainerWithDimension.h.

283{ return m_containerList;}

◆ countDerivedVariants()

unsigned int MeasurementContainerWithDimension< AtlasMeasurementContainerList, T_Container >::countDerivedVariants ( const container_t & a)
inlinestaticprotectedinherited

Definition at line 78 of file MeasurementContainerWithDimension.h.

78 {
79 if constexpr(N==0) {
80 return 0;
81 }
82 else {
83 if constexpr(isSameContainer<container_t, N-1>()) {
84 return countDerivedVariants<container_t, N-1>(a)+1;
85 }
86 else {
91 return countDerivedVariants<container_t, N-1>(a)+ ( dynamic_cast<const this_container_type *>(&a) != nullptr );
92 }
93 else {
95 }
96 }
97 }
98 }

◆ countVariants()

constexpr unsigned int MeasurementContainerWithDimension< AtlasMeasurementContainerList, T_Container >::countVariants ( )
inlinestaticconstexprprotectedinherited

Definition at line 69 of file MeasurementContainerWithDimension.h.

69 {
70 if constexpr(N==0) {
71 return 0;
72 }
73 else {
75 }
76 }

◆ derived()

const AtlasMeasurementContainerList & MeasurementContainerWithDimension< AtlasMeasurementContainerList, T_Container >::derived ( ) const
inlineprotectedinherited

Definition at line 47 of file MeasurementContainerWithDimension.h.

47{ return *static_cast<const derived_t *>(this); }

◆ dimMax()

constexpr std::size_t MeasurementContainerWithDimension< AtlasMeasurementContainerList, T_Container >::dimMax ( std::size_t max_dim = 0ul)
inlinestaticconstexprprotectedinherited

Definition at line 53 of file MeasurementContainerWithDimension.h.

53 {
54 if constexpr(N>0) {
57 }
58 return max_dim;
59 }

◆ dumpVariantTypes() [1/2]

void MeasurementContainerListWithDimension< AtlasMeasurementContainerList, T_Container >::dumpVariantTypes ( )
inlinestaticinherited

◆ dumpVariantTypes() [2/2]

void MeasurementContainerWithDimension< AtlasMeasurementContainerList, T_Container >::dumpVariantTypes ( std::ostream & out)
inlinestaticinherited

Definition at line 101 of file MeasurementContainerWithDimension.h.

101 {
102 if constexpr(N>0) {
104 out << N-1 << ": " << typeid(a_type).name() << std::endl;
106 }
107 }

◆ getContainerWithDimension()

measurement_container_variant_t MeasurementContainerWithDimension< AtlasMeasurementContainerList, T_Container >::getContainerWithDimension ( const container_t & a)
inlinestaticprotectedinherited

Definition at line 239 of file MeasurementContainerWithDimension.h.

239 {
240 constexpr unsigned int variant_multiplicity = countVariants<container_t>();
241 // the container must by among the options of the measurement_container_variant_t
243 if constexpr( variant_multiplicity == 1) {
245 }
246 else {
247 if (variant_multiplicity==0) {
250 }
251 }
252 DEBUG_TRACE( std::cout << "DEBUG need to search with dimension check for " << typeid(container_t).name() << " (aka " << typeid(a).name() << ")"
253 << " multiplicity : " << variant_multiplicity << " derived " << countDerivedVariants<container_t>(a)
254 << std:: endl );
256 }
257 }
#define DEBUG_TRACE(a)
static measurement_container_variant_t getContainerWithDimensionNoAmbiguities(const container_t &a, unsigned int dimension=0)

◆ getContainerWithDimensionNoAmbiguities()

measurement_container_variant_t MeasurementContainerWithDimension< AtlasMeasurementContainerList, T_Container >::getContainerWithDimensionNoAmbiguities ( const container_t & a,
unsigned int dimension = 0 )
inlinestaticprotectedinherited

Definition at line 117 of file MeasurementContainerWithDimension.h.

117 {
118 if constexpr(N==0) {
119 // this measns that the container_t has not been found in the list of possible options of the variant
120 // reasons: the type is not in the list, a derived type was provided and compaibility was not understood
123 return this_variant_type();
124 }
125 else {
128 DEBUG_TRACE( std::cout << "DEBUG search option for " << typeid(container_t).name() << " (aka " << typeid(a).name() << ")"
129 << " option: " << N << " " << typeid(this_container_type).name() << " dim " << this_variant_type::dimension()
130 << " check dimension ? " << check_dimension << " desired dimension " << dimension
131 << std:: endl );
133 // this option of the variant has perfect type match.
134 if constexpr(!check_dimension && countVariants<container_t>()==1) {
135 // if dimensions are not to be checked there must not be other options which also match the type
136 // the caller should have ensureed that this branch is impossible,
137 // but this can only be excluded at runtime, so a static_assert
138 // is impossible here
140 DEBUG_TRACE( std::cout << "DEBUG --> for " << typeid(container_t).name() << " (aka " << typeid(a).name() << ")"
141 << " foumd unambiguous option: " << N << " " << typeid(this_container_type).name() << " dim " << this_variant_type::dimension()
142 << std:: endl );
144 }
145 else {
146 // otherwise check if the dimension of this option is identical to the
147 // expected dimension
149 DEBUG_TRACE( std::cout << "DEBUG --> for " << typeid(container_t).name() << " (aka " << typeid(a).name() << ")"
150 << " foumd dimension option: " << N << " " << typeid(this_container_type).name() << " dim " << this_variant_type::dimension()
151 << std:: endl );
153 }
154 }
155 }
157 // it is also possible that the container is a base of an option of the variant.
159 // casting can only be done safely if dynamic casts are possible, which requires
160 // a virtuaal destructor
161 const this_container_type *derived_container = dynamic_cast<const this_container_type *>(&a);
162 if (derived_container) {
163 // if the provided container can be casted to the type of this variant option
164 // then check the dimensions
165 if constexpr(!check_dimension) {
166 // Branch may be incorrectly chose and/or assert may fail
167 // if A is base of B and B is Base of C and both B and C are options of the variant
168 // the auto-detection will treat B
169 if constexpr(countVariants<container_t,N-1>() != 0) {
171 }
172 else {
173 DEBUG_TRACE( std::cout << "DEBUG --> for " << typeid(this_container_type).name() << " (aka " << typeid(a).name() << ")"
174 << " foumd derived option: " << N << " " << typeid(this_container_type).name() << " dim " << this_variant_type::dimension()
175 << std:: endl );
177 }
178 }
179 else {
181 DEBUG_TRACE( std::cout << "DEBUG --> for " << typeid(this_container_type).name() << " (aka " << typeid(a).name() << ")"
182 << " derived with dimension option: " << N << " " << typeid(this_container_type).name()
183 << " dim " << this_variant_type::dimension()
184 << std:: endl );
186 }
187 }
188 }
189 }
190 }
192 }
193 }

◆ getDimension()

unsigned int ActsTrk::detail::AtlasMeasurementContainerList::getDimension ( const xAOD::PixelClusterContainer & container)
inline

Definition at line 243 of file AtlasUncalibSourceLinkAccessor.h.

243 {
244 if (isDimension<2>(container.auxbase())) { return 2u; }
245 else if (isDimension<3>(container.auxbase())) { return 3u; }
246 else {
247 throw std::runtime_error("Unsupported dimension for PixelClusterContainer");
248 }
249 }
static bool isDimension(const SG::AuxVectorBase &container)
const SG::AuxVectorBase & auxbase() const
Convert to AuxVectorBase.

◆ getDimensionOfDerivedVariantOption()

unsigned int MeasurementContainerWithDimension< AtlasMeasurementContainerList, T_Container >::getDimensionOfDerivedVariantOption ( const container_t & a)
inlinestaticprotectedinherited

Definition at line 196 of file MeasurementContainerWithDimension.h.

196 {
197 if constexpr(N==0) {
198 // failure
199 return 0;
200 }
201 else {
204
205 DEBUG_TRACE( std::cout << "DEBUG determin dimension for " << typeid(container_t).name() << " (aka " << typeid(a).name() << ")"
206 << " option: " << N << " " << typeid(this_container_type).name() << " dim " << this_variant_type::dimension()
207 << std:: endl );
208
210 DEBUG_TRACE( std::cout << "DEBUG get dimension for " << typeid(container_t).name() << " (aka " << typeid(a).name() << ")"
211 << " option: " << N << " " << typeid(this_container_type).name() << " dim " << this_variant_type::dimension()
212 << std:: endl );
214 }
216 DEBUG_TRACE( std::cout << "DEBUG try get dimension for derived " << typeid(container_t).name() << " (aka " << typeid(a).name() << ")"
217 << " option: " << N << " " << typeid(this_container_type).name() << " dim " << this_variant_type::dimension()
218 << std:: endl );
219 // it is also possible that the container is a base of an option of the variant.
221 // if there is no ambiguity there is no point in determining the dimension
222 // @TODO but this does not guarantee that this option matches if the provided container
223 // can have multiple dimensions.
224 if constexpr(countVariants<this_container_type>() > 1) {
225 // casting can only be done safely if dynamic casts are possible, which requires
226 // a virtual destructor
227 const this_container_type *derived_container = dynamic_cast<const this_container_type *>(&a);
228 if (derived_container) {
230 }
231 }
232 }
233 }
235 }
236 }

◆ getMeasurementDimMax()

constexpr std::size_t MeasurementContainerListWithDimension< AtlasMeasurementContainerList, T_Container >::getMeasurementDimMax ( )
inlinestaticconstexprinherited

Definition at line 269 of file MeasurementContainerWithDimension.h.

269 {
270 return Base::dimMax();
271 }

◆ isDimension()

template<std::size_t DIM>
bool ActsTrk::detail::AtlasMeasurementContainerList::isDimension ( const SG::AuxVectorBase & container)
inlinestatic

Definition at line 235 of file AtlasUncalibSourceLinkAccessor.h.

235 {
236 static const xAOD::PosAccessor<DIM> acc{"localPositionDim" + std::to_string(DIM)};
237 return container.isAvailable(acc.auxid());
238 }
bool isAvailable(const std::string &name, const std::string &clsname="") const
Test to see if a variable exists in the store.
SG::AuxElement::Accessor< std::array< float, N > > PosAccessor
xAOD Accessor to the position

◆ isSameContainer()

constexpr bool MeasurementContainerWithDimension< AtlasMeasurementContainerList, T_Container >::isSameContainer ( )
inlinestaticconstexprprotectedinherited

◆ lvalue()

constexpr T MeasurementContainerWithDimension< AtlasMeasurementContainerList, T_Container >::lvalue ( T && a)
inlinestaticconstexprprotectedinherited

Definition at line 50 of file MeasurementContainerWithDimension.h.

50{ return a;}

◆ setContainer()

void MeasurementContainerListWithDimension< AtlasMeasurementContainerList, T_Container >::setContainer ( std::size_t container_index,
const container_t & container )
inlineinherited

◆ size()

std::size_t MeasurementContainerListWithDimension< AtlasMeasurementContainerList, T_Container >::size ( ) const
inlineinherited

Definition at line 276 of file MeasurementContainerWithDimension.h.

276 {
277 return m_containerList.size();
278 }

◆ throwContainerNotInVariant()

void MeasurementContainerWithDimension< AtlasMeasurementContainerList, T_Container >::throwContainerNotInVariant ( const char * a)
inlinestaticprotectedinherited

Definition at line 109 of file MeasurementContainerWithDimension.h.

109 {
111 msg << "Container " << a << " not in variant:" << std::endl;
113 throw std::runtime_error(msg.str());
114 }

Member Data Documentation

◆ m_containerList

std::vector< measurement_container_variant_t > MeasurementContainerListWithDimension< AtlasMeasurementContainerList, T_Container >::m_containerList
privateinherited

Definition at line 266 of file MeasurementContainerWithDimension.h.


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