ATLAS Offline Software
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 #ifndef ONTRACKCALIBRATOR_ICC
6 #define ONTRACKCALIBRATOR_ICC
7 
8 namespace ActsTrk {
9 
10 template <typename traj_t>
11 OnTrackCalibrator<traj_t> OnTrackCalibrator<traj_t>::NoCalibration(
12  const ActsTrk::IActsToTrkConverterTool &converter_tool,
13  const TrackingSurfaceHelper &surface_helper)
14 {
15  ToolHandle<IOnTrackCalibratorTool<traj_t>> null(nullptr);
16  return OnTrackCalibrator(converter_tool, surface_helper, null, null);
17 }
18 
19 template <typename traj_t>
20 OnTrackCalibrator<traj_t>::OnTrackCalibrator(
21  const ActsTrk::IActsToTrkConverterTool &converter_tool,
22  const TrackingSurfaceHelper &surface_helper,
23  const ToolHandle<IOnTrackCalibratorTool<traj_t>>& pixelTool,
24  const ToolHandle<IOnTrackCalibratorTool<traj_t>>& stripTool)
25  : MeasurementCalibratorBase(converter_tool),
26  m_surfaceHelper(&surface_helper)
27 {
28  if (pixelTool.isEnabled()) {
29  pixelTool->connect(*this);
30  } else {
31  pixel_calibrator.template connect<&OnTrackCalibrator<traj_t>::passthrough<2, xAOD::PixelCluster>>(this);
32  }
33 
34  if (stripTool.isEnabled()) {
35  stripTool->connect(*this);
36  } else {
37  // cppcheck-suppress missingReturn; false positive
38  strip_calibrator.template connect<&OnTrackCalibrator<traj_t>::passthrough<1, xAOD::StripCluster>>(this);
39  }
40 }
41 
42 template <typename traj_t>
43 void OnTrackCalibrator<traj_t>::calibrate(
44  const Acts::GeometryContext& geoctx,
45  const Acts::CalibrationContext& cctx,
46  const Acts::SourceLink& link,
47  TrackStateProxy state) const
48 {
49  state.setUncalibratedSourceLink(link);
50  ATLASUncalibSourceLink sourceLink = link.template get<ATLASUncalibSourceLink>();
51  assert(sourceLink!=nullptr);
52  const xAOD::UncalibratedMeasurement &measurement = getUncalibratedMeasurement(sourceLink);
53  const Acts::Surface &surface = m_surfaceHelper->associatedActsSurface(measurement);
54 
55  switch (measurement.type()) {
56  case xAOD::UncalibMeasType::PixelClusterType: {
57  assert(pixel_calibrator.connected());
58  auto [pos, cov] = pixel_calibrator(
59  geoctx,
60  cctx,
61  *dynamic_cast<const xAOD::PixelCluster*>(&measurement),
62  state);
63  setState<2>(
64  xAOD::UncalibMeasType::PixelClusterType,
65  pos,
66  cov,
67  surface.bounds().type(),
68  state);
69  break;
70  }
71  case xAOD::UncalibMeasType::StripClusterType: {
72  assert(strip_calibrator.connected());
73  auto [pos, cov] = strip_calibrator(
74  geoctx,
75  cctx,
76  *dynamic_cast<const xAOD::StripCluster*>(&measurement),
77  state);
78  setState<1>(
79  xAOD::UncalibMeasType::StripClusterType,
80  pos,
81  cov,
82  surface.bounds().type(),
83  state);
84  break;
85  }
86  default:
87  throw std::domain_error("OnTrackCalibrator can only handle Pixel or Strip measurements");
88  }
89 }
90 
91 template <typename traj_t>
92 template <std::size_t Dim, typename Cluster>
93 std::pair<xAOD::MeasVector<Dim>, xAOD::MeasMatrix<Dim>>
94 OnTrackCalibrator<traj_t>::passthrough(
95  const Acts::GeometryContext& /*gctx*/,
96  const Acts::CalibrationContext& /*cctx*/,
97  const Cluster& cluster,
98  const TrackStateProxy& /*state*/) const
99 {
100  return std::make_pair(cluster.template localPosition<Dim>(),
101  cluster.template localCovariance<Dim>());
102 }
103 
104 
105 } // namespace ActsTrk
106 
107 #endif