Skip to content

Commit

Permalink
feat: Add INFO printouts about the layers & volumes (#1773)
Browse files Browse the repository at this point in the history
This PR adds permanent (to be discussed) messages about the geometry volumes & layers numbering. 
It seems to be the only robust way to get this information. 
The implementation is a variant of what @gagnonlg suggested. 

I can imagine an additional parameter steering if this messages occur. 
Tagging @asalzburger @gagnonlg
  • Loading branch information
tboldagh committed Jan 30, 2023
1 parent d20321a commit bdf2378
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 25 deletions.
8 changes: 6 additions & 2 deletions Core/include/Acts/Geometry/Layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "Acts/Surfaces/SurfaceArray.hpp"
#include "Acts/Utilities/BinnedArray.hpp"
#include "Acts/Utilities/Intersection.hpp"
#include "Acts/Utilities/Logger.hpp"

#include <memory>
#include <utility>
Expand Down Expand Up @@ -281,12 +282,15 @@ class Layer : public virtual GeometryObject {
/// @param layerID is the geometry id of the volume
/// as calculated by the TrackingGeometry
/// @param hook Identifier hook to be applied to surfaces
/// @param logger A @c Logger instance
///
void closeGeometry(const IMaterialDecorator* materialDecorator,
const GeometryIdentifier& layerID,
const GeometryIdentifierHook& hook);
const GeometryIdentifierHook& hook,
const Logger& logger = getDummyLogger());
};

/// Layers are constructedd with shared_ptr factories, hence the layer array is
/// Layers are constructed with shared_ptr factories, hence the layer array is
/// describes as:
using LayerArray = BinnedArray<LayerPtr>;

Expand Down
5 changes: 4 additions & 1 deletion Core/include/Acts/Geometry/TrackingGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Geometry/GeometryIdentifier.hpp"
#include "Acts/Geometry/TrackingVolume.hpp"
#include "Acts/Utilities/Logger.hpp"

#include <memory>
#include <string>
Expand Down Expand Up @@ -46,9 +47,11 @@ class TrackingGeometry {
/// @param materialDecorator is a dediated decorator that can assign
/// surface or volume based material to the TrackingVolume
/// @param hook Identifier hook to be applied to surfaces
/// @param logger instance of a logger (defaulting to the "silent" one)
TrackingGeometry(const MutableTrackingVolumePtr& highestVolume,
const IMaterialDecorator* materialDecorator = nullptr,
const GeometryIdentifierHook& hook = {});
const GeometryIdentifierHook& hook = {},
const Logger& logger = getDummyLogger());

/// Destructor
~TrackingGeometry();
Expand Down
8 changes: 5 additions & 3 deletions Core/include/Acts/Geometry/TrackingVolume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ class TrackingVolume : public Volume {
/// @param position The position for searching
/// @param direction The direction for searching
/// @param options The templated navigation options
/// @param logger A @c LoggerWrapper instance
/// @param logger A @c Logger instance
///
/// @return is the templated boundary intersection
boost::container::small_vector<BoundaryIntersection, 4> compatibleBoundaries(
const GeometryContext& gctx, const Vector3& position,
const Vector3& direction, const NavigationOptions<Surface>& options,
LoggerWrapper logger = getDummyLogger()) const;
const Logger& logger = getDummyLogger()) const;

/// @brief Return surfaces in given direction from bounding volume hierarchy
/// @tparam options_t Type of navigation options object for decomposition
Expand Down Expand Up @@ -438,11 +438,13 @@ class TrackingVolume : public Volume {
/// @param vol is the geometry id of the volume
/// as calculated by the TrackingGeometry
/// @param hook Identifier hook to be applied to surfaces
/// @param logger A @c LoggerWrapper instance
///
void closeGeometry(
const IMaterialDecorator* materialDecorator,
std::unordered_map<GeometryIdentifier, const TrackingVolume*>& volumeMap,
size_t& vol, const GeometryIdentifierHook& hook);
size_t& vol, const GeometryIdentifierHook& hook,
const Logger& logger = getDummyLogger());

