2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 #include "ActsGeometry/SurfaceOfMeasurementUtil.h"
6 #include "ActsGeometry/ATLASSourceLink.h"
8 namespace ActsTrk::detail {
10 template <typename traj_t>
11 OnTrackCalibrator<traj_t> OnTrackCalibrator<traj_t>::NoCalibration(const Acts::TrackingGeometry &trackingGeometry,
12 const ActsTrk::DetectorElementToActsGeometryIdMap &detectorElementToGeoId)
14 ToolHandle<IOnTrackCalibratorTool<traj_t>> null(nullptr);
15 return OnTrackCalibrator<traj_t>(trackingGeometry, detectorElementToGeoId, null, null, null);
18 template <typename traj_t>
19 OnTrackCalibrator<traj_t>::OnTrackCalibrator(const Acts::TrackingGeometry &trackingGeometry,
20 const ActsTrk::DetectorElementToActsGeometryIdMap &detectorElementToGeoId,
21 const ToolHandle<IOnTrackCalibratorTool<traj_t>>& pixelTool,
22 const ToolHandle<IOnTrackCalibratorTool<traj_t>>& stripTool,
23 const ToolHandle<IOnTrackCalibratorTool<traj_t>>& hgtdTool)
24 : m_trackingGeometry(&trackingGeometry),
25 m_detectorElementToGeoId(&detectorElementToGeoId)
27 if (pixelTool.isEnabled()) {
28 pixelTool->connect(*this);
30 pixelCalibrator.template connect<&OnTrackCalibrator<traj_t>::passthrough<2, xAOD::PixelCluster>>(this);
33 if (stripTool.isEnabled()) {
34 stripTool->connect(*this);
36 stripCalibrator.template connect<&OnTrackCalibrator<traj_t>::passthrough<1, xAOD::StripCluster>>(this);
38 if (hgtdTool.isEnabled()) {
39 hgtdTool->connect(*this);
41 // cppcheck-suppress missingReturn; false positive
42 hgtdCalibrator.template connect<&OnTrackCalibrator<traj_t>::passthrough<3, xAOD::HGTDCluster>>(this);
46 template <typename traj_t>
47 void OnTrackCalibrator<traj_t>::calibrate(
48 const Acts::GeometryContext& geoctx,
49 const Acts::CalibrationContext& cctx,
50 const Acts::SourceLink& link,
51 TrackStateProxy state) const
53 state.setUncalibratedSourceLink(Acts::SourceLink{link});
54 ATLASUncalibSourceLink sourceLink = link.template get<ATLASUncalibSourceLink>();
55 assert(sourceLink!=nullptr);
56 const xAOD::UncalibratedMeasurement &measurement = getUncalibratedMeasurement(sourceLink);
57 // @TODO in principle only need to lookup surface for strips
58 const Acts::Surface *surface = getSurfaceOfMeasurement(*m_trackingGeometry, *m_detectorElementToGeoId, measurement);
59 if (!surface) throw std::runtime_error("No surface for measurement.");
60 switch (measurement.type()) {
61 case xAOD::UncalibMeasType::PixelClusterType: {
62 assert(pixelCalibrator.connected());
63 auto [pos, cov] = pixelCalibrator(geoctx,
65 *dynamic_cast<const xAOD::PixelCluster*>(&measurement),
67 setState<2>(xAOD::UncalibMeasType::PixelClusterType,
70 surface->bounds().type(),
74 case xAOD::UncalibMeasType::StripClusterType: {
75 assert(stripCalibrator.connected());
76 auto [pos, cov] = stripCalibrator(geoctx,
78 *dynamic_cast<const xAOD::StripCluster*>(&measurement),
80 setState<1>(xAOD::UncalibMeasType::StripClusterType,
83 surface->bounds().type(),
87 case xAOD::UncalibMeasType::HGTDClusterType: {
88 assert(hgtdCalibrator.connected());
89 auto [pos, cov] = hgtdCalibrator(
92 *dynamic_cast<const xAOD::HGTDCluster*>(&measurement),
95 xAOD::UncalibMeasType::HGTDClusterType,
98 surface->bounds().type(),
103 throw std::domain_error("OnTrackCalibrator can only handle Pixel or Strip measurements");
107 template <typename traj_t>
108 template <std::size_t Dim, typename Cluster>
109 std::pair<xAOD::MeasVector<Dim>, xAOD::MeasMatrix<Dim>>
110 OnTrackCalibrator<traj_t>::passthrough(const Acts::GeometryContext& /*gctx*/,
111 const Acts::CalibrationContext& /*cctx*/,
112 const Cluster& cluster,
113 const TrackStateProxy& /*state*/) const
115 return std::make_pair(cluster.template localPosition<Dim>(),
116 cluster.template localCovariance<Dim>());
119 } // namespace ActsTrk