ATLAS Offline Software
Loading...
Searching...
No Matches
ActsTrk::ActsToTrkFitterWrapTool Class Reference

Tool wrapping an ACTS track fitter tool to expose the Trk::ITrackFitter interface. More...

#include <ActsToTrkFitterWrapTool.h>

Inheritance diagram for ActsTrk::ActsToTrkFitterWrapTool:
Collaboration diagram for ActsTrk::ActsToTrkFitterWrapTool:

Public Member Functions

 ~ActsToTrkFitterWrapTool ()=default
StatusCode initialize () override
virtual std::unique_ptr< Trk::Trackfit (const EventContext &ctx, const Trk::Track &track, const Trk::RunOutlierRemoval runOutlier=false, const Trk::ParticleHypothesis hypothesis=Trk::nonInteracting) const override
 Re-fit a track using the ACTS fitter tool.
virtual std::unique_ptr< Trk::Trackfit (const EventContext &ctx, const Trk::Track &track, const Trk::MeasurementSet &measSet, const Trk::RunOutlierRemoval runOutlier=false, const Trk::ParticleHypothesis hypothesis=Trk::nonInteracting) const override
 Re-fit a track adding a fittable measurement set.
virtual std::unique_ptr< Trk::Trackfit (const EventContext &ctx, const Trk::Track &track, const Trk::PrepRawDataSet &prepRawSet, const Trk::RunOutlierRemoval runOutlier=false, const Trk::ParticleHypothesis hypothesis=Trk::nonInteracting) const override
 Re-fit a track adding a set of prepared raw data.
virtual std::unique_ptr< Trk::Trackfit (const EventContext &ctx, const Trk::PrepRawDataSet &prepRawSet, const Trk::TrackParameters &params, const Trk::RunOutlierRemoval runOutlier=false, const Trk::ParticleHypothesis hypothesis=Trk::nonInteracting) const override
 Fit a track to a set of prepared raw data.
virtual std::unique_ptr< Trk::Trackfit (const EventContext &ctx, const Trk::MeasurementSet &measSet, const Trk::TrackParameters &params, const Trk::RunOutlierRemoval runOutlier=false, const Trk::ParticleHypothesis hypothesis=Trk::nonInteracting) const override
 Fit a track to a set of measurements.
virtual std::unique_ptr< Trk::Trackfit (const EventContext &ctx, const Trk::Track &track1, const Trk::Track &track2, const Trk::RunOutlierRemoval runOutlier=false, const Trk::ParticleHypothesis hypothesis=Trk::nonInteracting) const override
 Combines two tracks by fitting them together.

Private Member Functions

std::unique_ptr< Trk::TrackreFitImpl (const EventContext &ctx, const Trk::Track &track, const std::vector< Acts::SourceLink > &measColl, const Trk::ParticleHypothesis hypothesis, const bool useScaledCov=false) const
 Implementation of the logic for re-fitting a track adding a set of measurements passed as source links.
std::unique_ptr< Trk::TrackfitImpl (const EventContext &ctx, const std::vector< Acts::SourceLink > &measColl, const Acts::BoundTrackParameters &params) const
 Implementation of the logic for fitting a track to a set of measurements passed as source links.

Private Attributes

ToolHandle< IFitterToolm_actsFitterTool {this, "ActsFitterTool", ""}
 The underlying Acts fitter tool.
ToolHandle< ITrackConverterToolm_ATLASConverterTool {this, "ATLASConverterTool", ""}
 Track converter tool for converting Acts tracks to ATLAS tracks.
PublicToolHandle< IGeometryRealmConvToolm_geometryConvTool {this, "GeometryRealmConvTool", ""}
 Geometry realm converter tool.
ContextUtility m_ctxProvider {this}
 Auxiliary class to access the magnetic field, geometry and calibration context.
Gaudi::Property< double > m_option_seedCovarianceScale
 Property for the seed covariance scale factor.

Detailed Description

Tool wrapping an ACTS track fitter tool to expose the Trk::ITrackFitter interface.

The EDM objects are piped to the Acts::IFitterTool interface and processed by the ACTS infrastructure. The successful fit result is then converted back to a Trk::Track object. The wrapper leverages the usage of the ACTS fitters in the legacy reconstruction framework and is mainly meant to be used for validation and testing purposes.

