Skip to content

Commit

Permalink
refactor: navigator volume material handling (#2047)
Browse files Browse the repository at this point in the history
split off changes from my [calorimeter
demo](https://github.com/acts-project/acts/compare/main...andiwand:tmp-calorimeter-demo?expand=1).
this adds a shortcut for getting the current volume material from the
navigator. since the new geometry has a different volume class we cannot
reach the material in a generic way out of the box
  • Loading branch information
andiwand committed Apr 21, 2023
1 parent a1226a1 commit cc1f276
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
6 changes: 4 additions & 2 deletions Core/include/Acts/Navigation/NextNavigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <boost/container/small_vector.hpp>

namespace Acts {

namespace Experimental {

class NextNavigator {
Expand Down Expand Up @@ -104,6 +103,10 @@ class NextNavigator {
return nullptr; // TODO we do not have a tracking volume
}

const IVolumeMaterial* currentVolumeMaterial(const State& state) const {
return state.currentVolume->volumeMaterial();
}

const Surface* startSurface(const State& state) const {
return state.startSurface;
}
Expand Down Expand Up @@ -425,5 +428,4 @@ class NextNavigator {
};

} // namespace Experimental

} // namespace Acts
15 changes: 10 additions & 5 deletions Core/include/Acts/Propagator/DirectNavigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
#include "Acts/Propagator/Propagator.hpp"
#include "Acts/Surfaces/Surface.hpp"

#include <iomanip>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>

#include <boost/algorithm/string.hpp>
#include <memory>
#include <vector>

namespace Acts {

Expand Down Expand Up @@ -158,6 +156,13 @@ class DirectNavigator {
return state.currentVolume;
}

const IVolumeMaterial* currentVolumeMaterial(const State& state) const {
if (state.currentVolume == nullptr) {
return nullptr;
}
return state.currentVolume->volumeMaterial();
}

const Surface* startSurface(const State& state) const {
return state.startSurface;
}
Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/Propagator/MaterialInteractor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct MaterialInteractor {
if (recordInteractions && !result.materialInteractions.empty() &&
result.materialInteractions.back().volume != nullptr &&
result.materialInteractions.back().updatedVolumeStep == false) {
UpdateResult(state, stepper, result);
updateResult(state, stepper, result);
}

// If we are on target, everything should have been done
Expand Down Expand Up @@ -177,7 +177,7 @@ struct MaterialInteractor {
/// @param [in] stepper The stepper instance
/// @param [in, out] result Result storage
template <typename propagator_state_t, typename stepper_t>
void UpdateResult(propagator_state_t& state, const stepper_t& stepper,
void updateResult(propagator_state_t& state, const stepper_t& stepper,
result_type& result) const {
// Update the previous interaction
Vector3 shift = stepper.position(state.stepping) -
Expand All @@ -193,6 +193,6 @@ struct MaterialInteractor {
result.materialInL0 +=
result.materialInteractions.back().materialSlab.thicknessInL0();
}
}; // namespace Acts
};

} // namespace Acts
7 changes: 7 additions & 0 deletions Core/include/Acts/Propagator/Navigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@ class Navigator {
return state.currentVolume;
}

const IVolumeMaterial* currentVolumeMaterial(const State& state) const {
if (state.currentVolume == nullptr) {
return nullptr;
}
return state.currentVolume->volumeMaterial();
}

const Surface* startSurface(const State& state) const {
return state.startSurface;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ struct GenericDenseEnvironmentExtension {
}

// Check existence of a volume with material
if (!navigator.currentVolume(state.navigation) ||
!navigator.currentVolume(state.navigation)->volumeMaterial()) {
if (!navigator.currentVolumeMaterial(state.navigation)) {
return 0;
}

return 2;
}

Expand Down Expand Up @@ -118,8 +118,7 @@ struct GenericDenseEnvironmentExtension {
// i = 0 is used for setup and evaluation of k
if (i == 0) {
// Set up container for energy loss
auto volumeMaterial =
navigator.currentVolume(state.navigation)->volumeMaterial();
auto volumeMaterial = navigator.currentVolumeMaterial(state.navigation);
ThisVector3 position = stepper.position(state.stepping);
material = (volumeMaterial->material(position.template cast<double>()));
initialMomentum = stepper.momentum(state.stepping);
Expand Down

0 comments on commit cc1f276

Please sign in to comment.