diff --git a/Core/include/Acts/TrackFinding/MeasurementAdapter.hpp b/Core/include/Acts/TrackFinding/MeasurementAdapter.hpp new file mode 100644 index 00000000000..dcfdc513dab --- /dev/null +++ b/Core/include/Acts/TrackFinding/MeasurementAdapter.hpp @@ -0,0 +1,145 @@ +// This file is part of the ACTS project. +// +// Copyright (C) 2016 CERN for the benefit of the ACTS project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +#pragma once + +#include "Acts/Definitions/TrackParametrization.hpp" +#include "Acts/TrackFinding/MeasurementSelector.hpp" + +#include + +namespace Acts { + +class Surface; + +// TODO not too happy with the name `MeasurementAdapter` as it is still quite +// generic even tho this concept is only useful during combinatorial track +// finding. Maybe `CombinatorialMeasurementAdapter` would be better? + +template +concept MeasurementAdapterConcept = requires(const MeasurementAdapter& a, + const Surface& s) { + typename MeasurementAdapter::State; + + typename MeasurementAdapter::TrackStateContainer; + typename MeasurementAdapter::TrackStateProxy; + + typename MeasurementAdapter::PreBoundSelectionRange; + typename MeasurementAdapter::BoundSelectionRange; + + { a.makeState() } -> std::same_as; + + { a.clearState(s) } -> std::same_as; + + { a.isActive(s) } -> std::same_as; + + { + a.selectPreBound(s) + } -> std::same_as; + + requires requires( + const MeasurementAdapter::PreBoundSelectionRange& preBoundSelectionRange, + const MeasurementAdapter::TrackStateContainer& trackStateContainer, + const Surface& surface, const BoundVector& parameters, + const BoundMatrix& covariance) { + { + a.selectPreCalibrationImpl(preBoundSelectionRange, surface, parameters, + covariance, trackStateContainer) + } -> std::same_as; + }; +}; + +template +class MeasurementAdapterBase { + public: + using TrackStateContainer = traj_t; + using TrackStateProxy = typename traj_t::TrackStateProxy; + + using BoundSelectionRange = std::pair; + + struct State {}; + + Derived::State makeState() const { return {}; } + + void clearState(Derived::State& state, const Surface& surface) const { + (void)state; + (void)surface; + } + + bool isActive(Derived::State& state, const Surface& surface) const { + (void)state; + (void)surface; + + return true; + } + + bool shouldCreateHoleImpl( + Derived::State& state, + const Derived::BoundSelectionRange& postCalibrationSelectionRange, + const TrackStateContainer& trackStateContainer, const Surface& surface, + const BoundVector& parameters, const BoundMatrix& covariance) const { + (void)state; + (void)postCalibrationSelectionRange; + (void)trackStateContainer; + (void)surface; + (void)parameters; + (void)covariance; + + return postCalibrationSelectionRange.first == + postCalibrationSelectionRange.second; + } + + Derived::BoundSelectionRange selectPostBound( + Derived::State& state, + const Derived::PreBoundSelectionRange& preBoundSelectionRange, + const Derived::TrackStateContainer& trackStateContainer, + const Surface& surface, const BoundVector& parameters, + const BoundMatrix& covariance) const { + typename Derived::BoundSelectionRange range; + + // pre calibration selection and calibration + { + range.first = trackStateContainer.size(); + + for (auto measurementIt = preBoundSelectionRange.first; + measurementIt != preBoundSelectionRange.second; ++measurementIt) { + const auto& measurement = *measurementIt; + + if (!self().doSelectPreCalibrationImpl(state, measurement, surface, + parameters, covariance)) { + continue; + } + + TrackStateProxy trackState = trackStateContainer.makeTrackState( + TrackStatePropMask::None, MultiTrajectoryTraits::kInvalid); + + self().calibrateImpl(state, trackState, measurement); + + if (!self().doSelectPostCalibrationImpl(state, trackState, surface, + parameters, covariance)) { + // TODO pop the last track state + continue; + } + } + + range.second = trackStateContainer.size(); + } + + if (self().shouldCreateHoleImpl(state, range, trackStateContainer, surface, + parameters, covariance)) { + // TODO + } + + return range; + } + + private: + const Derived& self() const { return static_cast(*this); } +}; + +} // namespace Acts diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/DDG4/DDG4DetectorConstruction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/DDG4/DDG4DetectorConstruction.hpp index 529a3725980..54c590ac4d3 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/DDG4/DDG4DetectorConstruction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/DDG4/DDG4DetectorConstruction.hpp @@ -31,7 +31,7 @@ class DDG4DetectorConstruction final : public G4VUserDetectorConstruction { public: DDG4DetectorConstruction( std::shared_ptr detector, - std::vector> regionCreators = {}); + std::vector> regionCreators = {}); ~DDG4DetectorConstruction() final; /// Convert the stored DD4hep detector to a Geant4 description. @@ -47,7 +47,7 @@ class DDG4DetectorConstruction final : public G4VUserDetectorConstruction { /// The Acts DD4hep detector instance std::shared_ptr m_detector; /// Region creators - std::vector> m_regionCreators; + std::vector> m_regionCreators; /// The world volume G4VPhysicalVolume* m_world = nullptr; @@ -56,11 +56,11 @@ class DDG4DetectorConstruction final : public G4VUserDetectorConstruction { }; class DDG4DetectorConstructionFactory final - : public DetectorConstructionFactory { + : public Geant4::DetectorConstructionFactory { public: DDG4DetectorConstructionFactory( std::shared_ptr detector, - std::vector> regionCreators = {}); + std::vector> regionCreators = {}); ~DDG4DetectorConstructionFactory() final; std::unique_ptr factorize() const override; @@ -69,7 +69,7 @@ class DDG4DetectorConstructionFactory final /// The Acts DD4hep detector instance std::shared_ptr m_detector; /// Region creators - std::vector> m_regionCreators; + std::vector> m_regionCreators; }; } // namespace ActsExamples diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/DetectorConstructionFactory.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/DetectorConstructionFactory.hpp index a0f5b3e41cd..16cb2c3eae6 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/DetectorConstructionFactory.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/DetectorConstructionFactory.hpp @@ -12,7 +12,7 @@ #include -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// Silly Geant4 will destroy the detector construction after the run manager is /// destructed. This class works around it by factorizing a factory. @@ -23,4 +23,4 @@ class DetectorConstructionFactory { virtual std::unique_ptr factorize() const = 0; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/EventStore.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/EventStore.hpp index a46512ce299..7ca1775b81a 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/EventStore.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/EventStore.hpp @@ -21,8 +21,10 @@ #include "G4Types.hh" namespace ActsExamples { - class WhiteBoard; +} + +namespace ActsExamples::Geant4 { /// Common event store for all Geant4 related sub algorithms struct EventStore { @@ -80,4 +82,4 @@ struct EventStore { std::unordered_map subparticleMap; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/GdmlDetectorConstruction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/GdmlDetectorConstruction.hpp index 24924bd7867..69156e94e06 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/GdmlDetectorConstruction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/GdmlDetectorConstruction.hpp @@ -26,7 +26,7 @@ class GdmlDetectorConstruction final : public G4VUserDetectorConstruction { /// @param regionCreators are the region creators GdmlDetectorConstruction( std::string path, - std::vector> regionCreators = {}); + std::vector> regionCreators = {}); /// Read the file and parse it to construct the Geant4 description /// @@ -38,17 +38,17 @@ class GdmlDetectorConstruction final : public G4VUserDetectorConstruction { /// Path to the Gdml file std::string m_path; /// Region creators - std::vector> m_regionCreators; + std::vector> m_regionCreators; /// Cached world volume G4VPhysicalVolume* m_world = nullptr; }; class GdmlDetectorConstructionFactory final - : public DetectorConstructionFactory { + : public Geant4::DetectorConstructionFactory { public: GdmlDetectorConstructionFactory( std::string path, - std::vector> regionCreators = {}); + std::vector> regionCreators = {}); std::unique_ptr factorize() const override; @@ -56,7 +56,7 @@ class GdmlDetectorConstructionFactory final /// Path to the Gdml file std::string m_path; /// Region creators - std::vector> m_regionCreators; + std::vector> m_regionCreators; }; } // namespace ActsExamples diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Manager.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Manager.hpp index c3db1c3f2fe..bdf9ab7bb82 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Manager.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Manager.hpp @@ -18,8 +18,10 @@ class G4VUserPhysicsList; namespace ActsExamples { -class PhysicsListFactory; class Geant4Manager; +namespace Geant4 { +class PhysicsListFactory; +} /// Manages the life time of G4RunManager and G4VUserPhysicsList. /// @@ -75,12 +77,14 @@ class Geant4Manager { /// Registers a named physics list factory to the manager for easy /// instantiation when needed. void registerPhysicsListFactory( - std::string name, std::shared_ptr physicsListFactory); + std::string name, + std::shared_ptr physicsListFactory); std::unique_ptr createPhysicsList( const std::string &name) const; /// Get the current list of physics list factories. - const std::unordered_map> & + const std::unordered_map> & getPhysicsListFactories() const; private: @@ -89,7 +93,7 @@ class Geant4Manager { bool m_created = false; std::weak_ptr m_handle; - std::unordered_map> + std::unordered_map> m_physicsListFactories; }; diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp index f735dcd3859..88f526fff4f 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp @@ -39,14 +39,15 @@ class MagneticFieldProvider; class Volume; } // namespace Acts -class G4VUserDetectorConstruction; - namespace ActsExamples { +struct Geant4Handle; +namespace Geant4 { class DetectorConstructionFactory; class SensitiveSurfaceMapper; struct EventStore; -struct Geant4Handle; +class RegionCreator; +} // namespace Geant4 /// Abstracts common Geant4 Acts algorithm behaviour. class Geant4SimulationBase : public IAlgorithm { @@ -61,7 +62,8 @@ class Geant4SimulationBase : public IAlgorithm { /// Detector construction object. /// G4RunManager will take care of deletion - std::shared_ptr detectorConstructionFactory; + std::shared_ptr + detectorConstructionFactory; /// Optional Geant4 instance overwrite. std::shared_ptr geant4Handle; @@ -91,11 +93,11 @@ class Geant4SimulationBase : public IAlgorithm { G4RunManager& runManager() const; - EventStore& eventStore() const; + Geant4::EventStore& eventStore() const; std::unique_ptr m_logger; - std::shared_ptr m_eventStore; + std::shared_ptr m_eventStore; int m_geant4Level{}; @@ -122,8 +124,8 @@ class Geant4Simulation final : public Geant4SimulationBase { std::string outputParticles = "particles_simulated"; /// The ACTS sensitive surfaces in a mapper, used for hit creation - std::shared_ptr sensitiveSurfaceMapper = - nullptr; + std::shared_ptr + sensitiveSurfaceMapper = nullptr; /// The ACTS Magnetic field provider std::shared_ptr magneticField = nullptr; diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MagneticFieldWrapper.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MagneticFieldWrapper.hpp index a73663fb503..7581d5b6cf5 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MagneticFieldWrapper.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MagneticFieldWrapper.hpp @@ -18,7 +18,7 @@ namespace Acts { class MagneticFieldProvider; } -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// A magnetic field wrapper for the Acts magnetic field /// to be used with Geant4. @@ -58,4 +58,4 @@ class MagneticFieldWrapper : public G4MagneticField { std::unique_ptr m_logger; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialPhysicsList.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialPhysicsList.hpp index 9cfb45d0453..924c1b54e59 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialPhysicsList.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialPhysicsList.hpp @@ -12,11 +12,10 @@ #include #include -#include #include -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// @class MaterialPhysicsList /// @@ -57,4 +56,4 @@ class MaterialPhysicsList final : public G4VUserPhysicsList { std::unique_ptr m_logger; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialSteppingAction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialSteppingAction.hpp index 8b21c41a7ce..23ccb88764e 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialSteppingAction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialSteppingAction.hpp @@ -19,7 +19,7 @@ class G4Step; -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// @class MaterialSteppingAction /// @@ -66,4 +66,4 @@ class MaterialSteppingAction final : public G4UserSteppingAction { std::unique_ptr m_logger; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleKillAction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleKillAction.hpp index 4eb45d4f6ec..fe15a2d185c 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleKillAction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleKillAction.hpp @@ -22,7 +22,7 @@ namespace Acts { class Volume; } // namespace Acts -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// A G4SteppingAction that is called for every step in the simulation process. /// @@ -67,4 +67,4 @@ class ParticleKillAction : public G4UserSteppingAction { std::unique_ptr m_logger; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleTrackingAction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleTrackingAction.hpp index acf07ec75dc..4ff1d413f34 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleTrackingAction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleTrackingAction.hpp @@ -9,7 +9,6 @@ #pragma once #include "Acts/Utilities/Logger.hpp" -#include "ActsExamples/EventData/SimHit.hpp" #include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Geant4/EventStore.hpp" @@ -22,7 +21,7 @@ class G4Track; -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// The G4UserTrackingAction that is called for every track in /// the simulation process. @@ -82,4 +81,4 @@ class ParticleTrackingAction : public G4UserTrackingAction { std::unique_ptr m_logger; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/PhysicsListFactory.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/PhysicsListFactory.hpp index 6bbc39b4f04..e248beaffd4 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/PhysicsListFactory.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/PhysicsListFactory.hpp @@ -13,7 +13,7 @@ class G4VUserPhysicsList; -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// A factory around G4VUserPhysicsList which allows on demand instantiation. class PhysicsListFactory { @@ -36,4 +36,4 @@ class PhysicsListFactoryFunction final : public PhysicsListFactory { Function m_function; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/RegionCreator.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/RegionCreator.hpp index b141948ec90..5327e4f37eb 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/RegionCreator.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/RegionCreator.hpp @@ -13,7 +13,7 @@ #include #include -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// Geant4 Region Creator /// @@ -49,7 +49,7 @@ class RegionCreator { Acts::Logging::Level level); /// Construct the region - void Construct(); + void construct(); /// Readonly access to the configuration const Config& config() const { return m_cfg; } @@ -68,4 +68,4 @@ class RegionCreator { std::unique_ptr m_logger; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSteppingAction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSteppingAction.hpp index 664522349df..d415e77e940 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSteppingAction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSteppingAction.hpp @@ -23,7 +23,7 @@ namespace Acts { class Surface; } -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// The G4SteppingAction that is called for every step in /// the simulation process. @@ -83,4 +83,4 @@ class SensitiveSteppingAction : public G4UserSteppingAction { m_surfaceMapping; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSurfaceMapper.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSurfaceMapper.hpp index 60f86d0d4e3..7614635ff93 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSurfaceMapper.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSurfaceMapper.hpp @@ -12,7 +12,6 @@ #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Geometry/TrackingGeometry.hpp" -#include "Acts/Utilities/GridAccessHelpers.hpp" #include "Acts/Utilities/Logger.hpp" #include @@ -26,7 +25,7 @@ namespace Acts { class Surface; } -namespace ActsExamples { +namespace ActsExamples::Geant4 { struct SensitiveCandidatesBase { /// Get the sensitive surfaces for a given position @@ -148,4 +147,4 @@ class SensitiveSurfaceMapper { std::unique_ptr m_logger; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SimParticleTranslation.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SimParticleTranslation.hpp index 8a20f91ae39..5b43102d812 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SimParticleTranslation.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SimParticleTranslation.hpp @@ -20,7 +20,7 @@ class G4Event; -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// @class SimParticleTranslation /// @@ -81,4 +81,4 @@ class SimParticleTranslation final : public G4VUserPrimaryGeneratorAction { std::unique_ptr m_logger; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SteppingActionList.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SteppingActionList.hpp index b4a6d7e5d68..807417cf1f4 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SteppingActionList.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SteppingActionList.hpp @@ -8,17 +8,12 @@ #pragma once -#include "Acts/Utilities/Logger.hpp" -#include "ActsExamples/EventData/SimHit.hpp" -#include "ActsExamples/EventData/SimParticle.hpp" - #include -#include -#include +#include #include -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// Geant4 only allows one user action of each type. This simple wrapper /// dispatches multiple actions to Geant4. @@ -42,4 +37,4 @@ class SteppingActionList : public G4UserSteppingAction { Config m_cfg; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/GeoModelG4/GeoModelDetectorConstruction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/GeoModelG4/GeoModelDetectorConstruction.hpp index a919d2866b0..d3070bbc590 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/GeoModelG4/GeoModelDetectorConstruction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/GeoModelG4/GeoModelDetectorConstruction.hpp @@ -12,8 +12,6 @@ #include "ActsExamples/Geant4/DetectorConstructionFactory.hpp" #include "ActsExamples/Geant4/RegionCreator.hpp" -#include - #include class G4VPhysicalVolume; @@ -27,7 +25,7 @@ class GeoModelDetectorConstruction final : public G4VUserDetectorConstruction { /// @param regionCreators are the region creators GeoModelDetectorConstruction( const Acts::GeoModelTree& geoModelTree, - std::vector> regionCreators = {}); + std::vector> regionCreators = {}); /// Read the file and parse it to construct the Geant4 description /// @@ -39,17 +37,17 @@ class GeoModelDetectorConstruction final : public G4VUserDetectorConstruction { /// The GeoModel tree Acts::GeoModelTree m_geoModelTree; /// Region creators - std::vector> m_regionCreators; + std::vector> m_regionCreators; /// The world volume G4VPhysicalVolume* m_g4World = nullptr; }; class GeoModelDetectorConstructionFactory final - : public DetectorConstructionFactory { + : public Geant4::DetectorConstructionFactory { public: GeoModelDetectorConstructionFactory( const Acts::GeoModelTree& geoModelTree, - std::vector> regionCreators = {}); + std::vector> regionCreators = {}); std::unique_ptr factorize() const override; @@ -57,7 +55,7 @@ class GeoModelDetectorConstructionFactory final /// The GeoModel tree Acts::GeoModelTree m_geoModelTree; /// Region creators - std::vector> m_regionCreators; + std::vector> m_regionCreators; }; } // namespace ActsExamples diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/TelescopeDetector/TelescopeG4DetectorConstruction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/TelescopeDetector/TelescopeG4DetectorConstruction.hpp index 66fc363fe53..0d0fc522217 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/TelescopeDetector/TelescopeG4DetectorConstruction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/TelescopeDetector/TelescopeG4DetectorConstruction.hpp @@ -24,7 +24,7 @@ class TelescopeG4DetectorConstruction final public: TelescopeG4DetectorConstruction( const TelescopeDetector::Config& cfg, - std::vector> regionCreators = {}); + std::vector> regionCreators = {}); G4VPhysicalVolume* Construct() final; @@ -32,17 +32,17 @@ class TelescopeG4DetectorConstruction final /// The configuration of the telescope detector TelescopeDetector::Config m_cfg; /// Region creators - std::vector> m_regionCreators; + std::vector> m_regionCreators; /// The world volume G4VPhysicalVolume* m_world{}; }; class TelescopeG4DetectorConstructionFactory final - : public DetectorConstructionFactory { + : public Geant4::DetectorConstructionFactory { public: TelescopeG4DetectorConstructionFactory( const TelescopeDetector::Config& cfg, - std::vector> regionCreators = {}); + std::vector> regionCreators = {}); std::unique_ptr factorize() const override; @@ -50,7 +50,7 @@ class TelescopeG4DetectorConstructionFactory final /// The configuration of the telescope detector TelescopeDetector::Config m_cfg; /// Region creators - std::vector> m_regionCreators; + std::vector> m_regionCreators; }; } // namespace ActsExamples::Telescope diff --git a/Examples/Algorithms/Geant4/src/DDG4DetectorConstruction.cpp b/Examples/Algorithms/Geant4/src/DDG4DetectorConstruction.cpp index ae6a4609180..2868fbb3a63 100644 --- a/Examples/Algorithms/Geant4/src/DDG4DetectorConstruction.cpp +++ b/Examples/Algorithms/Geant4/src/DDG4DetectorConstruction.cpp @@ -22,22 +22,23 @@ class G4VPhysicalVolume; -ActsExamples::DDG4DetectorConstruction::DDG4DetectorConstruction( +namespace ActsExamples { + +DDG4DetectorConstruction::DDG4DetectorConstruction( std::shared_ptr detector, - std::vector> regionCreators) + std::vector> regionCreators) : G4VUserDetectorConstruction(), m_detector(std::move(detector)), m_regionCreators(std::move(regionCreators)) {} -ActsExamples::DDG4DetectorConstruction::~DDG4DetectorConstruction() = default; +DDG4DetectorConstruction::~DDG4DetectorConstruction() = default; -dd4hep::Detector& ActsExamples::DDG4DetectorConstruction::dd4hepDetector() - const { +dd4hep::Detector& DDG4DetectorConstruction::dd4hepDetector() const { return m_detector->geometryService->detector(); } // See DD4hep::Simulation::Geant4DetectorConstruction::Construct() -G4VPhysicalVolume* ActsExamples::DDG4DetectorConstruction::Construct() { +G4VPhysicalVolume* DDG4DetectorConstruction::Construct() { if (m_world == nullptr) { dd4hep::sim::Geant4Mapping& g4map = dd4hep::sim::Geant4Mapping::instance(); auto conv = dd4hep::sim::Geant4Converter(dd4hepDetector(), @@ -52,23 +53,24 @@ G4VPhysicalVolume* ActsExamples::DDG4DetectorConstruction::Construct() { // Create regions for (const auto& regionCreator : m_regionCreators) { - regionCreator->Construct(); + regionCreator->construct(); } } return m_world; } -ActsExamples::DDG4DetectorConstructionFactory::DDG4DetectorConstructionFactory( +DDG4DetectorConstructionFactory::DDG4DetectorConstructionFactory( std::shared_ptr detector, - std::vector> regionCreators) + std::vector> regionCreators) : m_detector(std::move(detector)), m_regionCreators(std::move(regionCreators)) {} -ActsExamples::DDG4DetectorConstructionFactory:: - ~DDG4DetectorConstructionFactory() = default; +DDG4DetectorConstructionFactory::~DDG4DetectorConstructionFactory() = default; std::unique_ptr -ActsExamples::DDG4DetectorConstructionFactory::factorize() const { +DDG4DetectorConstructionFactory::factorize() const { return std::make_unique(m_detector, m_regionCreators); } + +} // namespace ActsExamples diff --git a/Examples/Algorithms/Geant4/src/GdmlDetectorConstruction.cpp b/Examples/Algorithms/Geant4/src/GdmlDetectorConstruction.cpp index 5a10933bb3f..242597ac175 100644 --- a/Examples/Algorithms/Geant4/src/GdmlDetectorConstruction.cpp +++ b/Examples/Algorithms/Geant4/src/GdmlDetectorConstruction.cpp @@ -18,7 +18,7 @@ using namespace ActsExamples; GdmlDetectorConstruction::GdmlDetectorConstruction( std::string path, - std::vector> regionCreators) + std::vector> regionCreators) : G4VUserDetectorConstruction(), m_path(std::move(path)), m_regionCreators(std::move(regionCreators)) {} @@ -32,7 +32,7 @@ G4VPhysicalVolume* GdmlDetectorConstruction::Construct() { // Create regions for (const auto& regionCreator : m_regionCreators) { - regionCreator->Construct(); + regionCreator->construct(); } } return m_world; @@ -40,7 +40,7 @@ G4VPhysicalVolume* GdmlDetectorConstruction::Construct() { GdmlDetectorConstructionFactory::GdmlDetectorConstructionFactory( std::string path, - std::vector> regionCreators) + std::vector> regionCreators) : m_path(std::move(path)), m_regionCreators(std::move(regionCreators)) {} std::unique_ptr diff --git a/Examples/Algorithms/Geant4/src/Geant4Manager.cpp b/Examples/Algorithms/Geant4/src/Geant4Manager.cpp index fb981704561..13e7428ac60 100644 --- a/Examples/Algorithms/Geant4/src/Geant4Manager.cpp +++ b/Examples/Algorithms/Geant4/src/Geant4Manager.cpp @@ -109,7 +109,8 @@ std::shared_ptr Geant4Manager::createHandle( } void Geant4Manager::registerPhysicsListFactory( - std::string name, std::shared_ptr physicsListFactory) { + std::string name, + std::shared_ptr physicsListFactory) { if (m_physicsListFactories.contains(name)) { throw std::invalid_argument("name already mapped"); } @@ -126,22 +127,23 @@ std::unique_ptr Geant4Manager::createPhysicsList( return it->second->factorize(); } -const std::unordered_map>& +const std::unordered_map>& Geant4Manager::getPhysicsListFactories() const { return m_physicsListFactories; } Geant4Manager::Geant4Manager() { registerPhysicsListFactory( - "FTFP_BERT", std::make_shared( + "FTFP_BERT", std::make_shared( []() { return std::make_unique(); })); registerPhysicsListFactory( - "FTFP_BERT_ATL", std::make_shared( + "FTFP_BERT_ATL", std::make_shared( []() { return std::make_unique(); })); - registerPhysicsListFactory("MaterialPhysicsList", - std::make_shared([]() { - return std::make_unique(); - })); + registerPhysicsListFactory( + "MaterialPhysicsList", + std::make_shared( + []() { return std::make_unique(); })); } Geant4Manager::~Geant4Manager() = default; diff --git a/Examples/Algorithms/Geant4/src/Geant4Simulation.cpp b/Examples/Algorithms/Geant4/src/Geant4Simulation.cpp index 795ddad78fa..bbc5c533e5c 100644 --- a/Examples/Algorithms/Geant4/src/Geant4Simulation.cpp +++ b/Examples/Algorithms/Geant4/src/Geant4Simulation.cpp @@ -28,7 +28,6 @@ #include "ActsExamples/Geant4/SimParticleTranslation.hpp" #include "ActsExamples/Geant4/SteppingActionList.hpp" -#include #include #include @@ -47,22 +46,24 @@ #include #include -ActsExamples::Geant4SimulationBase::Geant4SimulationBase( - const Config& cfg, std::string name, Acts::Logging::Level level) +namespace ActsExamples { + +Geant4SimulationBase::Geant4SimulationBase(const Config& cfg, std::string name, + Acts::Logging::Level level) : IAlgorithm(std::move(name), level) { if (cfg.inputParticles.empty()) { throw std::invalid_argument("Missing input particle collection"); } - if (!cfg.detectorConstructionFactory) { + if (cfg.detectorConstructionFactory == nullptr) { throw std::invalid_argument("Missing detector construction factory"); } - if (!cfg.randomNumbers) { + if (cfg.randomNumbers == nullptr) { throw std::invalid_argument("Missing random numbers"); } m_logger = Acts::getDefaultLogger("Geant4", level); - m_eventStore = std::make_shared(); + m_eventStore = std::make_shared(); // tweak logging // If we are in VERBOSE mode, set the verbose level in Geant4 to 2. @@ -70,9 +71,9 @@ ActsExamples::Geant4SimulationBase::Geant4SimulationBase( m_geant4Level = logger().level() == Acts::Logging::VERBOSE ? 2 : 0; } -ActsExamples::Geant4SimulationBase::~Geant4SimulationBase() = default; +Geant4SimulationBase::~Geant4SimulationBase() = default; -void ActsExamples::Geant4SimulationBase::commonInitialization() { +void Geant4SimulationBase::commonInitialization() { // Set the detector construction { // Clear detector construction if it exists @@ -89,24 +90,22 @@ void ActsExamples::Geant4SimulationBase::commonInitialization() { m_geant4Instance->tweakLogging(m_geant4Level); } -G4RunManager& ActsExamples::Geant4SimulationBase::runManager() const { +G4RunManager& Geant4SimulationBase::runManager() const { return *m_geant4Instance->runManager.get(); } -ActsExamples::EventStore& ActsExamples::Geant4SimulationBase::eventStore() - const { +Geant4::EventStore& Geant4SimulationBase::eventStore() const { return *m_eventStore; } -ActsExamples::ProcessCode ActsExamples::Geant4SimulationBase::initialize() { +ProcessCode Geant4SimulationBase::initialize() { // Initialize the Geant4 run manager runManager().Initialize(); - return ActsExamples::ProcessCode::SUCCESS; + return ProcessCode::SUCCESS; } -ActsExamples::ProcessCode ActsExamples::Geant4SimulationBase::execute( - const ActsExamples::AlgorithmContext& ctx) const { +ProcessCode Geant4SimulationBase::execute(const AlgorithmContext& ctx) const { // Ensure exclusive access to the Geant4 run manager std::lock_guard guard(m_geant4Instance->mutex); @@ -114,7 +113,7 @@ ActsExamples::ProcessCode ActsExamples::Geant4SimulationBase::execute( G4Random::setTheSeed(config().randomNumbers->generateSeed(ctx)); // Get and reset event registry state - eventStore() = EventStore{}; + eventStore() = Geant4::EventStore{}; // Register the current event store to the registry // this will allow access from the User*Actions @@ -153,16 +152,15 @@ ActsExamples::ProcessCode ActsExamples::Geant4SimulationBase::execute( "Step merging: max hits per hit: " << eventStore().maxStepsForHit); } - return ActsExamples::ProcessCode::SUCCESS; + return ProcessCode::SUCCESS; } -std::shared_ptr -ActsExamples::Geant4SimulationBase::geant4Handle() const { +std::shared_ptr Geant4SimulationBase::geant4Handle() const { return m_geant4Instance; } -ActsExamples::Geant4Simulation::Geant4Simulation(const Config& cfg, - Acts::Logging::Level level) +Geant4Simulation::Geant4Simulation(const Config& cfg, + Acts::Logging::Level level) : Geant4SimulationBase(cfg, "Geant4Simulation", level), m_cfg(cfg) { m_geant4Instance = m_cfg.geant4Handle @@ -180,10 +178,10 @@ ActsExamples::Geant4Simulation::Geant4Simulation(const Config& cfg, if (runManager().GetUserPrimaryGeneratorAction() != nullptr) { delete runManager().GetUserPrimaryGeneratorAction(); } - SimParticleTranslation::Config prCfg; + Geant4::SimParticleTranslation::Config prCfg; prCfg.eventStore = m_eventStore; // G4RunManager will take care of deletion - auto primaryGeneratorAction = new SimParticleTranslation( + auto primaryGeneratorAction = new Geant4::SimParticleTranslation( prCfg, m_logger->cloneWithSuffix("SimParticleTranslation")); // Set the primary generator action runManager().SetUserAction(primaryGeneratorAction); @@ -195,48 +193,49 @@ ActsExamples::Geant4Simulation::Geant4Simulation(const Config& cfg, if (runManager().GetUserTrackingAction() != nullptr) { delete runManager().GetUserTrackingAction(); } - ParticleTrackingAction::Config trackingCfg; + Geant4::ParticleTrackingAction::Config trackingCfg; trackingCfg.eventStore = m_eventStore; trackingCfg.keepParticlesWithoutHits = cfg.keepParticlesWithoutHits; // G4RunManager will take care of deletion - auto trackingAction = new ParticleTrackingAction( + auto trackingAction = new Geant4::ParticleTrackingAction( trackingCfg, m_logger->cloneWithSuffix("ParticleTracking")); runManager().SetUserAction(trackingAction); } // Stepping actions - SensitiveSteppingAction* sensitiveSteppingActionAccess = nullptr; + Geant4::SensitiveSteppingAction* sensitiveSteppingActionAccess = nullptr; { // Clear stepping action if it exists if (runManager().GetUserSteppingAction() != nullptr) { delete runManager().GetUserSteppingAction(); } - ParticleKillAction::Config particleKillCfg; + Geant4::ParticleKillAction::Config particleKillCfg; particleKillCfg.eventStore = m_eventStore; particleKillCfg.volume = cfg.killVolume; particleKillCfg.maxTime = cfg.killAfterTime; particleKillCfg.secondaries = cfg.killSecondaries; - SensitiveSteppingAction::Config stepCfg; + Geant4::SensitiveSteppingAction::Config stepCfg; stepCfg.eventStore = m_eventStore; stepCfg.charged = true; stepCfg.neutral = cfg.recordHitsOfNeutrals; stepCfg.primary = true; stepCfg.secondary = cfg.recordHitsOfSecondaries; - SteppingActionList::Config steppingCfg; - steppingCfg.actions.push_back(std::make_unique( + Geant4::SteppingActionList::Config steppingCfg; + steppingCfg.actions.push_back(std::make_unique( particleKillCfg, m_logger->cloneWithSuffix("Killer"))); - auto sensitiveSteppingAction = std::make_unique( - stepCfg, m_logger->cloneWithSuffix("SensitiveStepping")); + auto sensitiveSteppingAction = + std::make_unique( + stepCfg, m_logger->cloneWithSuffix("SensitiveStepping")); sensitiveSteppingActionAccess = sensitiveSteppingAction.get(); steppingCfg.actions.push_back(std::move(sensitiveSteppingAction)); // G4RunManager will take care of deletion - auto steppingAction = new SteppingActionList(steppingCfg); + auto steppingAction = new Geant4::SteppingActionList(steppingCfg); runManager().SetUserAction(steppingAction); } @@ -251,9 +250,10 @@ ActsExamples::Geant4Simulation::Geant4Simulation(const Config& cfg, if (cfg.magneticField) { ACTS_INFO("Setting ACTS configured field to Geant4."); - MagneticFieldWrapper::Config g4FieldCfg; + Geant4::MagneticFieldWrapper::Config g4FieldCfg; g4FieldCfg.magneticField = cfg.magneticField; - m_magneticField = std::make_unique(g4FieldCfg); + m_magneticField = + std::make_unique(g4FieldCfg); // Set the field or the G4Field manager m_fieldManager = std::make_unique(); @@ -266,7 +266,7 @@ ActsExamples::Geant4Simulation::Geant4Simulation(const Config& cfg, // ACTS sensitive surfaces are provided, so hit creation is turned on if (cfg.sensitiveSurfaceMapper != nullptr) { - SensitiveSurfaceMapper::State sState; + Geant4::SensitiveSurfaceMapper::State sState; ACTS_INFO( "Remapping selected volumes from Geant4 to Acts::Surface::GeometryID"); cfg.sensitiveSurfaceMapper->remapSensitiveNames( @@ -288,10 +288,9 @@ ActsExamples::Geant4Simulation::Geant4Simulation(const Config& cfg, m_outputParticles.initialize(cfg.outputParticles); } -ActsExamples::Geant4Simulation::~Geant4Simulation() = default; +Geant4Simulation::~Geant4Simulation() = default; -ActsExamples::ProcessCode ActsExamples::Geant4Simulation::execute( - const ActsExamples::AlgorithmContext& ctx) const { +ProcessCode Geant4Simulation::execute(const AlgorithmContext& ctx) const { auto ret = Geant4SimulationBase::execute(ctx); if (ret != ProcessCode::SUCCESS) { return ret; @@ -313,18 +312,18 @@ ActsExamples::ProcessCode ActsExamples::Geant4Simulation::execute( ctx, SimHitContainer(eventStore().hits.begin(), eventStore().hits.end())); #endif - return ActsExamples::ProcessCode::SUCCESS; + return ProcessCode::SUCCESS; } -ActsExamples::Geant4MaterialRecording::Geant4MaterialRecording( - const Config& cfg, Acts::Logging::Level level) +Geant4MaterialRecording::Geant4MaterialRecording(const Config& cfg, + Acts::Logging::Level level) : Geant4SimulationBase(cfg, "Geant4Simulation", level), m_cfg(cfg) { auto physicsListName = "MaterialPhysicsList"; m_geant4Instance = m_cfg.geant4Handle ? m_cfg.geant4Handle : Geant4Manager::instance().createHandle( - std::make_unique( + std::make_unique( m_logger->cloneWithSuffix("MaterialPhysicsList")), physicsListName); if (m_geant4Instance->physicsListName != physicsListName) { @@ -340,14 +339,14 @@ ActsExamples::Geant4MaterialRecording::Geant4MaterialRecording( delete runManager().GetUserPrimaryGeneratorAction(); } - SimParticleTranslation::Config prCfg; + Geant4::SimParticleTranslation::Config prCfg; prCfg.eventStore = m_eventStore; prCfg.forcedPdgCode = 0; prCfg.forcedCharge = 0.; prCfg.forcedMass = 0.; // G4RunManager will take care of deletion - auto primaryGeneratorAction = new SimParticleTranslation( + auto primaryGeneratorAction = new Geant4::SimParticleTranslation( prCfg, m_logger->cloneWithSuffix("SimParticleTranslation")); // Set the primary generator action runManager().SetUserAction(primaryGeneratorAction); @@ -359,11 +358,11 @@ ActsExamples::Geant4MaterialRecording::Geant4MaterialRecording( if (runManager().GetUserTrackingAction() != nullptr) { delete runManager().GetUserTrackingAction(); } - ParticleTrackingAction::Config trackingCfg; + Geant4::ParticleTrackingAction::Config trackingCfg; trackingCfg.eventStore = m_eventStore; trackingCfg.keepParticlesWithoutHits = true; // G4RunManager will take care of deletion - auto trackingAction = new ParticleTrackingAction( + auto trackingAction = new Geant4::ParticleTrackingAction( trackingCfg, m_logger->cloneWithSuffix("ParticleTracking")); runManager().SetUserAction(trackingAction); } @@ -374,11 +373,11 @@ ActsExamples::Geant4MaterialRecording::Geant4MaterialRecording( if (runManager().GetUserSteppingAction() != nullptr) { delete runManager().GetUserSteppingAction(); } - MaterialSteppingAction::Config steppingCfg; + Geant4::MaterialSteppingAction::Config steppingCfg; steppingCfg.eventStore = m_eventStore; steppingCfg.excludeMaterials = m_cfg.excludeMaterials; // G4RunManager will take care of deletion - auto steppingAction = new MaterialSteppingAction( + auto steppingAction = new Geant4::MaterialSteppingAction( steppingCfg, m_logger->cloneWithSuffix("MaterialSteppingAction")); runManager().SetUserAction(steppingAction); } @@ -389,10 +388,10 @@ ActsExamples::Geant4MaterialRecording::Geant4MaterialRecording( m_outputMaterialTracks.initialize(cfg.outputMaterialTracks); } -ActsExamples::Geant4MaterialRecording::~Geant4MaterialRecording() = default; +Geant4MaterialRecording::~Geant4MaterialRecording() = default; -ActsExamples::ProcessCode ActsExamples::Geant4MaterialRecording::execute( - const ActsExamples::AlgorithmContext& ctx) const { +ProcessCode Geant4MaterialRecording::execute( + const AlgorithmContext& ctx) const { const auto ret = Geant4SimulationBase::execute(ctx); if (ret != ProcessCode::SUCCESS) { return ret; @@ -402,5 +401,7 @@ ActsExamples::ProcessCode ActsExamples::Geant4MaterialRecording::execute( m_outputMaterialTracks( ctx, decltype(eventStore().materialTracks)(eventStore().materialTracks)); - return ActsExamples::ProcessCode::SUCCESS; + return ProcessCode::SUCCESS; } + +} // namespace ActsExamples diff --git a/Examples/Algorithms/Geant4/src/GeoModelDetectorConstruction.cpp b/Examples/Algorithms/Geant4/src/GeoModelDetectorConstruction.cpp index c3ad0eea6de..8d33622714b 100644 --- a/Examples/Algorithms/Geant4/src/GeoModelDetectorConstruction.cpp +++ b/Examples/Algorithms/Geant4/src/GeoModelDetectorConstruction.cpp @@ -21,7 +21,7 @@ using namespace ActsExamples; GeoModelDetectorConstruction::GeoModelDetectorConstruction( const Acts::GeoModelTree& geoModelTree, - std::vector> regionCreators) + std::vector> regionCreators) : G4VUserDetectorConstruction(), m_geoModelTree(geoModelTree), m_regionCreators(std::move(regionCreators)) { @@ -42,7 +42,7 @@ G4VPhysicalVolume* GeoModelDetectorConstruction::Construct() { // Create regions for (const auto& regionCreator : m_regionCreators) { - regionCreator->Construct(); + regionCreator->construct(); } } return m_g4World; @@ -50,7 +50,7 @@ G4VPhysicalVolume* GeoModelDetectorConstruction::Construct() { GeoModelDetectorConstructionFactory::GeoModelDetectorConstructionFactory( const Acts::GeoModelTree& geoModelTree, - std::vector> regionCreators) + std::vector> regionCreators) : m_geoModelTree(geoModelTree), m_regionCreators(std::move(regionCreators)) {} diff --git a/Examples/Algorithms/Geant4/src/MagneticFieldWrapper.cpp b/Examples/Algorithms/Geant4/src/MagneticFieldWrapper.cpp index 33f15fa6586..757cac35fea 100644 --- a/Examples/Algorithms/Geant4/src/MagneticFieldWrapper.cpp +++ b/Examples/Algorithms/Geant4/src/MagneticFieldWrapper.cpp @@ -12,21 +12,20 @@ #include "Acts/Definitions/Units.hpp" #include "Acts/MagneticField/MagneticFieldContext.hpp" #include "Acts/MagneticField/MagneticFieldProvider.hpp" -#include "Acts/Utilities/Result.hpp" -#include -#include #include #include #include -ActsExamples::MagneticFieldWrapper::MagneticFieldWrapper( +namespace ActsExamples::Geant4 { + +MagneticFieldWrapper::MagneticFieldWrapper( const Config& cfg, std::unique_ptr logger) : G4MagneticField(), m_cfg(cfg), m_logger(std::move(logger)) {} -void ActsExamples::MagneticFieldWrapper::GetFieldValue(const G4double Point[4], - G4double* Bfield) const { +void MagneticFieldWrapper::GetFieldValue(const G4double Point[4], + G4double* Bfield) const { constexpr double convertLength = CLHEP::mm / Acts::UnitConstants::mm; constexpr double convertField = CLHEP::tesla / Acts::UnitConstants::T; @@ -47,3 +46,5 @@ void ActsExamples::MagneticFieldWrapper::GetFieldValue(const G4double Point[4], Bfield[1] = convertField * field[1]; Bfield[2] = convertField * field[2]; } + +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/MaterialPhysicsList.cpp b/Examples/Algorithms/Geant4/src/MaterialPhysicsList.cpp index d115e9e1794..bc0d228e87d 100644 --- a/Examples/Algorithms/Geant4/src/MaterialPhysicsList.cpp +++ b/Examples/Algorithms/Geant4/src/MaterialPhysicsList.cpp @@ -15,27 +15,31 @@ #include #include -ActsExamples::MaterialPhysicsList::MaterialPhysicsList( +namespace ActsExamples::Geant4 { + +MaterialPhysicsList::MaterialPhysicsList( std::unique_ptr logger) : G4VUserPhysicsList(), m_logger(std::move(logger)) { defaultCutValue = 1.0 * CLHEP::cm; } -void ActsExamples::MaterialPhysicsList::ConstructParticle() { +void MaterialPhysicsList::ConstructParticle() { ACTS_DEBUG("Construct Geantinos and Charged Geantinos."); G4Geantino::GeantinoDefinition(); G4ChargedGeantino::ChargedGeantinoDefinition(); } -void ActsExamples::MaterialPhysicsList::ConstructProcess() { +void MaterialPhysicsList::ConstructProcess() { ACTS_DEBUG("Adding Transport as single supperted Process."); AddTransportation(); } -void ActsExamples::MaterialPhysicsList::SetCuts() { +void MaterialPhysicsList::SetCuts() { SetCutsWithDefault(); if (verboseLevel > 0) { DumpCutValuesTable(); } } + +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/MaterialSteppingAction.cpp b/Examples/Algorithms/Geant4/src/MaterialSteppingAction.cpp index c4f0e6528bd..6773079dcd7 100644 --- a/Examples/Algorithms/Geant4/src/MaterialSteppingAction.cpp +++ b/Examples/Algorithms/Geant4/src/MaterialSteppingAction.cpp @@ -24,14 +24,15 @@ #include #include -ActsExamples::MaterialSteppingAction::MaterialSteppingAction( +namespace ActsExamples::Geant4 { + +MaterialSteppingAction::MaterialSteppingAction( const Config& cfg, std::unique_ptr logger) : G4UserSteppingAction(), m_cfg(cfg), m_logger(std::move(logger)) {} -ActsExamples::MaterialSteppingAction::~MaterialSteppingAction() = default; +MaterialSteppingAction::~MaterialSteppingAction() = default; -void ActsExamples::MaterialSteppingAction::UserSteppingAction( - const G4Step* step) { +void MaterialSteppingAction::UserSteppingAction(const G4Step* step) { // Get the material & check if it is present G4Material* material = step->GetPreStepPoint()->GetMaterial(); if (material == nullptr) { @@ -111,3 +112,5 @@ void ActsExamples::MaterialSteppingAction::UserSteppingAction( mInteraction); } } + +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/ParticleKillAction.cpp b/Examples/Algorithms/Geant4/src/ParticleKillAction.cpp index 5090a74dafa..bbc55390c69 100644 --- a/Examples/Algorithms/Geant4/src/ParticleKillAction.cpp +++ b/Examples/Algorithms/Geant4/src/ParticleKillAction.cpp @@ -23,11 +23,13 @@ #include #include -ActsExamples::ParticleKillAction::ParticleKillAction( +namespace ActsExamples::Geant4 { + +ParticleKillAction::ParticleKillAction( const Config& cfg, std::unique_ptr logger) : G4UserSteppingAction(), m_cfg(cfg), m_logger(std::move(logger)) {} -void ActsExamples::ParticleKillAction::UserSteppingAction(const G4Step* step) { +void ParticleKillAction::UserSteppingAction(const G4Step* step) { constexpr double convertLength = Acts::UnitConstants::mm / CLHEP::mm; constexpr double convertTime = Acts::UnitConstants::ns / CLHEP::ns; @@ -72,3 +74,5 @@ void ActsExamples::ParticleKillAction::UserSteppingAction(const G4Step* step) { } } } + +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/ParticleTrackingAction.cpp b/Examples/Algorithms/Geant4/src/ParticleTrackingAction.cpp index ba59debc893..886646a3655 100644 --- a/Examples/Algorithms/Geant4/src/ParticleTrackingAction.cpp +++ b/Examples/Algorithms/Geant4/src/ParticleTrackingAction.cpp @@ -25,12 +25,13 @@ #include #include -ActsExamples::ParticleTrackingAction::ParticleTrackingAction( +namespace ActsExamples::Geant4 { + +ParticleTrackingAction::ParticleTrackingAction( const Config& cfg, std::unique_ptr logger) : G4UserTrackingAction(), m_cfg(cfg), m_logger(std::move(logger)) {} -void ActsExamples::ParticleTrackingAction::PreUserTrackingAction( - const G4Track* aTrack) { +void ParticleTrackingAction::PreUserTrackingAction(const G4Track* aTrack) { // If this is not the case, there are unhandled cases of particle stopping in // the SensitiveSteppingAction // TODO We could also merge the remaining hits to a hit here, but it would be @@ -66,8 +67,7 @@ void ActsExamples::ParticleTrackingAction::PreUserTrackingAction( } } -void ActsExamples::ParticleTrackingAction::PostUserTrackingAction( - const G4Track* aTrack) { +void ParticleTrackingAction::PostUserTrackingAction(const G4Track* aTrack) { // The initial particle maybe was not registered because of a particle ID // collision if (!eventStore().trackIdMapping.contains(aTrack->GetTrackID())) { @@ -83,7 +83,7 @@ void ActsExamples::ParticleTrackingAction::PostUserTrackingAction( if (!m_cfg.keepParticlesWithoutHits && !hasHits) { [[maybe_unused]] auto n = eventStore().particlesSimulated.erase( - ActsExamples::SimParticle(barcode, Acts::PdgParticle::eInvalid)); + SimParticle(barcode, Acts::PdgParticle::eInvalid)); assert(n == 1); return; } @@ -107,8 +107,8 @@ void ActsExamples::ParticleTrackingAction::PostUserTrackingAction( } } -ActsExamples::SimParticleState ActsExamples::ParticleTrackingAction::convert( - const G4Track& aTrack, SimBarcode particleId) const { +SimParticleState ParticleTrackingAction::convert(const G4Track& aTrack, + SimBarcode particleId) const { // Unit conversions G4->::ACTS constexpr double convertTime = Acts::UnitConstants::ns / CLHEP::ns; constexpr double convertLength = Acts::UnitConstants::mm / CLHEP::mm; @@ -147,9 +147,8 @@ ActsExamples::SimParticleState ActsExamples::ParticleTrackingAction::convert( return aParticle; } -std::optional -ActsExamples::ParticleTrackingAction::makeParticleId(G4int trackId, - G4int parentId) const { +std::optional ParticleTrackingAction::makeParticleId( + G4int trackId, G4int parentId) const { // We already have this particle registered (it is one of the input particles // or we are making a final particle state) if (eventStore().trackIdMapping.contains(trackId)) { @@ -174,3 +173,5 @@ ActsExamples::ParticleTrackingAction::makeParticleId(G4int trackId, return pid; } + +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/PhysicsListFactory.cpp b/Examples/Algorithms/Geant4/src/PhysicsListFactory.cpp index 95866efa188..e1b88971b5b 100644 --- a/Examples/Algorithms/Geant4/src/PhysicsListFactory.cpp +++ b/Examples/Algorithms/Geant4/src/PhysicsListFactory.cpp @@ -10,7 +10,7 @@ #include -namespace ActsExamples { +namespace ActsExamples::Geant4 { PhysicsListFactoryFunction::PhysicsListFactoryFunction(Function function) : m_function(std::move(function)) {} @@ -20,4 +20,4 @@ std::unique_ptr PhysicsListFactoryFunction::factorize() return m_function(); } -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/RegionCreator.cpp b/Examples/Algorithms/Geant4/src/RegionCreator.cpp index 4e3384a98b7..c38dcf83078 100644 --- a/Examples/Algorithms/Geant4/src/RegionCreator.cpp +++ b/Examples/Algorithms/Geant4/src/RegionCreator.cpp @@ -13,7 +13,7 @@ #include #include -namespace ActsExamples { +namespace ActsExamples::Geant4 { RegionCreator::RegionCreator(const Config& cfg, std::string name, Acts::Logging::Level level) @@ -21,7 +21,7 @@ RegionCreator::RegionCreator(const Config& cfg, std::string name, m_cfg(cfg), m_logger(Acts::getDefaultLogger(m_name, level)) {} -void RegionCreator::Construct() { +void RegionCreator::construct() { // create a new G4Region G4Region* region = new G4Region(m_name); @@ -68,4 +68,4 @@ void RegionCreator::Construct() { region->SetProductionCuts(cuts); } -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/SensitiveSteppingAction.cpp b/Examples/Algorithms/Geant4/src/SensitiveSteppingAction.cpp index 17df42bdb21..098cce7b3aa 100644 --- a/Examples/Algorithms/Geant4/src/SensitiveSteppingAction.cpp +++ b/Examples/Algorithms/Geant4/src/SensitiveSteppingAction.cpp @@ -13,7 +13,6 @@ #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/MultiIndex.hpp" -#include "ActsExamples/EventData/SimHit.hpp" #include "ActsExamples/Geant4/EventStore.hpp" #include "ActsExamples/Geant4/SensitiveSurfaceMapper.hpp" #include "ActsFatras/EventData/Barcode.hpp" @@ -33,8 +32,6 @@ #include #include -class G4PrimaryParticle; - #if BOOST_VERSION >= 107800 #include @@ -95,12 +92,13 @@ ActsFatras::Hit hitFromStep(const G4StepPoint* preStepPoint, } } // namespace -ActsExamples::SensitiveSteppingAction::SensitiveSteppingAction( +namespace ActsExamples::Geant4 { + +SensitiveSteppingAction::SensitiveSteppingAction( const Config& cfg, std::unique_ptr logger) : G4UserSteppingAction(), m_cfg(cfg), m_logger(std::move(logger)) {} -void ActsExamples::SensitiveSteppingAction::UserSteppingAction( - const G4Step* step) { +void SensitiveSteppingAction::UserSteppingAction(const G4Step* step) { // Unit conversions G4->::ACTS static constexpr double convertLength = Acts::UnitConstants::mm / CLHEP::mm; @@ -279,3 +277,5 @@ void ActsExamples::SensitiveSteppingAction::UserSteppingAction( assert(false && "should never reach this"); } + +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp b/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp index 2fd1a924d94..924a898c238 100644 --- a/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp +++ b/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp @@ -63,6 +63,7 @@ struct access, Index> { } // namespace boost::geometry::traits namespace { + void writeG4Polyhedron( Acts::IVisualization3D& visualizer, const G4Polyhedron& polyhedron, const Acts::Transform3& trafo = Acts::Transform3::Identity(), @@ -89,10 +90,12 @@ void writeG4Polyhedron( visualizer.face(faces, color); } } + } // namespace -std::vector -ActsExamples::SensitiveCandidates::queryPosition( +namespace ActsExamples::Geant4 { + +std::vector SensitiveCandidates::queryPosition( const Acts::GeometryContext& gctx, const Acts::Vector3& position) const { std::vector surfaces; @@ -119,8 +122,7 @@ ActsExamples::SensitiveCandidates::queryPosition( return surfaces; } -std::vector ActsExamples::SensitiveCandidates::queryAll() - const { +std::vector SensitiveCandidates::queryAll() const { std::vector surfaces; const bool restrictToSensitives = true; @@ -130,11 +132,11 @@ std::vector ActsExamples::SensitiveCandidates::queryAll() return surfaces; } -ActsExamples::SensitiveSurfaceMapper::SensitiveSurfaceMapper( +SensitiveSurfaceMapper::SensitiveSurfaceMapper( const Config& cfg, std::unique_ptr logger) : m_cfg(cfg), m_logger(std::move(logger)) {} -void ActsExamples::SensitiveSurfaceMapper::remapSensitiveNames( +void SensitiveSurfaceMapper::remapSensitiveNames( State& state, const Acts::GeometryContext& gctx, G4VPhysicalVolume* g4PhysicalVolume, const Acts::Transform3& motherTransform) const { @@ -291,7 +293,7 @@ void ActsExamples::SensitiveSurfaceMapper::remapSensitiveNames( state.g4VolumeToSurfaces.insert({g4PhysicalVolume, mappedSurface}); } -bool ActsExamples::SensitiveSurfaceMapper::checkMapping( +bool SensitiveSurfaceMapper::checkMapping( const State& state, const Acts::GeometryContext& gctx, bool writeMissingG4VolsAsObj, bool writeMissingSurfacesAsObj) const { auto allSurfaces = m_cfg.candidateSurfaces->queryAll(); @@ -343,3 +345,5 @@ bool ActsExamples::SensitiveSurfaceMapper::checkMapping( return missing.empty(); } + +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/SimParticleTranslation.cpp b/Examples/Algorithms/Geant4/src/SimParticleTranslation.cpp index 8b8156ff3e4..e505edafa76 100644 --- a/Examples/Algorithms/Geant4/src/SimParticleTranslation.cpp +++ b/Examples/Algorithms/Geant4/src/SimParticleTranslation.cpp @@ -28,19 +28,17 @@ #include #include -namespace ActsExamples { -class WhiteBoard; -} // namespace ActsExamples +namespace ActsExamples::Geant4 { -ActsExamples::SimParticleTranslation::SimParticleTranslation( +SimParticleTranslation::SimParticleTranslation( const Config& cfg, std::unique_ptr logger) : G4VUserPrimaryGeneratorAction(), m_cfg(cfg), m_logger(std::move(logger)) {} -ActsExamples::SimParticleTranslation::~SimParticleTranslation() = default; +SimParticleTranslation::~SimParticleTranslation() = default; -void ActsExamples::SimParticleTranslation::GeneratePrimaries(G4Event* anEvent) { +void SimParticleTranslation::GeneratePrimaries(G4Event* anEvent) { anEvent->SetEventID(m_eventNr++); unsigned int eventID = anEvent->GetEventID(); @@ -158,3 +156,5 @@ void ActsExamples::SimParticleTranslation::GeneratePrimaries(G4Event* anEvent) { << lastVertex->transpose()); } } + +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/TelescopeG4DetectorConstruction.cpp b/Examples/Algorithms/Geant4/src/TelescopeG4DetectorConstruction.cpp index 423acf7e2a5..9d309932fbe 100644 --- a/Examples/Algorithms/Geant4/src/TelescopeG4DetectorConstruction.cpp +++ b/Examples/Algorithms/Geant4/src/TelescopeG4DetectorConstruction.cpp @@ -26,18 +26,18 @@ #include "G4RunManager.hh" #include "G4SystemOfUnits.hh" -ActsExamples::Telescope::TelescopeG4DetectorConstruction:: - TelescopeG4DetectorConstruction( - const TelescopeDetector::Config& cfg, - std::vector> regionCreators) +namespace ActsExamples { + +Telescope::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), "only plan is supported right now"); } -G4VPhysicalVolume* -ActsExamples::Telescope::TelescopeG4DetectorConstruction::Construct() { +G4VPhysicalVolume* Telescope::TelescopeG4DetectorConstruction::Construct() { if (m_world != nullptr) { return m_world; } @@ -162,21 +162,22 @@ ActsExamples::Telescope::TelescopeG4DetectorConstruction::Construct() { // Create regions for (const auto& regionCreator : m_regionCreators) { - regionCreator->Construct(); + regionCreator->construct(); } return m_world; } -ActsExamples::Telescope::TelescopeG4DetectorConstructionFactory:: +Telescope::TelescopeG4DetectorConstructionFactory:: TelescopeG4DetectorConstructionFactory( const TelescopeDetector::Config& cfg, - std::vector> regionCreators) + std::vector> regionCreators) : m_cfg(cfg), m_regionCreators(std::move(regionCreators)) {} std::unique_ptr -ActsExamples::Telescope::TelescopeG4DetectorConstructionFactory::factorize() - const { +Telescope::TelescopeG4DetectorConstructionFactory::factorize() const { return std::make_unique(m_cfg, m_regionCreators); } + +} // namespace ActsExamples diff --git a/Examples/Algorithms/Geant4HepMC/include/ActsExamples/Geant4HepMC/EventRecording.hpp b/Examples/Algorithms/Geant4HepMC/include/ActsExamples/Geant4HepMC/EventRecording.hpp index 256a82a4471..6f45940182c 100644 --- a/Examples/Algorithms/Geant4HepMC/include/ActsExamples/Geant4HepMC/EventRecording.hpp +++ b/Examples/Algorithms/Geant4HepMC/include/ActsExamples/Geant4HepMC/EventRecording.hpp @@ -8,8 +8,6 @@ #pragma once -#include "Acts/Definitions/Algebra.hpp" -#include "Acts/Propagator/MaterialInteractor.hpp" #include "Acts/Utilities/Logger.hpp" #include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Framework/DataHandle.hpp" @@ -24,9 +22,12 @@ class G4RunManager; -namespace ActsExamples { - +namespace ActsExamples::Geant4 { class DetectorConstructionFactory; +class RegionCreator; +} // namespace ActsExamples::Geant4 + +namespace ActsExamples { class EventRecording final : public ActsExamples::IAlgorithm { public: @@ -37,7 +38,8 @@ class EventRecording final : public ActsExamples::IAlgorithm { /// The recorded events output std::string outputHepMcTracks = "geant-outcome-tracks"; - std::shared_ptr detectorConstructionFactory; + std::shared_ptr + detectorConstructionFactory; /// random number seed 1 int seed1 = 12345; diff --git a/Examples/Algorithms/Geant4HepMC/src/EventRecording.cpp b/Examples/Algorithms/Geant4HepMC/src/EventRecording.cpp index e4900f63c05..93c27b0c1c1 100644 --- a/Examples/Algorithms/Geant4HepMC/src/EventRecording.cpp +++ b/Examples/Algorithms/Geant4HepMC/src/EventRecording.cpp @@ -11,9 +11,7 @@ #include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Framework/WhiteBoard.hpp" #include "ActsExamples/Geant4/DetectorConstructionFactory.hpp" -#include "ActsExamples/Geant4/GdmlDetectorConstruction.hpp" -#include #include #include @@ -26,14 +24,15 @@ #include "RunAction.hpp" #include "SteppingAction.hpp" -ActsExamples::EventRecording::~EventRecording() { +namespace ActsExamples { + +EventRecording::~EventRecording() { m_runManager = nullptr; } -ActsExamples::EventRecording::EventRecording( - const ActsExamples::EventRecording::Config& config, - Acts::Logging::Level level) - : ActsExamples::IAlgorithm("EventRecording", level), +EventRecording::EventRecording(const EventRecording::Config& config, + Acts::Logging::Level level) + : IAlgorithm("EventRecording", level), m_cfg(config), m_runManager(std::make_unique()) { if (m_cfg.inputParticles.empty()) { @@ -42,7 +41,7 @@ ActsExamples::EventRecording::EventRecording( if (m_cfg.outputHepMcTracks.empty()) { throw std::invalid_argument("Missing output event collection"); } - if (!m_cfg.detectorConstructionFactory) { + if (m_cfg.detectorConstructionFactory == nullptr) { throw std::invalid_argument("Missing detector construction object"); } @@ -55,19 +54,17 @@ ActsExamples::EventRecording::EventRecording( m_runManager->SetUserInitialization( m_cfg.detectorConstructionFactory->factorize().release()); m_runManager->SetUserInitialization(new FTFP_BERT); - m_runManager->SetUserAction(new ActsExamples::Geant4::HepMC3::RunAction()); + m_runManager->SetUserAction(new Geant4::HepMC3::RunAction()); m_runManager->SetUserAction( - new ActsExamples::Geant4::HepMC3::EventAction(m_cfg.processesCombine)); + new Geant4::HepMC3::EventAction(m_cfg.processesCombine)); m_runManager->SetUserAction( - new ActsExamples::Geant4::HepMC3::PrimaryGeneratorAction(m_cfg.seed1, - m_cfg.seed2)); + new Geant4::HepMC3::PrimaryGeneratorAction(m_cfg.seed1, m_cfg.seed2)); m_runManager->SetUserAction( - new ActsExamples::Geant4::HepMC3::SteppingAction(m_cfg.processesReject)); + new Geant4::HepMC3::SteppingAction(m_cfg.processesReject)); m_runManager->Initialize(); } -ActsExamples::ProcessCode ActsExamples::EventRecording::execute( - const ActsExamples::AlgorithmContext& context) const { +ProcessCode EventRecording::execute(const AlgorithmContext& context) const { // ensure exclusive access to the geant run manager std::lock_guard guard(m_runManagerLock); @@ -80,8 +77,8 @@ ActsExamples::ProcessCode ActsExamples::EventRecording::execute( for (const auto& part : initialParticles) { // Prepare the particle gun - ActsExamples::Geant4::HepMC3::PrimaryGeneratorAction::instance() - ->prepareParticleGun(part); + Geant4::HepMC3::PrimaryGeneratorAction::instance()->prepareParticleGun( + part); // Begin with the simulation m_runManager->BeamOn(1); @@ -92,8 +89,7 @@ ActsExamples::ProcessCode ActsExamples::EventRecording::execute( } // Set event start time - HepMC3::GenEvent event = - ActsExamples::Geant4::HepMC3::EventAction::instance()->event(); + HepMC3::GenEvent event = Geant4::HepMC3::EventAction::instance()->event(); HepMC3::FourVector shift(0., 0., 0., part.time() / Acts::UnitConstants::mm); event.shift_position_by(shift); @@ -174,5 +170,7 @@ ActsExamples::ProcessCode ActsExamples::EventRecording::execute( // Write the recorded material to the event store m_outputEvents(context, std::move(events)); - return ActsExamples::ProcessCode::SUCCESS; + return ProcessCode::SUCCESS; } + +} // namespace ActsExamples diff --git a/Examples/Python/src/Geant4Component.cpp b/Examples/Python/src/Geant4Component.cpp index 1a7edd58e7f..abba9cefe98 100644 --- a/Examples/Python/src/Geant4Component.cpp +++ b/Examples/Python/src/Geant4Component.cpp @@ -16,7 +16,6 @@ #include "Acts/Plugins/Python/Utilities.hpp" #include "Acts/Surfaces/SurfaceVisitorConcept.hpp" #include "Acts/Utilities/Logger.hpp" -#include "ActsExamples/Framework/AlgorithmContext.hpp" #include "ActsExamples/Framework/IContextDecorator.hpp" #include "ActsExamples/Geant4/DetectorConstructionFactory.hpp" #include "ActsExamples/Geant4/GdmlDetectorConstruction.hpp" @@ -65,7 +64,8 @@ namespace Acts::Python { void addGeant4HepMC3(Context& ctx); } -struct ExperimentalSensitiveCandidates : public SensitiveCandidatesBase { +struct ExperimentalSensitiveCandidates + : public Geant4::SensitiveCandidatesBase { std::shared_ptr detector; /// Find the sensitive surfaces for a given position @@ -97,8 +97,8 @@ struct ExperimentalSensitiveCandidates : public SensitiveCandidatesBase { }; PYBIND11_MODULE(ActsPythonBindingsGeant4, mod) { - py::class_>( + py::class_>( mod, "DetectorConstructionFactory"); py::class_>( @@ -129,14 +129,14 @@ PYBIND11_MODULE(ActsPythonBindingsGeant4, mod) { } { - using Config = SensitiveSurfaceMapper::Config; - using State = SensitiveSurfaceMapper::State; + using Config = Geant4::SensitiveSurfaceMapper::Config; + using State = Geant4::SensitiveSurfaceMapper::State; auto sm = - py::class_>( + py::class_>( mod, "SensitiveSurfaceMapper") .def(py::init([](const Config& cfg, Acts::Logging::Level level) { - return std::make_shared( + return std::make_shared( cfg, getDefaultLogger("SensitiveSurfaceMapper", level)); })); @@ -155,10 +155,10 @@ PYBIND11_MODULE(ActsPythonBindingsGeant4, mod) { // Set a new surface finder Config ccfg = cfg; auto candidateSurfaces = - std::make_shared(); + std::make_shared(); candidateSurfaces->trackingGeometry = tGeometry; ccfg.candidateSurfaces = candidateSurfaces; - return std::make_shared( + return std::make_shared( ccfg, getDefaultLogger("SensitiveSurfaceMapper", level)); }); @@ -173,20 +173,21 @@ PYBIND11_MODULE(ActsPythonBindingsGeant4, mod) { std::make_shared(); candidateSurfaces->detector = detector; ccfg.candidateSurfaces = candidateSurfaces; - return std::make_shared( + return std::make_shared( ccfg, getDefaultLogger("SensitiveSurfaceMapper", level)); }); sm.def( "remapSensitiveNames", - [](SensitiveSurfaceMapper& self, State& state, GeometryContext& gctx, - DetectorConstructionFactory& factory, Transform3& transform) { + [](Geant4::SensitiveSurfaceMapper& self, State& state, + GeometryContext& gctx, Geant4::DetectorConstructionFactory& factory, + Transform3& transform) { return self.remapSensitiveNames( state, gctx, factory.factorize()->Construct(), transform); }, "state"_a, "gctx"_a, "g4physicalVolume"_a, "motherTransform"_a); - sm.def("checkMapping", &SensitiveSurfaceMapper::checkMapping, "state"_a, - "gctx"_a, "writeMappedAsObj"_a, "writeMissingAsObj"_a); + sm.def("checkMapping", &Geant4::SensitiveSurfaceMapper::checkMapping, + "state"_a, "gctx"_a, "writeMappedAsObj"_a, "writeMissingAsObj"_a); } { @@ -237,27 +238,28 @@ PYBIND11_MODULE(ActsPythonBindingsGeant4, mod) { } { - py::class_>( mod, "GdmlDetectorConstructionFactory") .def(py::init>>(), + std::vector>>(), py::arg("path"), py::arg("regionCreators") = - std::vector>()); + std::vector>()); } { py::class_< Telescope::TelescopeG4DetectorConstructionFactory, - DetectorConstructionFactory, + Geant4::DetectorConstructionFactory, std::shared_ptr>( mod, "TelescopeG4DetectorConstructionFactory") .def(py::init>>(), + std::vector>>(), py::arg("cfg"), py::arg("regionCreators") = - std::vector>()); + std::vector>()); } { @@ -412,7 +414,7 @@ PYBIND11_MODULE(ActsPythonBindingsGeant4, mod) { } { - using Tool = RegionCreator; + using Tool = Geant4::RegionCreator; using Config = Tool::Config; auto tool = py::class_>(mod, "RegionCreator") .def(py::init(), diff --git a/Examples/Python/src/Geant4DD4hepComponent.cpp b/Examples/Python/src/Geant4DD4hepComponent.cpp index 16ed3b40223..f8dec7d35d1 100644 --- a/Examples/Python/src/Geant4DD4hepComponent.cpp +++ b/Examples/Python/src/Geant4DD4hepComponent.cpp @@ -8,7 +8,6 @@ #include "ActsExamples/DD4hepDetector/DD4hepDetector.hpp" #include "ActsExamples/DDG4/DDG4DetectorConstruction.hpp" -#include "ActsExamples/Framework/ProcessCode.hpp" #include "ActsExamples/Geant4/RegionCreator.hpp" #include @@ -25,12 +24,13 @@ using namespace Acts; PYBIND11_MODULE(ActsPythonBindingsDDG4, m) { py::module_::import("acts.ActsPythonBindingsGeant4"); - py::class_>( m, "DDG4DetectorConstructionFactory") .def(py::init, - std::vector>>(), + std::vector>>(), py::arg("detector"), py::arg("regionCreators") = - std::vector>()); + std::vector>()); } diff --git a/Examples/Python/src/Geant4GeoModelComponent.cpp b/Examples/Python/src/Geant4GeoModelComponent.cpp index 80f6f89eec8..d9c372984db 100644 --- a/Examples/Python/src/Geant4GeoModelComponent.cpp +++ b/Examples/Python/src/Geant4GeoModelComponent.cpp @@ -6,7 +6,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -#include "ActsExamples/Framework/ProcessCode.hpp" #include "ActsExamples/Geant4/DetectorConstructionFactory.hpp" #include "ActsExamples/Geant4/RegionCreator.hpp" #include "ActsExamples/GeoModelG4/GeoModelDetectorConstruction.hpp" @@ -25,12 +24,13 @@ using namespace Acts; PYBIND11_MODULE(ActsPythonBindingsGeoModelG4, m) { py::module_::import("acts.ActsPythonBindingsGeant4"); - py::class_>( m, "GeoModelDetectorConstructionFactory") .def(py::init>>(), + std::vector>>(), py::arg("geoModelTree"), py::arg("regionCreators") = - std::vector>()); + std::vector>()); } diff --git a/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4DetectorSurfaceFactory.hpp b/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4DetectorSurfaceFactory.hpp index d06c77412e4..e5868effd19 100644 --- a/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4DetectorSurfaceFactory.hpp +++ b/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4DetectorSurfaceFactory.hpp @@ -9,7 +9,6 @@ #pragma once #include "Acts/Definitions/Algebra.hpp" -#include "Acts/Definitions/Common.hpp" #include "Acts/Plugins/Geant4/Geant4PhysicalVolumeSelectors.hpp" #include "Acts/Surfaces/Surface.hpp" @@ -91,4 +90,5 @@ class Geant4DetectorSurfaceFactory { void construct(Cache& cache, const G4Transform3D& g4ToGlobal, const G4VPhysicalVolume& g4PhysVol, const Options& option); }; + } // namespace Acts diff --git a/Plugins/Geant4/src/Geant4DetectorElement.cpp b/Plugins/Geant4/src/Geant4DetectorElement.cpp index d5410d3b3de..179b351d50e 100644 --- a/Plugins/Geant4/src/Geant4DetectorElement.cpp +++ b/Plugins/Geant4/src/Geant4DetectorElement.cpp @@ -12,31 +12,36 @@ #include -Acts::Geant4DetectorElement::Geant4DetectorElement( - std::shared_ptr surface, const G4VPhysicalVolume& g4physVol, - const Acts::Transform3& toGlobal, Acts::ActsScalar thickness) +namespace Acts { + +Geant4DetectorElement::Geant4DetectorElement(std::shared_ptr surface, + const G4VPhysicalVolume& g4physVol, + const Transform3& toGlobal, + ActsScalar thickness) : m_surface(std::move(surface)), m_g4physVol(&g4physVol), m_toGlobal(toGlobal), m_thickness(thickness) {} -const Acts::Transform3& Acts::Geant4DetectorElement::transform( +const Transform3& Geant4DetectorElement::transform( const GeometryContext& /*gctx*/) const { return m_toGlobal; } -const Acts::Surface& Acts::Geant4DetectorElement::surface() const { +const Surface& Geant4DetectorElement::surface() const { return *m_surface; } -Acts::Surface& Acts::Geant4DetectorElement::surface() { +Surface& Geant4DetectorElement::surface() { return *m_surface; } -Acts::ActsScalar Acts::Geant4DetectorElement::thickness() const { +ActsScalar Geant4DetectorElement::thickness() const { return m_thickness; } -const G4VPhysicalVolume& Acts::Geant4DetectorElement::g4PhysicalVolume() const { +const G4VPhysicalVolume& Geant4DetectorElement::g4PhysicalVolume() const { return *m_g4physVol; } + +} // namespace Acts diff --git a/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelDetectorElementITk.hpp b/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelDetectorElementITk.hpp index 31cce3360e9..bbd12562eac 100644 --- a/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelDetectorElementITk.hpp +++ b/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelDetectorElementITk.hpp @@ -6,14 +6,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -// This file is part of the Acts project. -// -// Copyright (C) 2024 CERN for the benefit of the Acts project -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - #pragma once #include "Acts/Plugins/GeoModel/GeoModelDetectorElement.hpp" diff --git a/Plugins/GeoModel/src/GeoModelDetectorElementITk.cpp b/Plugins/GeoModel/src/GeoModelDetectorElementITk.cpp index f671386dec6..1f45a10d391 100644 --- a/Plugins/GeoModel/src/GeoModelDetectorElementITk.cpp +++ b/Plugins/GeoModel/src/GeoModelDetectorElementITk.cpp @@ -6,14 +6,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -// This file is part of the Acts project. -// -// Copyright (C) 2024 CERN for the benefit of the Acts project -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - #include "Acts/Plugins/GeoModel/GeoModelDetectorElementITk.hpp" #include "Acts/Surfaces/AnnulusBounds.hpp" diff --git a/Tests/UnitTests/Plugins/GeoModel/GeoModelDetectorElementITkTests.cpp b/Tests/UnitTests/Plugins/GeoModel/GeoModelDetectorElementITkTests.cpp index 0c945ebb6dd..f3e96e4a6f8 100644 --- a/Tests/UnitTests/Plugins/GeoModel/GeoModelDetectorElementITkTests.cpp +++ b/Tests/UnitTests/Plugins/GeoModel/GeoModelDetectorElementITkTests.cpp @@ -6,14 +6,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -// This file is part of the Acts project. -// -// Copyright (C) 2024 CERN for the benefit of the Acts project -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - #include #include "Acts/Plugins/GeoModel/GeoModelDetectorElementITk.hpp"