Definition at line 29 of file ActsToTrkFitterWrapTool.h.

Constructor & Destructor Documentation

◆ ~ActsToTrkFitterWrapTool()

ActsTrk::ActsToTrkFitterWrapTool::~ActsToTrkFitterWrapTool ( )
default

Member Function Documentation

◆ fit() [1/6]

std::unique_ptr< Trk::Track > ActsTrk::ActsToTrkFitterWrapTool::fit ( const EventContext & ctx,
const Trk::MeasurementSet & measSet,
const Trk::TrackParameters & params,
const Trk::RunOutlierRemoval runOutlier = false,
const Trk::ParticleHypothesis hypothesis = Trk::nonInteracting ) const
overridevirtual

Fit a track to a set of measurements.

Parameters
ctxThe event context.
measSetThe measurement set.
paramsThe initial track parameters.
runOutlierWhether to run outlier removal.
hypothesisThe particle hypothesis.
Returns
A unique pointer to the fitted track.

Definition at line 79 of file ActsToTrkFitterWrapTool.cxx.

83 {
84
85 std::vector<Acts::SourceLink> sourceLinks;
86 detail::MeasurementCalibratorBase::pack(prepRawSet, sourceLinks);
87
88 const auto initialParams = m_geometryConvTool->convertTrackParametersToActs(ctx, params);
89
90 return fitImpl(ctx, sourceLinks, initialParams);
91}
std::unique_ptr< Trk::Track > fitImpl(const EventContext &ctx, const std::vector< Acts::SourceLink > &measColl, const Acts::BoundTrackParameters &params) const
Implementation of the logic for fitting a track to a set of measurements passed as source links.
PublicToolHandle< IGeometryRealmConvTool > m_geometryConvTool
Geometry realm converter tool.
static Acts::SourceLink pack(const Ptr_t &measurement)
Pack the measurement type pointer to an Acts::SourceLink including the intermediate conversion into a...

◆ fit() [2/6]

std::unique_ptr< Trk::Track > ActsTrk::ActsToTrkFitterWrapTool::fit ( const EventContext & ctx,
const Trk::PrepRawDataSet & prepRawSet,
const Trk::TrackParameters & params,
const Trk::RunOutlierRemoval runOutlier = false,
const Trk::ParticleHypothesis hypothesis = Trk::nonInteracting ) const
overridevirtual

Fit a track to a set of prepared raw data.

Parameters
ctxThe event context.
prepRawSetThe set of prepared raw data.
paramsThe initial track parameters.
runOutlierWhether to run outlier removal.
hypothesisThe particle hypothesis.
Returns
A unique pointer to the fitted track.

Definition at line 64 of file ActsToTrkFitterWrapTool.cxx.

68 {
69
70 std::vector<Acts::SourceLink> sourceLinks;
71 detail::MeasurementCalibratorBase::pack(prepRawSet, sourceLinks);
72
73 const auto initialParams = m_geometryConvTool->convertTrackParametersToActs(ctx, params);
74
75 return fitImpl(ctx, sourceLinks, initialParams);
76}

◆ fit() [3/6]

std::unique_ptr< Trk::Track > ActsTrk::ActsToTrkFitterWrapTool::fit ( const EventContext & ctx,
const Trk::Track & track,
const Trk::MeasurementSet & measSet,
const Trk::RunOutlierRemoval runOutlier = false,
const Trk::ParticleHypothesis hypothesis = Trk::nonInteracting ) const
overridevirtual

Re-fit a track adding a fittable measurement set.

Parameters
ctxThe event context.
trackThe input track.
measSetThe measurement set to add.
runOutlierWhether to run outlier removal.
hypothesisThe particle hypothesis.
Returns
A unique pointer to the fitted track.

Definition at line 34 of file ActsToTrkFitterWrapTool.cxx.

38 {
39
40 std::vector<Acts::SourceLink> sourceLinks;
41 detail::MeasurementCalibratorBase::pack(measSet, sourceLinks);
42
43 bool useScaledCov = false;
44
45 return reFitImpl(ctx, track, sourceLinks, hypothesis, useScaledCov);
46}
std::unique_ptr< Trk::Track > reFitImpl(const EventContext &ctx, const Trk::Track &track, const std::vector< Acts::SourceLink > &measColl, const Trk::ParticleHypothesis hypothesis, const bool useScaledCov=false) const
Implementation of the logic for re-fitting a track adding a set of measurements passed as source link...

