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::AtlasBetheHeitlerApprox::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::AtlasBetheHeitlerApprox::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 auto bha = std::make_shared<Acts::AtlasBetheHeitlerApprox>(
84 readBHParFile(bhLow), readBHParFile(bhHigh),
92 Acts::DirectNavigator directNavigator(
logger().cloneWithSuffix(
"DirectNavigator") );
93 Acts::MultiEigenStepperLoop<> stepperDirect(field);
94 Acts::Propagator<Acts::MultiEigenStepperLoop<>, Acts::DirectNavigator> directPropagator(std::move(stepperDirect),
95 std::move(directNavigator),
96 logger().cloneWithSuffix(
"DirectPropagator"));
97 m_directFitter = std::make_unique<DirectFitter>(std::move(directPropagator), bha,
98 logger().cloneWithSuffix(
"DirectGaussianSumFitter"));
102 logger().cloneWithSuffix(
"Navigator") );
103 Acts::Propagator<Acts::MultiEigenStepperLoop<>, Acts::Navigator> propagator(std::move(stepper),
104 std::move(navigator),
105 logger().cloneWithSuffix(
"Prop"));
106 m_fitter = std::make_unique<Fitter>(std::move(propagator), bha,
107 logger().cloneWithSuffix(
"GaussianSumFitter"));
115 gsfExtensionsTemplate.mixtureReducer.connect<&Acts::reduceMixtureWithKLDistance>();
122 configureMe = gsfExtensionsTemplate;
126 configureMe.surfaceAccessor.connect<&detail::TrkMeasSurfaceAccessor::operator()>(&
m_trkSurfAcc);
134 configureMe = gsfExtensionsTemplate;
137 configureMe.surfaceAccessor.connect<&detail::TrkPrepRawDataSurfaceAcc::operator()>(&
m_prdSurfAcc);
149 configureMe = gsfExtensionsTemplate;
150 configureMe.surfaceAccessor.connect<&detail::xAODUncalibMeasSurfAcc::operator()>(&
m_unalibMeasSurfAcc);
168 return StatusCode::SUCCESS;
173 const Acts::MagneticFieldContext& mfContext,
174 const Acts::CalibrationContext& calContext,
175 const Acts::PerigeeSurface& surface,
179 const auto& gsfExtensions =
m_gsfExtensions.at(Acts::toUnderlying(slType));
181 Acts::PropagatorPlainOptions propagationOption(tgContext, mfContext);
185 gsfOptions.extensions=gsfExtensions;
186 gsfOptions.propagatorPlainOptions=std::move(propagationOption);
187 gsfOptions.referenceSurface = &surface;
190 gsfOptions.abortOnError =
false;
199std::unique_ptr< ActsTrk::MutableTrackContainer >
201 const Acts::BoundTrackParameters& ,
202 const Acts::GeometryContext& ,
203 const Acts::MagneticFieldContext& ,
204 const Acts::CalibrationContext& ,
205 const Acts::Surface& )
const
207 ATH_MSG_VERBOSE(
"ACTS seed refit is not implemented in GaussianSumFitterTool");
211std::unique_ptr< ActsTrk::MutableTrackContainer >
213 const Acts::BoundTrackParameters& ,
214 const Acts::GeometryContext& ,
215 const Acts::MagneticFieldContext& ,
216 const Acts::CalibrationContext& ,
217 const Acts::Surface* )
const
219 ATH_MSG_VERBOSE(
"ACTS uncalib slink refit is not implemented in GaussianSumFitterTool");
225 const EventContext& ctx,
226 const ActsTrk::TrackContainer::ConstTrackProxy& track,
228 const Acts::PerigeeSurface& pSurface)
const {
231 const Acts::BoundTrackParameters initialParams = track.createParametersAtReference();
232 std::vector<Acts::SourceLink> sourceLinks;
234 for (
auto ts : track.trackStates()){
235 if (!
ts.hasCalibrated()) {
238 if (
ts.typeFlags().hasMeasurement()) {
239 sourceLinks.push_back(
ts.getUncalibratedSourceLink());
243 if (sourceLinks.size() < 2) {
244 ATH_MSG_DEBUG(
"called to refit 0 or 1 sourceLink with too little information, reject fit");
245 return StatusCode::SUCCESS;
248 const Acts::GeometryContext tgContext{
m_ctxProvider.getGeometryContext(ctx)};
249 const Acts::MagneticFieldContext mfContext{
m_ctxProvider.getMagneticFieldContext(ctx)};
250 const Acts::CalibrationContext calContext{
m_ctxProvider.getCalibrationContext(ctx)};
252 std::unique_ptr< ActsTrk::MutableTrackContainer > refittedTracks =
253 fit(sourceLinks, initialParams, tgContext, mfContext, calContext, &pSurface);
255 if (!refittedTracks) {
257 return StatusCode::SUCCESS;
261 trackContainer.ensureDynamicColumns(*refittedTracks);
263 for (
auto trkProxy : *refittedTracks) {
266 auto destProxy = trackContainer.getTrack(trackContainer.addTrack());
267 destProxy.copyFrom(trkProxy);
270 return StatusCode::SUCCESS;
274std::unique_ptr<MutableTrackContainer>
276 const Acts::BoundTrackParameters& initialParams,
277 const Acts::GeometryContext& tgContext,
278 const Acts::MagneticFieldContext& mfContext,
279 const Acts::CalibrationContext& calContext,
280 const Acts::Surface* )
const {
281 if (sourceLinks.empty()) {
286 auto pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(Acts::Vector3::Zero());
294 auto tracks = std::make_unique<MutableTrackContainer>(std::move(trackContainerBackEnd),
295 std::move(multiTrajBackEnd));
297 bool fitSuccess =
false;
300 std::vector<const Acts::Surface*> surfaces;
301 surfaces.reserve(sourceLinks.size());
304 std::ranges::for_each(sourceLinks, [
this, &surfaces](
const Acts::SourceLink& sl) {
310 std::ranges::for_each(sourceLinks, [
this, &surfaces](
const Acts::SourceLink& sl) {
316 std::ranges::for_each(sourceLinks, [
this, &surfaces](
const Acts::SourceLink& sl) {
322 ATH_MSG_ERROR(
"Unsupported source link type for KalmanFitterTool::fit");
325 fitSuccess =
m_directFitter->fit(sourceLinks.begin(), sourceLinks.end(),
326 initialParams, gsfOptions, surfaces, *tracks).ok();
329 fitSuccess =
m_fitter->fit(sourceLinks.begin(), sourceLinks.end(),
330 initialParams, gsfOptions, *tracks).ok();
339 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