From 99da8ebe67f9d26597d68c54ffad8720d3337274 Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Mon, 13 May 2024 18:20:21 +0200 Subject: [PATCH] Create G4ScoringManager in Geant4Kernel steered by option --- DDG4/include/DDG4/Geant4Kernel.h | 6 +++--- DDG4/src/Geant4Kernel.cpp | 22 ++++++++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/DDG4/include/DDG4/Geant4Kernel.h b/DDG4/include/DDG4/Geant4Kernel.h index 7032959b3..f1022babf 100644 --- a/DDG4/include/DDG4/Geant4Kernel.h +++ b/DDG4/include/DDG4/Geant4Kernel.h @@ -98,11 +98,11 @@ namespace dd4hep { /// Property: Output level int m_outputLevel; - /// Property: Running in multi threaded context - //bool m_multiThreaded; /// Master property: Number of execution threads in multi threaded mode. int m_numThreads; - + /// Master property: Instantiate the Geant4 scoring manager object + int m_haveScoringMgr; + /// Registered action callbacks on configure UserCallbacks m_actionConfigure; /// Registered action callbacks on initialize diff --git a/DDG4/src/Geant4Kernel.cpp b/DDG4/src/Geant4Kernel.cpp index c2f2e2d09..8f83fa00b 100644 --- a/DDG4/src/Geant4Kernel.cpp +++ b/DDG4/src/Geant4Kernel.cpp @@ -25,6 +25,7 @@ // Geant4 include files #include +#include #include #include #include @@ -88,16 +89,16 @@ Geant4Kernel::Geant4Kernel(Detector& description_ref) m_numThreads(0), m_id(Geant4Kernel::thread_self()), m_master(this), m_shared(0), m_threadContext(0), phase(this) { - //m_detDesc->addExtension < Geant4Kernel > (this); m_ident = -1; - declareProperty("UI",m_uiName); - declareProperty("OutputLevel", m_outputLevel = DEBUG); - declareProperty("NumEvents", m_numEvent = 10); - declareProperty("OutputLevels", m_clientLevels); - declareProperty("NumberOfThreads", m_numThreads); + declareProperty("UI", m_uiName); + declareProperty("OutputLevel", m_outputLevel = DEBUG); + declareProperty("NumEvents", m_numEvent = 10); + declareProperty("OutputLevels", m_clientLevels); + declareProperty("NumberOfThreads", m_numThreads); + declareProperty("HaveScoringManager", m_haveScoringMgr = false); + declareProperty("SensitiveTypes", m_sensitiveDetectorTypes); + declareProperty("RunManagerType", m_runManagerType = "G4RunManager"); declareProperty("DefaultSensitiveType", m_dfltSensitiveDetectorType = "Geant4SensDet"); - declareProperty("SensitiveTypes", m_sensitiveDetectorTypes); - declareProperty("RunManagerType", m_runManagerType = "G4RunManager"); m_controlName = "/ddg4/"; m_control = new G4UIdirectory(m_controlName.c_str()); m_control->SetGuidance("Control for named Geant4 actions"); @@ -282,6 +283,11 @@ G4RunManager& Geant4Kernel::runManager() { } mgr->property("NumberOfThreads").set(m_numThreads); mgr->enableUI(); + if ( this->m_haveScoringMgr ) { + if ( nullptr == G4ScoringManager::GetScoringManager() ) { + except("Geant4Kernel", "+++ FAILED to create the G4ScoringManager instance."); + } + } m_runManager = dynamic_cast(mgr); if ( m_runManager ) { return *m_runManager;