Skip to content
Snippets Groups Projects
Commit 5f9495e0 authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'master-volumeDumper' into 'master'

User action that dumps all volumes and classifies them.

See merge request atlas/athena!21986
parents 1d69779f 8e1dd5a1
No related branches found
No related tags found
No related merge requests found
Showing
with 184 additions and 3 deletions
...@@ -26,6 +26,11 @@ find_package( TBB ) ...@@ -26,6 +26,11 @@ find_package( TBB )
find_package( XercesC ) find_package( XercesC )
# Component(s) in the package: # 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 atlas_add_component( G4DebuggingTools
src/*.cxx src/*.cxx
src/components/*.cxx src/components/*.cxx
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/ */
#include "StepHistogram.h" #include "G4DebuggingTools/G4DebuggingHelper.h"
#include "G4Electron.hh" #include "G4Electron.hh"
#include "G4Positron.hh" #include "G4Positron.hh"
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
//Athena //Athena
#include "AthenaBaseComps/AthMessaging.h" #include "AthenaBaseComps/AthMessaging.h"
#include "G4DebuggingHelper.h" #include "G4DebuggingTools/G4DebuggingHelper.h"
namespace G4UA{ namespace G4UA{
......
...@@ -23,6 +23,7 @@ atlas_depends_on_subdirs( PUBLIC ...@@ -23,6 +23,7 @@ atlas_depends_on_subdirs( PUBLIC
Simulation/G4Sim/SimHelpers Simulation/G4Sim/SimHelpers
Simulation/G4Utilities/TrackWriteFastSim Simulation/G4Utilities/TrackWriteFastSim
Control/AthToolSupport/AsgTools Control/AthToolSupport/AsgTools
Simulation/G4Utilities/G4DebuggingTools
Tools/PathResolver ) Tools/PathResolver )
# External dependencies: # External dependencies:
...@@ -37,7 +38,8 @@ atlas_add_component( G4UserActions ...@@ -37,7 +38,8 @@ atlas_add_component( G4UserActions
src/*.cxx src/*.cxx
src/components/*.cxx src/components/*.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${TBB_INCLUDE_DIRS} 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: # Install files from the package:
atlas_install_headers( G4UserActions ) atlas_install_headers( G4UserActions )
......
/*
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
/*
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
...@@ -115,3 +115,6 @@ def getLooperThresholdSetTool(name="G4UA::LooperThresholdSetTool", **kwargs): ...@@ -115,3 +115,6 @@ def getLooperThresholdSetTool(name="G4UA::LooperThresholdSetTool", **kwargs):
for prop,value in simFlags.UserActionConfig.get_Value()[name].iteritems(): for prop,value in simFlags.UserActionConfig.get_Value()[name].iteritems():
kwargs.setdefault(prop,value) kwargs.setdefault(prop,value)
return CfgMgr.G4UA__LooperThresholdSetTool(name, **kwargs) return CfgMgr.G4UA__LooperThresholdSetTool(name, **kwargs)
def getVolumeDumperTool(name="G4UA::VolumeDumperTool", **kwargs):
return CfgMgr.G4UA__VolumeDumperTool(name, **kwargs)
...@@ -26,3 +26,4 @@ addTool("G4UserActions.G4UserActionsConfig.getRadiationMapsMakerTool", "G4UA::Ra ...@@ -26,3 +26,4 @@ addTool("G4UserActions.G4UserActionsConfig.getRadiationMapsMakerTool", "G4UA::Ra
addTool("G4UserActions.G4UserActionsConfig.getStoppedParticleActionTool", "G4UA::StoppedParticleActionTool") addTool("G4UserActions.G4UserActionsConfig.getStoppedParticleActionTool", "G4UA::StoppedParticleActionTool")
addTool("G4UserActions.G4UserActionsConfig.getRadLengthActionTool", "G4UA::RadLengthActionTool") addTool("G4UserActions.G4UserActionsConfig.getRadLengthActionTool", "G4UA::RadLengthActionTool")
addTool("G4UserActions.G4UserActionsConfig.getLooperThresholdSetTool", "G4UA::LooperThresholdSetTool") addTool("G4UserActions.G4UserActionsConfig.getLooperThresholdSetTool", "G4UA::LooperThresholdSetTool")
addTool("G4UserActions.G4UserActionsConfig.getVolumeDumperTool", "G4UA::VolumeDumperTool")
#########################################################
#
# 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')
/*
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
/*
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;
}
}
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "G4UserActions/RadiationMapsMakerTool.h" #include "G4UserActions/RadiationMapsMakerTool.h"
#include "G4UserActions/RadLengthActionTool.h" #include "G4UserActions/RadLengthActionTool.h"
#include "G4UserActions/LooperThresholdSetTool.h" #include "G4UserActions/LooperThresholdSetTool.h"
#include "G4UserActions/VolumeDumperTool.h"
#include "../TestActionTool.h" #include "../TestActionTool.h"
DECLARE_COMPONENT( G4UA::G4SimTimerTool ) DECLARE_COMPONENT( G4UA::G4SimTimerTool )
...@@ -42,3 +43,4 @@ DECLARE_COMPONENT( G4UA::RadiationMapsMakerTool ) ...@@ -42,3 +43,4 @@ DECLARE_COMPONENT( G4UA::RadiationMapsMakerTool )
DECLARE_COMPONENT( G4UA::RadLengthActionTool ) DECLARE_COMPONENT( G4UA::RadLengthActionTool )
DECLARE_COMPONENT( G4UA::LooperThresholdSetTool ) DECLARE_COMPONENT( G4UA::LooperThresholdSetTool )
DECLARE_COMPONENT( G4UA::TestActionTool ) DECLARE_COMPONENT( G4UA::TestActionTool )
DECLARE_COMPONENT( G4UA::VolumeDumperTool )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment