ATLAS Offline Software
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 
9 // Helper class to store and retrieve calibrators for a certain measurement type and measurement dimension
10 // this class only provides calibrators for types and associated dimension which are defined by the measurement container
11 // and the associated dimension. The template parameter is assumed to be:
12 // std::variant< ContainerRefWithDim<ContainerType1,N1>, ContainerRefWithDim<ContainerType2,N2>, .... >
13 // where ContainerType1 is the type of the container e.g. xAOD::PixelClusterContainer, and N1 the associated
14 // dimension e.g. 2.
15 template <typename MeasurementTypeTraits, typename bound_track_parameters_t, typename measurement_container_variant_t>
17  template <std::size_t DIM>
19  template <std::size_t DIM>
21 
22  template <std::size_t DIM, typename measurement_t>
23  using Calibrator = Acts::Delegate<
24  std::pair<Measurement<DIM>,MeasurementCovariance<DIM> >
25  (const Acts::GeometryContext&,
26  const Acts::CalibrationContext&,
27  const measurement_t &,
28  const bound_track_parameters_t &)>;
29 
30  // Get the calibrator for the given measurement type T_ValueType, and the measurement dimension
31  template <std::size_t DIM, typename T_ValueType>
33 
34  // register a calibrator for the given measurement type and dimension.
35  // the allowed measurement types and their allowed dimensions are defined by the measurement container variant
36  template <std::size_t DIM, typename T_ValueType>
38 
39 private:
40  // helper for type specific calibrator storage
41  struct CalibratorType {
42  // the MeasurementContainer is a variant containing pointer to containers
43  template <typename T_ContainerPtr>
44  using container_type = std::remove_cv_t<std::remove_pointer_t<T_ContainerPtr> >;
45 
46  // this is supposed to be the value type of the measurement container
47  // T_Container is ContainerWithDimension<T>, needed is T::const_value_type where T should
48  // be xAOD::PixelClusterContainer which should be DataVector<xAOD::PixelCluster>
49  template <typename T_Container>
50  using value_type = typename MeasurementTypeTraits::template MeassurementContainerValueType<typename T_Container::container_type >;
51 
52  // the calibrators are associated to the element types of the container without pointer and const qualifiers
53  template <typename T_ContainerWithDimension>
54  using type = Calibrator< T_ContainerWithDimension::dimension() , std::remove_cv_t<std::remove_pointer_t< value_type<T_ContainerWithDimension> > > >;
55  };
56 
58 
59  std::array< CalibratorVariant, std::variant_size_v<measurement_container_variant_t> > m_calibrators;
60 
61  template <std::size_t DIM, typename T_ValueType, std::size_t N>
62  static
63  const CalibratorVariant &
64  getCalibratorGeneric(const std::array< CalibratorVariant, std::variant_size_v<measurement_container_variant_t> > &calibrator_arr);
65 };
66 
67 // helper to find the variant index for the given measurement type
68 template <typename MeasurementTypeTraits, typename bound_track_parameters_t, typename measurement_container_variant_t>
69 template <std::size_t DIM, typename T_ValueType, std::size_t N>
70 inline
73  ::getCalibratorGeneric(const std::array< CalibratorVariant, std::variant_size_v<measurement_container_variant_t> > &calibrator_arr){
74  if constexpr(N==1) {
75  return calibrator_arr[0];
76  }
77  else {
78  using Container = std::remove_cv_t<std::remove_pointer_t<decltype( ActsTrk::detail::MakeDerivedVariant::lvalue(std::get<N-1>(measurement_container_variant_t{})))> >;
79  // Container should be ContainerWithDimension<T>, needed is ContainerWithDimension<T>::contaienr_type
80  using ElementType = typename MeasurementTypeTraits::template MeassurementContainerValueType<typename Container::container_type>;
81  using BaseElementType = typename std::remove_cv_t<std::remove_pointer_t< ElementType > >;
82  if constexpr(std::is_same<T_ValueType,BaseElementType>::value && Container::dimension() == DIM) {
83  return calibrator_arr[N-1];
84  }
85  else {
86  return getCalibratorGeneric<DIM, T_ValueType,N-1>(calibrator_arr);
87  }
88  }
89 }
90 
91 template <typename MeasurementTypeTraits, typename bound_track_parameters_t, typename measurement_container_variant_t>
92 template <std::size_t DiM, typename T_ValueType>
93 inline
96  CalibratorVariant universial { calibrator };
97  assert( universial.index() < m_calibrators.size() );
98  m_calibrators.at(universial.index()) = std::move( universial);
99 }
100 
101 template <typename MeasurementTypeTraits, typename bound_track_parameters_t, typename measurement_container_variant_t>
102 template <std::size_t DIM, typename T_ValueType>
103 inline
106 ::calibrator() const {
107  const CalibratorVariant &universal = getCalibratorGeneric< DIM, T_ValueType,std::variant_size_v<measurement_container_variant_t> >(m_calibrators);
108  return std::get<Calibrator<DIM, T_ValueType> >(universal);
109 }
110 #endif
CalibratorRegistry< AtlasMeasurementSelector::CalibratedMeasurementTraits, typename traits::BoundTrackParameters, measurement_container_variant_t >::CalibratorVariant
ActsTrk::detail::MakeDerivedVariant::MakeVariant< CalibratorType, measurement_container_variant_t >::variant_type CalibratorVariant
Definition: CalibratorRegistry.h:57
Calibrator
A structure to contain data associated with the calibration of a certain sub-module.
Definition: Calibrator.h:178
taskman.template
dictionary template
Definition: taskman.py:317
athena.value
value
Definition: athena.py:124
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
Container
storage of the time histories of all the cells
CalibratorRegistry::setCalibrator
void setCalibrator(const Calibrator< DIM, T_ValueType > &calibrator)
CalibratorRegistry< AtlasMeasurementSelector::CalibratedMeasurementTraits, typename traits::BoundTrackParameters, measurement_container_variant_t >::MeasurementCovariance
typename MeasurementTypeTraits::template MeasurementCovariance< DIM > MeasurementCovariance
Definition: CalibratorRegistry.h:20
CalibratorRegistry::m_calibrators
std::array< CalibratorVariant, std::variant_size_v< measurement_container_variant_t > > m_calibrators
Definition: CalibratorRegistry.h:59
ActsTrk::detail::MakeDerivedVariant::MakeVariant::variant_type
decltype(extend(MakeVariant< TypeHelper, VariantType, N-1 >::m_val, typename TypeHelper::template type< decltype(lvalue(std::get< N-1 >(VariantType{})))> {})) variant_type
Definition: MakeDerivedVariant.h:27
CalibratorRegistry
Definition: CalibratorRegistry.h:16
CalibratorRegistry::CalibratorType::container_type
std::remove_cv_t< std::remove_pointer_t< T_ContainerPtr > > container_type
Definition: CalibratorRegistry.h:44
CalibratorRegistry::CalibratorType
Definition: CalibratorRegistry.h:41
lumiFormat.array
array
Definition: lumiFormat.py:91
CalibratorRegistry::CalibratorType::type
Calibrator< T_ContainerWithDimension::dimension(), std::remove_cv_t< std::remove_pointer_t< value_type< T_ContainerWithDimension > > > > type
Definition: CalibratorRegistry.h:54
CalibratorRegistry::getCalibratorGeneric
static const CalibratorVariant & getCalibratorGeneric(const std::array< CalibratorVariant, std::variant_size_v< measurement_container_variant_t > > &calibrator_arr)
Definition: CalibratorRegistry.h:73
CalibratorRegistry< AtlasMeasurementSelector::CalibratedMeasurementTraits, typename traits::BoundTrackParameters, measurement_container_variant_t >::Measurement
typename MeasurementTypeTraits::template Measurement< DIM > Measurement
Definition: CalibratorRegistry.h:18
CalibratorRegistry::calibrator
const Calibrator< DIM, T_ValueType > & calibrator() const
MakeDerivedVariant.h
value_type
Definition: EDM_MasterSearch.h:11