◆ fit() [4/6]

std::unique_ptr< Trk::Track > ActsTrk::ActsToTrkFitterWrapTool::fit ( const EventContext & ctx,
const Trk::Track & track,
const Trk::PrepRawDataSet & prepRawSet,
const Trk::RunOutlierRemoval runOutlier = false,
const Trk::ParticleHypothesis hypothesis = Trk::nonInteracting ) const
overridevirtual

Re-fit a track adding a set of prepared raw data.

Parameters
ctxThe event context.
trackThe input track.
prepRawSetThe set of prepared raw data to add.
runOutlierWhether to run outlier removal.
hypothesisThe particle hypothesis.
Returns
A unique pointer to the fitted track.

Definition at line 49 of file ActsToTrkFitterWrapTool.cxx.

53 {
54
55 std::vector<Acts::SourceLink> sourceLinks;
56 detail::MeasurementCalibratorBase::pack(prepRawSet, sourceLinks);
57
58 bool useScaledCov = false;
59
60 return reFitImpl(ctx, track, sourceLinks, hypothesis, useScaledCov);
61}

◆ fit() [5/6]

std::unique_ptr< Trk::Track > ActsTrk::ActsToTrkFitterWrapTool::fit ( const EventContext & ctx,
const Trk::Track & track,
const Trk::RunOutlierRemoval runOutlier = false,
const Trk::ParticleHypothesis hypothesis = Trk::nonInteracting ) const
overridevirtual

Re-fit a track using the ACTS fitter tool.

Parameters
ctxThe event context.
trackThe input track.
runOutlierWhether to run outlier removal.
hypothesisThe particle hypothesis.
Returns
A unique pointer to the fitted track.

Definition at line 24 of file ActsToTrkFitterWrapTool.cxx.

27 {
28
29 bool useScaledCov = std::abs(m_option_seedCovarianceScale - 1.0) > Acts::s_epsilon;
30
31 return reFitImpl(ctx, track, {}, hypothesis, useScaledCov);
32}
Gaudi::Property< double > m_option_seedCovarianceScale
Property for the seed covariance scale factor.

◆ fit() [6/6]

std::unique_ptr< Trk::Track > ActsTrk::ActsToTrkFitterWrapTool::fit ( const EventContext & ctx,
const Trk::Track & track1,
const Trk::Track & track2,
const Trk::RunOutlierRemoval runOutlier = false,
const Trk::ParticleHypothesis hypothesis = Trk::nonInteracting ) const
overridevirtual

Combines two tracks by fitting them together.

Parameters
ctxThe event context.
track1The first track.
track2The second track.
runOutlierWhether to run outlier removal.
hypothesisThe particle hypothesis.
Returns
A unique pointer to the combined track.

Definition at line 94 of file ActsToTrkFitterWrapTool.cxx.

