diff --git a/Simulation/DetSimCore/src/DetSimAlg.cpp b/Simulation/DetSimCore/src/DetSimAlg.cpp index 31583d82135590f33f4ed712740df02505d8199e..ae8d550681e3a36d15f846bc7053235543a86e22 100644 --- a/Simulation/DetSimCore/src/DetSimAlg.cpp +++ b/Simulation/DetSimCore/src/DetSimAlg.cpp @@ -2,12 +2,14 @@ #include "GaudiKernel/IEventProcessor.h" #include "GaudiKernel/IAppMgrUI.h" #include "GaudiKernel/GaudiException.h" +#include "GaudiKernel/IRndmEngine.h" #include "G4RunManager.hh" #include "G4UImanager.hh" #include "G4VisExecutive.hh" #include "G4UIExecutive.hh" +#include "Randomize.hh" #include "DetectorConstruction.h" #include "G4PhysListFactory.hh" #include "G4EmParameters.hh" @@ -30,6 +32,15 @@ DetSimAlg::initialize() { info() << "Initialize DetSimAlg... " << endmsg; + // Initialize random seed + if (not m_randomSeeds.empty()) { + randSvc()->engine()->setSeeds( m_randomSeeds ); + } + + info() << "Random Seed is initialized to " + << G4Random::getTheSeed() + << " in Geant4" << std::endl; + m_detsimsvc = service("DetSimSvc"); if (!m_detsimsvc) { error() << "Failed to find DetSimSvc. " << endmsg; diff --git a/Simulation/DetSimCore/src/DetSimAlg.h b/Simulation/DetSimCore/src/DetSimAlg.h index 36646d9e8b449058aa7588cc8bbe89d3acff5342..bb4571c74ad2dceddab2fea70a551bea292ddea7 100644 --- a/Simulation/DetSimCore/src/DetSimAlg.h +++ b/Simulation/DetSimCore/src/DetSimAlg.h @@ -31,6 +31,8 @@ private: private: + Gaudi::Property<std::vector<long>> m_randomSeeds{this, "RandomSeeds", {}}; + Gaudi::Property<std::vector<std::string>> m_run_macs{this, "RunMacs"}; Gaudi::Property<std::vector<std::string>> m_run_cmds{this, "RunCmds"}; Gaudi::Property<std::vector<std::string>> m_vis_macs{this, "VisMacs"};