diff --git a/Simulation/CMakeLists.txt b/Simulation/CMakeLists.txt index ebee926ff0f5dddc115635ae72df4d0ade74a253..bf9567ce9ebfbe014c1ddb6a17d1fb2e969d29e6 100644 --- a/Simulation/CMakeLists.txt +++ b/Simulation/CMakeLists.txt @@ -4,6 +4,17 @@ gaudi_subdir(Simulation v0r0) find_package(Geant4) include(${Geant4_USE_FILE}) +# DetSimInterface (headers only) +set(DetSimInterface_srcs + src/DetSimInterface/*.cpp +) + + +gaudi_add_library(DetSimInterfaces ${DetSimInterface_srcs} + INCLUDE_DIRS include + PUBLIC_HEADERS include/DetSimInterface +) + # DetSimCore module set(DetSimCore_srcs @@ -11,6 +22,6 @@ set(DetSimCore_srcs ) gaudi_add_module(DetSimCore ${DetSimCore_srcs} - INCLUDE_DIRS GaudiKernel Geant4 - LINK_LIBRARIES GaudiKernel Geant4 + INCLUDE_DIRS DetSimInterfaces GaudiKernel Geant4 + LINK_LIBRARIES DetSimInterfaces GaudiKernel Geant4 ) diff --git a/Simulation/include/DetSimInterface/IDetSimSvc.h b/Simulation/include/DetSimInterface/IDetSimSvc.h new file mode 100644 index 0000000000000000000000000000000000000000..3e7d078fc73b1a697acf5b6f636299a73ea3cd4a --- /dev/null +++ b/Simulation/include/DetSimInterface/IDetSimSvc.h @@ -0,0 +1,36 @@ +#ifndef IDetSimSvc_h +#define IDetSimSvc_h + +#include "GaudiKernel/IService.h" + +// IDetSimSvc is the interface between Gaudi and Geant4. +// All the initialization of Run Manager (RM) should be done here, including: +// * Detector Construction +// * Physics List +// * Primary Generator Action +// * User Actions +// Then, the real simulation should be also done by this service via Run Manager. +// +// Note, to decouple the Gaudi and Geant4, we keep all these classes still derived from +// the original Geant4's base classes, while using Gaudi tools to manage these objects. + +class G4RunManager; + +class IDetSimSvc: virtual public IInterface { +public: + DeclareInterfaceID(IDetSimSvc, 0, 1); // major/minor version + + virtual ~IDetSimSvc() = 0; + + // Get the Run Manager + virtual G4RunManager* getRM() = 0; + + // Control the run manager directly. + virtual StatusCode initializeRM() = 0; + virtual StatusCode simulateEvent(int i_event) = 0; + virtual StatusCode finalizeRM() = 0; + +}; + + +#endif diff --git a/Simulation/src/DetSimCore/DetSimAlg.h b/Simulation/src/DetSimCore/DetSimAlg.h index 4e3152c9749f7bcedffabc39c294880c0b9f3e6d..683456f4ffc2867f189e97cc910a18fff50ed863 100644 --- a/Simulation/src/DetSimCore/DetSimAlg.h +++ b/Simulation/src/DetSimCore/DetSimAlg.h @@ -7,7 +7,7 @@ #include <GaudiKernel/Algorithm.h> #include <GaudiKernel/Property.h> - +#include <DetSimInterface/IDetSimSvc.h> class DetSimAlg: public Algorithm { public: @@ -17,6 +17,9 @@ public: StatusCode execute() override; StatusCode finalize() override; +private: + SmartIF<IDetSimSvc> m_detsimsvc; + private: Gaudi::Property<std::vector<std::string>> m_run_macs{this, "RunMacs"}; diff --git a/Simulation/src/DetSimInterface/IDetSimSvc.cpp b/Simulation/src/DetSimInterface/IDetSimSvc.cpp new file mode 100644 index 0000000000000000000000000000000000000000..54cfdd6e061bfb8de05af5a63d37b3757afd6c3f --- /dev/null +++ b/Simulation/src/DetSimInterface/IDetSimSvc.cpp @@ -0,0 +1,5 @@ +#include "DetSimInterface/IDetSimSvc.h" + +IDetSimSvc::~IDetSimSvc() { + +}