diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/python/ISF_Geant4ToolsConfig.py b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/python/ISF_Geant4ToolsConfig.py index a519ea1dc9c522bb12029eaef72ae35211883e22..8d8f23114201a5359d5880801246088ce283d5b0 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/python/ISF_Geant4ToolsConfig.py +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/python/ISF_Geant4ToolsConfig.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration ## ----------------------------------------------------------------------------- ### Base Version @@ -71,8 +71,7 @@ def getAFII_G4TrackProcessorUserActionTool(name='AFII_G4TrackProcessorUserAction ### Base Version def getGeant4Tool(name="ISF_Geant4Tool", **kwargs): from G4AtlasApps.SimFlags import simFlags - kwargs.setdefault('RandomGenerator', 'athena') - kwargs.setdefault('RandomNumberService', simFlags.RandomSvc()) + kwargs.setdefault('RandomNumberService', simFlags.RandomSvcMT()) kwargs.setdefault('InputConverter', 'ISF_InputConverter') kwargs.setdefault('UserActionSvc','G4UA::ISFUserActionSvc') if hasattr(simFlags, 'RecordFlux') and simFlags.RecordFlux.statusOn: diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.cxx index 2be786cf81cd4211dd86b060aabad3a9c30f1216..dc5868acb5cc24b0f828a0f78e6a8649b088ed49 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // class header @@ -9,6 +9,8 @@ #include "G4AtlasAlg/G4AtlasRunManager.h" #include "ISFFluxRecorder.h" +#include "AthenaKernel/RNGWrapper.h" + // ISF classes #include "ISF_Event/ISFParticle.h" #include "ISF_Event/ISFParticleVector.h" @@ -53,7 +55,6 @@ iGeant4::G4TransportTool::G4TransportTool(const std::string& type, declareProperty("Dll", m_libList); declareProperty("Physics", m_physList); declareProperty("FieldMap", m_fieldMap); - declareProperty("RandomGenerator", m_rndmGen); declareProperty("ReleaseGeoModel", m_releaseGeoModel); declareProperty("RecordFlux", m_recordFlux); declareProperty("McEventCollection", m_mcEventCollectionName); @@ -93,6 +94,8 @@ StatusCode iGeant4::G4TransportTool::initialize() ATH_MSG_ERROR("Failure in iGeant4::G4TransportTool::initializeOnce: " << e.what()); return StatusCode::FAILURE; } + + ATH_CHECK( m_rndmGenSvc.retrieve() ); ATH_CHECK( m_userActionSvc.retrieve() ); ATH_CHECK(m_g4atlasSvc.retrieve()); @@ -157,19 +160,6 @@ void iGeant4::G4TransportTool::initializeOnce() ui->ApplyCommand("/MagneticField/Initialize"); } - if (m_rndmGen=="athena" || m_rndmGen=="ranecu") { - // Set the random number generator to AtRndmGen - if (m_rndmGenSvc.retrieve().isFailure()) { - throw std::runtime_error("Could not initialize ATLAS Random Generator Service"); - } - CLHEP::HepRandomEngine* engine = m_rndmGenSvc->GetEngine("AtlasG4"); - CLHEP::HepRandom::setTheEngine(engine); - ATH_MSG_DEBUG("Random nr. generator is set to Athena"); - } - else if (m_rndmGen=="geant4" || m_rndmGen.empty()) { - ATH_MSG_INFO("Random nr. generator is set to Geant4"); - } - // Send UI commands ATH_MSG_DEBUG("G4 Command: Trying at the end of initializeOnce()"); for (auto g4command : m_g4commands) { @@ -298,6 +288,12 @@ StatusCode iGeant4::G4TransportTool::setupEvent() { ATH_MSG_DEBUG ( "setup Event" ); + // Set the RNG to use for this event. We need to reset it for MT jobs + // because of the mismatch between Gaudi slot-local and G4 thread-local RNG. + ATHRNG::RNGWrapper* rngWrapper = m_rndmGenSvc->getEngine(this); + rngWrapper->setSeed( name(), Gaudi::Hive::currentContext() ); + G4Random::setTheEngine(*rngWrapper); + ATH_CHECK(m_senDetTool->BeginOfAthenaEvent()); m_nrOfEntries++; diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.h b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.h index a02c42784d037590914583d825b04f15d56d37bc..8a6289300ff7840c2be96fa786ebe980387f32c0 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.h +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef ISF_GEANT4TOOLS_TRANSPORTTOOL_H @@ -17,7 +17,7 @@ #include "AtlasDetDescr/AtlasRegion.h" // Athena headers -#include "AthenaKernel/IAtRndmGenSvc.h" +#include "AthenaKernel/IAthRNGSvc.h" #include "G4AtlasInterfaces/IG4AtlasSvc.h" #include "G4AtlasInterfaces/IUserActionSvc.h" #include "G4AtlasInterfaces/IDetectorGeometrySvc.h" @@ -123,7 +123,6 @@ namespace iGeant4 std::string m_libList{""}; std::string m_physList{""}; std::string m_fieldMap{""}; - std::string m_rndmGen{"athena"}; bool m_releaseGeoModel{true}; bool m_recordFlux{false}; /// Commands to send to the G4 UI @@ -131,7 +130,7 @@ namespace iGeant4 /// Activate multi-threading configuration bool m_useMT{false}; // Random number service - ServiceHandle<IAtRndmGenSvc> m_rndmGenSvc{this, "RandomNumberService", "AtDSFMTGenSvc", ""}; + ServiceHandle<IAthRNGSvc> m_rndmGenSvc{this, "RandomNumberService", "AthRNGSvc", ""}; /// G4AtlasSvc ServiceHandle<IG4AtlasSvc> m_g4atlasSvc{this, "G4AtlasSvc", "G4AtlasSvc", ""}; /// user action service diff --git a/Tools/PROCTools/python/RunTier0TestsTools.py b/Tools/PROCTools/python/RunTier0TestsTools.py index 225c24dd0b94fa0bf843fb027b3aa61d1cbb478e..80a3f51cb1096719c40de70bbe06fcb9d4f157ef 100644 --- a/Tools/PROCTools/python/RunTier0TestsTools.py +++ b/Tools/PROCTools/python/RunTier0TestsTools.py @@ -21,7 +21,7 @@ ciRefFileMap = { 's3126-21.0' : 'v1', 's3126-21.3' : 'v1', 's3126-21.9' : 'v1', - 's3126-22.0' : 'v1', + 's3126-22.0' : 'v2', # OverlayTier0Test_required-test 'overlay-d1498-21.0' : 'v1', 'overlay-d1498-22.0' : 'v2',