Skip to content

Commit

Permalink
Merge branch 'main' into ranges-find
Browse files Browse the repository at this point in the history
  • Loading branch information
AJPfleger authored Oct 2, 2024
2 parents 9b37664 + d468122 commit 7fdb3a0
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 6 deletions.
4 changes: 2 additions & 2 deletions CI/test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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(
Expand Down
20 changes: 20 additions & 0 deletions Core/include/Acts/Geometry/TrackingVolume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,25 @@ class TrackingVolume : public Volume {
/// @param portal The portal to add
void addPortal(std::shared_ptr<Portal> portal);

using MutableSurfaceRange =
detail::TransformRange<detail::Dereference,
std::vector<std::shared_ptr<Surface>>>;
using SurfaceRange =
detail::TransformRange<detail::ConstDereference,
const std::vector<std::shared_ptr<Surface>>>;

/// 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> 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.
Expand Down Expand Up @@ -516,6 +535,7 @@ class TrackingVolume : public Volume {

std::vector<std::unique_ptr<TrackingVolume>> m_volumes;
std::vector<std::shared_ptr<Portal>> m_portals;
std::vector<std::shared_ptr<Surface>> m_surfaces;
};

} // namespace Acts
37 changes: 33 additions & 4 deletions Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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.");
Expand All @@ -1413,7 +1416,33 @@ class Gx2Fitter {
auto& r = propagatorState.template get<Gx2FitterResult<traj_t>>();
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<GX2FResult>());

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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum class GlobalChiSquareFitterError {
DidNotConverge = 2,
NotEnoughMeasurements = 3,
UpdatePushedToNewVolume = 4,
UsedUnreachableMeasurements = 5,
};

std::error_code make_error_code(
Expand Down
18 changes: 18 additions & 0 deletions Core/src/Geometry/TrackingVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,25 @@ TrackingVolume::MutablePortalRange TrackingVolume::portals() {
}

void TrackingVolume::addPortal(std::shared_ptr<Portal> 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> surface) {
if (surface == nullptr) {
throw std::invalid_argument("Surface is nullptr");
}
m_surfaces.push_back(std::move(surface));
}

} // namespace Acts
2 changes: 2 additions & 0 deletions Core/src/TrackFitting/GlobalChiSquareFitterError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down

0 comments on commit 7fdb3a0

Please sign in to comment.