ATLAS Offline Software
TrkMeasurementCalibrator.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "ActsGeometry/ATLASSourceLink.h"
6 #include "TrkSurfaces/Surface.h"
7 #include "TrkSurfaces/SurfaceBounds.h"
8 
9 #include "InDetMeasurementUtilities/ClusterConversionUtilities.h"
10 #include "TrkRIO_OnTrack/RIO_OnTrack.h"
11 #include "InDetRIO_OnTrack/SCT_ClusterOnTrack.h"
12 
13 #include <format>
14 namespace ActsTrk::detail {
15 
16  template <typename trajectory_t>
17  void TrkMeasurementCalibrator::calibrate(const Acts::GeometryContext& /*gctx*/,
18  const Acts::CalibrationContext& /*cctx*/,
19  const Acts::SourceLink& sl,
20  TrackState_t<trajectory_t> trackState) const {
21  const SourceLink_t sourceLink = unpack(sl);
22  switch (sourceLink->localParameters().dimension()) {
23  case 1: {
24  ProjectorType projector{ProjectorType::e1DimNoTime};
25  /// Hack to make the coordinate systems between Acts & Trk match for the SCT endcap hits
26  if (sourceLink->associatedSurface().bounds().type() == Trk::SurfaceBounds::Annulus) {
27  projector = ProjectorType::e1DimRotNoTime;
28  if (sourceLink->type(Trk::MeasurementBaseType::Type::RIO_OnTrack)) {
29  const auto* rot = static_cast<const Trk::RIO_OnTrack*>(sourceLink);
30  if (rot->prepRawData()->type(Trk::PrepRawDataType::SCT_Cluster)) {
31  const auto* clust = static_cast<const InDet::SCT_ClusterOnTrack*>(rot);
32  const auto [pos, cov] = TrackingUtilities::convertSCT_LocalPosCov(*clust->prepRawData());
33  setState<1, trajectory_t>(projector, pos, cov, sl, trackState);
34  break;
35  }
36  }
37  }
38  setState<1, trajectory_t>(projector, sourceLink->localParameters(), sourceLink->localCovariance(),
39  sl, trackState);
40  break;
41  } case 2: {
42  setState<2, trajectory_t>(ProjectorType::e2DimNoTime, sourceLink->localParameters(),
43  sourceLink->localCovariance(), sl, trackState);
44  break;
45  }
46  case 3: {
47  setState<3, trajectory_t>(ProjectorType::e2DimWithTime, sourceLink->localParameters(),
48  sourceLink->localCovariance(), sl, trackState);
49  break;
50  }
51  default: {
52  std::stringstream linkDump{};
53  sourceLink->dump(linkDump);
54  throw std::domain_error(std::format("TrkMeasurementCalibrator::calibrate() - Invalid dimension {:d} for measurement {:} ",
55  sourceLink->localParameters().dimension(), linkDump.str()));
56  }
57  }
58  }
59 } // namespace ActsTrk::detail
60