Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
OnTrackCalibrator.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "ActsGeometry/SurfaceOfMeasurementUtil.h"
6 #include "ActsGeometry/ATLASSourceLink.h"
7 
8 namespace ActsTrk::detail {
9 
10  template <typename traj_t>
11  OnTrackCalibrator<traj_t> OnTrackCalibrator<traj_t>::NoCalibration(const Acts::TrackingGeometry &trackingGeometry,
12  const ActsTrk::DetectorElementToActsGeometryIdMap &detectorElementToGeoId)
13  {
14  ToolHandle<IOnTrackCalibratorTool<traj_t>> null(nullptr);
15  return OnTrackCalibrator<traj_t>(trackingGeometry, detectorElementToGeoId, null, null, null);
16  }
17 
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)
26  {
27  if (pixelTool.isEnabled()) {
28  pixelTool->connect(*this);
29  } else {
30  pixelCalibrator.template connect<&OnTrackCalibrator<traj_t>::passthrough<2, xAOD::PixelCluster>>(this);
31  }
32 
33  if (stripTool.isEnabled()) {
34  stripTool->connect(*this);
35  } else {
36  stripCalibrator.template connect<&OnTrackCalibrator<traj_t>::passthrough<1, xAOD::StripCluster>>(this);
37  }
38  if (hgtdTool.isEnabled()) {
39  hgtdTool->connect(*this);
40  } else {
41  // cppcheck-suppress missingReturn; false positive
42  hgtdCalibrator.template connect<&OnTrackCalibrator<traj_t>::passthrough<3, xAOD::HGTDCluster>>(this);
43  }
44  }
45 
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
52  {
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,
64  cctx,
65  *dynamic_cast<const xAOD::PixelCluster*>(&measurement),
66  state);
67  setState<2>(xAOD::UncalibMeasType::PixelClusterType,
68  pos,
69  cov,
70  surface->bounds().type(),
71  state);
72  break;
73  }
74  case xAOD::UncalibMeasType::StripClusterType: {
75  assert(stripCalibrator.connected());
76  auto [pos, cov] = stripCalibrator(geoctx,
77  cctx,
78  *dynamic_cast<const xAOD::StripCluster*>(&measurement),
79  state);
80  setState<1>(xAOD::UncalibMeasType::StripClusterType,
81  pos,
82  cov,
83  surface->bounds().type(),
84  state);
85  break;
86  }
87  case xAOD::UncalibMeasType::HGTDClusterType: {
88  assert(hgtdCalibrator.connected());
89  auto [pos, cov] = hgtdCalibrator(
90  geoctx,
91  cctx,
92  *dynamic_cast<const xAOD::HGTDCluster*>(&measurement),
93  state);
94  setState<3>(
95  xAOD::UncalibMeasType::HGTDClusterType,
96  pos,
97  cov,
98  surface->bounds().type(),
99  state);
100  break;
101  }
102  default:
103  throw std::domain_error("OnTrackCalibrator can only handle Pixel or Strip measurements");
104  }
105  }
106 
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
114  {
115  return std::make_pair(cluster.template localPosition<Dim>(),
116  cluster.template localCovariance<Dim>());
117  }
118 
119 } // namespace ActsTrk
120