Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gx2f): propagate final covariance for trackstates #2949

Merged
merged 5 commits into from
Feb 22, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,6 @@ class Gx2Fitter {
/// Calibration context for the fit
const CalibrationContext* calibrationContext{nullptr};

/// The current iteration of the fitter.
/// The variable is updated in fit().
/// The actor needs to know the current iteration for adding new
/// trackStates. During the first iteration, each measurement surfaces will
/// be added to the track.
std::size_t nUpdate = Acts::MultiTrajectoryTraits::kInvalid;

/// @brief Gx2f actor operation
///
/// @tparam propagator_state_t is the type of Propagator state
Expand All @@ -401,7 +394,8 @@ class Gx2Fitter {
// - Waiting for a current surface
auto surface = navigator.currentSurface(state.navigation);
// std::string direction = state.stepping.navDir.toString();
if (surface != nullptr) {
if (surface != nullptr and
AJPfleger marked this conversation as resolved.
Show resolved Hide resolved
surface->associatedDetectorElement() != nullptr) {
++result.surfaceCount;
ACTS_VERBOSE("Surface " << surface->geometryId() << " detected.");

Expand Down Expand Up @@ -641,7 +635,6 @@ class Gx2Fitter {
gx2fActor.extensions = gx2fOptions.extensions;
gx2fActor.calibrationContext = &gx2fOptions.calibrationContext.get();
gx2fActor.actorLogger = m_actorLogger.get();
gx2fActor.nUpdate = nUpdate;

auto propagatorState = m_propagator.makeState(params, propagatorOptions);

Expand Down Expand Up @@ -772,6 +765,36 @@ class Gx2Fitter {

ACTS_VERBOSE("final covariance:\n" << fullCovariancePredicted);

// Propagate again with the final covariance matrix. This is necessary to
// obtain the propagated covariance for each state.
if (gx2fOptions.nUpdateMax > 0) {
ACTS_VERBOSE("Propagate with the final covariance.");
// update covariance
params.covariance() = fullCovariancePredicted;

// set up propagator and co
Acts::GeometryContext geoCtx = gx2fOptions.geoContext;
Acts::MagneticFieldContext magCtx = gx2fOptions.magFieldContext;
// Set options for propagator
PropagatorOptions propagatorOptions(geoCtx, magCtx);
auto& gx2fActor = propagatorOptions.actionList.template get<GX2FActor>();
gx2fActor.inputMeasurements = &inputMeasurements;
gx2fActor.extensions = gx2fOptions.extensions;
gx2fActor.calibrationContext = &gx2fOptions.calibrationContext.get();
gx2fActor.actorLogger = m_actorLogger.get();

auto propagatorState = m_propagator.makeState(params, propagatorOptions);

auto& r = propagatorState.template get<Gx2FitterResult<traj_t>>();
r.fittedStates = &trackContainer.trackStateContainer();

// Clear the track container. It could be more performant to update the
// existing states, but this needs some more thinking.
trackContainer.clear();

m_propagator.template propagate(propagatorState);
}

if (!trackContainer.hasColumn(
Acts::hashString(Gx2fConstants::gx2fnUpdateColumn))) {
trackContainer.template addColumn<std::size_t>("Gx2fnUpdateColumn");
Expand Down
Loading