Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: TrackingGeometry interface cleanup #3612

2 changes: 1 addition & 1 deletion CI/physmon/workflows/physmon_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
rnd,
preSelectParticles=None,
postSelectParticles=ParticleSelectorConfig(removeSecondaries=True),
killVolume=setup.trackingGeometry.worldVolume,
killVolume=setup.trackingGeometry.highestTrackingVolume,
killAfterTime=25 * u.ns,
killSecondaries=True,
inputParticles="particles_input",
Expand Down
32 changes: 6 additions & 26 deletions Core/include/Acts/Geometry/TrackingGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "Acts/Utilities/Logger.hpp"

#include <memory>
#include <string>
#include <unordered_map>
#include <utility>

Expand All @@ -29,9 +28,6 @@ class PerigeeSurface;
class IMaterialDecorator;
class TrackingVolume;

using TrackingVolumePtr = std::shared_ptr<const TrackingVolume>;
using MutableTrackingVolumePtr = std::shared_ptr<TrackingVolume>;

/// @class TrackingGeometry
///
/// The TrackingGeometry class is the owner of the constructed TrackingVolumes.
Expand All @@ -52,7 +48,7 @@ class TrackingGeometry {
/// 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,
TrackingGeometry(const std::shared_ptr<TrackingVolume>& highestVolume,
const IMaterialDecorator* materialDecorator = nullptr,
const GeometryIdentifierHook& hook = {},
const Logger& logger = getDummyLogger());
Expand All @@ -66,8 +62,7 @@ class TrackingGeometry {

/// Access to the world volume
/// @return shared pointer to the world volume
const std::shared_ptr<const TrackingVolume>& highestTrackingVolumeShared()
const;
std::shared_ptr<const TrackingVolume> highestTrackingVolumePtr() const;

/// return the lowest tracking Volume
///
Expand All @@ -87,19 +82,6 @@ class TrackingGeometry {
const Layer* associatedLayer(const GeometryContext& gctx,
const Vector3& gp) const;

/// Register the beam tube
///
/// @param beam is the beam line surface
void registerBeamTube(std::shared_ptr<const PerigeeSurface> beam);

/// @brief surface representing the beam pipe
///
/// @note The ownership is not passed, e.g. do not delete the pointer
///
/// @return raw pointer to surface representing the beam pipe
/// (could be a null pointer)
const Surface* getBeamline() const;

/// @brief Visit all reachable surfaces
///
/// @tparam visitor_t Type of the callable visitor
Expand All @@ -108,7 +90,7 @@ class TrackingGeometry {
/// that is found, a selection of the surfaces can be done in the visitor
/// @param restrictToSensitives If true, only sensitive surfaces are visited
///
/// @note If a context is needed for the visit, the vistitor has to provide
/// @note If a context is needed for the visit, the visitor has to provide
/// this, e.g. as a private member
template <SurfaceVisitor visitor_t>
void visitSurfaces(visitor_t&& visitor, bool restrictToSensitives) const {
Expand All @@ -123,7 +105,7 @@ class TrackingGeometry {
/// @param visitor The callable. Will be called for each sensitive surface
/// that is found, a selection of the surfaces can be done in the visitor
///
/// @note If a context is needed for the visit, the vistitor has to provide
/// @note If a context is needed for the visit, the visitor has to provide
/// this, e.g. as a private member
template <SurfaceVisitor visitor_t>
void visitSurfaces(visitor_t&& visitor) const {
Expand All @@ -137,7 +119,7 @@ class TrackingGeometry {
/// @param visitor The callable. Will be called for each reachable volume
/// that is found, a selection of the volumes can be done in the visitor
///
/// @note If a context is needed for the visit, the vistitor has to provide
/// @note If a context is needed for the visit, the visitor has to provide
/// this, e.g. as a private member
template <TrackingVolumeVisitor visitor_t>
void visitVolumes(visitor_t&& visitor) const {
Expand Down Expand Up @@ -165,9 +147,7 @@ class TrackingGeometry {

private:
// the known world
TrackingVolumePtr m_world;
// beam line
std::shared_ptr<const PerigeeSurface> m_beam;
std::shared_ptr<TrackingVolume> m_world;
// lookup containers
std::unordered_map<GeometryIdentifier, const TrackingVolume*> m_volumesById;
std::unordered_map<GeometryIdentifier, const Surface*> m_surfacesById;
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Geometry/TrackingVolume.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class TrackingVolume : public Volume {
const IVolumeMaterial* volumeMaterial() const;

/// Return the material of the volume as shared pointer
const std::shared_ptr<const IVolumeMaterial>& volumeMaterialSharedPtr() const;
const std::shared_ptr<const IVolumeMaterial>& volumeMaterialPtr() const;

/// Set the volume material description
///
Expand Down
16 changes: 3 additions & 13 deletions Core/src/Geometry/TrackingGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ Acts::TrackingGeometry::TrackingGeometry(
const MutableTrackingVolumePtr& highestVolume,
const IMaterialDecorator* materialDecorator,
const GeometryIdentifierHook& hook, const Logger& logger)
: m_world(highestVolume),
m_beam(Surface::makeShared<PerigeeSurface>(Vector3::Zero())) {
: m_world(highestVolume) {
// Close the geometry: assign geometryID and successively the material
std::size_t volumeID = 0;
highestVolume->closeGeometry(materialDecorator, m_volumesById, volumeID, hook,
Expand All @@ -50,8 +49,8 @@ const Acts::TrackingVolume* Acts::TrackingGeometry::highestTrackingVolume()
return m_world.get();
}

const std::shared_ptr<const Acts::TrackingVolume>&
Acts::TrackingGeometry::highestTrackingVolumeShared() const {
std::shared_ptr<const Acts::TrackingVolume>
Acts::TrackingGeometry::highestTrackingVolumePtr() const {
return m_world;
}

Expand All @@ -64,15 +63,6 @@ const Acts::Layer* Acts::TrackingGeometry::associatedLayer(
return lowestVol->associatedLayer(gctx, gp);
}

void Acts::TrackingGeometry::registerBeamTube(
std::shared_ptr<const PerigeeSurface> beam) {
m_beam = std::move(beam);
}

const Acts::Surface* Acts::TrackingGeometry::getBeamline() const {
return m_beam.get();
}

const Acts::TrackingVolume* Acts::TrackingGeometry::findVolume(
GeometryIdentifier id) const {
auto vol = m_volumesById.find(id);
Expand Down
4 changes: 2 additions & 2 deletions Core/src/Geometry/TrackingVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ void TrackingVolume::closeGeometry(
thisVolume->motherVolume()->volumeMaterial());
if (protoMaterial == nullptr) {
thisVolume->assignVolumeMaterial(
thisVolume->motherVolume()->volumeMaterialSharedPtr());
thisVolume->motherVolume()->volumeMaterialPtr());
}
}

Expand Down Expand Up @@ -577,7 +577,7 @@ const IVolumeMaterial* TrackingVolume::volumeMaterial() const {
}

const std::shared_ptr<const IVolumeMaterial>&
TrackingVolume::volumeMaterialSharedPtr() const {
TrackingVolume::volumeMaterialPtr() const {
return m_volumeMaterial;
}

Expand Down
3 changes: 1 addition & 2 deletions Core/src/Material/SurfaceMaterialMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ void Acts::SurfaceMaterialMapper::collectMaterialVolumes(
<< "' for material surfaces.");
ACTS_VERBOSE("- Insert Volume ...");
if (tVolume.volumeMaterial() != nullptr) {
mState.volumeMaterial[tVolume.geometryId()] =
tVolume.volumeMaterialSharedPtr();
mState.volumeMaterial[tVolume.geometryId()] = tVolume.volumeMaterialPtr();
}

// Step down into the sub volume
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class MappingMaterialDecorator : public IMaterialDecorator {
}
if (tVolume->volumeMaterial() != nullptr) {
m_volumeMaterialMap.insert(
{tVolume->geometryId(), tVolume->volumeMaterialSharedPtr()});
{tVolume->geometryId(), tVolume->volumeMaterialPtr()});
}
// there are confined volumes
if (tVolume->confinedVolumes() != nullptr) {
Expand Down
4 changes: 2 additions & 2 deletions Examples/Io/Root/src/RootMaterialWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ void ActsExamples::RootMaterialWriter::collectMaterial(
const Acts::TrackingVolume& tVolume,
Acts::DetectorMaterialMaps& detMatMap) {
// If the volume has volume material, write that
if (tVolume.volumeMaterialSharedPtr() != nullptr && m_cfg.processVolumes) {
detMatMap.second[tVolume.geometryId()] = tVolume.volumeMaterialSharedPtr();
if (tVolume.volumeMaterialPtr() != nullptr && m_cfg.processVolumes) {
detMatMap.second[tVolume.geometryId()] = tVolume.volumeMaterialPtr();
}

// If confined layers exist, loop over them and collect the layer material
Expand Down
4 changes: 2 additions & 2 deletions Examples/Python/src/Geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ void addGeometry(Context& ctx) {
return selector.surfaces;
})
.def_property_readonly(
"worldVolume",
&Acts::TrackingGeometry::highestTrackingVolumeShared);
"highestTrackingVolume",
&Acts::TrackingGeometry::highestTrackingVolumePtr);
}

{
Expand Down
2 changes: 1 addition & 1 deletion Examples/Scripts/Python/full_chain_odd.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
outputDirRoot=outputDir if args.output_root else None,
outputDirCsv=outputDir if args.output_csv else None,
rnd=rnd,
killVolume=trackingGeometry.worldVolume,
killVolume=trackingGeometry.highestTrackingVolume,
killAfterTime=25 * u.ns,
)
else:
Expand Down
2 changes: 1 addition & 1 deletion Examples/Scripts/Python/full_chain_odd_LRT.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
outputDirRoot=outputDir if args.output_root else None,
outputDirCsv=outputDir if args.output_csv else None,
rnd=rnd,
killVolume=trackingGeometry.worldVolume,
killVolume=trackingGeometry.highestTrackingVolume,
killAfterTime=25 * u.ns,
)
else:
Expand Down
4 changes: 2 additions & 2 deletions Plugins/Json/src/MaterialMapJsonConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ Acts::SurfaceAndMaterialWithContext defaultSurfaceMaterial(
Acts::TrackingVolumeAndMaterial defaultVolumeMaterial(
const Acts::TrackingVolume* volume) {
Acts::BinUtility bUtility;
if (volume->volumeMaterialSharedPtr() != nullptr) {
return {volume, volume->volumeMaterialSharedPtr()};
if (volume->volumeMaterialPtr() != nullptr) {
return {volume, volume->volumeMaterialPtr()};
}
// Check which type of bound is associated to the volume
auto cyBounds = dynamic_cast<const Acts::CylinderVolumeBounds*>(
Expand Down
5 changes: 4 additions & 1 deletion Tests/UnitTests/Core/Propagator/NavigatorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "Acts/Propagator/Navigator.hpp"
#include "Acts/Propagator/StepperConcept.hpp"
#include "Acts/Surfaces/BoundaryTolerance.hpp"
#include "Acts/Surfaces/PerigeeSurface.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp"
#include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
Expand Down Expand Up @@ -392,7 +393,9 @@ BOOST_AUTO_TEST_CASE(Navigator_status_methods) {
nullptr, nullptr, nullptr, nullptr,
nullptr));
ACTS_INFO(" iii) Because the target surface is reached");
const Surface* startSurf = tGeometry->getBeamline();

auto beamline = Surface::makeShared<PerigeeSurface>(Vector3::Zero());
const Surface* startSurf = beamline.get();
state.stepping.pos4.segment<3>(Acts::ePos0) =
startSurf->center(state.geoContext);
const Surface* targetSurf = startSurf;
Expand Down
Loading