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 Acts::Surface &,
31 const measurement_t &,
32 const bound_track_parameters_t &)>;
33
34 // Get the calibrator for the given measurement type T_ValueType, and the measurement dimension
35 template <std::size_t DIM, typename T_ValueType>
37
38 // register a calibrator for the given measurement type and dimension.
39 // the allowed measurement types and their allowed dimensions are defined by the measurement container variant
40 template <std::size_t DIM, typename T_ValueType>
42
43private:
44 // helper for type specific calibrator storage
46 // the MeasurementContainer is a variant containing pointer to containers
47 template <typename T_ContainerPtr>
48 using container_type = std::remove_cv_t<std::remove_pointer_t<T_ContainerPtr> >;
49
50 // this is supposed to be the value type of the measurement container
51 // T_Container is ContainerWithDimension<T>, needed is T::const_value_type where T should
52 // be xAOD::PixelClusterContainer which should be DataVector<xAOD::PixelCluster>
53 template <typename T_Container>
54 using value_type = typename MeasurementTypeTraits::template MeassurementContainerValueType<typename T_Container::container_type >;
55
56 // the calibrators are associated to the element types of the container without pointer and const qualifiers
57 template <typename T_ContainerWithDimension>
58 using type = Calibrator< T_ContainerWithDimension::dimension() , std::remove_cv_t<std::remove_pointer_t< value_type<T_ContainerWithDimension> > > >;
59 };
60
62
63 std::array< CalibratorVariant, std::variant_size_v<measurement_container_variant_t> > m_calibrators;
64
65 template <std::size_t DIM, typename T_ValueType, std::size_t N>
66 static
67 const CalibratorVariant &
68 getCalibratorGeneric(const std::array< CalibratorVariant, std::variant_size_v<measurement_container_variant_t> > &calibrator_arr);
69};
70
71// helper to find the variant index for the given measurement type
72template <typename MeasurementTypeTraits, typename bound_track_parameters_t, typename measurement_container_variant_t>
73template <std::size_t DIM, typename T_ValueType, std::size_t N>
74inline
77 ::getCalibratorGeneric(const std::array< CalibratorVariant, std::variant_size_v<measurement_container_variant_t> > &calibrator_arr){
78 if constexpr(N==1) {
79 return calibrator_arr[0];
80 }
81 else {
82 using Container = std::remove_cv_t<std::remove_pointer_t<decltype( ActsTrk::detail::MakeDerivedVariant::lvalue(std::get<N-1>(measurement_container_variant_t{})))> >;
83 // Container should be ContainerWithDimension<T>, needed is ContainerWithDimension<T>::contaienr_type
84 using ElementType = typename MeasurementTypeTraits::template MeassurementContainerValueType<typename Container::container_type>;
85 using BaseElementType = typename std::remove_cv_t<std::remove_pointer_t< ElementType > >;
86 if constexpr(std::is_same<T_ValueType,BaseElementType>::value && Container::dimension() == DIM) {
87 return calibrator_arr[N-1];
88 }
89 else {
90 return getCalibratorGeneric<DIM, T_ValueType,N-1>(calibrator_arr);
91 }
92 }
93}
94
95template <typename MeasurementTypeTraits, typename bound_track_parameters_t, typename measurement_container_variant_t>
96template <std::size_t DiM, typename T_ValueType>
97inline
100 CalibratorVariant universial { calibrator };
101 assert( universial.index() < m_calibrators.size() );
102 m_calibrators.at(universial.index()) = std::move( universial);
103}
104
105template <typename MeasurementTypeTraits, typename bound_track_parameters_t, typename measurement_container_variant_t>
106template <std::size_t DIM, typename T_ValueType>
107inline
112 return std::get<Calibrator<DIM, T_ValueType> >(universal);
113}
114#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 Acts::Surface &, 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