ATLAS Offline Software
Loading...
Searching...
No Matches
CalibratorRegistry.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4#ifndef CALIBRATORREGISTRY_H
5#define CALIBRATORREGISTRY_H
6
8#include "Acts/Utilities/Delegate.hpp"
9#include "Acts/Geometry/GeometryContext.hpp"
10#include "Acts/Utilities/CalibrationContext.hpp"
11
12// Helper class to store and retrieve calibrators for a certain measurement type and measurement dimension
13// this class only provides calibrators for types and associated dimension which are defined by the measurement container
14// and the associated dimension. The template parameter is assumed to be:
15// std::variant< ContainerRefWithDim<ContainerType1,N1>, ContainerRefWithDim<ContainerType2,N2>, .... >
16// where ContainerType1 is the type of the container e.g. xAOD::PixelClusterContainer, and N1 the associated
17// dimension e.g. 2.
18template <typename MeasurementTypeTraits, typename bound_track_parameters_t, typename measurement_container_variant_t>
20 template <std::size_t DIM>
21 using Measurement = typename MeasurementTypeTraits::template Measurement<DIM>;
22 template <std::size_t DIM>
23 using MeasurementCovariance = typename MeasurementTypeTraits::template MeasurementCovariance<DIM>;
24
25 template <std::size_t DIM, typename measurement_t>
26 using Calibrator = Acts::Delegate<
27 std::pair<Measurement<DIM>,MeasurementCovariance<DIM> >
28 (const Acts::GeometryContext&,
29 const Acts::CalibrationContext&,
30 const measurement_t &,
31 const bound_track_parameters_t &)>;
32
33 // Get the calibrator for the given measurement type T_ValueType, and the measurement dimension
34 template <std::size_t DIM, typename T_ValueType>
36
37 // register a calibrator for the given measurement type and dimension.
38 // the allowed measurement types and their allowed dimensions are defined by the measurement container variant
39 template <std::size_t DIM, typename T_ValueType>
41
42private:
43 // helper for type specific calibrator storage
45 // the MeasurementContainer is a variant containing pointer to containers
46 template <typename T_ContainerPtr>
47 using container_type = std::remove_cv_t<std::remove_pointer_t<T_ContainerPtr> >;
48
49 // this is supposed to be the value type of the measurement container
50 // T_Container is ContainerWithDimension<T>, needed is T::const_value_type where T should
51 // be xAOD::PixelClusterContainer which should be DataVector<xAOD::PixelCluster>
52 template <typename T_Container>
53 using value_type = typename MeasurementTypeTraits::template MeassurementContainerValueType<typename T_Container::container_type >;
54
55 // the calibrators are associated to the element types of the container without pointer and const qualifiers
56 template <typename T_ContainerWithDimension>
57 using type = Calibrator< T_ContainerWithDimension::dimension() , std::remove_cv_t<std::remove_pointer_t< value_type<T_ContainerWithDimension> > > >;
58 };
59
61
62 std::array< CalibratorVariant, std::variant_size_v<measurement_container_variant_t> > m_calibrators;
63
64 template <std::size_t DIM, typename T_ValueType, std::size_t N>
65 static
66 const CalibratorVariant &
67 getCalibratorGeneric(const std::array< CalibratorVariant, std::variant_size_v<measurement_container_variant_t> > &calibrator_arr);
68};
69
70// helper to find the variant index for the given measurement type
71template <typename MeasurementTypeTraits, typename bound_track_parameters_t, typename measurement_container_variant_t>
72template <std::size_t DIM, typename T_ValueType, std::size_t N>
73inline
76 ::getCalibratorGeneric(const std::array< CalibratorVariant, std::variant_size_v<measurement_container_variant_t> > &calibrator_arr){
77 if constexpr(N==1) {
78 return calibrator_arr[0];
79 }
80 else {
81 using Container = std::remove_cv_t<std::remove_pointer_t<decltype( ActsTrk::detail::MakeDerivedVariant::lvalue(std::get<N-1>(measurement_container_variant_t{})))> >;
82 // Container should be ContainerWithDimension<T>, needed is ContainerWithDimension<T>::contaienr_type
83 using ElementType = typename MeasurementTypeTraits::template MeassurementContainerValueType<typename Container::container_type>;
84 using BaseElementType = typename std::remove_cv_t<std::remove_pointer_t< ElementType > >;
85 if constexpr(std::is_same<T_ValueType,BaseElementType>::value && Container::dimension() == DIM) {
86 return calibrator_arr[N-1];
87 }
88 else {
89 return getCalibratorGeneric<DIM, T_ValueType,N-1>(calibrator_arr);
90 }
91 }
92}
93
94template <typename MeasurementTypeTraits, typename bound_track_parameters_t, typename measurement_container_variant_t>
95template <std::size_t DiM, typename T_ValueType>
96inline
99 CalibratorVariant universial { calibrator };
100 assert( universial.index() < m_calibrators.size() );
101 m_calibrators.at(universial.index()) = std::move( universial);
102}
103
104template <typename MeasurementTypeTraits, typename bound_track_parameters_t, typename measurement_container_variant_t>
105template <std::size_t DIM, typename T_ValueType>
106inline
111 return std::get<Calibrator<DIM, T_ValueType> >(universal);
112}
113#endif
An instance of this class is created for each sub-level of the TRT by the TRTCalibrator.
Definition Calibrator.h:178
storage of the time histories of all the cells
decltype(extend(MakeVariant< TypeHelper, VariantType, N-1 >::m_val, typename TypeHelper::template type< decltype(lvalue(std::get< N-1 >(VariantType{})))> {})) variant_type
Calibrator< T_ContainerWithDimension::dimension(), std::remove_cv_t< std::remove_pointer_t< value_type< T_ContainerWithDimension > > > > type
std::remove_cv_t< std::remove_pointer_t< T_ContainerPtr > > container_type
typename MeasurementTypeTraits::template MeassurementContainerValueType< typename T_Container::container_type > value_type
typename MeasurementTypeTraits::template Measurement< DIM > Measurement
const CalibratorRegistry< AtlasMeasurementSelector::CalibratedMeasurementTraits, typename traits::BoundTrackParameters, measurement_container_variant_t >::template Calibrator< DIM, T_ValueType > & calibrator() const
const Calibrator< DIM, T_ValueType > & calibrator() const
void setCalibrator(const Calibrator< DIM, T_ValueType > &calibrator)
static const CalibratorVariant & getCalibratorGeneric(const std::array< CalibratorVariant, std::variant_size_v< measurement_container_variant_t > > &calibrator_arr)
ActsTrk::detail::MakeDerivedVariant::MakeVariant< CalibratorType, measurement_container_variant_t >::variant_type CalibratorVariant
Acts::Delegate< std::pair< Measurement< DIM >, MeasurementCovariance< DIM > >(const Acts::GeometryContext &, const Acts::CalibrationContext &, const measurement_t &, const bound_track_parameters_t &)> Calibrator
typename MeasurementTypeTraits::template MeasurementCovariance< DIM > MeasurementCovariance
std::array< CalibratorVariant, std::variant_size_v< measurement_container_variant_t > > m_calibrators