diff --git a/Simulation/G4Utilities/Geo2G4/src/ExtParameterisedVolumeBuilder.cxx b/Simulation/G4Utilities/Geo2G4/src/ExtParameterisedVolumeBuilder.cxx index 7687e247a4a5282d20f04fb925b6b2e2156c1d90..f397bff3fb1df6d197cc19da6a1fe0be8326845f 100644 --- a/Simulation/G4Utilities/Geo2G4/src/ExtParameterisedVolumeBuilder.cxx +++ b/Simulation/G4Utilities/Geo2G4/src/ExtParameterisedVolumeBuilder.cxx @@ -38,7 +38,7 @@ ExtParameterisedVolumeBuilder::ExtParameterisedVolumeBuilder(const std::string& { } -G4LogicalVolume* ExtParameterisedVolumeBuilder::Build(const PVConstLink theGeoPhysVolume, OpticalVolumesMap* optical_volumes) const +G4LogicalVolume* ExtParameterisedVolumeBuilder::Build(const PVConstLink theGeoPhysVolume, OpticalVolumesMap* optical_volumes) { PVConstLink theGeoPhysChild; const GeoSerialTransformer* serialTransformerChild{nullptr}; @@ -50,7 +50,7 @@ G4LogicalVolume* ExtParameterisedVolumeBuilder::Build(const PVConstLink theGeoPh if(m_getMatEther) getMatEther(); - static Geo2G4LVFactory LVFactory; + static const Geo2G4LVFactory LVFactory; G4LogicalVolume* theG4LogVolume = LVFactory.Build(theGeoPhysVolume,descend); @@ -185,7 +185,7 @@ G4LogicalVolume* ExtParameterisedVolumeBuilder::Build(const PVConstLink theGeoPh return theG4LogVolume; } -Geo2G4AssemblyVolume* ExtParameterisedVolumeBuilder::BuildAssembly(const PVConstLink& pv) const +Geo2G4AssemblyVolume* ExtParameterisedVolumeBuilder::BuildAssembly(const PVConstLink& pv) { PVConstLink theGeoPhysChild; G4LogicalVolume* theG4LogChild{nullptr}; @@ -258,7 +258,7 @@ void ExtParameterisedVolumeBuilder::PrintSTInfo(const std::string& volume) const ATH_MSG_INFO ( "********************************************** " ); } -void ExtParameterisedVolumeBuilder::getMatEther() const +void ExtParameterisedVolumeBuilder::getMatEther() { StoreGateSvc* pDetStore{nullptr}; ISvcLocator* svcLocator = Gaudi::svcLocator(); diff --git a/Simulation/G4Utilities/Geo2G4/src/ExtParameterisedVolumeBuilder.h b/Simulation/G4Utilities/Geo2G4/src/ExtParameterisedVolumeBuilder.h index 60216ad6e1668df2dd540e428d65979e16193181..b420b9355eee3b4f79aa102429ae1d264c32eef1 100644 --- a/Simulation/G4Utilities/Geo2G4/src/ExtParameterisedVolumeBuilder.h +++ b/Simulation/G4Utilities/Geo2G4/src/ExtParameterisedVolumeBuilder.h @@ -19,19 +19,19 @@ class ExtParameterisedVolumeBuilder: public VolumeBuilder, public AthMessaging public: ExtParameterisedVolumeBuilder(const std::string& n, Geo2G4AssemblyFactory* G4AssemblyFactory); /// - G4LogicalVolume* Build(PVConstLink pv, OpticalVolumesMap* optical_volumes = 0) const; + virtual G4LogicalVolume* Build(PVConstLink pv, OpticalVolumesMap* optical_volumes = 0) override; /// - Geo2G4AssemblyVolume* BuildAssembly(const PVConstLink& pv) const; + Geo2G4AssemblyVolume* BuildAssembly(const PVConstLink& pv); private: /// Prints info when some PhysVol contains both types (PV and ST) of daughters void PrintSTInfo(const std::string& volume) const; /// - void getMatEther() const; + void getMatEther(); - mutable bool m_getMatEther; - mutable const GeoMaterial* m_matEther; - mutable const GeoMaterial* m_matHypUr; + bool m_getMatEther; + const GeoMaterial* m_matEther; + const GeoMaterial* m_matHypUr; Geo2G4AssemblyFactory* m_G4AssemblyFactory; }; diff --git a/Simulation/G4Utilities/Geo2G4/src/Geo2G4AssemblyTriplet.h b/Simulation/G4Utilities/Geo2G4/src/Geo2G4AssemblyTriplet.h index a7ba9be6c493e06e593bbaf4ede758b8f89eb64a..40d2aba850c54ceed21382bb9e445fd865c4b049 100644 --- a/Simulation/G4Utilities/Geo2G4/src/Geo2G4AssemblyTriplet.h +++ b/Simulation/G4Utilities/Geo2G4/src/Geo2G4AssemblyTriplet.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ #ifndef GEO2G4_ASSEMBLYTRIPLET_H @@ -30,34 +30,38 @@ class Geo2G4AssemblyTriplet G4bool isReflection = false); // An explicit constructor for an assembly volume - Geo2G4AssemblyTriplet( const Geo2G4AssemblyTriplet& second ); + Geo2G4AssemblyTriplet( const Geo2G4AssemblyTriplet& second ) = default; // Copy constructor ~Geo2G4AssemblyTriplet(); // Destructor - Geo2G4AssemblyTriplet& operator=( const Geo2G4AssemblyTriplet& second ); + Geo2G4AssemblyTriplet& operator=( const Geo2G4AssemblyTriplet& second ) = default; // Assignment operator - G4LogicalVolume* GetVolume() const; + const G4LogicalVolume* GetVolume() const { return m_volume; } + G4LogicalVolume* GetVolume() { return m_volume; } // Retrieve the logical volume reference void SetVolume( G4LogicalVolume* pVolume ); // Update the logical volume reference - Geo2G4AssemblyVolume* GetAssembly() const; + const Geo2G4AssemblyVolume* GetAssembly() const { return m_assembly; } + Geo2G4AssemblyVolume* GetAssembly() { return m_assembly; } // Retrieve the assembly volume reference void SetAssembly( Geo2G4AssemblyVolume* pAssembly ); // Update the assembly volume reference - G4ThreeVector GetTranslation() const; + const G4ThreeVector GetTranslation() const { return m_translation; } + G4ThreeVector GetTranslation() { return m_translation; } // Retrieve the logical volume translation void SetTranslation( G4ThreeVector& pVolume ); // Update the logical volume translation - G4RotationMatrix* GetRotation() const; + const G4RotationMatrix* GetRotation() const { return m_rotation; } + G4RotationMatrix* GetRotation() { return m_rotation; } // Retrieve the logical volume rotation void SetRotation( G4RotationMatrix* pVolume ); @@ -116,27 +120,11 @@ Geo2G4AssemblyTriplet::Geo2G4AssemblyTriplet( Geo2G4AssemblyVolume* pAssembly, { } -inline -Geo2G4AssemblyTriplet::Geo2G4AssemblyTriplet( const Geo2G4AssemblyTriplet& second ) -{ - m_volume = second.GetVolume(); - m_rotation = second.GetRotation(); - m_translation = second.GetTranslation(); - m_assembly = second.GetAssembly(); - m_isReflection = second.IsReflection(); -} - inline Geo2G4AssemblyTriplet::~Geo2G4AssemblyTriplet() { } -inline -G4LogicalVolume* Geo2G4AssemblyTriplet::GetVolume() const -{ - return m_volume; -} - inline void Geo2G4AssemblyTriplet::SetVolume( G4LogicalVolume* pVolume ) { @@ -150,12 +138,6 @@ void Geo2G4AssemblyTriplet::SetVolume( G4LogicalVolume* pVolume ) m_assembly = 0; } -inline -Geo2G4AssemblyVolume* Geo2G4AssemblyTriplet::GetAssembly() const -{ - return m_assembly; -} - inline void Geo2G4AssemblyTriplet::SetAssembly( Geo2G4AssemblyVolume* pAssembly ) { @@ -169,24 +151,12 @@ void Geo2G4AssemblyTriplet::SetAssembly( Geo2G4AssemblyVolume* pAssembly ) m_volume = 0; } -inline -G4ThreeVector Geo2G4AssemblyTriplet::GetTranslation() const -{ - return m_translation; -} - inline void Geo2G4AssemblyTriplet::SetTranslation( G4ThreeVector& translation ) { m_translation = translation; } -inline -G4RotationMatrix* Geo2G4AssemblyTriplet::GetRotation() const -{ - return m_rotation; -} - inline void Geo2G4AssemblyTriplet::SetRotation( G4RotationMatrix* pRotation ) { @@ -199,20 +169,4 @@ G4bool Geo2G4AssemblyTriplet::IsReflection() const return m_isReflection; } -inline -Geo2G4AssemblyTriplet& -Geo2G4AssemblyTriplet::operator=( const Geo2G4AssemblyTriplet& second ) -{ - if( this != &second ) - { - m_volume = second.GetVolume(); - m_rotation = second.GetRotation(); - m_translation = second.GetTranslation(); - m_assembly = second.GetAssembly(); - m_isReflection = second.IsReflection(); - } - - return *this; -} - #endif diff --git a/Simulation/G4Utilities/Geo2G4/src/Geo2G4AssemblyVolume.cxx b/Simulation/G4Utilities/Geo2G4/src/Geo2G4AssemblyVolume.cxx index a5b14f2d9343f2cbe835eea10a068fe63c26980e..616ef273a4161992ef831035c4e98caade132eab 100644 --- a/Simulation/G4Utilities/Geo2G4/src/Geo2G4AssemblyVolume.cxx +++ b/Simulation/G4Utilities/Geo2G4/src/Geo2G4AssemblyVolume.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ #include "Geo2G4AssemblyVolume.h" @@ -12,7 +12,7 @@ #include -unsigned int Geo2G4AssemblyVolume::s_instanceCounter = 0; +std::atomic Geo2G4AssemblyVolume::s_instanceCounter = 0; // Default constructor // @@ -288,7 +288,7 @@ void Geo2G4AssemblyVolume::MakeImprint( Geo2G4AssemblyVolume* pAssembly, void Geo2G4AssemblyVolume::MakeImprint( G4LogicalVolume* pMotherLV, G4ThreeVector& translationInMother, - G4RotationMatrix* pRotationInMother, + const G4RotationMatrix* pRotationInMother, G4int copyNumBase, G4bool ITkScheme, G4bool surfCheck ) @@ -305,8 +305,7 @@ void Geo2G4AssemblyVolume::MakeImprint( G4LogicalVolume* pMotherLV, { // Make it by default an indentity matrix // - pRotationInMother = - const_cast( &G4RotationMatrix::IDENTITY ); + pRotationInMother = &G4RotationMatrix::IDENTITY; } G4Transform3D transform( *pRotationInMother, @@ -334,11 +333,6 @@ unsigned int Geo2G4AssemblyVolume::GetInstanceCount() const return Geo2G4AssemblyVolume::s_instanceCounter; } -void Geo2G4AssemblyVolume::SetInstanceCount( unsigned int value ) -{ - Geo2G4AssemblyVolume::s_instanceCounter = value; -} - void Geo2G4AssemblyVolume::InstanceCountPlus() { Geo2G4AssemblyVolume::s_instanceCounter++; diff --git a/Simulation/G4Utilities/Geo2G4/src/Geo2G4AssemblyVolume.h b/Simulation/G4Utilities/Geo2G4/src/Geo2G4AssemblyVolume.h index 6323037d6d33a9b6fd686f3a431f95e6192f5182..9fb505d8c759689de5b59dba8d00fe66d3b5b250 100644 --- a/Simulation/G4Utilities/Geo2G4/src/Geo2G4AssemblyVolume.h +++ b/Simulation/G4Utilities/Geo2G4/src/Geo2G4AssemblyVolume.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ #ifndef GEO2G4_ASSEMBLYVOLUME_H @@ -7,6 +7,7 @@ #include "Geo2G4AssemblyTriplet.h" #include "G4Transform3D.hh" +#include #include class G4VPhysicalVolume; @@ -87,7 +88,7 @@ public: // with description void MakeImprint( G4LogicalVolume* pMotherLV, G4ThreeVector& translationInMother, - G4RotationMatrix* pRotationInMother, + const G4RotationMatrix* pRotationInMother, G4int copyNumBase = 0, G4bool ITkScheme = false, G4bool surfCheck = false ); @@ -122,7 +123,6 @@ public: // with description protected: - void SetInstanceCount( unsigned int value ); void SetAssemblyID( unsigned int value ); void InstanceCountPlus(); @@ -171,7 +171,7 @@ private: // // Number of imprints of the given assembly volume. - static unsigned int s_instanceCounter; + static std::atomic s_instanceCounter; // // Class instance counter. diff --git a/Simulation/G4Utilities/Geo2G4/src/Geo2G4LogicalVolumeFactory.cxx b/Simulation/G4Utilities/Geo2G4/src/Geo2G4LogicalVolumeFactory.cxx index 10036af66702c9dba1195b6d860f5752aedb5305..6cb1caf96461bcbc96bca15ba8065468fc9356d6 100644 --- a/Simulation/G4Utilities/Geo2G4/src/Geo2G4LogicalVolumeFactory.cxx +++ b/Simulation/G4Utilities/Geo2G4/src/Geo2G4LogicalVolumeFactory.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ #include "Geo2G4LogicalVolumeFactory.h" @@ -17,7 +17,7 @@ Geo2G4LogicalVolumeFactory::Geo2G4LogicalVolumeFactory() { } -G4LogicalVolume *Geo2G4LogicalVolumeFactory::Build(const GeoLogVol* theLog) const +G4LogicalVolume *Geo2G4LogicalVolumeFactory::Build (const GeoLogVol* theLog) const { static Geo2G4SolidFactory theSolidFactory; static Geo2G4MaterialFactory theMaterialFactory; diff --git a/Simulation/G4Utilities/Geo2G4/src/Geo2G4SolidFactory.cxx b/Simulation/G4Utilities/Geo2G4/src/Geo2G4SolidFactory.cxx index 813004ca0ff5dce8bdd61374b27574862f1cadcd..230f7ee9f74e58e1c50bb2485e201acffaf33328 100644 --- a/Simulation/G4Utilities/Geo2G4/src/Geo2G4SolidFactory.cxx +++ b/Simulation/G4Utilities/Geo2G4/src/Geo2G4SolidFactory.cxx @@ -149,7 +149,7 @@ Geo2G4SolidFactory::Geo2G4SolidFactory() : { } -G4VSolid *Geo2G4SolidFactory::Build(const GeoShape* geoShape, std::string name) const +G4VSolid *Geo2G4SolidFactory::Build (const GeoShape* geoShape, std::string name) { G4VSolid* theSolid(nullptr); @@ -614,7 +614,7 @@ G4VSolid* Geo2G4SolidFactory::createLArWheelSolid(const std::string& name, const LArWheelSolidDDProxy * theLWS_p = new LArWheelSolidDDProxy(theLWS); // ownership is passed to detStore - if ( detStore()->record(theLWS_p, name).isFailure() ) { + if ( m_detStore->record(theLWS_p, name).isFailure() ) { ATH_MSG_WARNING("Can't store proxy for LArWheelSolid to the DetectorStore"); delete theLWS_p; } @@ -627,7 +627,7 @@ G4VSolid* Geo2G4SolidFactory::createLArWheelSliceSolid(const GeoUnidentifiedShap LArWheelSolidDDProxy *theLWS_p = new LArWheelSolidDDProxy(theLWS); // ownership is passed to detStore - if(detStore()->record(theLWS_p, theLWS->GetName()).isFailure()){ + if(m_detStore->record(theLWS_p, theLWS->GetName()).isFailure()){ ATH_MSG_WARNING("Can't store proxy for LArWheelSolid to the DetectorStore"); delete theLWS_p; } diff --git a/Simulation/G4Utilities/Geo2G4/src/Geo2G4SolidFactory.h b/Simulation/G4Utilities/Geo2G4/src/Geo2G4SolidFactory.h index b0b8330221164bb175de2a1cda76841667f49d1f..d3088c5125569bb9ebc9d51bca309a7a52b07127 100644 --- a/Simulation/G4Utilities/Geo2G4/src/Geo2G4SolidFactory.h +++ b/Simulation/G4Utilities/Geo2G4/src/Geo2G4SolidFactory.h @@ -26,23 +26,15 @@ public: typedef std::map LArWheelSolid_typemap; Geo2G4SolidFactory(); - G4VSolid* Build(const GeoShape*, std::string name=std::string("")) const; + G4VSolid* Build (const GeoShape*, std::string name=std::string("")); - /** @brief The standard @c StoreGateSvc/DetectorStore - * Returns (kind of) a pointer to the @c StoreGateSvc - */ - StoreGateSvc_t& detStore() const; private: G4VSolid* createLArWheelSolid(const std::string& name, const LArWheelSolidDef_t & lwsdef, const EMECData &emecData) const; G4VSolid* createLArWheelSliceSolid(const GeoUnidentifiedShape* ,const EMECData &emecData) const; static const LArWheelSolid_typemap s_lwsTypes; /// Pointer to StoreGate (detector store by default) - mutable StoreGateSvc_t m_detStore; + StoreGateSvc_t m_detStore; }; -inline ServiceHandle& Geo2G4SolidFactory::detStore() const { - return m_detStore; -} - #endif diff --git a/Simulation/G4Utilities/Geo2G4/src/Geo2G4Svc.cxx b/Simulation/G4Utilities/Geo2G4/src/Geo2G4Svc.cxx index 1bdf7e2d5978a2be91306982399e6d9c76075d99..54f08951c327bb8387ca88fafd59ca39b8681133 100644 --- a/Simulation/G4Utilities/Geo2G4/src/Geo2G4Svc.cxx +++ b/Simulation/G4Utilities/Geo2G4/src/Geo2G4Svc.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ #include "Geo2G4Svc.h" @@ -23,26 +23,18 @@ Geo2G4Svc::~Geo2G4Svc() StatusCode Geo2G4Svc::initialize() { - static int initialized=0; - if (initialized) - { - ATH_MSG_VERBOSE (" Geo2G4Svc already initialized."); - return StatusCode::SUCCESS; - } - ATH_MSG_VERBOSE ("Initializing the Geo2G4Svc."); - ATH_MSG_VERBOSE ("Creating all builders available."); + ATH_MSG_VERBOSE ("Initializing the Geo2G4Svc"); m_G4AssemblyFactory = std::make_unique(); m_builders = InitializeBuilders(m_G4AssemblyFactory.get()); const std::string nameBuilder = "Extended_Parameterised_Volume_Builder"; //TODO Configurable property?? this->SetDefaultBuilder(nameBuilder); - ATH_MSG_VERBOSE (nameBuilder << " --> set as default builder" ); - ATH_MSG_VERBOSE (nameBuilder << " --> ParamOn flag = " << GetDefaultBuilder()->GetParam()); - initialized=1; - if(msgLvl(MSG::VERBOSE)) - { - this->ListVolumeBuilders(); - } + if(msgLvl(MSG::VERBOSE)) { + ATH_MSG_VERBOSE (nameBuilder << " --> set as default builder" ); + ATH_MSG_VERBOSE (nameBuilder << " --> ParamOn flag = " << GetDefaultBuilder()->GetParam()); + this->ListVolumeBuilders(); + } + return StatusCode::SUCCESS; } diff --git a/Simulation/G4Utilities/Geo2G4/src/VolumeBuilder.h b/Simulation/G4Utilities/Geo2G4/src/VolumeBuilder.h index a187b6c9b7055950b0adb520906ea55ab3e8a9ea..4aeef6bd6c32b3ff027b28fda7136b39363f3f9e 100644 --- a/Simulation/G4Utilities/Geo2G4/src/VolumeBuilder.h +++ b/Simulation/G4Utilities/Geo2G4/src/VolumeBuilder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ #ifndef GEO2G4_VolumeBuilder_H @@ -33,7 +33,7 @@ class VolumeBuilder void SetParam(bool flag){m_paramOn = flag;} bool GetParam() const {return m_paramOn;} - virtual G4LogicalVolume* Build(PVConstLink pv, OpticalVolumesMap* optical_volumes = 0) const = 0; + virtual G4LogicalVolume* Build(PVConstLink pv, OpticalVolumesMap* optical_volumes = 0) = 0; protected: bool m_paramOn;