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< IExtrapolationToolm_extrapolationTool {this, "ExtrapolationTool", ""}
 Acts extrapolation tool.
PublicToolHandle< ITrackingGeometryToolm_trackingGeometryTool {this, "TrackingGeometryTool", ""}
 Tracking geometry 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.
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 31 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 82 of file ActsToTrkFitterWrapTool.cxx.

86 {
87
88 std::vector<Acts::SourceLink> sourceLinks;
89 detail::MeasurementCalibratorBase::pack(prepRawSet, sourceLinks);
90
91 const auto initialParams = m_geometryConvTool->convertTrackParametersToActs(ctx, params);
92
93 return fitImpl(ctx, sourceLinks, initialParams);
94}
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 67 of file ActsToTrkFitterWrapTool.cxx.

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

◆ 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 37 of file ActsToTrkFitterWrapTool.cxx.

41 {
42
43 std::vector<Acts::SourceLink> sourceLinks;
44 detail::MeasurementCalibratorBase::pack(measSet, sourceLinks);
45
46 bool useScaledCov = false;
47
48 return reFitImpl(ctx, track, sourceLinks, hypothesis, useScaledCov);
49}
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 52 of file ActsToTrkFitterWrapTool.cxx.

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

◆ 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 27 of file ActsToTrkFitterWrapTool.cxx.

30 {
31
32 bool useScaledCov = std::abs(m_option_seedCovarianceScale - 1.0) > Acts::s_epsilon;
33
34 return reFitImpl(ctx, track, {}, hypothesis, useScaledCov);
35}
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 97 of file ActsToTrkFitterWrapTool.cxx.

101 {
102 ATH_MSG_VERBOSE ("--> enter ActsToTrkFitterWrapTool::fit(Track,Track,)"
103 << "with Tracks from #1 = " << track1.info().dumpInfo()
104 << " and #2 = " << track2.info().dumpInfo());
105
106 // protection, if empty track2
107 if (!track2.measurementsOnTrack()) {
108 ATH_MSG_DEBUG( "input #2 is empty try to fit track 1 alone" );
109 return fit(ctx,track1);
110 }
111
112 // protection, if empty track1
113 if (!track1.measurementsOnTrack()) {
114 ATH_MSG_DEBUG( "input #1 is empty try to fit track 2 alone" );
115 return fit(ctx,track2);
116 }
117
118 std::vector<Acts::SourceLink> trackSourceLinks2 = m_ATLASConverterTool->trkTrackToSourceLinks(track2);
119
120 bool useScaledCov = std::abs(m_option_seedCovarianceScale - 1.0) > Acts::s_epsilon;
121
122 return reFitImpl(ctx, track1, trackSourceLinks2, hypothesis, useScaledCov);
123}
#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 164 of file ActsToTrkFitterWrapTool.cxx.

166 {
167 ATH_MSG_VERBOSE ("--> enter ActsToTrkFitterWrapTool::fitImpl(measColl,)"
168 << " with nMeas = " << measColl.size());
169
170 // protection against not having measurements on the input track
171 if (measColl.size() < 2) {
172 ATH_MSG_DEBUG("called to refit empty measurement set or a measurement set with too little information, reject fit");
173 return nullptr;
174 }
175
176 // Construct a perigee surface as the target surface
177 auto pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(Acts::Vector3::Zero());
178
179 const Acts::GeometryContext tgContext = m_trackingGeometryTool->getGeometryContext(ctx).context();
180 const Acts::MagneticFieldContext mfContext = m_extrapolationTool->getMagneticFieldContext(ctx);
181 const Acts::CalibrationContext calContext{getCalibrationContext(ctx)};
182
183 std::unique_ptr<MutableTrackContainer> outTracks =
184 m_actsFitterTool->fit(measColl, params, tgContext, mfContext, calContext, pSurface.get());
185
186 if (!outTracks || outTracks->size() == 0 ) {
187 ATH_MSG_DEBUG("Acts fitter failed to refit the track, reject fit");
188 return nullptr;
189 }
190
191 // We expect only one track to be returned
192 for (auto trkProxy : *outTracks) {
193
196 : xAOD::TrackFitter::Unknown;
197
198 std::unique_ptr<Trk::Track> convertedTrack =
199 m_ATLASConverterTool->convertActsToTrk(ctx, trkProxy, toTrkFitterType(fitterType));
200
201 if (convertedTrack) {
202 return convertedTrack;
203 }
204 }
205 return nullptr;
206}
@ Unknown
Definition TruthClasses.h:9
ToolHandle< IExtrapolationTool > m_extrapolationTool
Acts extrapolation tool.
ToolHandle< IFitterTool > m_actsFitterTool
The underlying Acts fitter tool.
PublicToolHandle< ITrackingGeometryTool > m_trackingGeometryTool
Tracking geometry tool.
Acts::CalibrationContext getCalibrationContext(const EventContext &ctx)
The Acts::Calibration context is piped through the Acts fitters to (re)calibrate the Acts::SourceLink...
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 16 of file ActsToTrkFitterWrapTool.cxx.

16 {
17 ATH_CHECK(m_actsFitterTool.retrieve());
21 ATH_CHECK(m_geometryConvTool.retrieve());
22
23 return StatusCode::SUCCESS;
24}
#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 126 of file ActsToTrkFitterWrapTool.cxx.

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

150{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 157 of file ActsToTrkFitterWrapTool.h.

157{this, "ATLASConverterTool", ""};

◆ m_extrapolationTool

ToolHandle<IExtrapolationTool> ActsTrk::ActsToTrkFitterWrapTool::m_extrapolationTool {this, "ExtrapolationTool", ""}
private

Acts extrapolation tool.

Definition at line 153 of file ActsToTrkFitterWrapTool.h.

153{this, "ExtrapolationTool", ""};

◆ m_geometryConvTool

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

Geometry realm converter tool.

Definition at line 159 of file ActsToTrkFitterWrapTool.h.

159{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 162 of file ActsToTrkFitterWrapTool.h.

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

◆ m_trackingGeometryTool

PublicToolHandle<ITrackingGeometryTool> ActsTrk::ActsToTrkFitterWrapTool::m_trackingGeometryTool {this, "TrackingGeometryTool", ""}
private

Tracking geometry tool.

Definition at line 155 of file ActsToTrkFitterWrapTool.h.

155{this, "TrackingGeometryTool", ""};

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