Skip to content

Commit

Permalink
Merge branch 'main' into feat/is-on-surface-tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgessinger authored Aug 23, 2024
2 parents 594503c + fb8c3bc commit 27f1094
Show file tree
Hide file tree
Showing 20 changed files with 37 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class GeoModelDetectorElement : public DetectorElementBase {
/// @return a shared pointer to an instance of the detector element
template <typename SurfaceType, typename BoundsType>
static std::shared_ptr<GeoModelDetectorElement> createDetectorElement(
PVConstLink geoPhysVol, const std::shared_ptr<BoundsType> bounds,
const PVConstLink& geoPhysVol, const std::shared_ptr<BoundsType> bounds,
const Transform3& sfTransform, ActsScalar thickness) {
// First create the detector element with a nullptr
auto detElement = std::make_shared<GeoModelDetectorElement>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,16 @@ class GeoModelDetectorObjectFactory {
void construct(Cache& cache, const GeometryContext& gctx,
const GeoModelTree& geoModelTree, const Options& options);

void convertSensitive(PVConstLink geoPV, const Acts::Transform3& transform,
void convertSensitive(const PVConstLink& geoPV,
const Acts::Transform3& transform,
std::vector<GeoModelSensitiveSurface>& sensitives);

std::vector<GeoChildNodeWithTrf> findAllSubVolumes(PVConstLink geoPV);
std::vector<GeoChildNodeWithTrf> findAllSubVolumes(const PVConstLink& vol);

bool convertBox(std::string name);
bool matches(const std::string& name, PVConstLink physvol);
bool matches(const std::string& name, const PVConstLink& physvol);

void convertFpv(std::string name, GeoFullPhysVol* fpv, Cache& cache,
void convertFpv(const std::string& name, GeoFullPhysVol* fpv, Cache& cache,
const GeometryContext& gctx);

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@

class GeoMaterial;

namespace Acts {
namespace Acts::GeoModel {

namespace GeoModel {
/// @brief Convert GeoMaterial to Acts::Material
///
/// @param gm The GeoMaterial to be converted
/// @return the Acts::Material
Material geoMaterialConverter(const GeoMaterial& gm,
bool useMolarDensity = true);

} // namespace GeoModel
} // namespace Acts
} // namespace Acts::GeoModel
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@
#include "GeoModelKernel/GeoDefinitions.h"
class GeoShape;

namespace Acts {
namespace Acts::GeoModel {

namespace GeoModel {
/// @brief Convert a GeoModel shape to a DetectorVolume
///
/// @param shape the GeoModel shape
/// @param transform the transform to be applied
/// @return the DetectorVolume
std::shared_ptr<Experimental::DetectorVolume> convertVolume(
const GeometryContext& context, const GeoShape& shape,
const std::string& name, const GeoTrf::Transform3D transform,
const std::string& name, const GeoTrf::Transform3D& transform,
const std::vector<GeoModelSensitiveSurface>& sensitives);
} // namespace GeoModel
} // namespace Acts

} // namespace Acts::GeoModel
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct GeoBoxConverter {
/// @param bool sensitive
///
/// @return The detector element and surface
Result<GeoModelSensitiveSurface> operator()(PVConstLink geoPV,
Result<GeoModelSensitiveSurface> operator()(const PVConstLink& geoPV,
const GeoBox& geoBox,
const Transform3& absTransform,
bool sensitive) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct GeoIntersectionAnnulusConverter {
///
/// @return The detector element and surface
Result<GeoModelSensitiveSurface> operator()(
PVConstLink geoPV, const GeoShapeIntersection& geoIntersection,
const PVConstLink& geoPV, const GeoShapeIntersection& geoIntersection,
const Transform3& absTransform, bool sensitive) const;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct GeoShiftConverter {
/// @param bool sensitive
///
/// @return The detector element and surface
Result<GeoModelSensitiveSurface> operator()(PVConstLink geoPV,
Result<GeoModelSensitiveSurface> operator()(const PVConstLink& geoPV,
const GeoShapeShift& geoShift,
const Transform3& absTransform,
bool sensitive) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct GeoTrdConverter {
/// @param bool sensitive
///
/// @return The detector element and surface
Result<GeoModelSensitiveSurface> operator()(PVConstLink geoPV,
Result<GeoModelSensitiveSurface> operator()(const PVConstLink& geoPV,
const GeoTrd& geoTrd,
const Transform3& absTransform,
bool sensitive) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct GeoTubeConverter {
/// @param bool sensitive
///
/// @return The detector element and surface
Result<GeoModelSensitiveSurface> operator()(PVConstLink geoPV,
Result<GeoModelSensitiveSurface> operator()(const PVConstLink& geoPV,
const GeoTube& geoTube,
const Transform3& absTransform,
bool sensitive) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ struct GeoUnionDoubleTrdConverter {
/// @param bool sensitive
///
/// @return The detector element and surface

Result<GeoModelSensitiveSurface> operator()(PVConstLink geoFPV,
Result<GeoModelSensitiveSurface> operator()(const PVConstLink& geoPV,
const GeoShapeUnion& geoUnion,
const Transform3& absTransform,
bool sensitive) const;
Expand Down
2 changes: 1 addition & 1 deletion Plugins/GeoModel/src/GeoModelDetectorElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Acts::GeoModelDetectorElement::GeoModelDetectorElement(
PVConstLink geoPhysVol, std::shared_ptr<Surface> surface,
const Transform3& sfTransform, ActsScalar thickness)
: m_geoPhysVol(geoPhysVol),
: m_geoPhysVol(std::move(geoPhysVol)),
m_surface(std::move(surface)),
m_surfaceTransform(sfTransform),
m_thickness(thickness) {}
Expand Down
12 changes: 6 additions & 6 deletions Plugins/GeoModel/src/GeoModelDetectorObjectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void Acts::GeoModelDetectorObjectFactory::construct(
}

void Acts::GeoModelDetectorObjectFactory::convertSensitive(
PVConstLink geoPV, const Acts::Transform3 &transform,
const PVConstLink &geoPV, const Acts::Transform3 &transform,
std::vector<GeoModelSensitiveSurface> &sensitives) {
const GeoLogVol *logVol = geoPV->getLogVol();
const GeoShape *shape = logVol->getShape();
Expand Down Expand Up @@ -120,7 +120,7 @@ void Acts::GeoModelDetectorObjectFactory::convertSensitive(
}

std::vector<GeoChildNodeWithTrf>
Acts::GeoModelDetectorObjectFactory::findAllSubVolumes(PVConstLink vol) {
Acts::GeoModelDetectorObjectFactory::findAllSubVolumes(const PVConstLink &vol) {
std::vector<GeoChildNodeWithTrf> subvolumes = getChildrenWithRef(vol, false);
std::vector<GeoChildNodeWithTrf> sensitives;
for (auto subvolume : subvolumes) {
Expand All @@ -147,19 +147,19 @@ bool Acts::GeoModelDetectorObjectFactory::convertBox(std::string name) {
return convB;
}
void Acts::GeoModelDetectorObjectFactory::convertFpv(
std::string name, GeoFullPhysVol *fpv, Cache &cache,
const std::string &name, GeoFullPhysVol *fpv, Cache &cache,
const GeometryContext &gctx) {
PVConstLink physVol{fpv};

// get children
std::vector<GeoChildNodeWithTrf> subvolumes =
getChildrenWithRef(physVol, false);
if (subvolumes.size() > 0) {
if (!subvolumes.empty()) {
// vector containing all subvolumes to be converted to surfaces
std::vector<GeoChildNodeWithTrf> surfaces = findAllSubVolumes(physVol);
std::vector<GeoModelSensitiveSurface> sensitives;

for (auto surface : surfaces) {
for (const auto &surface : surfaces) {
const Transform3 &transform =
fpv->getAbsoluteTransform() * surface.transform;
convertSensitive(surface.volume, transform, sensitives);
Expand All @@ -186,7 +186,7 @@ void Acts::GeoModelDetectorObjectFactory::convertFpv(
}
// lambda to determine if object fits query
bool Acts::GeoModelDetectorObjectFactory::matches(const std::string &name,
PVConstLink physvol) {
const PVConstLink &physvol) {
if (m_cfg.nameList.empty() && m_cfg.materialList.empty()) {
return true;
}
Expand Down
10 changes: 5 additions & 5 deletions Plugins/GeoModel/src/GeoModelToDetectorVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
#include <GeoModelKernel/GeoTube.h>
#include <GeoModelKernel/GeoTubs.h>

namespace Acts {
namespace GeoModel {
namespace Acts::GeoModel {

std::shared_ptr<Experimental::DetectorVolume> convertVolume(
const GeometryContext& context, const GeoShape& shape,
const std::string& name, const GeoTrf::Transform3D transform,
const std::string& name, const GeoTrf::Transform3D& transform,
const std::vector<GeoModelSensitiveSurface>& sensitives) {
// dummy volume for conversion with surfaces
std::vector<std::shared_ptr<Acts::Experimental::DetectorVolume>> a;
Expand Down Expand Up @@ -184,5 +184,5 @@ std::shared_ptr<Experimental::DetectorVolume> convertVolume(
}
throw std::runtime_error("FATAL: Unsupported GeoModel shape");
}
} // namespace GeoModel
} // namespace Acts

} // namespace Acts::GeoModel
2 changes: 1 addition & 1 deletion Plugins/GeoModel/src/detail/GeoBoxConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <GeoModelKernel/Units.h>

Acts::Result<Acts::GeoModelSensitiveSurface>
Acts::detail::GeoBoxConverter::operator()(PVConstLink geoPV,
Acts::detail::GeoBoxConverter::operator()(const PVConstLink& geoPV,
const GeoBox& geoBox,
const Transform3& absTransform,
bool sensitive) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

Acts::Result<Acts::GeoModelSensitiveSurface>
Acts::detail::GeoIntersectionAnnulusConverter::operator()(
PVConstLink geoPV, const GeoShapeIntersection& geoIntersection,
const PVConstLink& geoPV, const GeoShapeIntersection& geoIntersection,
const Transform3& absTransform, bool sensitive) const {
/// auto-calculate the unit length conversion
static constexpr ActsScalar unitLength =
Expand Down
2 changes: 1 addition & 1 deletion Plugins/GeoModel/src/detail/GeoShiftConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Result<GeoModelSensitiveSurface> impl(PVConstLink geoPV,
} // namespace

Result<GeoModelSensitiveSurface> GeoShiftConverter::operator()(
PVConstLink geoPV, const GeoShapeShift& geoShift,
const PVConstLink& geoPV, const GeoShapeShift& geoShift,
const Transform3& absTransform, bool sensitive) const {
auto r = impl<GeoTrd, detail::GeoTrdConverter, PlaneSurface, TrapezoidBounds>(
geoPV, geoShift, absTransform, sensitive);
Expand Down
2 changes: 1 addition & 1 deletion Plugins/GeoModel/src/detail/GeoTrdConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <GeoModelKernel/Units.h>

Acts::Result<Acts::GeoModelSensitiveSurface>
Acts::detail::GeoTrdConverter::operator()(PVConstLink geoPV,
Acts::detail::GeoTrdConverter::operator()(const PVConstLink& geoPV,
const GeoTrd& geoTrd,
const Transform3& absTransform,
bool sensitive) const {
Expand Down
2 changes: 1 addition & 1 deletion Plugins/GeoModel/src/detail/GeoTubeConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <GeoModelKernel/Units.h>

Acts::Result<Acts::GeoModelSensitiveSurface>
Acts::detail::GeoTubeConverter::operator()(PVConstLink geoPV,
Acts::detail::GeoTubeConverter::operator()(const PVConstLink& geoPV,
const GeoTube& geoTube,
const Transform3& absTransform,
bool sensitive) const {
Expand Down
2 changes: 1 addition & 1 deletion Plugins/GeoModel/src/detail/GeoUnionDoubleTrdConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool trapezoidsAreMergeable(const std::vector<Acts::Vector3> &vtxsa,
namespace Acts::detail {

Result<GeoModelSensitiveSurface> GeoUnionDoubleTrdConverter::operator()(
PVConstLink geoPV, const GeoShapeUnion &geoUnion,
const PVConstLink &geoPV, const GeoShapeUnion &geoUnion,
const Transform3 &absTransform, bool sensitive) const {
const auto shiftA = dynamic_cast<const GeoShapeShift *>(geoUnion.getOpA());
const auto shiftB = dynamic_cast<const GeoShapeShift *>(geoUnion.getOpB());
Expand Down
2 changes: 1 addition & 1 deletion Tests/UnitTests/Plugins/GeoModel/GeoDetectorObjectTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ BOOST_AUTO_TEST_CASE(GeoModelDetectorObjectFactory) {
factory.convertFpv("LogVolumeXY", fphysXY, gmCache, gContext);

// checking the dimension of the converted bounding boxes
for (auto box : gmCache.boundingBoxes) {
for (const auto& box : gmCache.boundingBoxes) {
const Acts::VolumeBounds& bounds = box->volumeBounds();
BOOST_CHECK(gmhlx == bounds.values()[0]);
BOOST_CHECK(gmhly == bounds.values()[1]);
Expand Down

0 comments on commit 27f1094

Please sign in to comment.