ATLAS Offline Software
MeasurementCalibrator2.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef MEASUREMENTCALIBRATOR2_H
6 #define MEASUREMENTCALIBRATOR2_H
7 
8 #include "Acts/EventData/Types.hpp"
15 
16 #include "Acts/EventData/MultiTrajectory.hpp"
17 #include "Acts/EventData/TrackParameters.hpp"
18 #include "Acts/Geometry/GeometryIdentifier.hpp"
19 #include "Acts/Surfaces/Surface.hpp"
20 #include "Acts/Surfaces/SurfaceBounds.hpp"
21 #include "Acts/Definitions/TrackParametrization.hpp"
22 #include "Acts/Utilities/AlgebraHelpers.hpp"
23 #include <Eigen/Core>
24 
27 
28 #include <stdexcept>
29 #include <string>
30 #include <cassert>
31 
32 namespace ActsTrk {
33  // helper to create map from nound track parameters to measurements
35 
36  std::array<unsigned char, 128> m_volumeIdToMeasurementType{};
37  xAOD::UncalibMeasType measurementTypeFromVolumeId(unsigned int volume_id) const {
38  unsigned char shift = (volume_id%2) ? 4 : 0;
39  unsigned char idx = volume_id/2;
40  return static_cast<xAOD::UncalibMeasType>((m_volumeIdToMeasurementType[idx] >> shift) & 0xf);
41  }
43  static_assert( static_cast<unsigned int>(xAOD::UncalibMeasType::nTypes) < 16u );
44  unsigned char shift = (volume_id%2) ? 4 : 0;
45  unsigned char idx = volume_id/2;
46  m_volumeIdToMeasurementType[idx] |= ((static_cast<unsigned int>(type) & 0xf) << shift);
47  }
49  // @TODO get mapping from converter tool ?
50  std::vector<unsigned int> pixel_vol {16, 15, 9, 20, 19, 18, 10, 14, 13, 8};
51  for (unsigned int vol_id : pixel_vol) {
53  }
54  std::vector<unsigned int> strip_vol {23, 22, 24};
55  for (unsigned int vol_id : strip_vol) {
57  }
58  std::vector<unsigned int> hgtd_vol {2, 25};
59  for (unsigned int vol_id : hgtd_vol) {
61  }
62  }
63 
64  template <std::size_t DIM>
65  Acts::SubspaceIndices<DIM> parameterMap([[maybe_unused]] const Acts::GeometryContext&,
66  [[maybe_unused]] const Acts::CalibrationContext&,
67  const Acts::Surface &surface) const {
68  // @TODO make interface measurement type aware ?
69  if constexpr(DIM==3) {
70  assert( measurementTypeFromVolumeId(surface.geometryId().volume()) == xAOD::UncalibMeasType::HGTDClusterType );
71  return s_hgtdSubspaceIndices;
72  }
73  else if constexpr(DIM==2) {
74  assert( measurementTypeFromVolumeId(surface.geometryId().volume()) == xAOD::UncalibMeasType::PixelClusterType );
76  }
77  else if constexpr(DIM==1) {
78  assert( measurementTypeFromVolumeId(surface.geometryId().volume()) == xAOD::UncalibMeasType::StripClusterType );
79  auto boundType = surface.bounds().type();
80  const std::size_t projector_idx = boundType == Acts::SurfaceBounds::eAnnulus;
81  return s_stripSubspaceIndices[projector_idx];
82  }
83  else {
84  throw std::runtime_error("Unsupported dimension");
85  }
86 
87  }
88 
89  constexpr static std::array<Acts::SubspaceIndices<1>, 2> s_stripSubspaceIndices = {
90  {{Acts::eBoundLoc0}, // normal strip: x -> l0
91  {Acts::eBoundLoc1}} // annulus strip: y -> l0
92  };
93  constexpr static Acts::SubspaceIndices<2> s_pixelSubspaceIndices = {
94  Acts::eBoundLoc0, Acts::eBoundLoc1
95  };
96  constexpr static Acts::SubspaceIndices<3> s_hgtdSubspaceIndices = {
97  Acts::eBoundLoc0, Acts::eBoundLoc1, Acts::eBoundTime
98  };
99  };
100 
104  // @TODO should pass through bound state
105  using PixelCalibrator = Acts::Delegate<
106  std::pair<PixelPos, PixelCov>(const Acts::GeometryContext&,
107  const Acts::CalibrationContext&,
108  const xAOD::PixelCluster &,
109  const Acts::BoundTrackParameters &)>;
110 
113  using StripCalibrator = Acts::Delegate<
114  std::pair<StripPos, StripCov>(const Acts::GeometryContext&,
115  const Acts::CalibrationContext&,
116  const xAOD::StripCluster &,
117  const Acts::BoundTrackParameters &)>;
120  using HGTDCalibrator = Acts::Delegate<
121  std::pair<hgtdPos, hgtdCov>(const Acts::GeometryContext&,
122  const Acts::CalibrationContext&,
123  const xAOD::HGTDCluster &,
124  const Acts::BoundTrackParameters &)>;
125 
132 
134  {
135  // @TODO add support for real calibrators
136 
137  bool calibrate_after_measurement_selection = true;
138  if (pixelTool) {
139  calibrate_after_measurement_selection = pixelTool->calibrateAfterMeasurementSelection();
140  pixelTool->connectPixelCalibrator( calibrate_after_measurement_selection ? pixel_postCalibrator : pixel_preCalibrator );
141  }
142  if (calibrate_after_measurement_selection) {
143  pixel_preCalibrator.template connect<&MeasurementCalibrator2::passthrough<2, xAOD::PixelCluster>>(this);
144  }
145  strip_preCalibrator.template connect<&MeasurementCalibrator2::passthrough<1, xAOD::StripCluster>>(this);
146  hgtd_preCalibrator.template connect<&MeasurementCalibrator2::passthrough<3, xAOD::HGTDCluster>>(this);
147  }
148 
155 
156 
157  template <std::size_t Dim, typename Cluster>
158  std::pair<xAOD::MeasVector<Dim>, xAOD::MeasMatrix<Dim>>
159  passthrough([[maybe_unused]] const Acts::GeometryContext& gctx,
160  [[maybe_unused]] const Acts::CalibrationContext& cctx,
161  const Cluster &cluster,
162  const Acts::BoundTrackParameters &) const
163  {
164  return std::make_pair(cluster.template localPosition<Dim>(),
165  cluster.template localCovariance<Dim>());
166  }
167  };
168 
169 }
170 #endif
ActsTrk::MeasurementCalibrator2::hgtd_preCalibrator
HGTDCalibrator hgtd_preCalibrator
Definition: MeasurementCalibrator2.h:131
ActsTrk::IOnBoundStateCalibratorTool
Definition: IOnBoundStateCalibratorTool.h:20
ActsTrk::MeasurementParameterMap::setMeasurementTypeForVolumeId
void setMeasurementTypeForVolumeId(unsigned int volume_id, xAOD::UncalibMeasType type)
Definition: MeasurementCalibrator2.h:42
StripCluster.h
UncalibratedMeasurement.h
ActsTrk::MeasurementCalibrator2::HGTDCalibrator
Acts::Delegate< std::pair< hgtdPos, hgtdCov >(const Acts::GeometryContext &, const Acts::CalibrationContext &, const xAOD::HGTDCluster &, const Acts::BoundTrackParameters &)> HGTDCalibrator
Definition: MeasurementCalibrator2.h:124
xAOD::UncalibMeasType::HGTDClusterType
@ HGTDClusterType
ActsTrk::MeasurementCalibrator2::hgtdPos
xAOD::MeasVector< 3 > hgtdPos
Definition: MeasurementCalibrator2.h:118
MeasurementBase.h
HGTDCluster.h
ActsTrk::MeasurementParameterMap::s_stripSubspaceIndices
constexpr static std::array< Acts::SubspaceIndices< 1 >, 2 > s_stripSubspaceIndices
Definition: MeasurementCalibrator2.h:89
ActsTrk::MeasurementCalibrator2::hgtdPostCalibrator
const HGTDCalibrator & hgtdPostCalibrator() const
Definition: MeasurementCalibrator2.h:151
xAOD::UncalibMeasType::StripClusterType
@ StripClusterType
ActsTrk::MeasurementCalibrator2::pixelPreCalibrator
const PixelCalibrator & pixelPreCalibrator() const
Definition: MeasurementCalibrator2.h:152
ActsTrk::MeasurementCalibrator2::stripPostCalibrator
const StripCalibrator & stripPostCalibrator() const
Definition: MeasurementCalibrator2.h:150
xAOD::HGTDCluster_v1
Definition: HGTDCluster_v1.h:23
ActsTrk::MeasurementCalibrator2::StripPos
xAOD::MeasVector< 1 > StripPos
Definition: MeasurementCalibrator2.h:111
ActsTrk::MeasurementCalibrator2::passthrough
std::pair< xAOD::MeasVector< Dim >, xAOD::MeasMatrix< Dim > > passthrough([[maybe_unused]] const Acts::GeometryContext &gctx, [[maybe_unused]] const Acts::CalibrationContext &cctx, const Cluster &cluster, const Acts::BoundTrackParameters &) const
Definition: MeasurementCalibrator2.h:159
ActsTrk::MeasurementParameterMap::s_pixelSubspaceIndices
constexpr static Acts::SubspaceIndices< 2 > s_pixelSubspaceIndices
Definition: MeasurementCalibrator2.h:93
ActsTrk::MeasurementCalibrator2::hgtdCov
xAOD::MeasMatrix< 3 > hgtdCov
Definition: MeasurementCalibrator2.h:119
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
ActsTrk::MeasurementCalibrator2::PixelCalibrator
Acts::Delegate< std::pair< PixelPos, PixelCov >(const Acts::GeometryContext &, const Acts::CalibrationContext &, const xAOD::PixelCluster &, const Acts::BoundTrackParameters &)> PixelCalibrator
Definition: MeasurementCalibrator2.h:109
ActsTrk::MeasurementCalibrator2::stripPreCalibrator
const StripCalibrator & stripPreCalibrator() const
Definition: MeasurementCalibrator2.h:153
ActsTrk::MeasurementCalibrator2::MeasurementCalibrator2
MeasurementCalibrator2(const IOnBoundStateCalibratorTool *pixelTool)
Definition: MeasurementCalibrator2.h:133
ActsTrk::MeasurementParameterMap::m_volumeIdToMeasurementType
std::array< unsigned char, 128 > m_volumeIdToMeasurementType
Definition: MeasurementCalibrator2.h:36
ActsTrk::MeasurementCalibrator2::pixel_postCalibrator
PixelCalibrator pixel_postCalibrator
Definition: MeasurementCalibrator2.h:126
ActsTrk::MeasurementParameterMap::measurementTypeFromVolumeId
xAOD::UncalibMeasType measurementTypeFromVolumeId(unsigned int volume_id) const
Definition: MeasurementCalibrator2.h:37
ActsTrk::MeasurementCalibrator2::strip_preCalibrator
StripCalibrator strip_preCalibrator
Definition: MeasurementCalibrator2.h:130
ActsTrk::MeasurementParameterMap
Definition: MeasurementCalibrator2.h:34
ActsTrk::MeasurementParameterMap::s_hgtdSubspaceIndices
constexpr static Acts::SubspaceIndices< 3 > s_hgtdSubspaceIndices
Definition: MeasurementCalibrator2.h:96
IOnBoundStateCalibratorTool.h
ActsTrk::MeasurementCalibrator2::PixelCov
xAOD::MeasMatrix< 2 > PixelCov
Definition: MeasurementCalibrator2.h:103
PixelCluster.h
ActsTrk::MeasurementCalibrator2::hgtd_postCalibrator
HGTDCalibrator hgtd_postCalibrator
Definition: MeasurementCalibrator2.h:128
xAOD::StripCluster_v1
Definition: StripCluster_v1.h:17
ActsTrk::IOnBoundStateCalibratorTool::connectPixelCalibrator
virtual void connectPixelCalibrator([[maybe_unused]] PixelCalibrator &calibrator) const
Definition: IOnBoundStateCalibratorTool.h:56
MeasurementDefs.h
ActsTrk::MeasurementCalibrator2
Definition: MeasurementCalibrator2.h:101
xAOD::MeasVector
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
Definition: MeasurementDefs.h:52
xAOD::UncalibMeasType::nTypes
@ nTypes
ActsTrk::MeasurementCalibrator2::pixelPostCalibrator
const PixelCalibrator & pixelPostCalibrator() const
Definition: MeasurementCalibrator2.h:149
ActsTrk::MeasurementCalibrator2::hgtdPreCalibrator
const HGTDCalibrator & hgtdPreCalibrator() const
Definition: MeasurementCalibrator2.h:154
ActsTrk::MeasurementParameterMap::MeasurementParameterMap
MeasurementParameterMap()
Definition: MeasurementCalibrator2.h:48
ActsTrk::MeasurementCalibrator2::StripCalibrator
Acts::Delegate< std::pair< StripPos, StripCov >(const Acts::GeometryContext &, const Acts::CalibrationContext &, const xAOD::StripCluster &, const Acts::BoundTrackParameters &)> StripCalibrator
Definition: MeasurementCalibrator2.h:117
ActsTrk::MeasurementCalibrator2::strip_postCalibrator
StripCalibrator strip_postCalibrator
Definition: MeasurementCalibrator2.h:127
xAOD::PixelCluster_v1
Definition: PixelCluster_v1.h:17
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ActsTrk::MeasurementCalibrator2::pixel_preCalibrator
PixelCalibrator pixel_preCalibrator
Definition: MeasurementCalibrator2.h:129
xAOD::UncalibMeasType
UncalibMeasType
Define the type of the uncalibrated measurement.
Definition: MeasurementDefs.h:24
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
ActsTrk::MeasurementParameterMap::parameterMap
Acts::SubspaceIndices< DIM > parameterMap([[maybe_unused]] const Acts::GeometryContext &, [[maybe_unused]] const Acts::CalibrationContext &, const Acts::Surface &surface) const
Definition: MeasurementCalibrator2.h:65
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:54
ActsTrk::IOnBoundStateCalibratorTool::calibrateAfterMeasurementSelection
virtual bool calibrateAfterMeasurementSelection() const =0
xAOD::MeasMatrix
Eigen::Matrix< float, N, N > MeasMatrix
Definition: MeasurementDefs.h:54
ActsTrk::MeasurementCalibrator2::PixelPos
xAOD::MeasVector< 2 > PixelPos
Definition: MeasurementCalibrator2.h:102
ActsTrk::MeasurementCalibrator2::StripCov
xAOD::MeasMatrix< 1 > StripCov
Definition: MeasurementCalibrator2.h:112
xAOD::UncalibMeasType::PixelClusterType
@ PixelClusterType