diff --git a/Simulation/G4Utilities/G4DebuggingTools/CMakeLists.txt b/Simulation/G4Utilities/G4DebuggingTools/CMakeLists.txt index 6fa548c160e522406f592f1d42b8f7cc34425a49..5dac3f8c875a7e16f44a9bf276a493ac285a834e 100644 --- a/Simulation/G4Utilities/G4DebuggingTools/CMakeLists.txt +++ b/Simulation/G4Utilities/G4DebuggingTools/CMakeLists.txt @@ -26,6 +26,11 @@ find_package( TBB ) find_package( XercesC ) # Component(s) in the package: +atlas_add_library( G4DebuggingHelperLib + src/G4DebuggingHelper.cxx + INCLUDE_DIRS ${GEANT4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} + LINK_LIBRARIES ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} ) + atlas_add_component( G4DebuggingTools src/*.cxx src/components/*.cxx diff --git a/Simulation/G4Utilities/G4DebuggingTools/src/G4DebuggingHelper.h b/Simulation/G4Utilities/G4DebuggingTools/G4DebuggingTools/G4DebuggingHelper.h similarity index 100% rename from Simulation/G4Utilities/G4DebuggingTools/src/G4DebuggingHelper.h rename to Simulation/G4Utilities/G4DebuggingTools/G4DebuggingTools/G4DebuggingHelper.h diff --git a/Simulation/G4Utilities/G4DebuggingTools/src/G4DebuggingHelper.cxx b/Simulation/G4Utilities/G4DebuggingTools/src/G4DebuggingHelper.cxx index 61c469262922c7c5e7fd5ca2d87f09e1a6c0b418..05bfd8b87c8e6264bd7d8cd039a24b0bf7883b7a 100644 --- a/Simulation/G4Utilities/G4DebuggingTools/src/G4DebuggingHelper.cxx +++ b/Simulation/G4Utilities/G4DebuggingTools/src/G4DebuggingHelper.cxx @@ -2,7 +2,7 @@ Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ -#include "StepHistogram.h" +#include "G4DebuggingTools/G4DebuggingHelper.h" #include "G4Electron.hh" #include "G4Positron.hh" diff --git a/Simulation/G4Utilities/G4DebuggingTools/src/StepHistogram.h b/Simulation/G4Utilities/G4DebuggingTools/src/StepHistogram.h index 9c0206d131d8634dc2693bde900b3130b8c609ea..711802c8cc41922204cf25fb6b9065c3d94cbd07 100644 --- a/Simulation/G4Utilities/G4DebuggingTools/src/StepHistogram.h +++ b/Simulation/G4Utilities/G4DebuggingTools/src/StepHistogram.h @@ -21,7 +21,7 @@ //Athena #include "AthenaBaseComps/AthMessaging.h" -#include "G4DebuggingHelper.h" +#include "G4DebuggingTools/G4DebuggingHelper.h" namespace G4UA{ diff --git a/Simulation/G4Utilities/G4UserActions/CMakeLists.txt b/Simulation/G4Utilities/G4UserActions/CMakeLists.txt index eed69df36bbb64321f4a6ec97f71abf6dd4accda..4847d6ba178ca093d15ee62d52d7a8c6455233d6 100644 --- a/Simulation/G4Utilities/G4UserActions/CMakeLists.txt +++ b/Simulation/G4Utilities/G4UserActions/CMakeLists.txt @@ -23,6 +23,7 @@ atlas_depends_on_subdirs( PUBLIC Simulation/G4Sim/SimHelpers Simulation/G4Utilities/TrackWriteFastSim Control/AthToolSupport/AsgTools + Simulation/G4Utilities/G4DebuggingTools Tools/PathResolver ) # External dependencies: @@ -37,7 +38,8 @@ atlas_add_component( G4UserActions src/*.cxx src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${TBB_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} ${TBB_LIBRARIES} AthenaBaseComps AthenaKernel StoreGateLib SGtests GaudiKernel G4AtlasInterfaces G4AtlasToolsLib CxxUtils EventInfo InDetSimEvent MuonSimEvent MCTruth SimHelpers TrackWriteFastSimLib PathResolver) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} ${TBB_LIBRARIES} AthenaBaseComps AthenaKernel StoreGateLib SGtests GaudiKernel G4AtlasInterfaces G4AtlasToolsLib CxxUtils EventInfo InDetSimEvent MuonSimEvent MCTruth SimHelpers TrackWriteFastSimLib PathResolver G4DebuggingHelperLib) + # Install files from the package: atlas_install_headers( G4UserActions ) diff --git a/Simulation/G4Utilities/G4UserActions/G4UserActions/VolumeDumper.h b/Simulation/G4Utilities/G4UserActions/G4UserActions/VolumeDumper.h new file mode 100644 index 0000000000000000000000000000000000000000..417a491b2e21da19e3cbd8acac60d45c9e1e3286 --- /dev/null +++ b/Simulation/G4Utilities/G4UserActions/G4UserActions/VolumeDumper.h @@ -0,0 +1,30 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + +#ifndef G4USERACTIONS_VOLUMEDUMPER_H +#define G4USERACTIONS_VOLUMEDUMPER_H + +#include "G4UserEventAction.hh" +#include "G4Event.hh" + +#include "AthenaBaseComps/AthMessaging.h" + + +namespace G4UA +{ + +class VolumeDumper final : public G4UserEventAction, + public AthMessaging +{ + +public: + +VolumeDumper(); +virtual void BeginOfEventAction( const G4Event* ) override; + +}; // class VolumeDumper + +} // namespace G4UA + +#endif diff --git a/Simulation/G4Utilities/G4UserActions/G4UserActions/VolumeDumperTool.h b/Simulation/G4Utilities/G4UserActions/G4UserActions/VolumeDumperTool.h new file mode 100644 index 0000000000000000000000000000000000000000..67fa21bd441115592cc5cbcf823be740c12d0274 --- /dev/null +++ b/Simulation/G4Utilities/G4UserActions/G4UserActions/VolumeDumperTool.h @@ -0,0 +1,46 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + +#ifndef G4USERACTIONS_G4UA_VOLUMEDUMPERTOOL_H +#define G4USERACTIONS_G4UA_VOLUMEDUMPERTOOL_H + +// System includes +#include <string> + +// Infrastructure includes +#include "G4AtlasTools/UserActionToolBase.h" + +// Local includes +#include "G4UserActions/VolumeDumper.h" + +namespace G4UA +{ + +/// @class VolumeDumperTool +/// @brief Tool which manages the volume dumper action. +/// +/// +/// @author Miha Muskinja +/// +class VolumeDumperTool : public UserActionToolBase<VolumeDumper> +{ + +public: + +/// Standard constructor +VolumeDumperTool(const std::string& type, + const std::string& name, + const IInterface* parent); + +protected: + +/// creates the action instances +virtual std::unique_ptr<VolumeDumper> +makeAndFillAction(G4AtlasUserActions&) override final; + +}; // class VolumeDumperTool + +} // namespace G4UA + +#endif diff --git a/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfig.py b/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfig.py index 641db08c0fa50451ba9070cca794ce289b230926..8c88b8ac0edebcac362e9358d85fbe1727773f13 100644 --- a/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfig.py +++ b/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfig.py @@ -115,3 +115,6 @@ def getLooperThresholdSetTool(name="G4UA::LooperThresholdSetTool", **kwargs): for prop,value in simFlags.UserActionConfig.get_Value()[name].iteritems(): kwargs.setdefault(prop,value) return CfgMgr.G4UA__LooperThresholdSetTool(name, **kwargs) + +def getVolumeDumperTool(name="G4UA::VolumeDumperTool", **kwargs): + return CfgMgr.G4UA__VolumeDumperTool(name, **kwargs) diff --git a/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfigDb.py b/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfigDb.py index cc35a37919f70cde08f708e8526ec41326f66277..29f5b98b9bcf6dd4451d84cabb38998f7cb999cf 100644 --- a/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfigDb.py +++ b/Simulation/G4Utilities/G4UserActions/python/G4UserActionsConfigDb.py @@ -26,3 +26,4 @@ addTool("G4UserActions.G4UserActionsConfig.getRadiationMapsMakerTool", "G4UA::Ra addTool("G4UserActions.G4UserActionsConfig.getStoppedParticleActionTool", "G4UA::StoppedParticleActionTool") addTool("G4UserActions.G4UserActionsConfig.getRadLengthActionTool", "G4UA::RadLengthActionTool") addTool("G4UserActions.G4UserActionsConfig.getLooperThresholdSetTool", "G4UA::LooperThresholdSetTool") +addTool("G4UserActions.G4UserActionsConfig.getVolumeDumperTool", "G4UA::VolumeDumperTool") diff --git a/Simulation/G4Utilities/G4UserActions/share/preInclude.VolumeDumper.py b/Simulation/G4Utilities/G4UserActions/share/preInclude.VolumeDumper.py new file mode 100644 index 0000000000000000000000000000000000000000..0e9acee013bbb719e1ba556941ca56ee6bf9223b --- /dev/null +++ b/Simulation/G4Utilities/G4UserActions/share/preInclude.VolumeDumper.py @@ -0,0 +1,11 @@ +######################################################### +# +# G4UserActions/preInclude.VolumeDumper.py +# @author Miha Muskinja +# +# Dumps all volume names and classifies them with G4DebuggingHelper +# +######################################################### + +from G4AtlasApps.SimFlags import simFlags +simFlags.OptionalUserActionList.addAction('G4UA::VolumeDumperTool') diff --git a/Simulation/G4Utilities/G4UserActions/src/VolumeDumper.cxx b/Simulation/G4Utilities/G4UserActions/src/VolumeDumper.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ac9416230497664375a8eb550cb319515856eb1f --- /dev/null +++ b/Simulation/G4Utilities/G4UserActions/src/VolumeDumper.cxx @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + +#include "G4UserActions/VolumeDumper.h" +#include "G4DebuggingTools/G4DebuggingHelper.h" + +// Geant4 +#include "G4PhysicalVolumeStore.hh" + +// Gaudi +#include "GaudiKernel/Bootstrap.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/IMessageSvc.h" + +namespace G4UA +{ + +//--------------------------------------------------------------------------- +VolumeDumper::VolumeDumper() : + AthMessaging(Gaudi::svcLocator()->service<IMessageSvc>("MessageSvc"), + "VolumeDumper") +{ +} + +//--------------------------------------------------------------------------- +void VolumeDumper::BeginOfEventAction(const G4Event*) +{ + ATH_MSG_INFO("Dumping G4PhysicalVolumeStore"); + ATH_MSG_INFO("-----------------------------"); + + G4PhysicalVolumeStore* store = G4PhysicalVolumeStore::GetInstance(); + std::set<G4String> volumes; + + ATH_MSG_INFO("Size: " << store->size()); + + for (unsigned int i = 0; i < store->size(); i++) { + volumes.insert((*store)[i]->GetName()); + } + + for (auto& vol : volumes) { + std::cout << "short: " << G4DebuggingHelpers::ClassifyVolume(vol) + << " full: " << vol << std::endl; + } + + ATH_MSG_INFO("Finished dumbing G4PhysicalVolumeStore"); + ATH_MSG_INFO("-----------------------------"); +} + +} // namespace G4UA diff --git a/Simulation/G4Utilities/G4UserActions/src/VolumeDumperTool.cxx b/Simulation/G4Utilities/G4UserActions/src/VolumeDumperTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a7f3a4fc0baec878bafbdf17d689d7e8e74da31b --- /dev/null +++ b/Simulation/G4Utilities/G4UserActions/src/VolumeDumperTool.cxx @@ -0,0 +1,31 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + */ + +#include "G4UserActions/VolumeDumperTool.h" + +namespace G4UA +{ + +//--------------------------------------------------------------------------- +// Constructor +//--------------------------------------------------------------------------- +VolumeDumperTool::VolumeDumperTool(const std::string& type, const std::string& name, + const IInterface* parent) : + UserActionToolBase<VolumeDumper>(type, name, parent) +{ +} + +//--------------------------------------------------------------------------- +// Create the action on request +//--------------------------------------------------------------------------- +std::unique_ptr<VolumeDumper> +VolumeDumperTool::makeAndFillAction(G4AtlasUserActions& actionList) +{ + ATH_MSG_DEBUG("Constructing a VolumeDumper action"); + auto action = std::make_unique<VolumeDumper>(); + actionList.eventActions.push_back( action.get() ); + return action; +} + +} diff --git a/Simulation/G4Utilities/G4UserActions/src/components/G4UserActions_entries.cxx b/Simulation/G4Utilities/G4UserActions/src/components/G4UserActions_entries.cxx index b8533db41f8bb7726ea106ce01ce13b7b6a1846f..572c3c1fef59b9818b7cda7ca5155096036c79c0 100644 --- a/Simulation/G4Utilities/G4UserActions/src/components/G4UserActions_entries.cxx +++ b/Simulation/G4Utilities/G4UserActions/src/components/G4UserActions_entries.cxx @@ -21,6 +21,7 @@ #include "G4UserActions/RadiationMapsMakerTool.h" #include "G4UserActions/RadLengthActionTool.h" #include "G4UserActions/LooperThresholdSetTool.h" +#include "G4UserActions/VolumeDumperTool.h" #include "../TestActionTool.h" DECLARE_COMPONENT( G4UA::G4SimTimerTool ) @@ -42,3 +43,4 @@ DECLARE_COMPONENT( G4UA::RadiationMapsMakerTool ) DECLARE_COMPONENT( G4UA::RadLengthActionTool ) DECLARE_COMPONENT( G4UA::LooperThresholdSetTool ) DECLARE_COMPONENT( G4UA::TestActionTool ) +DECLARE_COMPONENT( G4UA::VolumeDumperTool )