2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4 namespace ActsTrk::detail {
5 template <typename trackstate_t>
6 std::unique_ptr<Trk::RIO_OnTrack>
7 TrkPrepRawDataCalibrator::createROT(const Acts::GeometryContext &gctx,
8 const Acts::CalibrationContext & cctx,
9 const Acts::SourceLink& sl,
10 const trackstate_t& trackState) const {
12 SourceLink_t prd = unpack(sl);
13 /** @todo Check how the particle hypothesis can be retrieved from the track state */
14 const Acts::BoundTrackParameters actsParam{trackState.referenceSurface().getSharedPtr(),
15 trackState.predicted(),
16 trackState.predictedCovariance(),
17 Acts::ParticleHypothesis::pion()};
18 // Check that the conversion tool is set
19 assert(m_convTool != nullptr);
20 const auto trkParam = m_convTool->actsTrackParametersToTrkParameters(actsParam, gctx);
22 const EventContext* ctx = cctx.get<const EventContext*>();
23 /// Check that the ROT creator has been defined
24 assert(m_rotCreator != nullptr);
25 return std::unique_ptr<Trk::RIO_OnTrack>{m_rotCreator->correct(*prd, *trkParam, *ctx)};
27 template <typename trajectory_t>
28 inline void TrkPrepRawDataCalibrator::calibrate(const Acts::GeometryContext &gctx,
29 const Acts::CalibrationContext& cctx,
30 const Acts::SourceLink& sl,
31 TrackState_t<trajectory_t> trackState) const {
32 /// Calibrate the measurement
33 auto rot = createROT(gctx, cctx, sl, trackState);
34 /// Ensure that the rot is actually created.
36 /// copy the rot information onto the track state
37 m_rotCalib.calibrate<trajectory_t>(gctx, cctx, m_rotCalib.pack(rot.get()), trackState);
38 /// Overwrite the source link as the ROT leaves scope at the end of the method & is deleted
39 trackState.setUncalibratedSourceLink(pack(unpack(sl)));