/// interlink the layers in this TrackingVolume
void interlinkLayers();
Expand Down
3 changes: 1 addition & 2 deletions Core/include/Acts/Propagator/Navigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,7 @@ class Navigator {
state.navigation.navBoundaries =
state.navigation.currentVolume->compatibleBoundaries(
state.geoContext, stepper.position(state.stepping),
stepper.direction(state.stepping), navOpts,
LoggerWrapper{logger()});
stepper.direction(state.stepping), navOpts, logger());
// The number of boundary candidates
if (logger().doPrint(Logging::VERBOSE)) {
std::ostringstream os;
Expand Down
5 changes: 4 additions & 1 deletion Core/src/Geometry/Layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ Acts::ApproachDescriptor* Acts::Layer::approachDescriptor() {

void Acts::Layer::closeGeometry(const IMaterialDecorator* materialDecorator,
const GeometryIdentifier& layerID,
const GeometryIdentifierHook& hook) {
const GeometryIdentifierHook& hook,
const Logger& logger) {
// set the volumeID of this
assignGeometryId(layerID);
// assign to the representing surface
Surface* rSurface = const_cast<Surface*>(&surfaceRepresentation());
if (materialDecorator != nullptr) {
materialDecorator->decorate(*rSurface);
}
ACTS_DEBUG("layerID: " << layerID);

rSurface->assignGeometryId(layerID);

// also find out how the sub structure is defined
Expand Down
6 changes: 3 additions & 3 deletions Core/src/Geometry/TrackingGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
Acts::TrackingGeometry::TrackingGeometry(
const MutableTrackingVolumePtr& highestVolume,
const IMaterialDecorator* materialDecorator,
const GeometryIdentifierHook& hook)
const GeometryIdentifierHook& hook, const Logger& logger)
: m_world(highestVolume),
m_beam(Surface::makeShared<PerigeeSurface>(Vector3::Zero())) {
// Close the geometry: assign geometryID and successively the material
size_t volumeID = 0;
highestVolume->closeGeometry(materialDecorator, m_volumesById, volumeID,
hook);
highestVolume->closeGeometry(materialDecorator, m_volumesById, volumeID, hook,
logger);
m_volumesById.rehash(0);
// fill surface lookup container
m_world->visitSurfaces([this](const Acts::Surface* srf) {
Expand Down
2 changes: 1 addition & 1 deletion Core/src/Geometry/TrackingGeometryBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Acts::TrackingGeometryBuilder::trackingGeometry(
return std::make_unique<TrackingGeometry>(
highestVolume,
m_cfg.materialDecorator ? m_cfg.materialDecorator.get() : nullptr,
*m_cfg.geometryIdentifierHook);
*m_cfg.geometryIdentifierHook, logger());
} else {
throw std::runtime_error(
"Unable to construct tracking geometry: no tracking volume");
Expand Down
29 changes: 17 additions & 12 deletions Core/src/Geometry/TrackingVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,13 @@ void Acts::TrackingVolume::interlinkLayers() {
void Acts::TrackingVolume::closeGeometry(
const IMaterialDecorator* materialDecorator,
std::unordered_map<GeometryIdentifier, const TrackingVolume*>& volumeMap,
size_t& vol, const GeometryIdentifierHook& hook) {
size_t& vol, const GeometryIdentifierHook& hook, const Logger& logger) {
// we can construct the volume ID from this
auto volumeID = GeometryIdentifier().setVolume(++vol);
// assign the Volume ID to the volume itself
auto thisVolume = const_cast<TrackingVolume*>(this);
thisVolume->assignGeometryId(volumeID);

ACTS_DEBUG("volumeID: " << volumeID << ", name: " << volumeName());
// insert the volume into the map
volumeMap[volumeID] = thisVolume;

Expand Down Expand Up @@ -415,7 +415,8 @@ void Acts::TrackingVolume::closeGeometry(
auto layerID = GeometryIdentifier(volumeID).setLayer(++ilayer);
// now close the geometry
auto mutableLayerPtr = std::const_pointer_cast<Layer>(layerPtr);
mutableLayerPtr->closeGeometry(materialDecorator, layerID, hook);
mutableLayerPtr->closeGeometry(materialDecorator, layerID, hook,
logger);
}
} else if (m_bvhTop != nullptr) {
GeometryIdentifier::Value isurface = 0;
Expand All @@ -441,8 +442,8 @@ void Acts::TrackingVolume::closeGeometry(
auto mutableVolumesIter =
std::const_pointer_cast<TrackingVolume>(volumesIter);
mutableVolumesIter->setMotherVolume(this);
mutableVolumesIter->closeGeometry(materialDecorator, volumeMap, vol,
hook);
mutableVolumesIter->closeGeometry(materialDecorator, volumeMap, vol, hook,
logger);
}
}

Expand All @@ -451,8 +452,8 @@ void Acts::TrackingVolume::closeGeometry(
auto mutableVolumesIter =
std::const_pointer_cast<TrackingVolume>(volumesIter);
mutableVolumesIter->setMotherVolume(this);
mutableVolumesIter->closeGeometry(materialDecorator, volumeMap, vol,
hook);
mutableVolumesIter->closeGeometry(materialDecorator, volumeMap, vol, hook,
logger);
}
}
}
Expand All @@ -462,7 +463,7 @@ boost::container::small_vector<Acts::BoundaryIntersection, 4>
Acts::TrackingVolume::compatibleBoundaries(
const GeometryContext& gctx, const Vector3& position,
const Vector3& direction, const NavigationOptions<Surface>& options,
LoggerWrapper logger) const {
const Logger& logger) const {
ACTS_VERBOSE("Finding compatibleBoundaries");
// Loop over boundarySurfaces and calculate the intersection
auto excludeObject = options.startObject;
Expand Down Expand Up @@ -507,17 +508,21 @@ Acts::TrackingVolume::compatibleBoundaries(

ACTS_VERBOSE("Check intersection with surface "
<< bSurface->surfaceRepresentation().geometryId());
if (detail::checkIntersection(sIntersection.intersection, pLimit, oLimit,
s_onSurfaceTolerance, logger)) {
if (detail::checkIntersection<decltype(sIntersection.intersection),
decltype(logger)>(
sIntersection.intersection, pLimit, oLimit, s_onSurfaceTolerance,
logger)) {
sIntersection.intersection.pathLength *= options.navDir;
return BoundaryIntersection(sIntersection.intersection, bSurface,
sIntersection.object);
}

if (sIntersection.alternative) {
ACTS_VERBOSE("Consider alternative");
if (detail::checkIntersection(sIntersection.alternative, pLimit, oLimit,
s_onSurfaceTolerance, logger)) {
if (detail::checkIntersection<decltype(sIntersection.alternative),
decltype(logger)>(
sIntersection.alternative, pLimit, oLimit, s_onSurfaceTolerance,
logger)) {
sIntersection.alternative.pathLength *= options.navDir;
return BoundaryIntersection(sIntersection.alternative, bSurface,
sIntersection.object);
Expand Down

0 comments on commit bdf2378

Please sign in to comment.