diff --git a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp index 6b0e10dc86e..71066e0f0e9 100644 --- a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp +++ b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-2024 CERN for the benefit of the Acts project // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -56,7 +56,7 @@ constexpr TrackStatePropMask trackStateMask = TrackStatePropMask::Predicted | TrackStatePropMask::Calibrated; } // namespace Gx2fConstants -/// Extension struct which holds delegates to customize the KF behavior +/// Extension struct which holds delegates to customise the GX2F behaviour template struct Gx2FitterExtensions { using TrackStateProxy = typename MultiTrajectory::TrackStateProxy; @@ -243,13 +243,17 @@ void addToGx2fSums(BoundMatrix& aMatrix, BoundVector& bVector, double& chi2sum, const BoundMatrix& jacobianFromStart, const track_state_t& trackState, const Logger& logger) { BoundVector predicted = trackState.predicted(); + ActsVector measurement = trackState.template calibrated(); + ActsSquareMatrix covarianceMeasurement = trackState.template calibratedCovariance(); + ActsMatrix projector = trackState.projector().template topLeftCorner(); ActsMatrix projJacobian = projector * jacobianFromStart; + ActsMatrix projPredicted = projector * predicted; ActsVector residual = measurement - projPredicted; @@ -445,26 +449,23 @@ class Gx2Fitter { auto surface = navigator.currentSurface(state.navigation); if (surface != nullptr) { ++result.surfaceCount; - ACTS_VERBOSE("Surface " << surface->geometryId() << " detected."); + const GeometryIdentifier geoId = surface->geometryId(); + ACTS_DEBUG("Surface " << geoId << " detected."); + + // Found material + if (surface->surfaceMaterial() != nullptr) { + ACTS_DEBUG(" The surface contains material."); + } // Check if we have a measurement surface - if (auto sourcelink_it = inputMeasurements->find(surface->geometryId()); + if (auto sourcelink_it = inputMeasurements->find(geoId); sourcelink_it != inputMeasurements->end()) { - ACTS_VERBOSE("Measurement surface " << surface->geometryId() - << " detected."); + ACTS_DEBUG(" The surface contains a measurement."); // Transport the covariance to the surface stepper.transportCovarianceToBound(state.stepping, *surface, freeToBoundCorrection); - ACTS_VERBOSE( - "Actor - indices before processing:" - << "\n " - << "result.lastMeasurementIndex: " << result.lastMeasurementIndex - << "\n " - << "result.lastTrackIndex: " << result.lastTrackIndex << "\n " - << "result.fittedStates->size(): " << result.fittedStates->size()) - // TODO generalize the update of the currentTrackIndex auto& fittedStates = *result.fittedStates; @@ -473,7 +474,7 @@ class Gx2Fitter { typename traj_t::TrackStateProxy trackStateProxy = fittedStates.makeTrackState(Gx2fConstants::trackStateMask, result.lastTrackIndex); - std::size_t currentTrackIndex = trackStateProxy.index(); + const std::size_t currentTrackIndex = trackStateProxy.index(); // Set the trackStateProxy components with the state from the ongoing // propagation @@ -512,15 +513,7 @@ class Gx2Fitter { typeFlags.set(TrackStateFlag::MeasurementFlag); // We count the processed measurement ++result.processedMeasurements; - ACTS_VERBOSE("Actor - indices after processing, before over writing:" - << "\n " - << "result.lastMeasurementIndex: " - << result.lastMeasurementIndex << "\n " - << "trackStateProxy.index(): " << trackStateProxy.index() - << "\n " - << "result.lastTrackIndex: " << result.lastTrackIndex - << "\n " - << "currentTrackIndex: " << currentTrackIndex) + result.lastMeasurementIndex = currentTrackIndex; result.lastTrackIndex = currentTrackIndex; @@ -542,12 +535,9 @@ class Gx2Fitter { << " detected."); // We only create track states here if there is already a measurement - // detected or if the surface has material (no holes before the first - // measurement) - if (result.measurementStates > 0 - // || surface->surfaceMaterial() != nullptr - ) { - ACTS_VERBOSE("Handle hole."); + // detected (no holes before the first measurement) + if (result.measurementStates > 0) { + ACTS_DEBUG(" Handle hole."); auto& fittedStates = *result.fittedStates; @@ -556,7 +546,8 @@ class Gx2Fitter { typename traj_t::TrackStateProxy trackStateProxy = fittedStates.makeTrackState(Gx2fConstants::trackStateMask, result.lastTrackIndex); - std::size_t currentTrackIndex = trackStateProxy.index(); + const std::size_t currentTrackIndex = trackStateProxy.index(); + { // Set the trackStateProxy components with the state from the // ongoing propagation @@ -597,16 +588,6 @@ class Gx2Fitter { } } - ACTS_VERBOSE( - "Actor - indices after processing, before over writing:" - << "\n " - << "result.lastMeasurementIndex: " - << result.lastMeasurementIndex << "\n " - << "trackStateProxy.index(): " << trackStateProxy.index() - << "\n " - << "result.lastTrackIndex: " << result.lastTrackIndex - << "\n " - << "currentTrackIndex: " << currentTrackIndex) result.lastTrackIndex = currentTrackIndex; if (trackStateProxy.typeFlags().test(TrackStateFlag::HoleFlag)) { @@ -616,7 +597,7 @@ class Gx2Fitter { ++result.processedStates; } else { - ACTS_VERBOSE("Ignoring hole, because no preceding measurements."); + ACTS_DEBUG(" Ignoring hole, because no preceding measurements."); } if (surface->surfaceMaterial() != nullptr) { @@ -626,12 +607,12 @@ class Gx2Fitter { // MaterialUpdateStage::FullUpdate); } } else { - ACTS_INFO("Actor: This case is not implemented yet") + ACTS_INFO("Surface " << geoId << " has no measurement/material/hole.") } } - ACTS_DEBUG("result.processedMeasurements: " - << result.processedMeasurements << "\n" - << "inputMeasurements.size(): " << inputMeasurements->size()) + ACTS_VERBOSE("result.processedMeasurements: " + << result.processedMeasurements << "\n" + << "inputMeasurements.size(): " << inputMeasurements->size()) if (result.processedMeasurements >= inputMeasurements->size()) { ACTS_INFO("Actor: finish: all measurements found."); result.finished = true; @@ -693,7 +674,7 @@ class Gx2Fitter { const -> std::enable_if_t< !_isdn, Result::TrackProxy>> { - // Preprocess Measurements (Sourcelinks -> map) + // Preprocess Measurements (SourceLinks -> map) // To be able to find measurements later, we put them into a map // We need to copy input SourceLinks anyway, so the map can own them. ACTS_VERBOSE("Preparing " << std::distance(it, end)