ATLAS Offline Software
Loading...
Searching...
No Matches
MeasurementCalibrator.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
32namespace 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 );
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 const IOnBoundStateCalibratorTool *stripCalibratorTool,
135 const IOnBoundStateCalibratorTool *hgtdCalibratorTool)
136 {
137
138 if (pixelCalibratorTool) {
139 bool calibrate_after_measurement_selection = pixelCalibratorTool->calibrateAfterMeasurementSelection();
140 pixelCalibratorTool->connectPixelCalibrator( calibrate_after_measurement_selection ?
142 if (calibrate_after_measurement_selection)
143 pixel_preCalibrator.template connect<&MeasurementCalibrator::passthrough<2, xAOD::PixelCluster>>(this);
144 } else
145 pixel_preCalibrator.template connect<&MeasurementCalibrator::passthrough<2, xAOD::PixelCluster>>(this);
146
147 if (stripCalibratorTool) {
148 bool calibrate_after_measurement_selection = stripCalibratorTool->calibrateAfterMeasurementSelection();
149 stripCalibratorTool->connectStripCalibrator( calibrate_after_measurement_selection ?
151 if (calibrate_after_measurement_selection)
152 strip_preCalibrator.template connect<&MeasurementCalibrator::passthrough<1, xAOD::StripCluster>>(this);
153 } else
154 strip_preCalibrator.template connect<&MeasurementCalibrator::passthrough<1, xAOD::StripCluster>>(this);
155
156
157 if (hgtdCalibratorTool) {
158 bool calibrate_after_measurement_selection = hgtdCalibratorTool->calibrateAfterMeasurementSelection();
159 hgtdCalibratorTool->connectHGTDCalibrator( calibrate_after_measurement_selection ?
161 if(calibrate_after_measurement_selection)
162 hgtd_preCalibrator.template connect<&MeasurementCalibrator::passthrough<3, xAOD::HGTDCluster>>(this);
163 } else
164 hgtd_preCalibrator.template connect<&MeasurementCalibrator::passthrough<3, xAOD::HGTDCluster>>(this);
165
166 }
167
174
175
176 template <std::size_t Dim, typename Cluster>
177 std::pair<xAOD::MeasVector<Dim>, xAOD::MeasMatrix<Dim>>
178 passthrough([[maybe_unused]] const Acts::GeometryContext& gctx,
179 [[maybe_unused]] const Acts::CalibrationContext& cctx,
180 const Cluster &cluster,
181 const Acts::BoundTrackParameters &) const
182 {
183 return std::make_pair(cluster.template localPosition<Dim>(),
184 cluster.template localCovariance<Dim>());
185 }
186 };
187
188}
189#endif
virtual bool calibrateAfterMeasurementSelection() const =0
virtual void connectStripCalibrator(StripCalibrator &calibrator) const
virtual void connectPixelCalibrator(PixelCalibrator &calibrator) const
virtual void connectHGTDCalibrator(HGTDCalibrator &calibrator) const
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
StripCluster_v1 StripCluster
Define the version of the strip cluster class.
Eigen::Matrix< float, N, N > MeasMatrix
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
PixelCluster_v1 PixelCluster
Define the version of the pixel cluster class.
UncalibMeasType
Define the type of the uncalibrated measurement.
HGTDCluster_v1 HGTDCluster
Define the version of the pixel cluster class.
Definition HGTDCluster.h:13
const StripCalibrator & stripPostCalibrator() const
Acts::Delegate< std::pair< StripPos, StripCov >(const Acts::GeometryContext &, const Acts::CalibrationContext &, const xAOD::StripCluster &, const Acts::BoundTrackParameters &)> StripCalibrator
Acts::Delegate< std::pair< hgtdPos, hgtdCov >(const Acts::GeometryContext &, const Acts::CalibrationContext &, const xAOD::HGTDCluster &, const Acts::BoundTrackParameters &)> HGTDCalibrator
const PixelCalibrator & pixelPreCalibrator() const
const StripCalibrator & stripPreCalibrator() const
const PixelCalibrator & pixelPostCalibrator() const
MeasurementCalibrator(const IOnBoundStateCalibratorTool *pixelCalibratorTool, const IOnBoundStateCalibratorTool *stripCalibratorTool, const IOnBoundStateCalibratorTool *hgtdCalibratorTool)
std::pair< xAOD::MeasVector< Dim >, xAOD::MeasMatrix< Dim > > passthrough(const Acts::GeometryContext &gctx, const Acts::CalibrationContext &cctx, const Cluster &cluster, const Acts::BoundTrackParameters &) const
const HGTDCalibrator & hgtdPreCalibrator() const
Acts::Delegate< std::pair< PixelPos, PixelCov >(const Acts::GeometryContext &, const Acts::CalibrationContext &, const xAOD::PixelCluster &, const Acts::BoundTrackParameters &)> PixelCalibrator
const HGTDCalibrator & hgtdPostCalibrator() const
void setMeasurementTypeForVolumeId(unsigned int volume_id, xAOD::UncalibMeasType type)
static constexpr Acts::SubspaceIndices< 2 > s_pixelSubspaceIndices
static constexpr std::array< Acts::SubspaceIndices< 1 >, 2 > s_stripSubspaceIndices
Acts::SubspaceIndices< DIM > parameterMap(const Acts::GeometryContext &, const Acts::CalibrationContext &, const Acts::Surface &surface) const
std::array< unsigned char, 128 > m_volumeIdToMeasurementType
static constexpr Acts::SubspaceIndices< 3 > s_hgtdSubspaceIndices
xAOD::UncalibMeasType measurementTypeFromVolumeId(unsigned int volume_id) const