8#include "Acts/MagneticField/MagneticFieldContext.hpp"
9#include "Acts/Surfaces/PerigeeSurface.hpp"
10#include "Acts/Surfaces/Surface.hpp"
11#include "Acts/TrackFitting/GsfMixtureReduction.hpp"
12#include "Acts/EventData/BoundTrackParameters.hpp"
20#include "Acts/Propagator/DirectNavigator.hpp"
34 constexpr std::size_t MAXDEGREE = 30;
36 Acts::PolynomialBetheHeitlerApprox::Data readBHParFile(
const std::string& path) {
37 std::ifstream
fin(path);
39 throw std::invalid_argument(
"Could not open BH par file: " + path);
41 std::size_t n_cmps = 0,
degree = 0;
43 if (!fin || n_cmps == 0 || degree == 0 || degree > MAXDEGREE) {
44 throw std::invalid_argument(
"Bad header in BH par file: " + path);
46 Acts::PolynomialBetheHeitlerApprox::Data
data(n_cmps);
47 for (
auto& cmp : data) {
48 cmp.weightCoeffs.resize(degree + 1);
49 cmp.meanCoeffs.resize(degree + 1);
50 cmp.varCoeffs.resize(degree + 1);
51 for (
double& c :
cmp.weightCoeffs) {
fin >>
c; }
52 for (
double& c :
cmp.meanCoeffs) {
fin >>
c; }
53 for (
double& c :
cmp.varCoeffs) {
fin >>
c; }
56 throw std::invalid_argument(
"Truncated data in BH par file: " + path);
72 auto field = std::make_shared<ATLASMagneticFieldWrapper>();
74 Acts::MultiEigenStepperLoop<> stepper(field);
82 ATH_MSG_INFO(
"ACTS GSF: loading GeantSim BH parameterisation (" << bhLow <<
", " << bhHigh <<
")");
83 std::vector<Acts::PolynomialBetheHeitlerApprox::RangeData> bhRanges;
84 bhRanges.emplace_back(0.0, 0.1, readBHParFile(bhLow),
true);
85 bhRanges.emplace_back(0.1, 0.2, readBHParFile(bhHigh),
true);
86 auto bha = std::make_shared<Acts::PolynomialBetheHeitlerApprox>(
87 std::move(bhRanges),
true,
93 Acts::DirectNavigator directNavigator(
logger().cloneWithSuffix(
"DirectNavigator") );
94 Acts::MultiEigenStepperLoop<> stepperDirect(field);
95 Acts::Propagator<Acts::MultiEigenStepperLoop<>, Acts::DirectNavigator> directPropagator(std::move(stepperDirect),
96 std::move(directNavigator),
97 logger().cloneWithSuffix(
"DirectPropagator"));
98 m_directFitter = std::make_unique<DirectFitter>(std::move(directPropagator), bha,
99 logger().cloneWithSuffix(
"DirectGaussianSumFitter"));
103 logger().cloneWithSuffix(
"Navigator") );
104 Acts::Propagator<Acts::MultiEigenStepperLoop<>, Acts::Navigator> propagator(std::move(stepper),
105 std::move(navigator),
106 logger().cloneWithSuffix(
"Prop"));
107 m_fitter = std::make_unique<Fitter>(std::move(propagator), bha,
108 logger().cloneWithSuffix(
"GaussianSumFitter"));
116 gsfExtensionsTemplate.mixtureReducer.connect<&Acts::reduceMixtureWithKLDistance>();
123 configureMe = gsfExtensionsTemplate;
127 configureMe.surfaceAccessor.connect<&detail::TrkMeasSurfaceAccessor::operator()>(&
m_trkSurfAcc);
135 configureMe = gsfExtensionsTemplate;
138 configureMe.surfaceAccessor.connect<&detail::TrkPrepRawDataSurfaceAcc::operator()>(&
m_prdSurfAcc);
150 configureMe = gsfExtensionsTemplate;
151 configureMe.surfaceAccessor.connect<&detail::xAODUncalibMeasSurfAcc::operator()>(&
m_unalibMeasSurfAcc);
169 return StatusCode::SUCCESS;
174 const Acts::MagneticFieldContext& mfContext,
175 const Acts::CalibrationContext& calContext,
176 const Acts::PerigeeSurface& surface,
180 const auto& gsfExtensions =
m_gsfExtensions.at(Acts::toUnderlying(slType));
182 Acts::PropagatorPlainOptions propagationOption(tgContext, mfContext);
186 gsfOptions.extensions=gsfExtensions;
187 gsfOptions.propagatorPlainOptions=std::move(propagationOption);
188 gsfOptions.referenceSurface = &surface;
191 gsfOptions.abortOnError =
false;
200std::unique_ptr< ActsTrk::MutableTrackContainer >
202 const Acts::BoundTrackParameters& ,
203 const Acts::GeometryContext& ,
204 const Acts::MagneticFieldContext& ,
205 const Acts::CalibrationContext& ,
206 const Acts::Surface& )
const
208 ATH_MSG_VERBOSE(
"ACTS seed refit is not implemented in GaussianSumFitterTool");
212std::unique_ptr< ActsTrk::MutableTrackContainer >
214 const Acts::BoundTrackParameters& ,
215 const Acts::GeometryContext& ,
216 const Acts::MagneticFieldContext& ,
217 const Acts::CalibrationContext& ,
218 const Acts::Surface* )
const
220 ATH_MSG_VERBOSE(
"ACTS uncalib slink refit is not implemented in GaussianSumFitterTool");
226 const EventContext& ctx,
227 const ActsTrk::TrackContainer::ConstTrackProxy& track,
229 const Acts::PerigeeSurface& pSurface)
const {
232 const Acts::BoundTrackParameters initialParams = track.createParametersAtReference();
233 std::vector<Acts::SourceLink> sourceLinks;
235 for (
auto ts : track.trackStates()){
236 if (!
ts.hasCalibrated()) {
239 if (
ts.typeFlags().hasMeasurement()) {
240 sourceLinks.push_back(
ts.getUncalibratedSourceLink());
244 if (sourceLinks.size() < 2) {
245 ATH_MSG_DEBUG(
"called to refit 0 or 1 sourceLink with too little information, reject fit");
246 return StatusCode::SUCCESS;
249 const Acts::GeometryContext tgContext{
m_ctxProvider.getGeometryContext(ctx)};
250 const Acts::MagneticFieldContext mfContext{
m_ctxProvider.getMagneticFieldContext(ctx)};
251 const Acts::CalibrationContext calContext{
m_ctxProvider.getCalibrationContext(ctx)};
253 std::unique_ptr< ActsTrk::MutableTrackContainer > refittedTracks =
254 fit(sourceLinks, initialParams, tgContext, mfContext, calContext, &pSurface);
256 if (!refittedTracks) {
258 return StatusCode::SUCCESS;
262 trackContainer.ensureDynamicColumns(*refittedTracks);
264 for (
auto trkProxy : *refittedTracks) {
267 auto destProxy = trackContainer.getTrack(trackContainer.addTrack());
268 destProxy.copyFrom(trkProxy);
271 return StatusCode::SUCCESS;
275std::unique_ptr<MutableTrackContainer>
277 const Acts::BoundTrackParameters& initialParams,
278 const Acts::GeometryContext& tgContext,
279 const Acts::MagneticFieldContext& mfContext,
280 const Acts::CalibrationContext& calContext,
281 const Acts::Surface* )
const {
282 if (sourceLinks.empty()) {
287 auto pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(Acts::Vector3::Zero());
295 auto tracks = std::make_unique<MutableTrackContainer>(std::move(trackContainerBackEnd),
296 std::move(multiTrajBackEnd));
298 bool fitSuccess =
false;
301 std::vector<const Acts::Surface*> surfaces;
302 surfaces.reserve(sourceLinks.size());
305 std::ranges::for_each(sourceLinks, [
this, &surfaces](
const Acts::SourceLink& sl) {
311 std::ranges::for_each(sourceLinks, [
this, &surfaces](
const Acts::SourceLink& sl) {
317 std::ranges::for_each(sourceLinks, [
this, &surfaces](
const Acts::SourceLink& sl) {
323 ATH_MSG_ERROR(
"Unsupported source link type for KalmanFitterTool::fit");
326 fitSuccess =
m_directFitter->fit(sourceLinks.begin(), sourceLinks.end(),
327 initialParams, gsfOptions, surfaces, *tracks).ok();
330 fitSuccess =
m_fitter->fit(sourceLinks.begin(), sourceLinks.end(),
331 initialParams, gsfOptions, *tracks).ok();
340 for (
auto trkProxy : *tracks) {
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
static SourceLinkType getType(const Acts::SourceLink &sl)
Returns the enumeration corresponding to the object type cached within the Acts::SourceLink.
void calibrate(const Acts::GeometryContext &geoctx, const Acts::CalibrationContext &cctx, const Acts::SourceLink &link, TrackStateProxy state) const
static OnTrackCalibrator NoCalibration(const ActsTrk::ITrackingGeometrySvc *trackGeoSvc)
void calibrate(const Acts::GeometryContext &gctx, const Acts::CalibrationContext &cctx, const Acts::SourceLink &sourceLink, MutableTrackStateProxy trackState) const
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.
Class to calibrate the Acts track states with uncalibrated Trk::PrepRaw data objects.
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::PrepRawData objects.
Helper class to access the Acts::surface associated with a Trk::PrepRawData measurement.
Helper class to access the Acts::surface associated with an Uncalibrated xAOD measurement.
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
Acts::Result< void > gainMatrixUpdate(const Acts::GeometryContext &gctx, typename trajectory_t::TrackStateProxy trackState, const Acts::Logger &logger)
SourceLinkType
Enumeration to distinguish between the ATLAS EDM -> Acts::SourceLink variants.
@ xAODUnCalibMeas
UnCalibrated Trk::PrepRawData objects.
@ TrkPrepRawData
Calibrated Trk::MeasurementBase objects.
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::VectorTrackContainer MutableTrackBackend
@ GaussianSumFilter
Tracks from Gaussian Sum Filter.
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