ATLAS Offline Software
Loading...
Searching...
No Matches
FitterTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4#include "FitterTool.h"
5
6#include "GeoModelKernel/throwExcept.h"
7
12#include "ActsInterop/Logger.h"
13
14using namespace ActsTrk::detail;
15namespace MuonR4 {
18 ATH_CHECK(m_muonCalibrator.retrieve());
22 }
23
24 m_extensions.surfaceAccessor.connect<&ActsTrk::detail::xAODUncalibMeasSurfAcc::operator()>(&m_unalibMeasSurfAcc);
26 auto logger = makeActsAthenaLogger(this, "MuonTrackFit");
27
28 Acts::Navigator::Config navConfig{m_trackingGeometrySvc->trackingGeometry()};
29 Acts::Navigator navigator(std::move(navConfig), logger->cloneWithSuffix("Navigator"));
31 CurvedPropagator_t::Stepper stepper{std::make_shared<ATLASMagneticFieldWrapper>()};
32 CurvedPropagator_t propagator{std::move(stepper),
33 std::move(navigator), logger->cloneWithSuffix("Prop")};
34 m_fitter = CurvedFitter_t{std::move(propagator), logger->cloneWithSuffix("Fitter")};
35 } else {
36 StraightPropagator_t propagator{Acts::StraightLineStepper{},
37 std::move(navigator), logger->cloneWithSuffix("Prop")};
38 m_fitter = StraightFitter_t{std::move(propagator), logger->cloneWithSuffix("Fitter")};
39 }
40 return StatusCode::SUCCESS;
41 }
42 StatusCode FitterTool::fit(const EventContext& /*ctx*/,
43 const ActsTrk::TrackContainer::ConstTrackProxy& /*track*/,
44 ActsTrk::MutableTrackContainer& /*trackContainer*/,
45 const Acts::PerigeeSurface& /*pSurface*/) const {
46 ATH_MSG_ERROR(__func__<<"() "<<__LINE__<<" - The method is not implemented");
47 return StatusCode::FAILURE;
48 }
49 std::unique_ptr<ActsTrk::MutableTrackContainer>
51 const Acts::BoundTrackParameters&/* initialParams*/,
52 const Acts::GeometryContext& /*tgContext*/,
53 const Acts::MagneticFieldContext& /*mfContext*/,
54 const Acts::CalibrationContext& /*calContext*/,
55 const Acts::Surface& /*targetSurface*/) const {
56 THROW_EXCEPTION("Method is not implemented");
57 return nullptr;
58 }
59 std::unique_ptr<ActsTrk::MutableTrackContainer>
60 FitterTool::fit(const std::vector<const xAOD::UncalibratedMeasurement* > & measList,
61 const Acts::BoundTrackParameters& initialParams,
62 const Acts::GeometryContext& tgContext,
63 const Acts::MagneticFieldContext& mfContext,
64 const Acts::CalibrationContext& calContext,
65 const Acts::Surface* targetSurface) const {
66 std::vector<Acts::SourceLink> sourceLinks{};
67 std::ranges::transform(measList, std::back_inserter(sourceLinks),
70 });
71 return fit (sourceLinks, initialParams, tgContext, mfContext, calContext, targetSurface);
72
73 }
74 std::unique_ptr<ActsTrk::MutableTrackContainer>
75 FitterTool::fit(const std::vector<Acts::SourceLink>& sourceLinks,
76 const Acts::BoundTrackParameters& initialParams,
77 const Acts::GeometryContext& tgContext,
78 const Acts::MagneticFieldContext& mfContext,
79 const Acts::CalibrationContext& calContext,
80 const Acts::Surface* /*targetSurface*/) const {
81
82 Acts::PropagatorPlainOptions propagationOption{tgContext, mfContext};
83 propagationOption.maxSteps = m_doMaxSteps;
84 propagationOption.maxTargetSkipping = m_maxSurfaces;
85
86 Gx2FitterOptions_t options{tgContext, mfContext, calContext,
87 m_extensions, std::move(propagationOption)};
88
89 options.doMultipleScattering = m_doScattering;
90 options.doEnergyLoss = m_doEnergyLoss;
91 options.nUpdateMax = m_maxIter;
92 auto tracks = std::make_unique<ActsTrk::MutableTrackContainer>(ActsTrk::MutableTrackBackend{},
94
95 bool ok{false};
96 std::visit([&](const auto& fitter) {
97 using Fitter_t = std::decay_t<decltype(fitter)>;
98 if constexpr(std::is_same_v<Fitter_t, std::monostate>) {
99 ATH_MSG_WARNING("The fitter is uninitalized. That should not happen");
100 } else {
101 ok = fitter.fit(sourceLinks.begin(), sourceLinks.end(),
102 initialParams, options, *tracks).ok();
103 }
104 }, m_fitter);
105 if (!ok) {
106 ATH_MSG_VERBOSE("Fit failed");
107 return nullptr;
108 }
110 for (auto trkProxy : *tracks) {
112 }
113 return tracks;
114 }
115}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
Definition Logger.cxx:64
static Acts::SourceLink pack(const Ptr_t &measurement)
Pack the measurement type pointer to an Acts::SourceLink including the intermediate conversion into a...
void calibrate(const Acts::GeometryContext &gctx, const Acts::CalibrationContext &cctx, const Acts::SourceLink &sl, const MutableTrackStateBackend::TrackStateProxy trackState) const
: Interface method for the Acts fitter to calibrate the trajectory track states from the source link ...
Helper class to access the Acts::surface associated with an Uncalibrated xAOD measurement.
bool fit(const LArSamples::AbsShape &data, const AbsShape &reference, double &k, double &deltaT, double &chi2, const ScaledErrorData *sed=0) const
virtual std::unique_ptr< ActsTrk::MutableTrackContainer > fit(const ActsTrk::Seed &seed, const Acts::BoundTrackParameters &initialParams, const Acts::GeometryContext &tgContext, const Acts::MagneticFieldContext &mfContext, const Acts::CalibrationContext &calContext, const Acts::Surface &targetSurface) const override final
Tries to fit a short-line track from an initial ITk/ID seed made up out of three spacepoints.
ToolHandle< MuonR4::ISpacePointCalibrator > m_muonCalibrator
Tool handle to calibrate the muon measurmeents.
Definition FitterTool.h:99
Acts::Propagator< Acts::EigenStepper<>, Acts::Navigator > CurvedPropagator_t
Abrivation for the curved standard propagator.
Definition FitterTool.h:72
Gaudi::Property< bool > m_doStraightLineFit
Do the straight line fit.
Definition FitterTool.h:84
Acts::Propagator< Acts::StraightLineStepper, Acts::Navigator > StraightPropagator_t
Abrivation for the straight line propagator.
Definition FitterTool.h:70
MuonExperimental::Gx2Fitter< StraightPropagator_t, ActsTrk::MutableTrackStateBackend > StraightFitter_t
Abrivation of the fitter using the straight line propagator.
Definition FitterTool.h:74
Gaudi::Property< bool > m_doEnergyLoss
Do energy loss modelling in the fit.
Definition FitterTool.h:92
Gaudi::Property< bool > m_doScattering
Increase the nuissances by introducing scattering angles.
Definition FitterTool.h:94
MuonExperimental::Gx2FitterOptions< ActsTrk::MutableTrackStateBackend > Gx2FitterOptions_t
Abbrivation of the configuration to launch the fit.
Definition FitterTool.h:79
ActsTrk::detail::xAODUncalibMeasSurfAcc m_unalibMeasSurfAcc
Surface accessor delegate for xAOD::UncalibratedMeasurement objects.
Definition FitterTool.h:102
virtual StatusCode initialize() override final
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
Tracking geometry service.
Definition FitterTool.h:96
Gx2FitterExtension_t m_extensions
Definition FitterTool.h:106
std::variant< std::monostate, StraightFitter_t, CurvedFitter_t > Fitter_t
Definition FitterTool.h:108
Gaudi::Property< unsigned > m_maxSurfaces
How many surfaces to try.
Definition FitterTool.h:88
Gaudi::Property< unsigned > m_doMaxSteps
How ,many steps to go.
Definition FitterTool.h:86
Gaudi::Property< unsigned > m_maxIter
How many iterations to use in the fit.
Definition FitterTool.h:90
ActsTrk::detail::xAODUncalibMeasCalibrator m_uncalibMeasCalibrator
Calibrator for the uncalibrated xAOD::UnCalibratedMeasurement objects.
Definition FitterTool.h:104
MuonExperimental::Gx2Fitter< CurvedPropagator_t, ActsTrk::MutableTrackStateBackend > CurvedFitter_t
Abrivation of the fitter using the curved line propagator.
Definition FitterTool.h:76
virtual void calibrateSourceLink(const Acts::GeometryContext &geoctx, const Acts::CalibrationContext &cctx, const Acts::SourceLink &link, ActsTrk::MutableTrackStateBackend::TrackStateProxy state) const =0
Function that's hooked to the calibration delegate of the implemented Acts fitters.
static Root::TMsgLogger logger("iLumiCalc")
Hash functions to pack the source link into unordered_maps / unordered_sets.
Acts::VectorMultiTrajectory MutableTrackStateBackend
Acts::TrackContainer< MutableTrackBackend, MutableTrackStateBackend, Acts::detail::ValueHolder > MutableTrackContainer
Acts::VectorTrackContainer MutableTrackBackend
This header ties the generic definitions in this package.
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.
@ GlobalChi2Fitter
Track's from Thijs' global chi^2 fitter or the ACTS implementation.
UncalibMeasType
Define the type of the uncalibrated measurement.
std::span< const UncalibMeasType > muonMeasurementTypes()
Returns a view on all the defined muon measurement types.
static void addFitterTypeProperty(track_container_t &tracksContainer)
add fitter column to the track container
static void setFitterType(trackproxy_t &trackProxy, xAOD::TrackFitter fitterType)
set fitter type of a track
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10