Skip to content

Commit

Permalink
feat: make stepping logger volume agnostic (#2454)
Browse files Browse the repository at this point in the history
This PR removes the explicit setting of `TrackingVolume` in favour of
the `GeometryIdentifier` (which is the only thing that is accessed from
the `TrackingVolume` in the `Step` struct of the `SteppingLogger` and
thus makes the step logging infrastructure accessible to the new
`Acts::Detector` geometry as well.
  • Loading branch information
asalzburger committed Sep 19, 2023
1 parent d62a42f commit 68658f1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 41 deletions.
23 changes: 14 additions & 9 deletions Core/include/Acts/Propagator/detail/SteppingLogger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "Acts/Definitions/Direction.hpp"
#include "Acts/Geometry/GeometryIdentifier.hpp"
#include "Acts/Propagator/ConstrainedStep.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/Logger.hpp"

#include <memory>
Expand All @@ -21,19 +22,21 @@
namespace Acts {

class Surface;
class Layer;
class TrackingVolume;

namespace detail {

/// @brief the step information for
/// @brief The step information for recording
///
/// The surface object could be a temporarily created object
/// and as the Step vector is collected and written out at a
/// later stage, the surface is referenced counted here.
struct Step {
ConstrainedStep stepSize;
Direction navDir;
Vector3 position = Vector3(0., 0., 0.);
Vector3 momentum = Vector3(0., 0., 0.);
std::shared_ptr<const Surface> surface = nullptr;
const TrackingVolume* volume = nullptr;
GeometryIdentifier geoID = 0;
};

/// @brief a step length logger for debugging the stepping
Expand Down Expand Up @@ -65,23 +68,25 @@ struct SteppingLogger {
void operator()(propagator_state_t& state, const stepper_t& stepper,
const navigator_t& navigator, result_type& result,
const Logger& /*logger*/) const {
// don't log if you have reached the target
// Don't log if you have reached the target or are sterile
if (sterile or navigator.targetReached(state.navigation)) {
return;
}
// record the propagation state
// Record the propagation state
Step step;
step.stepSize = state.stepping.stepSize;
step.navDir = state.options.direction;
step.position = stepper.position(state.stepping);
step.momentum = stepper.momentum(state.stepping);

// Record the information about the surface
if (navigator.currentSurface(state.navigation) != nullptr) {
// hang on to surface
step.surface = navigator.currentSurface(state.navigation)->getSharedPtr();
step.geoID = step.surface->geometryId();
} else if (navigator.currentVolume(state.navigation) != nullptr) {
// If there's no surface but a volume, this sets the geoID
step.geoID = navigator.currentVolume(state.navigation)->geometryId();
}

step.volume = navigator.currentVolume(state.navigation);
result.steps.push_back(std::move(step));
}
};
Expand Down
42 changes: 13 additions & 29 deletions Examples/Io/Root/src/RootPropagationStepsWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ ActsExamples::ProcessCode ActsExamples::RootPropagationStepsWriter::writeT(
// Exclusive access to the tree while writing
std::lock_guard<std::mutex> lock(m_writeMutex);

// we get the event number
// Get the event number
m_eventNr = context.eventNumber;

// loop over the step vector of each test propagation in this
// Loop over the step vector of each test propagation in this
for (auto& steps : stepCollection) {
// clear the vectors for each collection
// Clear the vectors for each collection
m_volumeID.clear();
m_boundaryID.clear();
m_layerID.clear();
Expand All @@ -127,37 +127,21 @@ ActsExamples::ProcessCode ActsExamples::RootPropagationStepsWriter::writeT(
m_step_usr.clear();
m_nStepTrials.clear();

// loop over single steps
// Loop over single steps
for (auto& step : steps) {
// the identification of the step
Acts::GeometryIdentifier::Value volumeID = 0;
Acts::GeometryIdentifier::Value boundaryID = 0;
Acts::GeometryIdentifier::Value layerID = 0;
Acts::GeometryIdentifier::Value approachID = 0;
Acts::GeometryIdentifier::Value sensitiveID = 0;
const auto& geoID = step.geoID;
m_sensitiveID.push_back(geoID.sensitive());
m_approachID.push_back(geoID.approach());
m_layerID.push_back(geoID.layer());
m_boundaryID.push_back(geoID.boundary());
m_volumeID.push_back(geoID.volume());

int material = 0;
// get the identification from the surface first
if (step.surface) {
auto geoID = step.surface->geometryId();
volumeID = geoID.volume();
boundaryID = geoID.boundary();
layerID = geoID.layer();
approachID = geoID.approach();
sensitiveID = geoID.sensitive();
if (step.surface->surfaceMaterial() != nullptr) {
material = 1;
}
}
// a current volume overwrites the surface tagged one
if (step.volume != nullptr) {
volumeID = step.volume->geometryId().volume();
}
// now fill
m_sensitiveID.push_back(sensitiveID);
m_approachID.push_back(approachID);
m_layerID.push_back(layerID);
m_boundaryID.push_back(boundaryID);
m_volumeID.push_back(volumeID);
m_material.push_back(material);

// kinematic information
Expand Down Expand Up @@ -189,13 +173,13 @@ ActsExamples::ProcessCode ActsExamples::RootPropagationStepsWriter::writeT(
m_step_type.push_back(3);
}

// step size information
// Step size information
m_step_acc.push_back(Acts::clampValue<float>(accuracy));
m_step_act.push_back(Acts::clampValue<float>(actor));
m_step_abt.push_back(Acts::clampValue<float>(aborter));
m_step_usr.push_back(Acts::clampValue<float>(user));

// stepper efficiency
// Stepper efficiency
m_nStepTrials.push_back(step.stepSize.nStepTrials);
}
m_outputTree->Fill();
Expand Down
6 changes: 3 additions & 3 deletions Examples/Python/tests/root_file_hashes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ test_vertex_fitting_reading[AMVF-False-100]__performance_vertexing.root: 009e4b1
test_vertex_fitting_reading[AMVF-True-100]__performance_vertexing.root: 2d0dc1e02bfd1f7eaae26ef8ac657ce0291f70c7e4efddd35d171d31988a631e
test_bfield_writing__solenoid.root: 7ab4d298cd1657c93c90ad7759ea536ad93f52b11cc90f8e3abe611b9cf13234
test_bfield_writing__solenoid2.root: 948435fab0d2d23b61884acb44e150adc6ab7b432dc41e4e03ae289d8ac30224
test_root_prop_step_writer[configPosConstructor]__prop_steps.root: 2bc273f9ec51d800de0b16fd3332ba6453c66d9be8eb3c28ce5856927b295ac3
test_root_prop_step_writer[configKwConstructor]__prop_steps.root: 2bc273f9ec51d800de0b16fd3332ba6453c66d9be8eb3c28ce5856927b295ac3
test_root_prop_step_writer[kwargsConstructor]__prop_steps.root: 2bc273f9ec51d800de0b16fd3332ba6453c66d9be8eb3c28ce5856927b295ac3
test_root_prop_step_writer[configPosConstructor]__prop_steps.root: 53adaabc7856c888ad4005bacb2fb4c0af6ac74f5b7f0255c296cd8e1f2601a3
test_root_prop_step_writer[configKwConstructor]__prop_steps.root: 53adaabc7856c888ad4005bacb2fb4c0af6ac74f5b7f0255c296cd8e1f2601a3
test_root_prop_step_writer[kwargsConstructor]__prop_steps.root: 53adaabc7856c888ad4005bacb2fb4c0af6ac74f5b7f0255c296cd8e1f2601a3
test_root_particle_writer[configPosConstructor]__particles.root: 8ca3987523360e4cd52f9bc138e82230996baa105c77ddb2cde775733d8acc4c
test_root_particle_writer[configKwConstructor]__particles.root: 8ca3987523360e4cd52f9bc138e82230996baa105c77ddb2cde775733d8acc4c
test_root_particle_writer[kwargsConstructor]__particles.root: 8ca3987523360e4cd52f9bc138e82230996baa105c77ddb2cde775733d8acc4c
Expand Down

0 comments on commit 68658f1

Please sign in to comment.