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"
31Acts::AtlasBetheHeitlerApprox::Data readBHParFile(
const std::string& path) {
32 std::ifstream
fin(path);
34 throw std::invalid_argument(
"Could not open BH par file: " + path);
36 std::size_t n_cmps = 0,
degree = 0;
38 if (!fin || n_cmps == 0 || degree == 0) {
39 throw std::invalid_argument(
"Bad header in BH par file: " + path);
41 Acts::AtlasBetheHeitlerApprox::Data
data(n_cmps);
42 for (
auto& cmp : data) {
43 cmp.weightCoeffs.resize(degree + 1);
44 cmp.meanCoeffs.resize(degree + 1);
45 cmp.varCoeffs.resize(degree + 1);
46 for (
double& c :
cmp.weightCoeffs) {
fin >>
c; }
47 for (
double& c :
cmp.meanCoeffs) {
fin >>
c; }
48 for (
double& c :
cmp.varCoeffs) {
fin >>
c; }
51 throw std::invalid_argument(
"Truncated data in BH par file: " + path);
67 auto field = std::make_shared<ATLASMagneticFieldWrapper>();
69 Acts::MultiEigenStepperLoop<> stepper(field);
77 ATH_MSG_INFO(
"ACTS GSF: loading GeantSim BH parameterisation (" << bhLow <<
", " << bhHigh <<
")");
78 auto bha = std::make_shared<Acts::AtlasBetheHeitlerApprox>(
79 readBHParFile(bhLow), readBHParFile(bhHigh),
87 Acts::DirectNavigator directNavigator(
logger().cloneWithSuffix(
"DirectNavigator") );
88 Acts::MultiEigenStepperLoop<> stepperDirect(field);
89 Acts::Propagator<Acts::MultiEigenStepperLoop<>, Acts::DirectNavigator> directPropagator(std::move(stepperDirect),
90 std::move(directNavigator),
91 logger().cloneWithSuffix(
"DirectPropagator"));
92 m_directFitter = std::make_unique<DirectFitter>(std::move(directPropagator), bha,
93 logger().cloneWithSuffix(
"DirectGaussianSumFitter"));
97 logger().cloneWithSuffix(
"Navigator") );
98 Acts::Propagator<Acts::MultiEigenStepperLoop<>, Acts::Navigator> propagator(std::move(stepper),
100 logger().cloneWithSuffix(
"Prop"));
101 m_fitter = std::make_unique<Fitter>(std::move(propagator), bha,
102 logger().cloneWithSuffix(
"GaussianSumFitter"));
110 gsfExtensionsTemplate.mixtureReducer.connect<&Acts::reduceMixtureWithKLDistance>();
117 configureMe = gsfExtensionsTemplate;
121 configureMe.surfaceAccessor.connect<&detail::TrkMeasSurfaceAccessor::operator()>(&
m_trkSurfAcc);
129 configureMe = gsfExtensionsTemplate;
132 configureMe.surfaceAccessor.connect<&detail::TrkPrepRawDataSurfaceAcc::operator()>(&
m_prdSurfAcc);
144 configureMe = gsfExtensionsTemplate;
145 configureMe.surfaceAccessor.connect<&detail::xAODUncalibMeasSurfAcc::operator()>(&
m_unalibMeasSurfAcc);
163 return StatusCode::SUCCESS;
168 const Acts::MagneticFieldContext& mfContext,
169 const Acts::CalibrationContext& calContext,
170 const Acts::PerigeeSurface& surface,
174 const auto& gsfExtensions =
m_gsfExtensions.at(Acts::toUnderlying(slType));
176 Acts::PropagatorPlainOptions propagationOption(tgContext, mfContext);
180 gsfOptions.extensions=gsfExtensions;
181 gsfOptions.propagatorPlainOptions=std::move(propagationOption);
182 gsfOptions.referenceSurface = &surface;
185 gsfOptions.abortOnError =
false;
194std::unique_ptr< ActsTrk::MutableTrackContainer >
196 const Acts::BoundTrackParameters& ,
197 const Acts::GeometryContext& ,
198 const Acts::MagneticFieldContext& ,
199 const Acts::CalibrationContext& ,
200 const Acts::Surface& )
const
202 ATH_MSG_VERBOSE(
"ACTS seed refit is not implemented in GaussianSumFitterTool");
206std::unique_ptr< ActsTrk::MutableTrackContainer >
208 const Acts::BoundTrackParameters& ,
209 const Acts::GeometryContext& ,
210 const Acts::MagneticFieldContext& ,
211 const Acts::CalibrationContext& ,
212 const Acts::Surface* )
const
214 ATH_MSG_VERBOSE(
"ACTS uncalib slink refit is not implemented in GaussianSumFitterTool");
220 const EventContext& ctx,
221 const ActsTrk::TrackContainer::ConstTrackProxy& track,
223 const Acts::PerigeeSurface& pSurface)
const {
226 const Acts::BoundTrackParameters initialParams = track.createParametersAtReference();
227 std::vector<Acts::SourceLink> sourceLinks;
229 for (
auto ts : track.trackStates()){
230 if (!
ts.hasCalibrated()) {
233 if (
ts.typeFlags().hasMeasurement()) {
234 sourceLinks.push_back(
ts.getUncalibratedSourceLink());
238 if (sourceLinks.size() < 2) {
239 ATH_MSG_DEBUG(
"called to refit 0 or 1 sourceLink with too little information, reject fit");
240 return StatusCode::SUCCESS;
243 const Acts::GeometryContext tgContext{
m_ctxProvider.getGeometryContext(ctx)};
244 const Acts::MagneticFieldContext mfContext{
m_ctxProvider.getMagneticFieldContext(ctx)};
245 const Acts::CalibrationContext calContext{
m_ctxProvider.getCalibrationContext(ctx)};
247 std::unique_ptr< ActsTrk::MutableTrackContainer > refittedTracks =
248 fit(sourceLinks, initialParams, tgContext, mfContext, calContext, &pSurface);
250 if (!refittedTracks) {
252 return StatusCode::SUCCESS;
256 trackContainer.ensureDynamicColumns(*refittedTracks);
258 for (
auto trkProxy : *refittedTracks) {
261 auto destProxy = trackContainer.getTrack(trackContainer.addTrack());
262 destProxy.copyFrom(trkProxy);
265 return StatusCode::SUCCESS;
269std::unique_ptr<MutableTrackContainer>
271 const Acts::BoundTrackParameters& initialParams,
272 const Acts::GeometryContext& tgContext,
273 const Acts::MagneticFieldContext& mfContext,
274 const Acts::CalibrationContext& calContext,
275 const Acts::Surface* )
const {
276 if (sourceLinks.empty()) {
281 auto pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(Acts::Vector3::Zero());
289 auto tracks = std::make_unique<MutableTrackContainer>(std::move(trackContainerBackEnd),
290 std::move(multiTrajBackEnd));
292 bool fitSuccess =
false;
295 std::vector<const Acts::Surface*> surfaces;
296 surfaces.reserve(sourceLinks.size());
299 std::ranges::for_each(sourceLinks, [
this, &surfaces](
const Acts::SourceLink& sl) {
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 ATH_MSG_ERROR(
"Unsupported source link type for KalmanFitterTool::fit");
320 fitSuccess =
m_directFitter->fit(sourceLinks.begin(), sourceLinks.end(),
321 initialParams, gsfOptions, surfaces, *tracks).ok();
324 fitSuccess =
m_fitter->fit(sourceLinks.begin(), sourceLinks.end(),
325 initialParams, gsfOptions, *tracks).ok();
334 for (
auto trkProxy : *tracks) {
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(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