98 {
99 ATH_MSG_VERBOSE ("--> enter ActsToTrkFitterWrapTool::fit(Track,Track,)"
100 << "with Tracks from #1 = " << track1.info().dumpInfo()
101 << " and #2 = " << track2.info().dumpInfo());
102
103 // protection, if empty track2
104 if (!track2.measurementsOnTrack()) {
105 ATH_MSG_DEBUG( "input #2 is empty try to fit track 1 alone" );
106 return fit(ctx,track1);
107 }
108
109 // protection, if empty track1
110 if (!track1.measurementsOnTrack()) {
111 ATH_MSG_DEBUG( "input #1 is empty try to fit track 2 alone" );
112 return fit(ctx,track2);
113 }
114
115 std::vector<Acts::SourceLink> trackSourceLinks2 = m_ATLASConverterTool->trkTrackToSourceLinks(track2);
116
117 bool useScaledCov = std::abs(m_option_seedCovarianceScale - 1.0) > Acts::s_epsilon;
118
119 return reFitImpl(ctx, track1, trackSourceLinks2, hypothesis, useScaledCov);
120}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
virtual std::unique_ptr< Trk::Track > fit(const EventContext &ctx, const Trk::Track &track, const Trk::RunOutlierRemoval runOutlier=false, const Trk::ParticleHypothesis hypothesis=Trk::nonInteracting) const override
Re-fit a track using the ACTS fitter tool.
ToolHandle< ITrackConverterTool > m_ATLASConverterTool
Track converter tool for converting Acts tracks to ATLAS tracks.
std::string dumpInfo() const
Returns a string with the name of the fitter of this track (i.e.
const DataVector< const MeasurementBase > * measurementsOnTrack() const
return a pointer to a vector of MeasurementBase (NOT including any that come from outliers).
const TrackInfo & info() const
Returns a const ref to info of a const tracks.

◆ fitImpl()

std::unique_ptr< Trk::Track > ActsTrk::ActsToTrkFitterWrapTool::fitImpl ( const EventContext & ctx,
const std::vector< Acts::SourceLink > & measColl,
const Acts::BoundTrackParameters & params ) const
private

Implementation of the logic for fitting a track to a set of measurements passed as source links.

Parameters
ctxThe event context.
measCollThe collection of measurements.
paramsThe initial track parameters.
Returns
A unique pointer to the fitted track.

Definition at line 161 of file ActsToTrkFitterWrapTool.cxx.

163 {
164 ATH_MSG_VERBOSE ("--> enter ActsToTrkFitterWrapTool::fitImpl(measColl,)"
165 << " with nMeas = " << measColl.size());
166
167 // protection against not having measurements on the input track
168 if (measColl.size() < 2) {
169 ATH_MSG_DEBUG("called to refit empty measurement set or a measurement set with too little information, reject fit");
170 return nullptr;
171 }
172
173 // Construct a perigee surface as the target surface
174 auto pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(Acts::Vector3::Zero());
175
176 const Acts::GeometryContext tgContext{m_ctxProvider.getGeometryContext(ctx)};
177 const Acts::MagneticFieldContext mfContext{m_ctxProvider.getMagneticFieldContext(ctx)};
178 const Acts::CalibrationContext calContext{m_ctxProvider.getCalibrationContext(ctx)};
179
180 std::unique_ptr<MutableTrackContainer> outTracks =
181 m_actsFitterTool->fit(measColl, params, tgContext, mfContext, calContext, pSurface.get());
182
183 if (!outTracks || outTracks->size() == 0 ) {
184 ATH_MSG_DEBUG("Acts fitter failed to refit the track, reject fit");
185 return nullptr;
186 }
187
188 // We expect only one track to be returned
189 for (auto trkProxy : *outTracks) {
190
193 : xAOD::TrackFitter::Unknown;
194
195 std::unique_ptr<Trk::Track> convertedTrack =
196 m_ATLASConverterTool->convertActsToTrk(ctx, trkProxy, toTrkFitterType(fitterType));
197
198 if (convertedTrack) {
199 return convertedTrack;
200 }
201 }
202 return nullptr;
203}
@ Unknown
Definition TruthClasses.h:9
ToolHandle< IFitterTool > m_actsFitterTool
The underlying Acts fitter tool.
ContextUtility m_ctxProvider
Auxiliary class to access the magnetic field, geometry and calibration context.
Trk::TrackInfo::TrackFitter toTrkFitterType(const xAOD::TrackFitter fType)
Converts xAOD fitter type to Trk fitter type.
TrackFitter
Enums to identify who created this track and which properties does it have.
static xAOD::TrackFitter fitterType(const consttrackproxy_t &trackProxy)
get fitter type of a track
static bool hasFitterType(const consttrackproxy_t &trackProxy)
test whether a track has a fitter type

◆ initialize()

StatusCode ActsTrk::ActsToTrkFitterWrapTool::initialize ( )
override

Definition at line 15 of file ActsToTrkFitterWrapTool.cxx.

15 {
16 ATH_CHECK(m_actsFitterTool.retrieve());
18 ATH_CHECK(m_geometryConvTool.retrieve());
19 ATH_CHECK(m_ctxProvider.initialize());
20 return StatusCode::SUCCESS;
21}
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ reFitImpl()

std::unique_ptr< Trk::Track > ActsTrk::ActsToTrkFitterWrapTool::reFitImpl ( const EventContext & ctx,
const Trk::Track & track,
const std::vector< Acts::SourceLink > & measColl,
const Trk::ParticleHypothesis hypothesis,
const bool useScaledCov = false ) const
private

Implementation of the logic for re-fitting a track adding a set of measurements passed as source links.

Parameters
ctxThe event context.
trackThe input track.
measCollThe collection of measurements.
hypothesisThe particle hypothesis.
useScaledCovWhether to use scaled covariance.
Returns
A unique pointer to the re-fitted track.

Definition at line 123 of file ActsToTrkFitterWrapTool.cxx.

127 {
128 ATH_MSG_VERBOSE ("--> enter ActsToTrkFitterWrapTool::reFitImpl(Track,measColl,)"
129 << " with Track from author = " << track.info().dumpInfo());
130
131 // protection against not having measurements on the input track
132 if (!track.measurementsOnTrack() || (track.measurementsOnTrack()->size() < 2 && measColl.empty())) {
133 ATH_MSG_DEBUG("called to refit empty track or track with too little information, reject fit");
134 return nullptr;
135 }
136
137 // protection against not having track parameters on the input track
138 if (!track.trackParameters() || track.trackParameters()->empty()) {
139 ATH_MSG_DEBUG("input fails to provide track parameters for seeding the fitter, reject fit");
140 return nullptr;
141 }
142
143 std::vector<Acts::SourceLink> trackSourceLinks = m_ATLASConverterTool->trkTrackToSourceLinks(track);
144 trackSourceLinks.insert(trackSourceLinks.end(), std::make_move_iterator(measColl.begin()),
145 std::make_move_iterator(measColl.end()));
146
147 auto initialParams = m_geometryConvTool->convertTrackParametersToActs(ctx, *track.perigeeParameters());
148 if (useScaledCov) {
149 // The covariance from already fitted track are too small and would result an incorect smoothing.
150 // We scale up the input covaraiance to avoid this.
151 Acts::BoundMatrix scaledCov = m_option_seedCovarianceScale * (*initialParams.covariance());
152 initialParams = Acts::BoundTrackParameters(initialParams.referenceSurface().getSharedPtr(),
153 initialParams.parameters(),
154 scaledCov, ParticleHypothesis::convert(hypothesis));
155 }
156
157 return fitImpl(ctx, trackSourceLinks, initialParams);
158}
xAOD::ParticleHypothesis convert(Acts::ParticleHypothesis h)

Member Data Documentation

◆ m_actsFitterTool

ToolHandle<IFitterTool> ActsTrk::ActsToTrkFitterWrapTool::m_actsFitterTool {this, "ActsFitterTool", ""}
private

The underlying Acts fitter tool.

Definition at line 148 of file ActsToTrkFitterWrapTool.h.

148{this, "ActsFitterTool", ""};

◆ m_ATLASConverterTool

ToolHandle<ITrackConverterTool> ActsTrk::ActsToTrkFitterWrapTool::m_ATLASConverterTool {this, "ATLASConverterTool", ""}
private

Track converter tool for converting Acts tracks to ATLAS tracks.

Definition at line 151 of file ActsToTrkFitterWrapTool.h.

151{this, "ATLASConverterTool", ""};

◆ m_ctxProvider

ContextUtility ActsTrk::ActsToTrkFitterWrapTool::m_ctxProvider {this}
private

Auxiliary class to access the magnetic field, geometry and calibration context.

Definition at line 155 of file ActsToTrkFitterWrapTool.h.

155{this};

◆ m_geometryConvTool

PublicToolHandle<IGeometryRealmConvTool> ActsTrk::ActsToTrkFitterWrapTool::m_geometryConvTool {this, "GeometryRealmConvTool", ""}
private

Geometry realm converter tool.

Definition at line 153 of file ActsToTrkFitterWrapTool.h.

153{this, "GeometryRealmConvTool", ""};

◆ m_option_seedCovarianceScale

Gaudi::Property< double > ActsTrk::ActsToTrkFitterWrapTool::m_option_seedCovarianceScale
private
Initial value:
{this, "SeedCovarianceScale", 1.,
"Scale factor for the input seed covariance when doing refitting"}

Property for the seed covariance scale factor.

Definition at line 157 of file ActsToTrkFitterWrapTool.h.

157 {this, "SeedCovarianceScale", 1.,
158 "Scale factor for the input seed covariance when doing refitting"};

The documentation for this class was generated from the following files: