15#include "Acts/Propagator/MultiEigenStepperLoop.hpp"
16#include "Acts/MagneticField/MagneticFieldContext.hpp"
17#include "Acts/Surfaces/PerigeeSurface.hpp"
18#include "Acts/Utilities/CalibrationContext.hpp"
19#include "Acts/Definitions/TrackParametrization.hpp"
20#include "Acts/Definitions/Units.hpp"
21#include "Acts/Propagator/EigenStepper.hpp"
22#include "Acts/Surfaces/Surface.hpp"
23#include "Acts/TrackFitting/GsfMixtureReduction.hpp"
24#include "Acts/Utilities/Helpers.hpp"
25#include "Acts/EventData/VectorMultiTrajectory.hpp"
26#include "Acts/EventData/VectorTrackContainer.hpp"
27#include "Acts/EventData/BoundTrackParameters.hpp"
28#include "Acts/Utilities/Logger.hpp"
29#include "Acts/Utilities/CalibrationContext.hpp"
38#include "Acts/Propagator/DirectNavigator.hpp"
45#include <system_error>
52Acts::AtlasBetheHeitlerApprox::Data readBHParFile(
const std::string& path) {
53 std::ifstream
fin(path);
55 throw std::invalid_argument(
"Could not open BH par file: " + path);
57 std::size_t n_cmps = 0,
degree = 0;
59 if (!fin || n_cmps == 0 || degree == 0) {
60 throw std::invalid_argument(
"Bad header in BH par file: " + path);
62 Acts::AtlasBetheHeitlerApprox::Data
data(n_cmps);
63 for (
auto& cmp : data) {
64 cmp.weightCoeffs.resize(degree + 1);
65 cmp.meanCoeffs.resize(degree + 1);
66 cmp.varCoeffs.resize(degree + 1);
67 for (
double& c :
cmp.weightCoeffs) {
fin >>
c; }
68 for (
double& c :
cmp.meanCoeffs) {
fin >>
c; }
69 for (
double& c :
cmp.varCoeffs) {
fin >>
c; }
72 throw std::invalid_argument(
"Truncated data in BH par file: " + path);
96 auto field = std::make_shared<ATLASMagneticFieldWrapper>();
97 Acts::MultiEigenStepperLoop<> stepper(field);
99 logger().cloneWithSuffix(
"Navigator") );
100 Acts::Propagator<Acts::MultiEigenStepperLoop<>, Acts::Navigator> propagator(std::move(stepper),
101 std::move(navigator),
102 logger().cloneWithSuffix(
"Prop"));
110 ATH_MSG_INFO(
"ACTS GSF: loading GeantSim BH parameterisation (" << bhLow <<
", " << bhHigh <<
")");
111 auto bha = std::make_shared<Acts::AtlasBetheHeitlerApprox>(
112 readBHParFile(bhLow), readBHParFile(bhHigh),
116 m_fitter = std::make_unique<Fitter>(std::move(propagator), bha,
117 logger().cloneWithSuffix(
"GaussianSumFitter"));
121 Acts::DirectNavigator directNavigator(
logger().cloneWithSuffix(
"DirectNavigator") );
122 Acts::MultiEigenStepperLoop<> stepperDirect(field);
123 Acts::Propagator<Acts::MultiEigenStepperLoop<>, Acts::DirectNavigator> directPropagator(std::move(stepperDirect),
124 std::move(directNavigator),
125 logger().cloneWithSuffix(
"DirectPropagator"));
126 m_directFitter = std::make_unique<DirectFitter>(std::move(directPropagator), bha,
127 logger().cloneWithSuffix(
"DirectGaussianSumFitter"));
132 m_calibrator = std::make_unique<ActsTrk::detail::TrkMeasurementCalibrator>();
137 m_gsfExtensions.mixtureReducer.connect<&Acts::reduceMixtureWithKLDistance>();
155 return StatusCode::SUCCESS;
160std::unique_ptr<Trk::Track>
168 std::unique_ptr<Trk::Track> track =
nullptr;
169 ATH_MSG_VERBOSE (
"--> enter GaussianSumFitter::fit(Track,,) with Track from author = "
174 ATH_MSG_DEBUG(
"called to refit empty track or track with too little information, reject fit");
180 ATH_MSG_DEBUG(
"input fails to provide track parameters for seeding the GSF, reject fit");
185 std::shared_ptr<Acts::PerigeeSurface> pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(
186 Acts::Vector3::Zero());
189 const Acts::MagneticFieldContext mfContext =
m_extrapolationTool->getMagneticFieldContext(ctx);
193 Acts::GsfOptions<ActsTrk::MutableTrackStateBackend>
203 std::vector<Acts::SourceLink> trackSourceLinks =
m_ATLASConverterTool->trkTrackToSourceLinks(inputTrack);
214std::unique_ptr<Trk::Track>
221 std::unique_ptr<Trk::Track> track =
nullptr;
223 if (inputMeasSet.size() < 2) {
224 ATH_MSG_DEBUG(
"called to refit empty measurement set or a measurement set with too little information, reject fit");
229 std::shared_ptr<Acts::PerigeeSurface> pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(
230 Acts::Vector3::Zero());
233 const Acts::MagneticFieldContext mfContext =
m_extrapolationTool->getMagneticFieldContext(ctx);
237 Acts::GsfOptions<ActsTrk::MutableTrackStateBackend>
244 gsfOptions.abortOnError =
false;
246 std::vector< Acts::SourceLink > trackSourceLinks;
249 const auto initialParams =
m_geometryConvTool->convertTrackParametersToActs(ctx, estimatedStartParameters);
253 std::vector<const Acts::Surface*> surfaces;
254 surfaces.reserve(inputMeasSet.size());
255 std::ranges::transform(trackSourceLinks, std::back_inserter(surfaces),
m_surfaceAccessor);
272std::unique_ptr<Trk::Track>
287std::unique_ptr<Trk::Track>
294 ATH_MSG_VERBOSE (
"--> enter GaussianSumFitter::fit(Track,Meas'BaseSet,,)");
298 if (addMeasColl.empty()) {
299 ATH_MSG_DEBUG(
"client tries to add an empty MeasurementSet to the track fit." );
300 return fit(ctx,inputTrack);
305 ATH_MSG_DEBUG(
"called to refit empty track or track with too little information, reject fit");
311 ATH_MSG_DEBUG(
"input fails to provide track parameters for seeding the GSF, reject fit");
315 std::unique_ptr<Trk::Track> track =
nullptr;
318 std::shared_ptr<Acts::PerigeeSurface> pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(Acts::Vector3::Zero());
321 const Acts::MagneticFieldContext mfContext =
m_extrapolationTool->getMagneticFieldContext(ctx);
325 Acts::GsfOptions<ActsTrk::MutableTrackStateBackend>
331 std::vector<Acts::SourceLink> trackSourceLinks =
m_ATLASConverterTool->trkTrackToSourceLinks(inputTrack);
343std::unique_ptr<Trk::Track>
351 ATH_MSG_DEBUG(
"Fit of Track with additional PrepRawDataSet not yet implemented");
357std::unique_ptr<Trk::Track>
370 ATH_MSG_DEBUG(
"input #2 is empty try to fit track 1 alone" );
371 return fit(ctx,intrk1);
376 ATH_MSG_DEBUG(
"input #1 is empty try to fit track 2 alone" );
377 return fit(ctx,intrk2);
382 ATH_MSG_DEBUG(
"input #1 fails to provide track parameters for seeding the GSF, reject fit");
386 std::unique_ptr<Trk::Track> track =
nullptr;
389 std::shared_ptr<Acts::PerigeeSurface> pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(
390 Acts::Vector3::Zero());
393 const Acts::MagneticFieldContext mfContext =
m_extrapolationTool->getMagneticFieldContext(ctx);
397 Acts::GsfOptions<ActsTrk::MutableTrackStateBackend>
403 std::vector<Acts::SourceLink> trackSourceLinks =
m_ATLASConverterTool->trkTrackToSourceLinks(intrk1);
404 std::vector<Acts::SourceLink> trackSourceLinks2 =
m_ATLASConverterTool->trkTrackToSourceLinks(intrk2);
405 trackSourceLinks.insert(trackSourceLinks.end(), trackSourceLinks2.begin(), trackSourceLinks2.end());
414std::unique_ptr< ActsTrk::MutableTrackContainer >
416 const Acts::BoundTrackParameters& ,
417 const Acts::GeometryContext& ,
418 const Acts::MagneticFieldContext& ,
419 const Acts::CalibrationContext& ,
420 const Acts::Surface& )
const
422 ATH_MSG_VERBOSE(
"ACTS seed refit is not implemented in GaussianSumFitterTool");
426std::unique_ptr< ActsTrk::MutableTrackContainer >
428 const Acts::BoundTrackParameters& ,
429 const Acts::GeometryContext& ,
430 const Acts::MagneticFieldContext& ,
431 const Acts::CalibrationContext& ,
432 const Acts::Surface* )
const
434 ATH_MSG_VERBOSE(
"ACTS uncalib slink refit is not implemented in GaussianSumFitterTool");
440 const EventContext& ctx,
441 const ActsTrk::TrackContainer::ConstTrackProxy& track,
443 const Acts::PerigeeSurface& pSurface)
const {
446 const Acts::BoundTrackParameters initialParams = track.createParametersAtReference();
447 std::vector<Acts::SourceLink> sourceLinks;
448 std::vector<const Acts::Surface*> surfSequence;
450 for (
auto ts : track.trackStates()){
451 surfSequence.push_back(&
ts.referenceSurface());
452 if (!
ts.hasCalibrated()) {
456 if (
ts.typeFlags().hasMeasurement()) {
457 sourceLinks.push_back(
ts.getUncalibratedSourceLink());
461 if (sourceLinks.size() < 2) {
462 ATH_MSG_DEBUG(
"called to refit 0 or 1 sourceLink with too little information, reject fit");
463 return StatusCode::SUCCESS;
470 Acts::GsfOptions<ActsTrk::MutableTrackStateBackend> gsfOptions =
prepareOptions(tgContext, mfContext, calContext, pSurface);
484 gsfExtensions.surfaceAccessor.connect<&detail::RefittingSurfaceAccesor::operator()>(&surfaceAcc);
485 gsfOptions.extensions = gsfExtensions;
486 gsfOptions.abortOnError =
false;
489 m_directFitter->fit(sourceLinks.begin(), sourceLinks.end(), initialParams, gsfOptions, surfSequence, trackContainer);
491 m_fitter->fit(sourceLinks.begin(), sourceLinks.end(), initialParams, gsfOptions, trackContainer);
494 return StatusCode::SUCCESS;
497const Acts::GsfExtensions<typename ActsTrk::MutableTrackStateBackend>&
510Acts::GsfOptions<typename ActsTrk::MutableTrackStateBackend>
512 const Acts::MagneticFieldContext& mfContext,
513 const Acts::CalibrationContext& calContext,
514 const Acts::PerigeeSurface& surface)
const
516 Acts::PropagatorPlainOptions propagationOption(tgContext, mfContext);
519 Acts::GsfOptions<typename ActsTrk::MutableTrackStateBackend> gsfOptions(tgContext, mfContext, calContext);
521 gsfOptions.propagatorPlainOptions=propagationOption;
522 gsfOptions.referenceSurface = &surface;
525 gsfOptions.abortOnError =
false;
#define ATH_CHECK
Evaluate an expression and check for errors.
#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)
static Acts::SourceLink pack(const Ptr_t &measurement)
Pack the measurement type pointer to an Acts::SourceLink including the intermediate conversion into a...
Inner detector / ITk calibrator implementation used in the KalmanFilterTool.
void calibrate(const Acts::GeometryContext &gctx, const Acts::CalibrationContext &cctx, const Acts::SourceLink &sourceLink, MutableTrackStateProxy trackState) const
void connect(const xAOD::UncalibMeasType type, const Type *instance)
Register a calibrator implementation instance for a given measurement type.
Helper class to access the Acts::Surface for a given Acts::SourceLink which is poiniting to a Trk::Me...
void calibrate(const Acts::GeometryContext &gctx, const Acts::CalibrationContext &cctx, const Acts::SourceLink &sl, proxy_t trackState) const
Calibrator delegate implementation to calibrate the ActsTrk fit from Trk::MeasurementBase objects.
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
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 DataVector< const TrackParameters > * trackParameters() const
Return a pointer to a vector of TrackParameters.
const TrackInfo & info() const
Returns a const ref to info of a const tracks.
const Perigee * perigeeParameters() const
return Perigee.
Acts::Result< void > gainMatrixUpdate(const Acts::GeometryContext &gctx, typename trajectory_t::TrackStateProxy trackState, const Acts::Logger &logger)
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Acts::VectorMultiTrajectory MutableTrackStateBackend
Acts::TrackContainer< MutableTrackBackend, MutableTrackStateBackend, Acts::detail::ValueHolder > MutableTrackContainer
Acts::CalibrationContext getCalibrationContext(const EventContext &ctx)
The Acts::Calibration context is piped through the Acts fitters to (re)calibrate the Acts::SourceLink...
std::vector< const MeasurementBase * > MeasurementSet
vector of fittable measurements
bool RunOutlierRemoval
switch to toggle quality processing after fit
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
ParametersBase< TrackParametersDim, Charged > TrackParameters
std::vector< const PrepRawData * > PrepRawDataSet
vector of clusters and drift circles