From f6f8df402507ec1f2550a73c013f3195facc43f9 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Tue, 26 Nov 2024 23:21:17 +0100 Subject: [PATCH] refactor: Cleanup some more detector code in Examples (#3908) - organize includes and forward delerations - remove special detector namespaces when possible - make use of namespaces in source files ## Summary by CodeRabbit - **New Features** - Simplified namespace structure across various classes for improved readability. - Updated method signatures to enhance clarity and reduce redundancy. - Enhanced error handling and logging in the `EDM4hepReader` class. - Introduced new member functions in the `GenericDetectorElement` class for better property access. - Added new member variables in the `Geant4Simulation` configuration structure for improved functionality. - Updated the `Config` struct in `EDM4hepReader` to simplify the `dd4hepDetector` reference. - **Bug Fixes** - Improved checks for configuration parameters in the `EDM4hepReader` constructor. - **Chores** - Removed unnecessary include directives to streamline dependencies. - Adjusted type references for various classes and methods to eliminate namespace prefixes. --- .../DDG4/DDG4DetectorConstruction.hpp | 11 ++- .../TelescopeG4DetectorConstruction.hpp | 4 +- .../Geant4/src/DDG4DetectorConstruction.cpp | 4 +- .../src/TelescopeG4DetectorConstruction.cpp | 16 ++-- .../ContextualDetector/AlignedDetector.hpp | 14 ++-- .../ContextualDetector/AlignmentDecorator.hpp | 12 +-- .../ExternalAlignmentDecorator.hpp | 5 -- .../ExternallyAlignedDetectorElement.hpp | 13 +--- .../InternalAlignmentDecorator.hpp | 7 +- .../InternallyAlignedDetectorElement.hpp | 13 +--- .../src/AlignedDetector.cpp | 24 +++--- .../src/ExternalAlignmentDecorator.cpp | 16 ++-- .../src/InternalAlignmentDecorator.cpp | 14 ++-- .../DD4hepDetector/DD4hepDetector.hpp | 10 +-- .../DD4hepDetector/DD4hepGeometryService.hpp | 9 +-- .../DD4hepDetector/src/DD4hepDetector.cpp | 11 +-- .../src/DD4hepGeometryService.cpp | 61 +++++++-------- .../Geant4Detector/Geant4Detector.hpp | 7 +- .../Geant4Detector/src/Geant4Detector.cpp | 21 ++--- .../GenericDetector/BuildGenericDetector.hpp | 8 +- .../GenericDetector/GenericDetector.hpp | 16 ++-- .../GenericDetectorElement.hpp | 28 +------ .../GenericDetector/LayerBuilderT.hpp | 6 -- .../GenericDetector/ProtoLayerCreatorT.hpp | 3 - .../src/BuildGenericDetector.cpp | 16 ++-- .../GenericDetector/src/GenericDetector.cpp | 10 ++- .../src/GenericDetectorElement.cpp | 29 ++++++- .../ITkModuleSplitting/ITkModuleSplitting.hpp | 1 - .../src/ScalableBFieldService.cpp | 14 ++-- .../src/MockupSectorBuilder.cpp | 24 +++--- .../TGeoDetector/JsonTGeoDetectorConfig.hpp | 24 +++--- .../TGeoDetector/TGeoDetector.hpp | 7 +- .../TGeoDetector/src/TGeoDetector.cpp | 7 +- .../src/TGeoITkModuleSplitter.cpp | 23 +++--- .../BuildTelescopeDetector.hpp | 13 ++-- .../TelescopeDetector/TelescopeDetector.hpp | 25 ++---- .../TelescopeDetectorElement.hpp | 4 +- .../src/BuildTelescopeDetector.cpp | 12 +-- .../src/TelescopeDetector.cpp | 24 +++--- .../src/TelescopeDetectorElement.cpp | 8 +- .../ActsExamples/Io/EDM4hep/EDM4hepReader.hpp | 4 +- Examples/Io/EDM4hep/src/EDM4hepReader.cpp | 1 - Examples/Python/src/DD4hepComponent.cpp | 29 +++---- Examples/Python/src/Detector.cpp | 77 +++++++++---------- Examples/Python/src/Geant4Component.cpp | 36 +++------ Examples/Python/src/Geant4DD4hepComponent.cpp | 4 +- 46 files changed, 309 insertions(+), 416 deletions(-) diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/DDG4/DDG4DetectorConstruction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/DDG4/DDG4DetectorConstruction.hpp index 54c590ac4d3..6706b5c20e4 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/DDG4/DDG4DetectorConstruction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/DDG4/DDG4DetectorConstruction.hpp @@ -20,17 +20,16 @@ class G4VPhysicalVolume; namespace dd4hep { class Detector; } + namespace ActsExamples { -namespace DD4hep { struct DD4hepDetector; -} /// Construct the Geant4 detector from a DD4hep description. class DDG4DetectorConstruction final : public G4VUserDetectorConstruction { public: DDG4DetectorConstruction( - std::shared_ptr detector, + std::shared_ptr detector, std::vector> regionCreators = {}); ~DDG4DetectorConstruction() final; @@ -45,7 +44,7 @@ class DDG4DetectorConstruction final : public G4VUserDetectorConstruction { private: /// The Acts DD4hep detector instance - std::shared_ptr m_detector; + std::shared_ptr m_detector; /// Region creators std::vector> m_regionCreators; /// The world volume @@ -59,7 +58,7 @@ class DDG4DetectorConstructionFactory final : public Geant4::DetectorConstructionFactory { public: DDG4DetectorConstructionFactory( - std::shared_ptr detector, + std::shared_ptr detector, std::vector> regionCreators = {}); ~DDG4DetectorConstructionFactory() final; @@ -67,7 +66,7 @@ class DDG4DetectorConstructionFactory final private: /// The Acts DD4hep detector instance - std::shared_ptr m_detector; + std::shared_ptr m_detector; /// Region creators std::vector> m_regionCreators; }; diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/TelescopeDetector/TelescopeG4DetectorConstruction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/TelescopeDetector/TelescopeG4DetectorConstruction.hpp index 0d0fc522217..dba44638152 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/TelescopeDetector/TelescopeG4DetectorConstruction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/TelescopeDetector/TelescopeG4DetectorConstruction.hpp @@ -17,7 +17,7 @@ class G4VPhysicalVolume; class G4LogicalVolume; -namespace ActsExamples::Telescope { +namespace ActsExamples { class TelescopeG4DetectorConstruction final : public G4VUserDetectorConstruction { @@ -53,4 +53,4 @@ class TelescopeG4DetectorConstructionFactory final std::vector> m_regionCreators; }; -} // namespace ActsExamples::Telescope +} // namespace ActsExamples diff --git a/Examples/Algorithms/Geant4/src/DDG4DetectorConstruction.cpp b/Examples/Algorithms/Geant4/src/DDG4DetectorConstruction.cpp index 2868fbb3a63..1b24da8f273 100644 --- a/Examples/Algorithms/Geant4/src/DDG4DetectorConstruction.cpp +++ b/Examples/Algorithms/Geant4/src/DDG4DetectorConstruction.cpp @@ -25,7 +25,7 @@ class G4VPhysicalVolume; namespace ActsExamples { DDG4DetectorConstruction::DDG4DetectorConstruction( - std::shared_ptr detector, + std::shared_ptr detector, std::vector> regionCreators) : G4VUserDetectorConstruction(), m_detector(std::move(detector)), @@ -60,7 +60,7 @@ G4VPhysicalVolume* DDG4DetectorConstruction::Construct() { } DDG4DetectorConstructionFactory::DDG4DetectorConstructionFactory( - std::shared_ptr detector, + std::shared_ptr detector, std::vector> regionCreators) : m_detector(std::move(detector)), m_regionCreators(std::move(regionCreators)) {} diff --git a/Examples/Algorithms/Geant4/src/TelescopeG4DetectorConstruction.cpp b/Examples/Algorithms/Geant4/src/TelescopeG4DetectorConstruction.cpp index 9d309932fbe..e8412a18c93 100644 --- a/Examples/Algorithms/Geant4/src/TelescopeG4DetectorConstruction.cpp +++ b/Examples/Algorithms/Geant4/src/TelescopeG4DetectorConstruction.cpp @@ -28,16 +28,15 @@ namespace ActsExamples { -Telescope::TelescopeG4DetectorConstruction::TelescopeG4DetectorConstruction( +TelescopeG4DetectorConstruction::TelescopeG4DetectorConstruction( const TelescopeDetector::Config& cfg, std::vector> regionCreators) : m_cfg(cfg), m_regionCreators(std::move(regionCreators)) { - throw_assert(cfg.surfaceType == - static_cast(Telescope::TelescopeSurfaceType::Plane), + throw_assert(cfg.surfaceType == static_cast(TelescopeSurfaceType::Plane), "only plan is supported right now"); } -G4VPhysicalVolume* Telescope::TelescopeG4DetectorConstruction::Construct() { +G4VPhysicalVolume* TelescopeG4DetectorConstruction::Construct() { if (m_world != nullptr) { return m_world; } @@ -168,14 +167,13 @@ G4VPhysicalVolume* Telescope::TelescopeG4DetectorConstruction::Construct() { return m_world; } -Telescope::TelescopeG4DetectorConstructionFactory:: - TelescopeG4DetectorConstructionFactory( - const TelescopeDetector::Config& cfg, - std::vector> regionCreators) +TelescopeG4DetectorConstructionFactory::TelescopeG4DetectorConstructionFactory( + const TelescopeDetector::Config& cfg, + std::vector> regionCreators) : m_cfg(cfg), m_regionCreators(std::move(regionCreators)) {} std::unique_ptr -Telescope::TelescopeG4DetectorConstructionFactory::factorize() const { +TelescopeG4DetectorConstructionFactory::factorize() const { return std::make_unique(m_cfg, m_regionCreators); } diff --git a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/AlignedDetector.hpp b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/AlignedDetector.hpp index 66a0f3b6b42..cfd12568d63 100644 --- a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/AlignedDetector.hpp +++ b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/AlignedDetector.hpp @@ -23,20 +23,16 @@ class IMaterialDecorator; } // namespace Acts namespace ActsExamples { + class IContextDecorator; -namespace Generic { class GenericDetectorElement; -} // namespace Generic -} // namespace ActsExamples -namespace ActsExamples::Contextual { class InternallyAlignedDetectorElement; class InternalAlignmentDecorator; class AlignedDetector { public: - using ContextDecorators = - std::vector>; + using ContextDecorators = std::vector>; using TrackingGeometryPtr = std::shared_ptr; struct Config : public GenericDetector::Config { @@ -69,15 +65,15 @@ class AlignedDetector { const Config& cfg, std::shared_ptr mdecorator); - std::vector>>& + std::vector>>& detectorStore() { return m_detectorStore; } private: /// The Store of the detector elements (lifetime: job) - std::vector>> + std::vector>> m_detectorStore; }; -} // namespace ActsExamples::Contextual +} // namespace ActsExamples diff --git a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/AlignmentDecorator.hpp b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/AlignmentDecorator.hpp index 1edf7e03d06..27bc1272fcf 100644 --- a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/AlignmentDecorator.hpp +++ b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/AlignmentDecorator.hpp @@ -9,17 +9,10 @@ #pragma once #include "Acts/Definitions/Algebra.hpp" -#include "Acts/Utilities/Logger.hpp" -#include "ActsExamples/ContextualDetector/InternallyAlignedDetectorElement.hpp" -#include "ActsExamples/Framework/AlgorithmContext.hpp" #include "ActsExamples/Framework/IContextDecorator.hpp" #include "ActsExamples/Framework/RandomNumbers.hpp" -#include -#include -#include - -namespace ActsExamples::Contextual { +namespace ActsExamples { /// @brief A mockup service that rotates the modules in a /// simple tracking geometry @@ -85,4 +78,5 @@ class AlignmentDecorator : public IContextDecorator { } } }; -} // namespace ActsExamples::Contextual + +} // namespace ActsExamples diff --git a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/ExternalAlignmentDecorator.hpp b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/ExternalAlignmentDecorator.hpp index de3f58b7e0a..6b873a0bdc9 100644 --- a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/ExternalAlignmentDecorator.hpp +++ b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/ExternalAlignmentDecorator.hpp @@ -9,12 +9,10 @@ #pragma once #include "Acts/Definitions/Algebra.hpp" -#include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Utilities/Logger.hpp" #include "ActsExamples/ContextualDetector/AlignmentDecorator.hpp" #include "ActsExamples/ContextualDetector/ExternallyAlignedDetectorElement.hpp" #include "ActsExamples/Framework/AlgorithmContext.hpp" -#include "ActsExamples/Framework/IContextDecorator.hpp" #include "ActsExamples/Framework/ProcessCode.hpp" #include @@ -31,8 +29,6 @@ class TrackingGeometry; namespace ActsExamples { struct AlgorithmContext; -namespace Contextual { - /// @brief A mockup service that rotates the modules in a /// simple tracking geometry /// @@ -96,6 +92,5 @@ class ExternalAlignmentDecorator : public AlignmentDecorator { /// @param tGeometry the tracking geometry void parseGeometry(const Acts::TrackingGeometry& tGeometry); }; -} // namespace Contextual } // namespace ActsExamples diff --git a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/ExternallyAlignedDetectorElement.hpp b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/ExternallyAlignedDetectorElement.hpp index 7456b9bb61e..f504b3a7c4a 100644 --- a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/ExternallyAlignedDetectorElement.hpp +++ b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/ExternallyAlignedDetectorElement.hpp @@ -10,13 +10,9 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Geometry/GeometryContext.hpp" -#include "Acts/Geometry/GeometryIdentifier.hpp" -#include "Acts/Surfaces/Surface.hpp" #include "ActsExamples/GenericDetector/GenericDetectorElement.hpp" -#include - -namespace ActsExamples::Contextual { +namespace ActsExamples { /// @class ExternallyAlignedDetectorElement extends GenericDetectorElement /// @@ -34,8 +30,7 @@ namespace ActsExamples::Contextual { /// In this simple implementation, it does rely on the Identifier /// to be orderded from 0 to N-1, as the identifier is simply taken /// as a vector index for the alignment store -class ExternallyAlignedDetectorElement - : public Generic::GenericDetectorElement { +class ExternallyAlignedDetectorElement : public GenericDetectorElement { public: struct AlignmentStore { // GenericDetector identifiers are sequential @@ -50,7 +45,7 @@ class ExternallyAlignedDetectorElement std::shared_ptr alignmentStore{nullptr}; }; - using Generic::GenericDetectorElement::GenericDetectorElement; + using GenericDetectorElement::GenericDetectorElement; /// Return local to global transform associated with this identifier /// @@ -80,4 +75,4 @@ inline const Acts::Transform3& ExternallyAlignedDetectorElement::transform( return alignContext.alignmentStore->transforms[idValue]; } -} // namespace ActsExamples::Contextual +} // namespace ActsExamples diff --git a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/InternalAlignmentDecorator.hpp b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/InternalAlignmentDecorator.hpp index e9af06d7755..d571c02ec2c 100644 --- a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/InternalAlignmentDecorator.hpp +++ b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/InternalAlignmentDecorator.hpp @@ -8,12 +8,10 @@ #pragma once -#include "Acts/Definitions/Algebra.hpp" #include "Acts/Utilities/Logger.hpp" #include "ActsExamples/ContextualDetector/AlignmentDecorator.hpp" #include "ActsExamples/ContextualDetector/InternallyAlignedDetectorElement.hpp" #include "ActsExamples/Framework/AlgorithmContext.hpp" -#include "ActsExamples/Framework/IContextDecorator.hpp" #include "ActsExamples/Framework/ProcessCode.hpp" #include "ActsExamples/Framework/RandomNumbers.hpp" @@ -25,9 +23,6 @@ #include namespace ActsExamples { -struct AlgorithmContext; - -namespace Contextual { class InternallyAlignedDetectorElement; /// @brief A mockup service that rotates the modules in a @@ -87,5 +82,5 @@ class InternalAlignmentDecorator : public AlignmentDecorator { /// Private access to the logging instance const Acts::Logger& logger() const { return *m_logger; } }; -} // namespace Contextual + } // namespace ActsExamples diff --git a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/InternallyAlignedDetectorElement.hpp b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/InternallyAlignedDetectorElement.hpp index aaa1c8d9b98..68c958e87b0 100644 --- a/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/InternallyAlignedDetectorElement.hpp +++ b/Examples/Detectors/ContextualDetector/include/ActsExamples/ContextualDetector/InternallyAlignedDetectorElement.hpp @@ -10,16 +10,12 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Geometry/GeometryContext.hpp" -#include "Acts/Geometry/GeometryIdentifier.hpp" -#include "Acts/Surfaces/Surface.hpp" #include "ActsExamples/GenericDetector/GenericDetectorElement.hpp" -#include -#include #include #include -namespace ActsExamples::Contextual { +namespace ActsExamples { /// @class InternallyAlignedDetectorElement extends GenericDetectorElement /// @@ -33,8 +29,7 @@ namespace ActsExamples::Contextual { /// store and then in a contextual call the actual detector element /// position is taken internal multi component store - the latter /// has to be filled though from an external source -class InternallyAlignedDetectorElement - : public Generic::GenericDetectorElement { +class InternallyAlignedDetectorElement : public GenericDetectorElement { public: struct ContextType { /// The current interval of validity @@ -43,7 +38,7 @@ class InternallyAlignedDetectorElement }; // Inherit constructor - using Generic::GenericDetectorElement::GenericDetectorElement; + using GenericDetectorElement::GenericDetectorElement; /// Return local to global transform associated with this identifier /// @@ -117,4 +112,4 @@ inline void InternallyAlignedDetectorElement::clearAlignedTransform( } } -} // namespace ActsExamples::Contextual +} // namespace ActsExamples diff --git a/Examples/Detectors/ContextualDetector/src/AlignedDetector.cpp b/Examples/Detectors/ContextualDetector/src/AlignedDetector.cpp index 044cc943a81..84e050c8470 100644 --- a/Examples/Detectors/ContextualDetector/src/AlignedDetector.cpp +++ b/Examples/Detectors/ContextualDetector/src/AlignedDetector.cpp @@ -8,8 +8,7 @@ #include "ActsExamples/ContextualDetector/AlignedDetector.hpp" -#include "Acts/Definitions/Units.hpp" -#include "Acts/Geometry/ILayerBuilder.hpp" +#include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/TrackingGeometry.hpp" #include "Acts/Utilities/Logger.hpp" #include "ActsExamples/ContextualDetector/AlignmentDecorator.hpp" @@ -19,10 +18,8 @@ #include "ActsExamples/ContextualDetector/InternallyAlignedDetectorElement.hpp" #include "ActsExamples/Framework/RandomNumbers.hpp" #include "ActsExamples/GenericDetector/BuildGenericDetector.hpp" -#include "ActsExamples/GenericDetector/ProtoLayerCreatorT.hpp" -using namespace Acts::UnitLiterals; -namespace ActsExamples::Contextual { +namespace ActsExamples { auto AlignedDetector::finalize( const Config& cfg, @@ -31,10 +28,9 @@ auto AlignedDetector::finalize( ContextDecorators aContextDecorators; // Let's create a random number service - ActsExamples::RandomNumbers::Config randomNumberConfig; + RandomNumbers::Config randomNumberConfig; randomNumberConfig.seed = cfg.seed; - auto randomNumberSvc = - std::make_shared(randomNumberConfig); + auto randomNumberSvc = std::make_shared(randomNumberConfig); auto fillDecoratorConfig = [&](AlignmentDecorator::Config& config) { config.iovSize = cfg.iovSize; @@ -55,6 +51,7 @@ auto AlignedDetector::finalize( TrackingGeometryPtr aTrackingGeometry; if (cfg.mode == Config::Mode::External) { ExternallyAlignedDetectorElement::ContextType nominalContext; + Acts::GeometryContext geometryContext(nominalContext); ExternalAlignmentDecorator::Config agcsConfig; fillDecoratorConfig(agcsConfig); @@ -63,8 +60,8 @@ auto AlignedDetector::finalize( detectorStore; aTrackingGeometry = - ActsExamples::Generic::buildDetector( - nominalContext, detectorStore, cfg.buildLevel, + Generic::buildDetector( + geometryContext, detectorStore, cfg.buildLevel, std::move(mdecorator), cfg.buildProto, cfg.surfaceLogLevel, cfg.layerLogLevel, cfg.volumeLogLevel); @@ -84,13 +81,14 @@ auto AlignedDetector::finalize( } else { InternallyAlignedDetectorElement::ContextType nominalContext; nominalContext.nominal = true; + Acts::GeometryContext geometryContext(nominalContext); InternalAlignmentDecorator::Config agcsConfig; fillDecoratorConfig(agcsConfig); aTrackingGeometry = - ActsExamples::Generic::buildDetector( - nominalContext, agcsConfig.detectorStore, cfg.buildLevel, + Generic::buildDetector( + geometryContext, agcsConfig.detectorStore, cfg.buildLevel, std::move(mdecorator), cfg.buildProto, cfg.surfaceLogLevel, cfg.layerLogLevel, cfg.volumeLogLevel); @@ -112,4 +110,4 @@ auto AlignedDetector::finalize( std::move(aTrackingGeometry), std::move(aContextDecorators)); } -} // namespace ActsExamples::Contextual +} // namespace ActsExamples diff --git a/Examples/Detectors/ContextualDetector/src/ExternalAlignmentDecorator.cpp b/Examples/Detectors/ContextualDetector/src/ExternalAlignmentDecorator.cpp index bca56249419..5120a29c334 100644 --- a/Examples/Detectors/ContextualDetector/src/ExternalAlignmentDecorator.cpp +++ b/Examples/Detectors/ContextualDetector/src/ExternalAlignmentDecorator.cpp @@ -10,7 +10,6 @@ #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/TrackingGeometry.hpp" -#include "Acts/Surfaces/SurfaceArray.hpp" #include "ActsExamples/ContextualDetector/ExternallyAlignedDetectorElement.hpp" #include "ActsExamples/Framework/AlgorithmContext.hpp" #include "ActsExamples/Framework/RandomNumbers.hpp" @@ -20,9 +19,10 @@ #include #include -ActsExamples::Contextual::ExternalAlignmentDecorator:: - ExternalAlignmentDecorator(const Config& cfg, - std::unique_ptr logger) +namespace ActsExamples { + +ExternalAlignmentDecorator::ExternalAlignmentDecorator( + const Config& cfg, std::unique_ptr logger) : m_cfg(cfg), m_logger(std::move(logger)) { if (m_cfg.trackingGeometry != nullptr) { // parse and populate @@ -30,9 +30,7 @@ ActsExamples::Contextual::ExternalAlignmentDecorator:: } } -ActsExamples::ProcessCode -ActsExamples::Contextual::ExternalAlignmentDecorator::decorate( - AlgorithmContext& context) { +ProcessCode ExternalAlignmentDecorator::decorate(AlgorithmContext& context) { // Iov map access needs to be synchronized std::lock_guard lock{m_iovMutex}; @@ -96,7 +94,7 @@ ActsExamples::Contextual::ExternalAlignmentDecorator::decorate( return ProcessCode::SUCCESS; } -void ActsExamples::Contextual::ExternalAlignmentDecorator::parseGeometry( +void ExternalAlignmentDecorator::parseGeometry( const Acts::TrackingGeometry& tGeometry) { // Double-visit - first count std::size_t nTransforms = 0; @@ -125,3 +123,5 @@ void ActsExamples::Contextual::ExternalAlignmentDecorator::parseGeometry( tGeometry.visitSurfaces(fillTransforms); m_nominalStore = std::move(aStore); } + +} // namespace ActsExamples diff --git a/Examples/Detectors/ContextualDetector/src/InternalAlignmentDecorator.cpp b/Examples/Detectors/ContextualDetector/src/InternalAlignmentDecorator.cpp index 0ce8dd80f1c..c1b44ed0747 100644 --- a/Examples/Detectors/ContextualDetector/src/InternalAlignmentDecorator.cpp +++ b/Examples/Detectors/ContextualDetector/src/InternalAlignmentDecorator.cpp @@ -9,7 +9,6 @@ #include "ActsExamples/ContextualDetector/InternalAlignmentDecorator.hpp" #include "Acts/Definitions/Algebra.hpp" -#include "Acts/Geometry/GeometryContext.hpp" #include "ActsExamples/ContextualDetector/InternallyAlignedDetectorElement.hpp" #include "ActsExamples/Framework/AlgorithmContext.hpp" #include "ActsExamples/Framework/RandomNumbers.hpp" @@ -18,14 +17,13 @@ #include #include -ActsExamples::Contextual::InternalAlignmentDecorator:: - InternalAlignmentDecorator(const Config& cfg, - std::unique_ptr logger) +namespace ActsExamples { + +InternalAlignmentDecorator::InternalAlignmentDecorator( + const Config& cfg, std::unique_ptr logger) : m_cfg(cfg), m_logger(std::move(logger)) {} -ActsExamples::ProcessCode -ActsExamples::Contextual::InternalAlignmentDecorator::decorate( - AlgorithmContext& context) { +ProcessCode InternalAlignmentDecorator::decorate(AlgorithmContext& context) { // We need to lock the Decorator std::lock_guard alignmentLock(m_alignmentMutex); @@ -92,3 +90,5 @@ ActsExamples::Contextual::InternalAlignmentDecorator::decorate( return ProcessCode::SUCCESS; } + +} // namespace ActsExamples diff --git a/Examples/Detectors/DD4hepDetector/include/ActsExamples/DD4hepDetector/DD4hepDetector.hpp b/Examples/Detectors/DD4hepDetector/include/ActsExamples/DD4hepDetector/DD4hepDetector.hpp index 015b511825f..422af198ff5 100644 --- a/Examples/Detectors/DD4hepDetector/include/ActsExamples/DD4hepDetector/DD4hepDetector.hpp +++ b/Examples/Detectors/DD4hepDetector/include/ActsExamples/DD4hepDetector/DD4hepDetector.hpp @@ -8,7 +8,6 @@ #pragma once -#include "Acts/MagneticField/MagneticFieldProvider.hpp" #include "Acts/Plugins/DD4hep/DD4hepDetectorElement.hpp" #include "Acts/Plugins/DD4hep/DD4hepDetectorStructure.hpp" #include "ActsExamples/DD4hepDetector/DD4hepGeometryService.hpp" @@ -32,15 +31,12 @@ class Detector; } // namespace Acts namespace ActsExamples { -class IContextDecorator; -} // namespace ActsExamples -namespace ActsExamples::DD4hep { +class IContextDecorator; struct DD4hepDetector { /// @brief The context decorators - using ContextDecorators = - std::vector>; + using ContextDecorators = std::vector>; /// @brief The tracking geometry using TrackingGeometryPtr = std::shared_ptr; @@ -92,4 +88,4 @@ struct DD4hepDetector { std::shared_ptr field() const; }; -} // namespace ActsExamples::DD4hep +} // namespace ActsExamples diff --git a/Examples/Detectors/DD4hepDetector/include/ActsExamples/DD4hepDetector/DD4hepGeometryService.hpp b/Examples/Detectors/DD4hepDetector/include/ActsExamples/DD4hepDetector/DD4hepGeometryService.hpp index edbb720825c..1111f8de8e7 100644 --- a/Examples/Detectors/DD4hepDetector/include/ActsExamples/DD4hepDetector/DD4hepGeometryService.hpp +++ b/Examples/Detectors/DD4hepDetector/include/ActsExamples/DD4hepDetector/DD4hepGeometryService.hpp @@ -35,7 +35,7 @@ namespace dd4hep { class Detector; } // namespace dd4hep -namespace ActsExamples::DD4hep { +namespace ActsExamples { void sortFCChhDetElements(std::vector& det); @@ -115,11 +115,10 @@ class DD4hepGeometryService { private: /// Private method to initiate building of the DD4hep geometry - ActsExamples::ProcessCode buildDD4hepGeometry(); + ProcessCode buildDD4hepGeometry(); /// Private method to initiate building of the ACTS tracking geometry - ActsExamples::ProcessCode buildTrackingGeometry( - const Acts::GeometryContext& gctx); + ProcessCode buildTrackingGeometry(const Acts::GeometryContext& gctx); /// The config class Config m_cfg; @@ -135,4 +134,4 @@ class DD4hepGeometryService { std::unique_ptr m_logger; }; -} // namespace ActsExamples::DD4hep +} // namespace ActsExamples diff --git a/Examples/Detectors/DD4hepDetector/src/DD4hepDetector.cpp b/Examples/Detectors/DD4hepDetector/src/DD4hepDetector.cpp index a6494ce0860..4ecae308134 100644 --- a/Examples/Detectors/DD4hepDetector/src/DD4hepDetector.cpp +++ b/Examples/Detectors/DD4hepDetector/src/DD4hepDetector.cpp @@ -9,11 +9,9 @@ #include "ActsExamples/DD4hepDetector/DD4hepDetector.hpp" #include "Acts/Geometry/GeometryContext.hpp" -#include "Acts/MagneticField/MagneticFieldProvider.hpp" #include "Acts/Plugins/DD4hep/DD4hepFieldAdapter.hpp" #include "ActsExamples/DD4hepDetector/DD4hepGeometryService.hpp" -#include #include #include #include @@ -23,20 +21,19 @@ #include #include -namespace ActsExamples::DD4hep { +namespace ActsExamples { DD4hepDetector::DD4hepDetector( std::shared_ptr _geometryService) : geometryService(std::move(_geometryService)) {} auto DD4hepDetector::finalize( - ActsExamples::DD4hep::DD4hepGeometryService::Config config, + DD4hepGeometryService::Config config, std::shared_ptr mdecorator) -> std::pair { Acts::GeometryContext dd4HepContext; config.matDecorator = std::move(mdecorator); - geometryService = - std::make_shared(config); + geometryService = std::make_shared(config); TrackingGeometryPtr dd4tGeometry = geometryService->trackingGeometry(dd4HepContext); if (!dd4tGeometry) { @@ -85,4 +82,4 @@ std::shared_ptr DD4hepDetector::field() const { return std::make_shared(detector.field()); } -} // namespace ActsExamples::DD4hep +} // namespace ActsExamples diff --git a/Examples/Detectors/DD4hepDetector/src/DD4hepGeometryService.cpp b/Examples/Detectors/DD4hepDetector/src/DD4hepGeometryService.cpp index 2912e39b757..c746dd84343 100644 --- a/Examples/Detectors/DD4hepDetector/src/DD4hepGeometryService.cpp +++ b/Examples/Detectors/DD4hepDetector/src/DD4hepGeometryService.cpp @@ -22,10 +22,9 @@ #include #include -class TGeoNode; +namespace ActsExamples { -ActsExamples::DD4hep::DD4hepGeometryService::DD4hepGeometryService( - const ActsExamples::DD4hep::DD4hepGeometryService::Config& cfg) +DD4hepGeometryService::DD4hepGeometryService(const Config& cfg) : m_cfg(cfg), m_logger{Acts::getDefaultLogger("DD4hepGeometryService", cfg.logLevel)} { if (m_cfg.xmlFileNames.empty()) { @@ -33,12 +32,11 @@ ActsExamples::DD4hep::DD4hepGeometryService::DD4hepGeometryService( } } -ActsExamples::DD4hep::DD4hepGeometryService::~DD4hepGeometryService() { +DD4hepGeometryService::~DD4hepGeometryService() { drop(); } -ActsExamples::ProcessCode -ActsExamples::DD4hep::DD4hepGeometryService::buildDD4hepGeometry() { +ProcessCode DD4hepGeometryService::buildDD4hepGeometry() { const int old_gErrorIgnoreLevel = gErrorIgnoreLevel; switch (m_cfg.dd4hepLogLevel) { case Acts::Logging::Level::VERBOSE: @@ -83,33 +81,31 @@ ActsExamples::DD4hep::DD4hepGeometryService::buildDD4hepGeometry() { gErrorIgnoreLevel = old_gErrorIgnoreLevel; std::cout.clear(); - return ActsExamples::ProcessCode::SUCCESS; + return ProcessCode::SUCCESS; } -dd4hep::Detector& -ActsExamples::DD4hep::DD4hepGeometryService::DD4hepGeometryService::detector() { +dd4hep::Detector& DD4hepGeometryService::detector() { if (m_detector == nullptr) { buildDD4hepGeometry(); } return *m_detector; } -dd4hep::DetElement& ActsExamples::DD4hep::DD4hepGeometryService::geometry() { +dd4hep::DetElement& DD4hepGeometryService::geometry() { if (!m_geometry) { buildDD4hepGeometry(); } return m_geometry; } -TGeoNode& ActsExamples::DD4hep::DD4hepGeometryService::tgeoGeometry() { +TGeoNode& DD4hepGeometryService::tgeoGeometry() { if (!m_geometry) { buildDD4hepGeometry(); } return *m_geometry.placement().ptr(); } -ActsExamples::ProcessCode -ActsExamples::DD4hep::DD4hepGeometryService::buildTrackingGeometry( +ProcessCode DD4hepGeometryService::buildTrackingGeometry( const Acts::GeometryContext& gctx) { // Set the tracking geometry auto logger = Acts::getDefaultLogger("DD4hepConversion", m_cfg.logLevel); @@ -118,19 +114,18 @@ ActsExamples::DD4hep::DD4hepGeometryService::buildTrackingGeometry( m_cfg.envelopeR, m_cfg.envelopeZ, m_cfg.defaultLayerThickness, m_cfg.sortDetectors, gctx, m_cfg.matDecorator, m_cfg.geometryIdentifierHook); - return ActsExamples::ProcessCode::SUCCESS; + return ProcessCode::SUCCESS; } std::shared_ptr -ActsExamples::DD4hep::DD4hepGeometryService::trackingGeometry( - const Acts::GeometryContext& gctx) { +DD4hepGeometryService::trackingGeometry(const Acts::GeometryContext& gctx) { if (!m_trackingGeometry) { buildTrackingGeometry(gctx); } return m_trackingGeometry; } -void ActsExamples::DD4hep::DD4hepGeometryService::drop() { +void DD4hepGeometryService::drop() { if (m_detector == nullptr) { return; } @@ -140,12 +135,12 @@ void ActsExamples::DD4hep::DD4hepGeometryService::drop() { m_trackingGeometry = nullptr; } -void ActsExamples::DD4hep::sortFCChhDetElements( - std::vector& det) { +void sortFCChhDetElements(std::vector& det) { std::vector tracker; std::vector eCal; std::vector hCal; std::vector muon; + for (auto& detElement : det) { std::string detName = detElement.name(); if (detName.find("Muon") != std::string::npos) { @@ -158,22 +153,16 @@ void ActsExamples::DD4hep::sortFCChhDetElements( tracker.push_back(detElement); } } - sort(muon.begin(), muon.end(), - [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) { - return (a.id() < b.id()); - }); - sort(eCal.begin(), eCal.end(), - [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) { - return (a.id() < b.id()); - }); - sort(hCal.begin(), hCal.end(), - [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) { - return (a.id() < b.id()); - }); - sort(tracker.begin(), tracker.end(), - [](const dd4hep::DetElement& a, const dd4hep::DetElement& b) { - return (a.id() < b.id()); - }); + + auto byId = [](const dd4hep::DetElement& a, + const dd4hep::DetElement& b) -> bool { + return a.id() < b.id(); + }; + sort(muon.begin(), muon.end(), byId); + sort(eCal.begin(), eCal.end(), byId); + sort(hCal.begin(), hCal.end(), byId); + sort(tracker.begin(), tracker.end(), byId); + det.clear(); det = tracker; @@ -181,3 +170,5 @@ void ActsExamples::DD4hep::sortFCChhDetElements( det.insert(det.end(), hCal.begin(), hCal.end()); det.insert(det.end(), muon.begin(), muon.end()); } + +} // namespace ActsExamples diff --git a/Examples/Detectors/Geant4Detector/include/ActsExamples/Geant4Detector/Geant4Detector.hpp b/Examples/Detectors/Geant4Detector/include/ActsExamples/Geant4Detector/Geant4Detector.hpp index 5a948c3f3b5..32c7a7568ea 100644 --- a/Examples/Detectors/Geant4Detector/include/ActsExamples/Geant4Detector/Geant4Detector.hpp +++ b/Examples/Detectors/Geant4Detector/include/ActsExamples/Geant4Detector/Geant4Detector.hpp @@ -31,9 +31,8 @@ class Detector; } // namespace Acts namespace ActsExamples { -class IContextDecorator; -namespace Geant4 { +class IContextDecorator; struct Geant4Detector { using DetectorElements = @@ -41,8 +40,7 @@ struct Geant4Detector { using DetectorPtr = std::shared_ptr; using Surfaces = std::vector>; - using ContextDecorators = - std::vector>; + using ContextDecorators = std::vector>; using TrackingGeometryPtr = std::shared_ptr; /// Nested configuration struct @@ -90,5 +88,4 @@ struct Geant4Detector { const Config& cfg, const Acts::Logger& logger) const; }; -} // namespace Geant4 } // namespace ActsExamples diff --git a/Examples/Detectors/Geant4Detector/src/Geant4Detector.cpp b/Examples/Detectors/Geant4Detector/src/Geant4Detector.cpp index e3b52f36cd3..67ab547db26 100644 --- a/Examples/Detectors/Geant4Detector/src/Geant4Detector.cpp +++ b/Examples/Detectors/Geant4Detector/src/Geant4Detector.cpp @@ -23,9 +23,10 @@ #include "G4Transform3D.hh" #include "G4VPhysicalVolume.hh" -auto ActsExamples::Geant4::Geant4Detector::constructDetector( - const ActsExamples::Geant4::Geant4Detector::Config& cfg, - const Acts::Logger& logger) +namespace ActsExamples { + +auto Geant4Detector::constructDetector(const Geant4Detector::Config& cfg, + const Acts::Logger& logger) -> std::tuple { if (cfg.g4World == nullptr) { throw std::invalid_argument( @@ -44,9 +45,8 @@ auto ActsExamples::Geant4::Geant4Detector::constructDetector( return std::tie(detector, decorators, elements); } -auto ActsExamples::Geant4::Geant4Detector::constructTrackingGeometry( - const ActsExamples::Geant4::Geant4Detector::Config& cfg, - const Acts::Logger& logger) +auto Geant4Detector::constructTrackingGeometry( + const Geant4Detector::Config& cfg, const Acts::Logger& logger) -> std::tuple { if (cfg.g4World == nullptr) { throw std::invalid_argument( @@ -104,10 +104,9 @@ auto ActsExamples::Geant4::Geant4Detector::constructTrackingGeometry( return std::tie(trackingGeometry, decorators, elements); } -auto ActsExamples::Geant4::Geant4Detector::convertGeant4Volumes( - const Geant4Detector::Config& cfg, const Acts::Logger& logger) const - -> std::tuple { +auto Geant4Detector::convertGeant4Volumes(const Geant4Detector::Config& cfg, + const Acts::Logger& logger) const + -> std::tuple { // Generate the surface cache Acts::Geant4DetectorSurfaceFactory::Cache g4SurfaceCache; G4Transform3D g4ToWorld; @@ -143,3 +142,5 @@ auto ActsExamples::Geant4::Geant4Detector::convertGeant4Volumes( return std::tie(surfaces, elements); } + +} // namespace ActsExamples diff --git a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/BuildGenericDetector.hpp b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/BuildGenericDetector.hpp index c5968ef4ca3..aea978be935 100644 --- a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/BuildGenericDetector.hpp +++ b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/BuildGenericDetector.hpp @@ -31,11 +31,7 @@ #include "ActsExamples/GenericDetector/LayerBuilderT.hpp" #include "ActsExamples/GenericDetector/ProtoLayerCreatorT.hpp" -#include -#include #include -#include -#include #include #include #include @@ -108,7 +104,7 @@ std::vector> modulePositionsDisc( /// return a unique vector to the tracking geometry template std::unique_ptr buildDetector( - const typename detector_element_t::ContextType& gctxIn, + const Acts::GeometryContext& gctxIn, std::vector>>& detectorStore, std::size_t level, @@ -782,7 +778,7 @@ std::unique_ptr buildDetector( Acts::getDefaultLogger("TrackerGeometryBuilder", volumeLLevel)); // get the geometry auto trackingGeometry = cylinderGeometryBuilder->trackingGeometry(gctx); - /// return the tracking geometry + // return the tracking geometry return trackingGeometry; } diff --git a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/GenericDetector.hpp b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/GenericDetector.hpp index c487f43d3a6..21a1f85bec6 100644 --- a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/GenericDetector.hpp +++ b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/GenericDetector.hpp @@ -24,17 +24,12 @@ namespace ActsExamples { class IContextDecorator; } // namespace ActsExamples -namespace ActsExamples::Generic { +namespace ActsExamples { + class GenericDetectorElement; -} // namespace ActsExamples::Generic struct GenericDetector { - using DetectorElement = ActsExamples::Generic::GenericDetectorElement; - using DetectorElementPtr = std::shared_ptr; - using DetectorStore = std::vector>; - - using ContextDecorators = - std::vector>; + using ContextDecorators = std::vector>; using TrackingGeometryPtr = std::shared_ptr; struct Config { @@ -46,9 +41,12 @@ struct GenericDetector { }; /// The Store of the detector elements (lifetime: job) - DetectorStore detectorStore; + std::vector>> + detectorStore; std::pair finalize( const Config& cfg, std::shared_ptr mdecorator); }; + +} // namespace ActsExamples diff --git a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/GenericDetectorElement.hpp b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/GenericDetectorElement.hpp index 97d2f7fad3e..9ac48f6cc68 100644 --- a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/GenericDetectorElement.hpp +++ b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/GenericDetectorElement.hpp @@ -22,7 +22,7 @@ class DiscBounds; class ISurfaceMaterial; } // namespace Acts -namespace ActsExamples::Generic { +namespace ActsExamples { /// @class GenericDetectorElement /// @@ -101,28 +101,4 @@ class GenericDetectorElement : public Acts::DetectorElementBase { std::shared_ptr m_elementDiscBounds = nullptr; }; -inline const Acts::Transform3& -ActsExamples::Generic::GenericDetectorElement::transform( - const Acts::GeometryContext& /*gctx*/) const { - return *m_elementTransform; -} - -inline const Acts::Surface& -ActsExamples::Generic::GenericDetectorElement::surface() const { - return *m_elementSurface; -} - -inline Acts::Surface& ActsExamples::Generic::GenericDetectorElement::surface() { - return *m_elementSurface; -} - -inline double ActsExamples::Generic::GenericDetectorElement::thickness() const { - return m_elementThickness; -} - -inline ActsExamples::Generic::GenericDetectorElement::Identifier -ActsExamples::Generic::GenericDetectorElement::identifier() const { - return m_elementIdentifier; -} - -} // namespace ActsExamples::Generic +} // namespace ActsExamples diff --git a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/LayerBuilderT.hpp b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/LayerBuilderT.hpp index 642b4a63ffc..66a5c8f2f37 100644 --- a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/LayerBuilderT.hpp +++ b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/LayerBuilderT.hpp @@ -15,17 +15,11 @@ #include "Acts/Geometry/ILayerBuilder.hpp" #include "Acts/Geometry/Layer.hpp" #include "Acts/Geometry/LayerCreator.hpp" -#include "Acts/Geometry/ProtoLayer.hpp" -#include "Acts/Material/HomogeneousSurfaceMaterial.hpp" -#include "Acts/Material/Material.hpp" -#include "Acts/Material/MaterialSlab.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Logger.hpp" #include "ActsExamples/GenericDetector/GenericDetectorElement.hpp" #include "ActsExamples/GenericDetector/ProtoLayerCreatorT.hpp" -#include - namespace ActsExamples::Generic { using Acts::VectorHelpers::eta; diff --git a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/ProtoLayerCreatorT.hpp b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/ProtoLayerCreatorT.hpp index 977c11d9121..d8e1ce24fb0 100644 --- a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/ProtoLayerCreatorT.hpp +++ b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/ProtoLayerCreatorT.hpp @@ -16,11 +16,8 @@ #include "Acts/Material/ISurfaceMaterial.hpp" #include "Acts/Surfaces/PlanarBounds.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" -#include "Acts/Surfaces/RadialBounds.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Surfaces/TrapezoidBounds.hpp" -#include "Acts/Utilities/BinUtility.hpp" -#include "Acts/Utilities/BinnedArray.hpp" #include "Acts/Utilities/Logger.hpp" #include "ActsExamples/GenericDetector/GenericDetectorElement.hpp" diff --git a/Examples/Detectors/GenericDetector/src/BuildGenericDetector.cpp b/Examples/Detectors/GenericDetector/src/BuildGenericDetector.cpp index 5f396bbe4e8..594ff3120d9 100644 --- a/Examples/Detectors/GenericDetector/src/BuildGenericDetector.cpp +++ b/Examples/Detectors/GenericDetector/src/BuildGenericDetector.cpp @@ -11,10 +11,8 @@ #include #include -namespace ActsExamples::Generic { - /// helper method for cylinder -std::vector modulePositionsCylinder( +std::vector ActsExamples::Generic::modulePositionsCylinder( double radius, double zStagger, double moduleHalfLength, double lOverlap, const std::pair& binningSchema) { int nPhiBins = binningSchema.first; @@ -45,7 +43,8 @@ std::vector modulePositionsCylinder( } /// helper method for disc -std::vector> modulePositionsDisc( +std::vector> +ActsExamples::Generic::modulePositionsDisc( double z, double ringStagger, std::vector phiStagger, std::vector phiSubStagger, double innerRadius, double outerRadius, const std::vector& discBinning, @@ -95,10 +94,9 @@ std::vector> modulePositionsDisc( } /// Helper method for positioning -std::vector modulePositionsRing(double z, double radius, - double phiStagger, - double phiSubStagger, - int nPhiBins) { +std::vector ActsExamples::Generic::modulePositionsRing( + double z, double radius, double phiStagger, double phiSubStagger, + int nPhiBins) { // create and fill the positions std::vector rPositions; rPositions.reserve(nPhiBins); @@ -130,5 +128,3 @@ std::vector modulePositionsRing(double z, double radius, } return rPositions; } - -} // namespace ActsExamples::Generic diff --git a/Examples/Detectors/GenericDetector/src/GenericDetector.cpp b/Examples/Detectors/GenericDetector/src/GenericDetector.cpp index 6a152128edc..bf033fc1e3e 100644 --- a/Examples/Detectors/GenericDetector/src/GenericDetector.cpp +++ b/Examples/Detectors/GenericDetector/src/GenericDetector.cpp @@ -8,20 +8,20 @@ #include "ActsExamples/GenericDetector/GenericDetector.hpp" -#include "Acts/Geometry/ILayerBuilder.hpp" #include "Acts/Geometry/TrackingGeometry.hpp" #include "ActsExamples/GenericDetector/BuildGenericDetector.hpp" #include "ActsExamples/GenericDetector/GenericDetectorElement.hpp" -#include "ActsExamples/GenericDetector/ProtoLayerCreatorT.hpp" + +namespace ActsExamples { auto GenericDetector::finalize( const Config& cfg, std::shared_ptr mdecorator) -> std::pair { - DetectorElement::ContextType nominalContext; + GenericDetectorElement::ContextType nominalContext; /// Return the generic detector TrackingGeometryPtr gGeometry = - ActsExamples::Generic::buildDetector( + Generic::buildDetector( nominalContext, detectorStore, cfg.buildLevel, std::move(mdecorator), cfg.buildProto, cfg.surfaceLogLevel, cfg.layerLogLevel, cfg.volumeLogLevel); @@ -30,3 +30,5 @@ auto GenericDetector::finalize( return std::make_pair( std::move(gGeometry), std::move(gContextDecorators)); } + +} // namespace ActsExamples diff --git a/Examples/Detectors/GenericDetector/src/GenericDetectorElement.cpp b/Examples/Detectors/GenericDetector/src/GenericDetectorElement.cpp index def22d443d3..c1448a67599 100644 --- a/Examples/Detectors/GenericDetector/src/GenericDetectorElement.cpp +++ b/Examples/Detectors/GenericDetector/src/GenericDetectorElement.cpp @@ -13,7 +13,9 @@ #include -ActsExamples::Generic::GenericDetectorElement::GenericDetectorElement( +namespace ActsExamples { + +GenericDetectorElement::GenericDetectorElement( const Identifier identifier, std::shared_ptr transform, std::shared_ptr pBounds, double thickness, @@ -29,7 +31,7 @@ ActsExamples::Generic::GenericDetectorElement::GenericDetectorElement( m_elementSurface->assignSurfaceMaterial(std::move(material)); } -ActsExamples::Generic::GenericDetectorElement::GenericDetectorElement( +GenericDetectorElement::GenericDetectorElement( const Identifier identifier, std::shared_ptr transform, std::shared_ptr dBounds, double thickness, @@ -44,3 +46,26 @@ ActsExamples::Generic::GenericDetectorElement::GenericDetectorElement( m_elementDiscBounds(std::move(dBounds)) { m_elementSurface->assignSurfaceMaterial(std::move(material)); } + +const Acts::Transform3& GenericDetectorElement::transform( + const Acts::GeometryContext& /*gctx*/) const { + return *m_elementTransform; +} + +const Acts::Surface& GenericDetectorElement::surface() const { + return *m_elementSurface; +} + +Acts::Surface& GenericDetectorElement::surface() { + return *m_elementSurface; +} + +double GenericDetectorElement::thickness() const { + return m_elementThickness; +} + +GenericDetectorElement::Identifier GenericDetectorElement::identifier() const { + return m_elementIdentifier; +} + +} // namespace ActsExamples diff --git a/Examples/Detectors/ITkModuleSplitting/include/ActsExamples/ITkModuleSplitting/ITkModuleSplitting.hpp b/Examples/Detectors/ITkModuleSplitting/include/ActsExamples/ITkModuleSplitting/ITkModuleSplitting.hpp index 61a827ca29d..c0860bd31bf 100644 --- a/Examples/Detectors/ITkModuleSplitting/include/ActsExamples/ITkModuleSplitting/ITkModuleSplitting.hpp +++ b/Examples/Detectors/ITkModuleSplitting/include/ActsExamples/ITkModuleSplitting/ITkModuleSplitting.hpp @@ -17,7 +17,6 @@ #include #include #include -#include namespace ActsExamples::ITk { diff --git a/Examples/Detectors/MagneticField/src/ScalableBFieldService.cpp b/Examples/Detectors/MagneticField/src/ScalableBFieldService.cpp index 0d1cb1bfa6a..2501ae42536 100644 --- a/Examples/Detectors/MagneticField/src/ScalableBFieldService.cpp +++ b/Examples/Detectors/MagneticField/src/ScalableBFieldService.cpp @@ -8,7 +8,6 @@ #include "ActsExamples/MagneticField/ScalableBFieldService.hpp" -#include "Acts/MagneticField/MagneticFieldContext.hpp" #include "ActsExamples/Framework/AlgorithmContext.hpp" #include "ActsExamples/MagneticField/ScalableBField.hpp" @@ -19,18 +18,21 @@ namespace { const std::string s_name = "ScalableBFieldService"; } -ActsExamples::ScalableBFieldService::ScalableBFieldService( - const Config& cfg, Acts::Logging::Level lvl) +namespace ActsExamples { + +ScalableBFieldService::ScalableBFieldService(const Config& cfg, + Acts::Logging::Level lvl) : m_cfg(cfg), m_logger(Acts::getDefaultLogger(s_name, lvl)) {} -const std::string& ActsExamples::ScalableBFieldService::name() const { +const std::string& ScalableBFieldService::name() const { return s_name; } -ActsExamples::ProcessCode ActsExamples::ScalableBFieldService::decorate( - AlgorithmContext& ctx) { +ProcessCode ScalableBFieldService::decorate(AlgorithmContext& ctx) { ScalableBFieldContext magCtx; magCtx.scalor = std::pow(m_cfg.scalor, ctx.eventNumber); ctx.magFieldContext = std::make_any(magCtx); return ProcessCode::SUCCESS; } + +} // namespace ActsExamples diff --git a/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp b/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp index 91272a828f6..585aef06756 100644 --- a/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp +++ b/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp @@ -24,7 +24,6 @@ #include "Acts/Surfaces/StrawSurface.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Surfaces/SurfaceBounds.hpp" -#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/Logger.hpp" #include "Acts/Visualization/GeometryView3D.hpp" #include "Acts/Visualization/ObjVisualization3D.hpp" @@ -40,20 +39,21 @@ #include #include #include -#include #include #include -ActsExamples::MockupSectorBuilder::MockupSectorBuilder( - const ActsExamples::MockupSectorBuilder::Config& config) { +namespace ActsExamples { + +MockupSectorBuilder::MockupSectorBuilder( + const MockupSectorBuilder::Config& config) { mCfg = config; - ActsExamples::GdmlDetectorConstruction geo_gdml(mCfg.gdmlPath); + GdmlDetectorConstruction geo_gdml(mCfg.gdmlPath); g4World = geo_gdml.Construct(); } std::shared_ptr -ActsExamples::MockupSectorBuilder::buildChamber( - const ActsExamples::MockupSectorBuilder::ChamberConfig& chamberConfig) { +MockupSectorBuilder::buildChamber( + const MockupSectorBuilder::ChamberConfig& chamberConfig) { if (g4World == nullptr) { throw std::invalid_argument("MockupSector: No g4World initialized"); } @@ -61,7 +61,7 @@ ActsExamples::MockupSectorBuilder::buildChamber( const Acts::GeometryContext gctx; // Geant4Detector Config creator with the g4world from the gdml file - auto g4WorldConfig = ActsExamples::Geant4::Geant4Detector::Config(); + auto g4WorldConfig = Geant4Detector::Config(); g4WorldConfig.name = "Chamber"; g4WorldConfig.g4World = g4World; @@ -78,7 +78,7 @@ ActsExamples::MockupSectorBuilder::buildChamber( g4SurfaceOptions.passiveSurfaceSelector = g4Passive; g4WorldConfig.g4SurfaceOptions = g4SurfaceOptions; - auto g4detector = ActsExamples::Geant4::Geant4Detector(); + auto g4detector = Geant4Detector(); auto [detector, surfaces, detectorElements] = g4detector.constructDetector(g4WorldConfig, Acts::getDummyLogger()); @@ -155,7 +155,7 @@ ActsExamples::MockupSectorBuilder::buildChamber( } std::shared_ptr -ActsExamples::MockupSectorBuilder::buildSector( +MockupSectorBuilder::buildSector( std::vector> detVolumes) { if (mCfg.NumberOfSectors > maxNumberOfSectors) { @@ -313,7 +313,7 @@ ActsExamples::MockupSectorBuilder::buildSector( return detectorVolume; } -void ActsExamples::MockupSectorBuilder::drawSector( +void MockupSectorBuilder::drawSector( const std::shared_ptr& detectorVolumeSector, const std::string& nameObjFile) { @@ -327,3 +327,5 @@ void ActsExamples::MockupSectorBuilder::drawSector( objSector.write(nameObjFile); } + +} // namespace ActsExamples diff --git a/Examples/Detectors/TGeoDetector/include/ActsExamples/TGeoDetector/JsonTGeoDetectorConfig.hpp b/Examples/Detectors/TGeoDetector/include/ActsExamples/TGeoDetector/JsonTGeoDetectorConfig.hpp index eb038572fcf..c1b006f6593 100644 --- a/Examples/Detectors/TGeoDetector/include/ActsExamples/TGeoDetector/JsonTGeoDetectorConfig.hpp +++ b/Examples/Detectors/TGeoDetector/include/ActsExamples/TGeoDetector/JsonTGeoDetectorConfig.hpp @@ -58,15 +58,13 @@ namespace ActsExamples { namespace Options { /// Read config for options interval -void from_json(const nlohmann::json& j, - ActsExamples::Options::Interval& interval) { +void from_json(const nlohmann::json& j, Interval& interval) { interval.lower = j.at("lower"); interval.upper = j.at("upper"); } /// Write config for options interval -void to_json(nlohmann::json& j, - const ActsExamples::Options::Interval& interval) { +void to_json(nlohmann::json& j, const Interval& interval) { // no direct conversion from std::optional to json j = nlohmann::json{{"lower", interval.lower.value_or(0)}, {"upper", interval.upper.value_or(0)}}; @@ -74,8 +72,7 @@ void to_json(nlohmann::json& j, } // namespace Options -void from_json(const nlohmann::json& j, - ActsExamples::TGeoITkModuleSplitter::Config& msc) { +void from_json(const nlohmann::json& j, TGeoITkModuleSplitter::Config& msc) { msc.barrelMap = j["geo-tgeo-barrel-map"].get>(); msc.discMap = @@ -83,8 +80,7 @@ void from_json(const nlohmann::json& j, .get>>>(); } -void to_json(nlohmann::json& j, - const ActsExamples::TGeoITkModuleSplitter::Config& msc) { +void to_json(nlohmann::json& j, const TGeoITkModuleSplitter::Config& msc) { j["geo-tgeo-barrel-map"] = msc.barrelMap; j["geo-tgeo-disc-map"] = msc.discMap; } @@ -92,7 +88,7 @@ void to_json(nlohmann::json& j, /// Read layer configuration triplets template void from_json(const nlohmann::json& j, - ActsExamples::TGeoDetector::Config::LayerTriplet& ltr) { + TGeoDetector::Config::LayerTriplet& ltr) { ltr.negative = j.at("negative").get(); ltr.central = j.at("central").get(); ltr.positive = j.at("positive").get(); @@ -101,15 +97,14 @@ void from_json(const nlohmann::json& j, /// Write layer configuration triplets template void to_json(nlohmann::json& j, - const ActsExamples::TGeoDetector::Config::LayerTriplet& ltr) { + const TGeoDetector::Config::LayerTriplet& ltr) { j = nlohmann::json{{"negative", ltr.negative}, {"central", ltr.central}, {"positive", ltr.positive}}; } /// Read volume struct -void from_json(const nlohmann::json& j, - ActsExamples::TGeoDetector::Config::Volume& vol) { +void from_json(const nlohmann::json& j, TGeoDetector::Config::Volume& vol) { // subdetector selection vol.name = j.at("geo-tgeo-volume-name"); @@ -145,8 +140,7 @@ void from_json(const nlohmann::json& j, if (j.count("geo-tgeo-itk-module-split") != 0) { vol.itkModuleSplit = j.at("geo-tgeo-itk-module-split"); if (vol.itkModuleSplit) { - ActsExamples::TGeoITkModuleSplitter::Config itkConfig = - j.at("Splitters").at("ITk"); + TGeoITkModuleSplitter::Config itkConfig = j.at("Splitters").at("ITk"); vol.barrelMap = itkConfig.barrelMap; vol.discMap = itkConfig.discMap; } @@ -185,7 +179,7 @@ void to_json(nlohmann::json& j, const TGeoDetector::Config::Volume& vol) { j["Splitters"]["CylinderDisk"] = cdConfig; if (vol.itkModuleSplit) { - ActsExamples::TGeoITkModuleSplitter::Config itkConfig; + TGeoITkModuleSplitter::Config itkConfig; itkConfig.barrelMap = vol.barrelMap; itkConfig.discMap = vol.discMap; j["Splitters"]["ITk"] = itkConfig; diff --git a/Examples/Detectors/TGeoDetector/include/ActsExamples/TGeoDetector/TGeoDetector.hpp b/Examples/Detectors/TGeoDetector/include/ActsExamples/TGeoDetector/TGeoDetector.hpp index 0fae0df1c5a..41134fdfa54 100644 --- a/Examples/Detectors/TGeoDetector/include/ActsExamples/TGeoDetector/TGeoDetector.hpp +++ b/Examples/Detectors/TGeoDetector/include/ActsExamples/TGeoDetector/TGeoDetector.hpp @@ -29,17 +29,14 @@ class IMaterialDecorator; } // namespace Acts namespace ActsExamples { -class IContextDecorator; -} // namespace ActsExamples -namespace ActsExamples { +class IContextDecorator; struct TGeoDetector { using DetectorElementPtr = std::shared_ptr; using DetectorStore = std::vector; - using ContextDecorators = - std::vector>; + using ContextDecorators = std::vector>; using TrackingGeometryPtr = std::shared_ptr; /// The Store of the detector elements (lifetime: job) diff --git a/Examples/Detectors/TGeoDetector/src/TGeoDetector.cpp b/Examples/Detectors/TGeoDetector/src/TGeoDetector.cpp index aeed881eb1e..0ece428a438 100644 --- a/Examples/Detectors/TGeoDetector/src/TGeoDetector.cpp +++ b/Examples/Detectors/TGeoDetector/src/TGeoDetector.cpp @@ -30,10 +30,7 @@ #include #include -#include #include -#include -#include #include #include #include @@ -135,12 +132,12 @@ std::vector makeLayerBuilderConfigs( cdsConfig, logger.clone("TGeoCylinderDiscSplitter", config.layerLogLevel)); } else if (volume.itkModuleSplit) { - ActsExamples::TGeoITkModuleSplitter::Config itkConfig; + TGeoITkModuleSplitter::Config itkConfig; itkConfig.barrelMap = volume.barrelMap; itkConfig.discMap = volume.discMap; itkConfig.splitPatterns = volume.splitPatterns; layerBuilderConfig.detectorElementSplitter = - std::make_shared( + std::make_shared( itkConfig, logger.clone("TGeoITkModuleSplitter", config.layerLogLevel)); } diff --git a/Examples/Detectors/TGeoDetector/src/TGeoITkModuleSplitter.cpp b/Examples/Detectors/TGeoDetector/src/TGeoITkModuleSplitter.cpp index 42bbbd9c882..2ad248f2e13 100644 --- a/Examples/Detectors/TGeoDetector/src/TGeoITkModuleSplitter.cpp +++ b/Examples/Detectors/TGeoDetector/src/TGeoITkModuleSplitter.cpp @@ -21,14 +21,16 @@ #include #include -ActsExamples::TGeoITkModuleSplitter::TGeoITkModuleSplitter( - const ActsExamples::TGeoITkModuleSplitter::Config& cfg, +namespace ActsExamples { + +TGeoITkModuleSplitter::TGeoITkModuleSplitter( + const TGeoITkModuleSplitter::Config& cfg, std::unique_ptr logger) : m_cfg(cfg), m_logger(std::move(logger)) { initSplitCategories(); } -void ActsExamples::TGeoITkModuleSplitter::initSplitCategories() { +void TGeoITkModuleSplitter::initSplitCategories() { m_splitCategories.reserve(m_cfg.splitPatterns.size()); for (const std::pair& pattern_split_category : m_cfg.splitPatterns) { @@ -50,7 +52,7 @@ void ActsExamples::TGeoITkModuleSplitter::initSplitCategories() { /// If applicable, returns a split detector element inline std::vector> -ActsExamples::TGeoITkModuleSplitter::split( +TGeoITkModuleSplitter::split( const Acts::GeometryContext& gctx, std::shared_ptr detElement) const { // Is the current node covered by this splitter? @@ -66,10 +68,10 @@ ActsExamples::TGeoITkModuleSplitter::split( " node " + sensorName + " using split ranges of category " + std::get<1>(split_category)); if (!std::get<2>(split_category)) { - return ActsExamples::TGeoITkModuleSplitter::splitBarrelModule( + return TGeoITkModuleSplitter::splitBarrelModule( gctx, detElement, m_cfg.barrelMap.at(std::get<1>(split_category))); } else { - return ActsExamples::TGeoITkModuleSplitter::splitDiscModule( + return TGeoITkModuleSplitter::splitDiscModule( gctx, detElement, m_cfg.discMap.at(std::get<1>(split_category))); } } @@ -83,7 +85,7 @@ ActsExamples::TGeoITkModuleSplitter::split( /// If applicable, returns a split detector element inline std::vector> -ActsExamples::TGeoITkModuleSplitter::splitBarrelModule( +TGeoITkModuleSplitter::splitBarrelModule( const Acts::GeometryContext& gctx, const std::shared_ptr& detElement, unsigned int nSegments) const { @@ -101,11 +103,10 @@ ActsExamples::TGeoITkModuleSplitter::splitBarrelModule( /// If applicable, returns a split detector element inline std::vector> -ActsExamples::TGeoITkModuleSplitter::splitDiscModule( +TGeoITkModuleSplitter::splitDiscModule( const Acts::GeometryContext& gctx, const std::shared_ptr& detElement, - const std::vector& - splitRanges) const { + const std::vector& splitRanges) const { auto name = detElement->tgeoNode().GetName(); auto factory = [&](const auto& trafo, const auto& bounds) { @@ -117,3 +118,5 @@ ActsExamples::TGeoITkModuleSplitter::splitDiscModule( return ITk::splitDiscModule(gctx, detElement, splitRanges, factory, name, logger()); } + +} // namespace ActsExamples diff --git a/Examples/Detectors/TelescopeDetector/include/ActsExamples/TelescopeDetector/BuildTelescopeDetector.hpp b/Examples/Detectors/TelescopeDetector/include/ActsExamples/TelescopeDetector/BuildTelescopeDetector.hpp index 9e3b5977a6a..6e3b4e31cdf 100644 --- a/Examples/Detectors/TelescopeDetector/include/ActsExamples/TelescopeDetector/BuildTelescopeDetector.hpp +++ b/Examples/Detectors/TelescopeDetector/include/ActsExamples/TelescopeDetector/BuildTelescopeDetector.hpp @@ -9,9 +9,7 @@ #pragma once #include "Acts/Geometry/TrackingGeometry.hpp" -#include "Acts/Utilities/BinUtility.hpp" #include "Acts/Utilities/BinningType.hpp" -#include "ActsExamples/TelescopeDetector/TelescopeDetectorElement.hpp" #include #include @@ -21,7 +19,7 @@ namespace Acts { class TrackingGeometry; } // namespace Acts -namespace ActsExamples::Telescope { +namespace ActsExamples { /// The telescope detector surface type enum class TelescopeSurfaceType { @@ -45,13 +43,14 @@ enum class TelescopeSurfaceType { /// @param surfaceType is the detector surface type /// @param binValue indicates which axis the detector surface normals are /// parallel to -std::unique_ptr buildDetector( - const typename TelescopeDetectorElement::ContextType& gctx, - std::vector>& detectorStore, +std::unique_ptr buildTelescopeDetector( + const Acts::GeometryContext& gctx, + std::vector>& + detectorStore, const std::vector& positions, const std::vector& stereoAngles, const std::array& offsets, const std::array& bounds, double thickness, TelescopeSurfaceType surfaceType, Acts::BinningValue binValue = Acts::BinningValue::binZ); -} // namespace ActsExamples::Telescope +} // namespace ActsExamples diff --git a/Examples/Detectors/TelescopeDetector/include/ActsExamples/TelescopeDetector/TelescopeDetector.hpp b/Examples/Detectors/TelescopeDetector/include/ActsExamples/TelescopeDetector/TelescopeDetector.hpp index 31095f42636..76b81984fb0 100644 --- a/Examples/Detectors/TelescopeDetector/include/ActsExamples/TelescopeDetector/TelescopeDetector.hpp +++ b/Examples/Detectors/TelescopeDetector/include/ActsExamples/TelescopeDetector/TelescopeDetector.hpp @@ -9,37 +9,24 @@ #pragma once #include "Acts/Definitions/Units.hpp" -#include "Acts/Utilities/Logger.hpp" -#include "ActsExamples/Utilities/Options.hpp" +#include "Acts/Geometry/DetectorElementBase.hpp" #include #include #include #include -using namespace Acts::UnitLiterals; - namespace Acts { class TrackingGeometry; class IMaterialDecorator; } // namespace Acts namespace ActsExamples { -class IContextDecorator; -} // namespace ActsExamples - -namespace ActsExamples::Telescope { -class TelescopeDetectorElement; -class TelescopeG4DetectorConstruction; +class IContextDecorator; struct TelescopeDetector { - using DetectorElement = ActsExamples::Telescope::TelescopeDetectorElement; - using DetectorElementPtr = std::shared_ptr; - using DetectorStore = std::vector; - - using ContextDecorators = - std::vector>; + using ContextDecorators = std::vector>; using TrackingGeometryPtr = std::shared_ptr; struct Config { @@ -47,18 +34,18 @@ struct TelescopeDetector { std::vector stereos{{0, 0, 0, 0, 0, 0}}; std::array offsets{{0, 0}}; std::array bounds{{25, 100}}; - double thickness{80_um}; + double thickness{80 * Acts::UnitConstants::um}; int surfaceType{0}; int binValue{2}; }; Config config; /// The store of the detector elements (lifetime: job) - DetectorStore detectorStore; + std::vector> detectorStore; std::pair finalize( const Config& cfg, const std::shared_ptr& mdecorator); }; -} // namespace ActsExamples::Telescope +} // namespace ActsExamples diff --git a/Examples/Detectors/TelescopeDetector/include/ActsExamples/TelescopeDetector/TelescopeDetectorElement.hpp b/Examples/Detectors/TelescopeDetector/include/ActsExamples/TelescopeDetector/TelescopeDetectorElement.hpp index 5a5d276cf9e..f3fa5a4b8bd 100644 --- a/Examples/Detectors/TelescopeDetector/include/ActsExamples/TelescopeDetector/TelescopeDetectorElement.hpp +++ b/Examples/Detectors/TelescopeDetector/include/ActsExamples/TelescopeDetector/TelescopeDetectorElement.hpp @@ -24,7 +24,7 @@ class DiscBounds; class ISurfaceMaterial; } // namespace Acts -namespace ActsExamples::Telescope { +namespace ActsExamples { /// @class TelescopeDetectorElement /// @@ -159,4 +159,4 @@ TelescopeDetectorElement::alignedTransforms() const { return m_alignedTransforms; } -} // namespace ActsExamples::Telescope +} // namespace ActsExamples diff --git a/Examples/Detectors/TelescopeDetector/src/BuildTelescopeDetector.cpp b/Examples/Detectors/TelescopeDetector/src/BuildTelescopeDetector.cpp index 7e01a9499bd..d436d577235 100644 --- a/Examples/Detectors/TelescopeDetector/src/BuildTelescopeDetector.cpp +++ b/Examples/Detectors/TelescopeDetector/src/BuildTelescopeDetector.cpp @@ -12,6 +12,7 @@ #include "Acts/Definitions/Units.hpp" #include "Acts/Geometry/CuboidVolumeBounds.hpp" #include "Acts/Geometry/CylinderVolumeBounds.hpp" +#include "Acts/Geometry/DetectorElementBase.hpp" #include "Acts/Geometry/DiscLayer.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/ILayerArrayCreator.hpp" @@ -28,22 +29,21 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Surfaces/SurfaceArray.hpp" #include "Acts/Utilities/Logger.hpp" +#include "ActsExamples/TelescopeDetector/TelescopeDetectorElement.hpp" #include #include #include std::unique_ptr -ActsExamples::Telescope::buildDetector( - const typename ActsExamples::Telescope::TelescopeDetectorElement:: - ContextType& gctx, - std::vector< - std::shared_ptr>& +ActsExamples::buildTelescopeDetector( + const Acts::GeometryContext& gctx, + std::vector>& detectorStore, const std::vector& positions, const std::vector& stereoAngles, const std::array& offsets, const std::array& bounds, - double thickness, ActsExamples::Telescope::TelescopeSurfaceType surfaceType, + double thickness, TelescopeSurfaceType surfaceType, Acts::BinningValue binValue) { using namespace Acts::UnitLiterals; diff --git a/Examples/Detectors/TelescopeDetector/src/TelescopeDetector.cpp b/Examples/Detectors/TelescopeDetector/src/TelescopeDetector.cpp index 7a5e262067a..bbf1aff4106 100644 --- a/Examples/Detectors/TelescopeDetector/src/TelescopeDetector.cpp +++ b/Examples/Detectors/TelescopeDetector/src/TelescopeDetector.cpp @@ -8,6 +8,7 @@ #include "ActsExamples/TelescopeDetector/TelescopeDetector.hpp" +#include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/TrackingGeometry.hpp" #include "Acts/Utilities/BinningType.hpp" #include "ActsExamples/TelescopeDetector/BuildTelescopeDetector.hpp" @@ -16,10 +17,12 @@ #include #include -auto ActsExamples::Telescope::TelescopeDetector::finalize( +namespace ActsExamples { + +auto TelescopeDetector::finalize( const Config& cfg, const std::shared_ptr& /*mdecorator*/) -> std::pair { - DetectorElement::ContextType nominalContext; + TelescopeDetectorElement::ContextType nominalContext; if (cfg.surfaceType > 1) { throw std::invalid_argument( @@ -48,15 +51,18 @@ auto ActsExamples::Telescope::TelescopeDetector::finalize( std::vector stereos = cfg.stereos; std::ranges::sort(positions); - /// Return the telescope detector - TrackingGeometryPtr gGeometry = ActsExamples::Telescope::buildDetector( - nominalContext, detectorStore, positions, stereos, cfg.offsets, - cfg.bounds, cfg.thickness, - static_cast( - cfg.surfaceType), - static_cast(cfg.binValue)); + Acts::GeometryContext geometryContext(nominalContext); + + // Return the telescope detector + TrackingGeometryPtr gGeometry = + buildTelescopeDetector(geometryContext, detectorStore, positions, stereos, + cfg.offsets, cfg.bounds, cfg.thickness, + static_cast(cfg.surfaceType), + static_cast(cfg.binValue)); ContextDecorators gContextDecorators = {}; // return the pair of geometry and empty decorators return std::make_pair( std::move(gGeometry), std::move(gContextDecorators)); } + +} // namespace ActsExamples diff --git a/Examples/Detectors/TelescopeDetector/src/TelescopeDetectorElement.cpp b/Examples/Detectors/TelescopeDetector/src/TelescopeDetectorElement.cpp index 22421064ef1..25fdca6c852 100644 --- a/Examples/Detectors/TelescopeDetector/src/TelescopeDetectorElement.cpp +++ b/Examples/Detectors/TelescopeDetector/src/TelescopeDetectorElement.cpp @@ -11,7 +11,9 @@ #include "Acts/Surfaces/DiscSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" -ActsExamples::Telescope::TelescopeDetectorElement::TelescopeDetectorElement( +namespace ActsExamples { + +TelescopeDetectorElement::TelescopeDetectorElement( std::shared_ptr transform, std::shared_ptr pBounds, double thickness, std::shared_ptr material) @@ -27,7 +29,7 @@ ActsExamples::Telescope::TelescopeDetectorElement::TelescopeDetectorElement( mutableSurface->assignSurfaceMaterial(std::move(material)); } -ActsExamples::Telescope::TelescopeDetectorElement::TelescopeDetectorElement( +TelescopeDetectorElement::TelescopeDetectorElement( std::shared_ptr transform, std::shared_ptr dBounds, double thickness, std::shared_ptr material) @@ -40,3 +42,5 @@ ActsExamples::Telescope::TelescopeDetectorElement::TelescopeDetectorElement( m_elementDiscBounds(std::move(dBounds)) { m_elementSurface->assignSurfaceMaterial(std::move(material)); } + +} // namespace ActsExamples diff --git a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepReader.hpp b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepReader.hpp index 204f88ad83a..07c4e771857 100644 --- a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepReader.hpp +++ b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepReader.hpp @@ -25,9 +25,7 @@ namespace ActsExamples { -namespace DD4hep { struct DD4hepDetector; -} /// Read particles from EDM4hep. /// @@ -55,7 +53,7 @@ class EDM4hepReader final : public IReader { std::string graphvizOutput = ""; /// DD4hep detector for cellID resolution. - std::shared_ptr dd4hepDetector; + std::shared_ptr dd4hepDetector; /// Tracking geometry for cellID resolution. std::shared_ptr trackingGeometry; diff --git a/Examples/Io/EDM4hep/src/EDM4hepReader.cpp b/Examples/Io/EDM4hep/src/EDM4hepReader.cpp index 3d5008863a3..4aef2c30e56 100644 --- a/Examples/Io/EDM4hep/src/EDM4hepReader.cpp +++ b/Examples/Io/EDM4hep/src/EDM4hepReader.cpp @@ -9,7 +9,6 @@ #include "ActsExamples/Io/EDM4hep/EDM4hepReader.hpp" #include "Acts/Definitions/Units.hpp" -#include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Plugins/DD4hep/DD4hepDetectorElement.hpp" #include "ActsExamples/DD4hepDetector/DD4hepDetector.hpp" #include "ActsExamples/EventData/SimHit.hpp" diff --git a/Examples/Python/src/DD4hepComponent.cpp b/Examples/Python/src/DD4hepComponent.cpp index f4ad0277aea..e38a33cf82c 100644 --- a/Examples/Python/src/DD4hepComponent.cpp +++ b/Examples/Python/src/DD4hepComponent.cpp @@ -16,32 +16,25 @@ #include "ActsExamples/DD4hepDetector/DD4hepDetector.hpp" #include "ActsExamples/DD4hepDetector/DD4hepGeometryService.hpp" #include "ActsExamples/Framework/IContextDecorator.hpp" -#include "ActsExamples/Framework/ProcessCode.hpp" -#include #include #include -#include #include #include -namespace Acts { -class IMaterialDecorator; -} // namespace Acts - namespace py = pybind11; using namespace ActsExamples; using namespace Acts::Python; PYBIND11_MODULE(ActsPythonBindingsDD4hep, m) { { - using Config = DD4hep::DD4hepGeometryService::Config; - auto s = py::class_>( + using Config = DD4hepGeometryService::Config; + auto s = py::class_>( m, "DD4hepGeometryService") .def(py::init()) - .def("drop", &DD4hep::DD4hepGeometryService::drop); + .def("drop", &DD4hepGeometryService::drop); auto c = py::class_(s, "Config").def(py::init<>()); ACTS_PYTHON_STRUCT_BEGIN(c, Config); @@ -155,20 +148,20 @@ PYBIND11_MODULE(ActsPythonBindingsDD4hep, m) { } { - py::class_>( + py::class_>( m, "DD4hepDetector") .def(py::init<>()) - .def(py::init>()) + .def(py::init>()) .def("finalize", - py::overload_cast>( - &DD4hep::DD4hepDetector::finalize)) + &DD4hepDetector::finalize)) .def("finalize", py::overload_cast< const Acts::GeometryContext&, const Acts::Experimental::DD4hepDetectorStructure::Options&>( - &DD4hep::DD4hepDetector::finalize)) - .def("drop", &DD4hep::DD4hepDetector::drop) - .def_property_readonly("field", &DD4hep::DD4hepDetector::field); + &DD4hepDetector::finalize)) + .def("drop", &DD4hepDetector::drop) + .def_property_readonly("field", &DD4hepDetector::field); } } diff --git a/Examples/Python/src/Detector.cpp b/Examples/Python/src/Detector.cpp index 6b9ef68f927..833364301a7 100644 --- a/Examples/Python/src/Detector.cpp +++ b/Examples/Python/src/Detector.cpp @@ -10,7 +10,6 @@ #include "Acts/Material/IMaterialDecorator.hpp" #include "Acts/Plugins/Python/Utilities.hpp" #include "Acts/Utilities/BinningType.hpp" -#include "Acts/Utilities/Logger.hpp" #include "ActsExamples/ContextualDetector/AlignedDetector.hpp" #include "ActsExamples/Framework/IContextDecorator.hpp" #include "ActsExamples/GenericDetector/GenericDetector.hpp" @@ -18,12 +17,9 @@ #include "ActsExamples/TelescopeDetector/TelescopeDetector.hpp" #include "ActsExamples/Utilities/Options.hpp" -#include -#include #include #include #include -#include #include #include @@ -34,6 +30,7 @@ namespace py = pybind11; using namespace ActsExamples; namespace Acts::Python { + void addDetector(Context& ctx) { auto [m, mex] = ctx.get("main", "examples"); { @@ -44,16 +41,17 @@ void addDetector(Context& ctx) { } { - using Config = GenericDetector::Config; + using Detector = GenericDetector; + using Config = Detector::Config; - auto gd = py::class_>( - mex, "GenericDetector") - .def(py::init<>()) - .def("finalize", - py::overload_cast< - const Config&, - std::shared_ptr>( - &GenericDetector::finalize)); + auto gd = + py::class_>(mex, "GenericDetector") + .def(py::init<>()) + .def("finalize", + py::overload_cast< + const Config&, + std::shared_ptr>( + &Detector::finalize)); py::class_(gd, "Config") .def(py::init<>()) @@ -65,18 +63,18 @@ void addDetector(Context& ctx) { } { - using TelescopeDetector = Telescope::TelescopeDetector; - using Config = TelescopeDetector::Config; + using Detector = TelescopeDetector; + using Config = Detector::Config; auto td = - py::class_>( - mex, "TelescopeDetector") + py::class_>(mex, + "TelescopeDetector") .def(py::init<>()) .def("finalize", py::overload_cast< const Config&, const std::shared_ptr&>( - &TelescopeDetector::finalize)); + &Detector::finalize)); py::class_(td, "Config") .def(py::init<>()) @@ -90,17 +88,17 @@ void addDetector(Context& ctx) { } { - using AlignedDetector = Contextual::AlignedDetector; - using Config = AlignedDetector::Config; - - auto d = py::class_>( - mex, "AlignedDetector") - .def(py::init<>()) - .def("finalize", - py::overload_cast< - const Config&, - std::shared_ptr>( - &AlignedDetector::finalize)); + using Detector = AlignedDetector; + using Config = Detector::Config; + + auto d = + py::class_>(mex, "AlignedDetector") + .def(py::init<>()) + .def("finalize", + py::overload_cast< + const Config&, + std::shared_ptr>( + &Detector::finalize)); auto c = py::class_(d, "Config") .def(py::init<>()); @@ -124,16 +122,17 @@ void addDetector(Context& ctx) { } { - using Config = TGeoDetector::Config; - - auto d = py::class_>( - mex, "TGeoDetector") - .def(py::init<>()) - .def("finalize", - py::overload_cast< - const Config&, - std::shared_ptr>( - &TGeoDetector::finalize)); + using Detector = TGeoDetector; + using Config = Detector::Config; + + auto d = + py::class_>(mex, "TGeoDetector") + .def(py::init<>()) + .def("finalize", + py::overload_cast< + const Config&, + std::shared_ptr>( + &Detector::finalize)); py::class_(mex, "Interval") .def(py::init<>()) diff --git a/Examples/Python/src/Geant4Component.cpp b/Examples/Python/src/Geant4Component.cpp index abba9cefe98..53984168740 100644 --- a/Examples/Python/src/Geant4Component.cpp +++ b/Examples/Python/src/Geant4Component.cpp @@ -42,17 +42,6 @@ #include #include -class G4UserSteppingAction; -class G4VUserPhysicsList; -namespace Acts { -class MagneticFieldProvider; -class TrackingGeometry; -class Volume; -} // namespace Acts -namespace ActsExamples { -class RandomNumbers; -} // namespace ActsExamples - namespace py = pybind11; using namespace pybind11::literals; @@ -250,12 +239,11 @@ PYBIND11_MODULE(ActsPythonBindingsGeant4, mod) { } { - py::class_< - Telescope::TelescopeG4DetectorConstructionFactory, - Geant4::DetectorConstructionFactory, - std::shared_ptr>( + py::class_>( mod, "TelescopeG4DetectorConstructionFactory") - .def(py::init>>(), py::arg("cfg"), py::arg("regionCreators") = @@ -289,31 +277,29 @@ PYBIND11_MODULE(ActsPythonBindingsGeant4, mod) { std::shared_ptr>( mod, "Geant4DetectorElement"); - using Geant4Detector = Geant4::Geant4Detector; + using Detector = Geant4Detector; + using Config = Detector::Config; auto g = - py::class_>( - mod, "Geant4Detector") + py::class_>(mod, "Geant4Detector") .def(py::init<>()) .def( "constructDetector", - [](Geant4Detector& self, const Geant4Detector::Config& cfg, - Logging::Level logLevel) { + [](Detector& self, const Config& cfg, Logging::Level logLevel) { auto logger = getDefaultLogger("Geant4Detector", logLevel); return self.constructDetector(cfg, *logger); }, py::arg("cfg"), py::arg("logLevel") = Logging::INFO) .def( "constructTrackingGeometry", - [](Geant4Detector& self, const Geant4Detector::Config& cfg, - Logging::Level logLevel) { + [](Detector& self, const Config& cfg, Logging::Level logLevel) { auto logger = getDefaultLogger("Geant4Detector", logLevel); return self.constructTrackingGeometry(cfg, *logger); }, py::arg("cfg"), py::arg("logLevel") = Logging::INFO); - auto c = py::class_(g, "Config").def(py::init<>()); - ACTS_PYTHON_STRUCT_BEGIN(c, Geant4Detector::Config); + auto c = py::class_(g, "Config").def(py::init<>()); + ACTS_PYTHON_STRUCT_BEGIN(c, Config); ACTS_PYTHON_MEMBER(name); ACTS_PYTHON_MEMBER(g4World); ACTS_PYTHON_MEMBER(g4SurfaceOptions); diff --git a/Examples/Python/src/Geant4DD4hepComponent.cpp b/Examples/Python/src/Geant4DD4hepComponent.cpp index f8dec7d35d1..409bca273d1 100644 --- a/Examples/Python/src/Geant4DD4hepComponent.cpp +++ b/Examples/Python/src/Geant4DD4hepComponent.cpp @@ -14,8 +14,6 @@ #include #include -class G4VUserDetectorConstruction; - namespace py = pybind11; using namespace ActsExamples; @@ -28,7 +26,7 @@ PYBIND11_MODULE(ActsPythonBindingsDDG4, m) { Geant4::DetectorConstructionFactory, std::shared_ptr>( m, "DDG4DetectorConstructionFactory") - .def(py::init, + .def(py::init, std::vector>>(), py::arg("detector"), py::arg("regionCreators") =