diff --git a/CI/test_coverage.py b/CI/test_coverage.py index 06b13a06abb..0488a71d85d 100755 --- a/CI/test_coverage.py +++ b/CI/test_coverage.py @@ -41,7 +41,7 @@ def call(cmd): ret, gcovr_version_text = check_output(["gcovr", "--version"]) gcovr_version = tuple( - map(int, re.match("gcovr (\d+\.\d+)", gcovr_version_text).group(1).split(".")) + map(int, re.match(r"gcovr (\d+\.\d+)", gcovr_version_text).group(1).split(".")) ) extra_flags = [] @@ -63,7 +63,7 @@ def call(cmd): if not os.path.exists(coverage_dir): os.makedirs(coverage_dir) -excludes = ["-e", "../Tests/", "-e", ".*json\.hpp"] +excludes = ["-e", "../Tests/", "-e", r".*json\.hpp"] # create the html report call( diff --git a/Core/include/Acts/Geometry/TrackingVolume.hpp b/Core/include/Acts/Geometry/TrackingVolume.hpp index 290e5c21425..b208eefa54b 100644 --- a/Core/include/Acts/Geometry/TrackingVolume.hpp +++ b/Core/include/Acts/Geometry/TrackingVolume.hpp @@ -322,6 +322,25 @@ class TrackingVolume : public Volume { /// @param portal The portal to add void addPortal(std::shared_ptr portal); + using MutableSurfaceRange = + detail::TransformRange>>; + using SurfaceRange = + detail::TransformRange>>; + + /// Return all surfaces registered under this tracking volume + /// @return the range of surfaces + SurfaceRange surfaces() const; + + /// Return mutable view of the registered surfaces under this tracking volume + /// @return the range of surfaces + MutableSurfaceRange surfaces(); + + /// Add a surface to this tracking volume + /// @param surface The surface to add + void addSurface(std::shared_ptr surface); + /// Add a child volume to this tracking volume /// @param volume The volume to add /// @note The @p volume will have its mother volume assigned to @p this. @@ -516,6 +535,7 @@ class TrackingVolume : public Volume { std::vector> m_volumes; std::vector> m_portals; + std::vector> m_surfaces; }; } // namespace Acts diff --git a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp index 2de65a78a07..92a6a4f76ba 100644 --- a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp +++ b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp @@ -610,10 +610,10 @@ class Gx2Fitter { // Check if we can stop to propagate if (result.measurementStates == inputMeasurements->size()) { - ACTS_INFO("Actor: finish: All measurements have been found."); + ACTS_DEBUG("Actor: finish: All measurements have been found."); result.finished = true; } else if (state.navigation.navigationBreak) { - ACTS_INFO("Actor: finish: navigationBreak."); + ACTS_DEBUG("Actor: finish: navigationBreak."); result.finished = true; } @@ -1218,7 +1218,7 @@ class Gx2Fitter { // We only consider states with a measurement (and/or material) if (!stateHasMeasurement && !doMaterial) { - ACTS_INFO(" Skip state."); + ACTS_DEBUG(" Skip state."); continue; } @@ -1388,6 +1388,9 @@ class Gx2Fitter { // Propagate again with the final covariance matrix. This is necessary to // obtain the propagated covariance for each state. + // We also need to recheck the result and find the tipIndex, because at this + // step, we will not ignore the boundary checks for measurement surfaces. We + // want to create trackstates only on surfaces, that we actually hit. if (gx2fOptions.nUpdateMax > 0) { ACTS_VERBOSE("final deltaParams:\n" << deltaParams); ACTS_VERBOSE("Propagate with the final covariance."); @@ -1413,7 +1416,33 @@ class Gx2Fitter { auto& r = propagatorState.template get>(); r.fittedStates = &trackContainer.trackStateContainer(); - m_propagator.template propagate(propagatorState); + auto propagationResult = m_propagator.template propagate(propagatorState); + + // Run the fitter + auto result = m_propagator.template makeResult(std::move(propagatorState), + propagationResult, + propagatorOptions, false); + + if (!result.ok()) { + ACTS_ERROR("Propagation failed: " << result.error()); + return result.error(); + } + + auto& propRes = *result; + GX2FResult gx2fResult = std::move(propRes.template get()); + + if (!gx2fResult.result.ok()) { + ACTS_INFO("GlobalChiSquareFitter failed in actor: " + << gx2fResult.result.error() << ", " + << gx2fResult.result.error().message()); + return gx2fResult.result.error(); + } + + if (tipIndex != gx2fResult.lastMeasurementIndex) { + ACTS_INFO("Final fit used unreachable measurements."); + return Experimental::GlobalChiSquareFitterError:: + UsedUnreachableMeasurements; + } } if (!trackContainer.hasColumn( diff --git a/Core/include/Acts/TrackFitting/GlobalChiSquareFitterError.hpp b/Core/include/Acts/TrackFitting/GlobalChiSquareFitterError.hpp index 7c95750a3f6..5bc4c55b3e2 100644 --- a/Core/include/Acts/TrackFitting/GlobalChiSquareFitterError.hpp +++ b/Core/include/Acts/TrackFitting/GlobalChiSquareFitterError.hpp @@ -19,6 +19,7 @@ enum class GlobalChiSquareFitterError { DidNotConverge = 2, NotEnoughMeasurements = 3, UpdatePushedToNewVolume = 4, + UsedUnreachableMeasurements = 5, }; std::error_code make_error_code( diff --git a/Core/src/Geometry/TrackingVolume.cpp b/Core/src/Geometry/TrackingVolume.cpp index d2c1124a1ae..79ffdc9d180 100644 --- a/Core/src/Geometry/TrackingVolume.cpp +++ b/Core/src/Geometry/TrackingVolume.cpp @@ -663,7 +663,25 @@ TrackingVolume::MutablePortalRange TrackingVolume::portals() { } void TrackingVolume::addPortal(std::shared_ptr portal) { + if (portal == nullptr) { + throw std::invalid_argument("Portal is nullptr"); + } m_portals.push_back(std::move(portal)); } +TrackingVolume::SurfaceRange TrackingVolume::surfaces() const { + return SurfaceRange{m_surfaces}; +} + +TrackingVolume::MutableSurfaceRange TrackingVolume::surfaces() { + return MutableSurfaceRange{m_surfaces}; +} + +void TrackingVolume::addSurface(std::shared_ptr surface) { + if (surface == nullptr) { + throw std::invalid_argument("Surface is nullptr"); + } + m_surfaces.push_back(std::move(surface)); +} + } // namespace Acts diff --git a/Core/src/TrackFitting/GlobalChiSquareFitterError.cpp b/Core/src/TrackFitting/GlobalChiSquareFitterError.cpp index 98beceb8cb1..3a3cc713173 100644 --- a/Core/src/TrackFitting/GlobalChiSquareFitterError.cpp +++ b/Core/src/TrackFitting/GlobalChiSquareFitterError.cpp @@ -32,6 +32,8 @@ class GlobalChiSquareFitterErrorCategory : public std::error_category { return "Gx2f: Not enough measurements."; case GlobalChiSquareFitterError::UpdatePushedToNewVolume: return "Gx2f: Update pushed the parameters to a new volume."; + case GlobalChiSquareFitterError::UsedUnreachableMeasurements: + return "Gx2f: Final fit used unreachable measurements."; default: return "unknown"; }