From 1738d4ff39d10c78cce2c619eafd33c6a4ed8a13 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 7 Aug 2019 12:10:09 +0200 Subject: [PATCH 1/7] fixed G4 sequential --- SimG4Core/Application/python/g4SimHits_cfi.py | 12 +++--- SimG4Core/Application/src/RunManager.cc | 37 ++++++++++++++----- .../Application/src/RunManagerMTWorker.cc | 10 ++--- 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/SimG4Core/Application/python/g4SimHits_cfi.py b/SimG4Core/Application/python/g4SimHits_cfi.py index 52e8419162972..ef7927520200a 100644 --- a/SimG4Core/Application/python/g4SimHits_cfi.py +++ b/SimG4Core/Application/python/g4SimHits_cfi.py @@ -43,9 +43,7 @@ g4SimHits = cms.EDProducer("OscarMTProducer", g4GeometryDD4hepSource = cms.bool(False), NonBeamEvent = cms.bool(False), - G4EventManagerVerbosity = cms.untracked.int32(0), - G4StackManagerVerbosity = cms.untracked.int32(0), - G4TrackingManagerVerbosity = cms.untracked.int32(0), + G4EventManagerVerbosity = cms.int32(0), UseMagneticField = cms.bool(True), StoreRndmSeeds = cms.bool(False), RestoreRndmSeeds = cms.bool(False), @@ -82,10 +80,10 @@ Watchers = cms.VPSet(), HepMCProductLabel = cms.InputTag("generatorSmeared"), theLHCTlinkTag = cms.InputTag("LHCTransport"), - CustomUIsession = cms.untracked.PSet( - Type = cms.untracked.string("MessageLogger"), # MessageLoggerThreadPrefix, FilePerThread; the non-default ones are meant only for MT debugging - ThreadPrefix = cms.untracked.string("W"), # For MessageLoggerThreadPrefix - ThreadFile = cms.untracked.string("sim_output_thread"), # For FilePerThread + CustomUIsession = cms.PSet( + Type = cms.string("MessageLogger"), # alternatives: MessageLoggerThreadPrefix, FilePerThread + ThreadPrefix = cms.string("W"), # for MessageLoggerThreadPrefix + ThreadFile = cms.string("sim_output_thread"), # for FilePerThread ), MagneticField = cms.PSet( UseLocalMagFieldManager = cms.bool(False), diff --git a/SimG4Core/Application/src/RunManager.cc b/SimG4Core/Application/src/RunManager.cc index ebd744acee4da..be54439552761 100644 --- a/SimG4Core/Application/src/RunManager.cc +++ b/SimG4Core/Application/src/RunManager.cc @@ -69,6 +69,12 @@ #include "G4Field.hh" #include "G4FieldManager.hh" +#include "G4LogicalVolume.hh" +#include "G4LogicalVolumeStore.hh" +#include "G4PhysicalVolumeStore.hh" +#include "G4Region.hh" +#include "G4RegionStore.hh" + #include "G4GDMLParser.hh" #include "G4SystemOfUnits.hh" @@ -124,7 +130,7 @@ RunManager::RunManager(edm::ParameterSet const& p, edm::ConsumesCollector&& iC) m_PhysicsTablesDir(p.getParameter("PhysicsTablesDirectory")), m_StorePhysicsTables(p.getParameter("StorePhysicsTables")), m_RestorePhysicsTables(p.getParameter("RestorePhysicsTables")), - m_EvtMgrVerbosity(p.getUntrackedParameter("G4EventManagerVerbosity", 0)), + m_EvtMgrVerbosity(p.getParameter("G4EventManagerVerbosity")), m_pField(p.getParameter("MagneticField")), m_pGenerator(p.getParameter("Generator")), m_pPhysics(p.getParameter("Physics")), @@ -187,9 +193,9 @@ void RunManager::initG4(const edm::EventSetup& es) { bool geoFromDD4hep = m_p.getParameter("g4GeometryDD4hepSource"); bool cuts = m_pPhysics.getParameter("CutsPerRegion"); bool protonCut = m_pPhysics.getParameter("CutsOnProton"); - int verb = std::max(m_pPhysics.getParameter("Verbosity"), m_p.getParameter("SteppingVerbosity")); + int verb = std::max(m_pPhysics.getUntrackedParameter("Verbosity"), m_p.getParameter("SteppingVerbosity")); edm::LogVerbatim("SimG4CoreApplication") - << "RunManagerMT: start initialising of geometry DD4Hep: " << geoFromDD4hep << "\n" + << "RunManager: start initialising of geometry DD4Hep: " << geoFromDD4hep << "\n" << " cutsPerRegion: " << cuts << " cutForProton: " << protonCut << "\n" << " G4 verbosity: " << verb; @@ -210,17 +216,28 @@ void RunManager::initG4(const edm::EventSetup& es) { const DDCompactView* pDD = nullptr; const cms::DDCompactView* pDD4hep = nullptr; if (geoFromDD4hep) { - edm::ESTransientHandle pDD; - es.get().get(pDD); - pDD4hep = pDD.product(); + edm::ESTransientHandle ph; + es.get().get(ph); + pDD4hep = ph.product(); } else { - edm::ESTransientHandle pDD; - es.get().get(pDD); - pDD = pDD.product(); + edm::ESTransientHandle ph; + es.get().get(ph); + pDD = ph.product(); } SensitiveDetectorCatalog catalog; const DDDWorld* world = new DDDWorld(pDD, pDD4hep, catalog, verb, cuts, protonCut); G4VPhysicalVolume* pworld = world->GetWorldVolume(); + + const G4RegionStore* regStore = G4RegionStore::GetInstance(); + const G4PhysicalVolumeStore* pvs = G4PhysicalVolumeStore::GetInstance(); + const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance(); + unsigned int numPV = pvs->size(); + unsigned int numLV = lvs->size(); + unsigned int nn = regStore->size(); + edm::LogVerbatim("SimG4CoreApplication") + << "###RunManager: " << numPV << " PhysVolumes; " << numLV << " LogVolumes; " << nn << " Regions."; + + m_kernel->DefineWorldVolume(pworld, true); m_registry.dddWorldSignal_(world); if (m_pUseMagneticField) { @@ -335,6 +352,7 @@ void RunManager::initG4(const edm::EventSetup& es) { G4UImanager::GetUIpointer()->ApplyCommand(m_G4Commands[it]); } } + G4StateManager::GetStateManager()->SetNewState(G4State_Init); if (!m_WriteFile.empty()) { G4GDMLParser gdml; @@ -368,6 +386,7 @@ void RunManager::stopG4() { } void RunManager::produce(edm::Event& inpevt, const edm::EventSetup& es) { + //if(!m_runInitialized) { initG4(es); } m_currentEvent = generateEvent(inpevt); m_simEvent = new G4SimEvent; m_simEvent->hepEvent(m_generator->genEvent()); diff --git a/SimG4Core/Application/src/RunManagerMTWorker.cc b/SimG4Core/Application/src/RunManagerMTWorker.cc index 6cf44f161a756..d3e9f1747208f 100644 --- a/SimG4Core/Application/src/RunManagerMTWorker.cc +++ b/SimG4Core/Application/src/RunManagerMTWorker.cc @@ -152,14 +152,14 @@ RunManagerMTWorker::RunManagerMTWorker(const edm::ParameterSet& iConfig, edm::Co iC.consumes(iConfig.getParameter("theLHCTlinkTag"))), m_nonBeam(iConfig.getParameter("NonBeamEvent")), m_pUseMagneticField(iConfig.getParameter("UseMagneticField")), - m_EvtMgrVerbosity(iConfig.getUntrackedParameter("G4EventManagerVerbosity", 0)), + m_EvtMgrVerbosity(iConfig.getParameter("G4EventManagerVerbosity")), m_pField(iConfig.getParameter("MagneticField")), m_pRunAction(iConfig.getParameter("RunAction")), m_pEventAction(iConfig.getParameter("EventAction")), m_pStackingAction(iConfig.getParameter("StackingAction")), m_pTrackingAction(iConfig.getParameter("TrackingAction")), m_pSteppingAction(iConfig.getParameter("SteppingAction")), - m_pCustomUIsession(iConfig.getUntrackedParameter("CustomUIsession")), + m_pCustomUIsession(iConfig.getParameter("CustomUIsession")), m_p(iConfig), m_simEvent(nullptr), m_sVerbose(nullptr) { @@ -251,15 +251,15 @@ void RunManagerMTWorker::initializeThread(RunManagerMT& runManagerMaster, const // Initialize per-thread output G4Threading::G4SetThreadId(thisID); G4UImanager::GetUIpointer()->SetUpForAThread(thisID); - const std::string& uitype = m_pCustomUIsession.getUntrackedParameter("Type"); + const std::string& uitype = m_pCustomUIsession.getParameter("Type"); if (uitype == "MessageLogger") { m_tls->UIsession.reset(new CustomUIsession()); } else if (uitype == "MessageLoggerThreadPrefix") { m_tls->UIsession.reset(new CustomUIsessionThreadPrefix( - m_pCustomUIsession.getUntrackedParameter("ThreadPrefix", ""), thisID)); + m_pCustomUIsession.getParameter("ThreadPrefix"), thisID)); } else if (uitype == "FilePerThread") { m_tls->UIsession.reset( - new CustomUIsessionToFile(m_pCustomUIsession.getUntrackedParameter("ThreadFile", ""), thisID)); + new CustomUIsessionToFile(m_pCustomUIsession.getParameter("ThreadFile"), thisID)); } else { throw edm::Exception(edm::errors::Configuration) << "Invalid value of CustomUIsession.Type '" << uitype From a0c56964bdce2ceeb13fa1f734e904cc7ee9918f Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 7 Aug 2019 12:16:29 +0200 Subject: [PATCH 2/7] code format --- SimG4Core/Application/src/RunManagerMTWorker.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SimG4Core/Application/src/RunManagerMTWorker.cc b/SimG4Core/Application/src/RunManagerMTWorker.cc index d3e9f1747208f..5ed0ed83db813 100644 --- a/SimG4Core/Application/src/RunManagerMTWorker.cc +++ b/SimG4Core/Application/src/RunManagerMTWorker.cc @@ -255,8 +255,8 @@ void RunManagerMTWorker::initializeThread(RunManagerMT& runManagerMaster, const if (uitype == "MessageLogger") { m_tls->UIsession.reset(new CustomUIsession()); } else if (uitype == "MessageLoggerThreadPrefix") { - m_tls->UIsession.reset(new CustomUIsessionThreadPrefix( - m_pCustomUIsession.getParameter("ThreadPrefix"), thisID)); + m_tls->UIsession.reset( + new CustomUIsessionThreadPrefix(m_pCustomUIsession.getParameter("ThreadPrefix"), thisID)); } else if (uitype == "FilePerThread") { m_tls->UIsession.reset( new CustomUIsessionToFile(m_pCustomUIsession.getParameter("ThreadFile"), thisID)); From be65166a4761b53ec0127a8d4c2e20ec4ea22dae Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 7 Aug 2019 12:19:48 +0200 Subject: [PATCH 3/7] code checks --- SimG4Core/Application/interface/ExceptionHandler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SimG4Core/Application/interface/ExceptionHandler.h b/SimG4Core/Application/interface/ExceptionHandler.h index e55ef64674642..7b4aeb431278d 100644 --- a/SimG4Core/Application/interface/ExceptionHandler.h +++ b/SimG4Core/Application/interface/ExceptionHandler.h @@ -30,8 +30,8 @@ class ExceptionHandler : public G4VExceptionHandler { const char *description) override; private: - ExceptionHandler(const ExceptionHandler &) = delete; - ExceptionHandler &operator=(const ExceptionHandler &right) = delete; + ExceptionHandler(const ExceptionHandler &); + ExceptionHandler &operator=(const ExceptionHandler &right); }; #endif From 1c48cf92bab5b9b45bff2a314face7c5037278dd Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 7 Aug 2019 12:22:46 +0200 Subject: [PATCH 4/7] removed debug --- SimG4Core/Application/src/RunManager.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/SimG4Core/Application/src/RunManager.cc b/SimG4Core/Application/src/RunManager.cc index be54439552761..4daef65345bfa 100644 --- a/SimG4Core/Application/src/RunManager.cc +++ b/SimG4Core/Application/src/RunManager.cc @@ -386,7 +386,6 @@ void RunManager::stopG4() { } void RunManager::produce(edm::Event& inpevt, const edm::EventSetup& es) { - //if(!m_runInitialized) { initG4(es); } m_currentEvent = generateEvent(inpevt); m_simEvent = new G4SimEvent; m_simEvent->hepEvent(m_generator->genEvent()); From de79aa6aca99719c18f361fda4def2b1ffa10aff Mon Sep 17 00:00:00 2001 From: Vladimir Date: Thu, 8 Aug 2019 15:50:56 +0200 Subject: [PATCH 5/7] cleanup --- SimG4Core/Application/interface/ExceptionHandler.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/SimG4Core/Application/interface/ExceptionHandler.h b/SimG4Core/Application/interface/ExceptionHandler.h index 7b4aeb431278d..315b0adfecf3a 100644 --- a/SimG4Core/Application/interface/ExceptionHandler.h +++ b/SimG4Core/Application/interface/ExceptionHandler.h @@ -29,9 +29,8 @@ class ExceptionHandler : public G4VExceptionHandler { G4ExceptionSeverity severity, const char *description) override; -private: - ExceptionHandler(const ExceptionHandler &); - ExceptionHandler &operator=(const ExceptionHandler &right); + ExceptionHandler(const ExceptionHandler &) = delete; + ExceptionHandler &operator=(const ExceptionHandler &right) = delete; }; #endif From cc23e088fa49751ea45f2801a3254da7157d18b8 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Thu, 8 Aug 2019 18:08:11 +0200 Subject: [PATCH 6/7] cleanup --- SimG4Core/Application/python/g4SimHits_cfi.py | 28 +++++++-------- SimG4Core/Application/src/RunManager.cc | 35 ++++++++++--------- SimG4Core/Application/src/RunManagerMT.cc | 18 +++++----- .../Application/src/RunManagerMTWorker.cc | 19 +++++----- 4 files changed, 50 insertions(+), 50 deletions(-) diff --git a/SimG4Core/Application/python/g4SimHits_cfi.py b/SimG4Core/Application/python/g4SimHits_cfi.py index ef7927520200a..7b20a2343ceef 100644 --- a/SimG4Core/Application/python/g4SimHits_cfi.py +++ b/SimG4Core/Application/python/g4SimHits_cfi.py @@ -43,15 +43,15 @@ g4SimHits = cms.EDProducer("OscarMTProducer", g4GeometryDD4hepSource = cms.bool(False), NonBeamEvent = cms.bool(False), - G4EventManagerVerbosity = cms.int32(0), + G4EventManagerVerbosity = cms.untracked.int32(0), UseMagneticField = cms.bool(True), StoreRndmSeeds = cms.bool(False), RestoreRndmSeeds = cms.bool(False), - PhysicsTablesDirectory = cms.string('PhysicsTables'), - StorePhysicsTables = cms.bool(False), - RestorePhysicsTables = cms.bool(False), - CheckGeometry = cms.bool(False), - G4CheckOverlap = cms.PSet( + PhysicsTablesDirectory = cms.untracked.string('PhysicsTables'), + StorePhysicsTables = cms.untracked.bool(False), + RestorePhysicsTables = cms.untracked.bool(False), + CheckGeometry = cms.untracked.bool(False), + G4CheckOverlap = cms.untracked.PSet( OutputBaseName = cms.string('2017'), MaterialFlag = cms.bool(True), GeomFlag = cms.bool(True), @@ -69,14 +69,14 @@ NodeNames = cms.vstring('World') ), G4Commands = cms.vstring(), - SteppingVerbosity = cms.int32(0), - StepVerboseThreshold = cms.double(0.1), # in GeV - VerboseEvents = cms.vint32(), - VertexNumber = cms.vint32(), - VerboseTracks = cms.vint32(), - FileNameField = cms.string(''), - FileNameGDML = cms.string(''), - FileNameRegions = cms.string(''), + SteppingVerbosity = cms.untracked.int32(0), + StepVerboseThreshold = cms.untracked.double(0.1), # in GeV + VerboseEvents = cms.untracked.vint32(), + VertexNumber = cms.untracked.vint32(), + VerboseTracks = cms.untracked.vint32(), + FileNameField = cms.untracked.string(''), + FileNameGDML = cms.untracked.string(''), + FileNameRegions = cms.untracked.string(''), Watchers = cms.VPSet(), HepMCProductLabel = cms.InputTag("generatorSmeared"), theLHCTlinkTag = cms.InputTag("LHCTransport"), diff --git a/SimG4Core/Application/src/RunManager.cc b/SimG4Core/Application/src/RunManager.cc index 4daef65345bfa..4c0afa32723f7 100644 --- a/SimG4Core/Application/src/RunManager.cc +++ b/SimG4Core/Application/src/RunManager.cc @@ -127,10 +127,10 @@ RunManager::RunManager(edm::ParameterSet const& p, edm::ConsumesCollector&& iC) m_currentRun(nullptr), m_currentEvent(nullptr), m_simEvent(nullptr), - m_PhysicsTablesDir(p.getParameter("PhysicsTablesDirectory")), - m_StorePhysicsTables(p.getParameter("StorePhysicsTables")), - m_RestorePhysicsTables(p.getParameter("RestorePhysicsTables")), - m_EvtMgrVerbosity(p.getParameter("G4EventManagerVerbosity")), + m_PhysicsTablesDir(p.getUntrackedParameter("PhysicsTablesDirectory", "")), + m_StorePhysicsTables(p.getUntrackedParameter("StorePhysicsTables", false)), + m_RestorePhysicsTables(p.getUntrackedParameter("RestorePhysicsTables", false)), + m_EvtMgrVerbosity(p.getUntrackedParameter("G4EventManagerVerbosity", 0)), m_pField(p.getParameter("MagneticField")), m_pGenerator(p.getParameter("Generator")), m_pPhysics(p.getParameter("Physics")), @@ -139,7 +139,7 @@ RunManager::RunManager(edm::ParameterSet const& p, edm::ConsumesCollector&& iC) m_pStackingAction(p.getParameter("StackingAction")), m_pTrackingAction(p.getParameter("TrackingAction")), m_pSteppingAction(p.getParameter("SteppingAction")), - m_g4overlap(p.getParameter("G4CheckOverlap")), + m_g4overlap(p.getUntrackedParameter("G4CheckOverlap")), m_G4Commands(p.getParameter >("G4Commands")), m_p(p) { m_UIsession.reset(new CustomUIsession()); @@ -148,10 +148,10 @@ RunManager::RunManager(edm::ParameterSet const& p, edm::ConsumesCollector&& iC) m_physicsList.reset(nullptr); - m_check = p.getParameter("CheckGeometry"); - m_WriteFile = p.getParameter("FileNameGDML"); - m_FieldFile = p.getParameter("FileNameField"); - m_RegionFile = p.getParameter("FileNameRegions"); + m_check = p.getUntrackedParameter("CheckGeometry", false); + m_WriteFile = p.getUntrackedParameter("FileNameGDML", ""); + m_FieldFile = p.getUntrackedParameter("FileNameField", ""); + m_RegionFile = p.getUntrackedParameter("FileNameRegions", ""); m_userRunAction = nullptr; m_runInterface = nullptr; @@ -193,7 +193,8 @@ void RunManager::initG4(const edm::EventSetup& es) { bool geoFromDD4hep = m_p.getParameter("g4GeometryDD4hepSource"); bool cuts = m_pPhysics.getParameter("CutsPerRegion"); bool protonCut = m_pPhysics.getParameter("CutsOnProton"); - int verb = std::max(m_pPhysics.getUntrackedParameter("Verbosity"), m_p.getParameter("SteppingVerbosity")); + int verb = std::max(m_pPhysics.getUntrackedParameter("Verbosity", 0), + m_p.getUntrackedParameter("SteppingVerbosity", 0)); edm::LogVerbatim("SimG4CoreApplication") << "RunManager: start initialising of geometry DD4Hep: " << geoFromDD4hep << "\n" << " cutsPerRegion: " << cuts << " cutForProton: " << protonCut << "\n" @@ -334,11 +335,11 @@ void RunManager::initG4(const edm::EventSetup& es) { BeginOfJob aBeginOfJob(&es); m_registry.beginOfJobSignal_(&aBeginOfJob); - G4int sv = m_p.getParameter("SteppingVerbosity"); - G4double elim = m_p.getParameter("StepVerboseThreshold") * CLHEP::GeV; - std::vector ve = m_p.getParameter >("VerboseEvents"); - std::vector vn = m_p.getParameter >("VertexNumber"); - std::vector vt = m_p.getParameter >("VerboseTracks"); + G4int sv = m_p.getUntrackedParameter("SteppingVerbosity", 0); + G4double elim = m_p.getUntrackedParameter("StepVerboseThreshold", 0.1) * CLHEP::GeV; + std::vector ve = m_p.getUntrackedParameter >("VerboseEvents"); + std::vector vn = m_p.getUntrackedParameter >("VertexNumber"); + std::vector vt = m_p.getUntrackedParameter >("VerboseTracks"); if (sv > 0) { m_sVerbose.reset(new CMSSteppingVerbose(sv, elim, ve, vn, vt)); @@ -362,7 +363,7 @@ void RunManager::initG4(const edm::EventSetup& es) { } // G4Region dump file name - auto regionFile = m_p.getParameter("FileNameRegions"); + auto regionFile = m_p.getUntrackedParameter("FileNameRegions", ""); // Geometry checks if (m_check || !regionFile.empty()) { @@ -385,7 +386,7 @@ void RunManager::stopG4() { } } -void RunManager::produce(edm::Event& inpevt, const edm::EventSetup& es) { +void RunManager::produce(edm::Event& inpevt, const edm::EventSetup&) { m_currentEvent = generateEvent(inpevt); m_simEvent = new G4SimEvent; m_simEvent->hepEvent(m_generator->genEvent()); diff --git a/SimG4Core/Application/src/RunManagerMT.cc b/SimG4Core/Application/src/RunManagerMT.cc index ed8b7f33020e2..2f3a312cee5f5 100644 --- a/SimG4Core/Application/src/RunManagerMT.cc +++ b/SimG4Core/Application/src/RunManagerMT.cc @@ -61,12 +61,12 @@ RunManagerMT::RunManagerMT(edm::ParameterSet const& p) : m_managerInitialized(false), m_runTerminated(false), - m_PhysicsTablesDir(p.getParameter("PhysicsTablesDirectory")), - m_StorePhysicsTables(p.getParameter("StorePhysicsTables")), - m_RestorePhysicsTables(p.getParameter("RestorePhysicsTables")), + m_PhysicsTablesDir(p.getUntrackedParameter("PhysicsTablesDirectory", "")), + m_StorePhysicsTables(p.getUntrackedParameter("StorePhysicsTables", false)), + m_RestorePhysicsTables(p.getUntrackedParameter("RestorePhysicsTables", false)), m_pPhysics(p.getParameter("Physics")), m_pRunAction(p.getParameter("RunAction")), - m_g4overlap(p.getParameter("G4CheckOverlap")), + m_g4overlap(p.getUntrackedParameter("G4CheckOverlap")), m_G4Commands(p.getParameter >("G4Commands")), m_p(p) { m_currentRun = nullptr; @@ -83,7 +83,7 @@ RunManagerMT::RunManagerMT(edm::ParameterSet const& p) m_stateManager->SetExceptionHandler(new ExceptionHandler()); m_geometryManager->G4GeometryManager::GetInstance(); - m_check = p.getParameter("CheckGeometry"); + m_check = p.getUntrackedParameter("CheckGeometry", false); } RunManagerMT::~RunManagerMT() { stopG4(); } @@ -98,8 +98,8 @@ void RunManagerMT::initG4(const DDCompactView* pDD, bool geoFromDD4hep = m_p.getParameter("g4GeometryDD4hepSource"); bool cuts = m_pPhysics.getParameter("CutsPerRegion"); bool protonCut = m_pPhysics.getParameter("CutsOnProton"); - int verb = - std::max(m_pPhysics.getUntrackedParameter("Verbosity", 0), m_p.getParameter("SteppingVerbosity")); + int verb = std::max(m_pPhysics.getUntrackedParameter("Verbosity", 0), + m_p.getUntrackedParameter("SteppingVerbosity", 0)); edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMT: start initialising of geometry DD4Hep: " << geoFromDD4hep << "\n" << " cutsPerRegion: " << cuts << " cutForProton: " << protonCut << "\n" @@ -212,7 +212,7 @@ void RunManagerMT::initG4(const DDCompactView* pDD, initializeUserActions(); // geometry dump - auto writeFile = m_p.getParameter("FileNameGDML"); + auto writeFile = m_p.getUntrackedParameter("FileNameGDML", ""); if (!writeFile.empty()) { G4GDMLParser gdml; gdml.SetRegionExport(true); @@ -221,7 +221,7 @@ void RunManagerMT::initG4(const DDCompactView* pDD, } // G4Region dump file name - auto regionFile = m_p.getParameter("FileNameRegions"); + auto regionFile = m_p.getUntrackedParameter("FileNameRegions", ""); // Geometry checks if (m_check || !regionFile.empty()) { diff --git a/SimG4Core/Application/src/RunManagerMTWorker.cc b/SimG4Core/Application/src/RunManagerMTWorker.cc index 5ed0ed83db813..b593530c7bf2e 100644 --- a/SimG4Core/Application/src/RunManagerMTWorker.cc +++ b/SimG4Core/Application/src/RunManagerMTWorker.cc @@ -82,8 +82,7 @@ namespace { void createWatchers(const edm::ParameterSet& iP, SimActivityRegistry* iReg, std::vector >& oWatchers, - std::vector >& oProds, - int thisThreadID) { + std::vector >& oProds) { if (!iP.exists("Watchers")) { return; } @@ -152,7 +151,7 @@ RunManagerMTWorker::RunManagerMTWorker(const edm::ParameterSet& iConfig, edm::Co iC.consumes(iConfig.getParameter("theLHCTlinkTag"))), m_nonBeam(iConfig.getParameter("NonBeamEvent")), m_pUseMagneticField(iConfig.getParameter("UseMagneticField")), - m_EvtMgrVerbosity(iConfig.getParameter("G4EventManagerVerbosity")), + m_EvtMgrVerbosity(iConfig.getUntrackedParameter("G4EventManagerVerbosity", 0)), m_pField(iConfig.getParameter("MagneticField")), m_pRunAction(iConfig.getParameter("RunAction")), m_pEventAction(iConfig.getParameter("EventAction")), @@ -236,7 +235,7 @@ void RunManagerMTWorker::initializeTLS() { } } if (m_hasWatchers) { - createWatchers(m_p, m_tls->registry.get(), m_tls->watchers, m_tls->producers, thisID); + createWatchers(m_p, m_tls->registry.get(), m_tls->watchers, m_tls->producers); } } @@ -299,7 +298,7 @@ void RunManagerMTWorker::initializeThread(RunManagerMT& runManagerMaster, const tM->SetFieldManager(fieldManager); fieldBuilder.build(fieldManager, tM->GetPropagatorInField()); - std::string fieldFile = m_p.getParameter("FileNameField"); + std::string fieldFile = m_p.getUntrackedParameter("FileNameField", ""); if (!fieldFile.empty()) { std::call_once(applyOnce, []() { dumpMF = true; }); if (dumpMF) { @@ -348,11 +347,11 @@ void RunManagerMTWorker::initializeThread(RunManagerMT& runManagerMaster, const BeginOfJob aBeginOfJob(&es); m_tls->registry->beginOfJobSignal_(&aBeginOfJob); - G4int sv = m_p.getParameter("SteppingVerbosity"); - G4double elim = m_p.getParameter("StepVerboseThreshold") * CLHEP::GeV; - std::vector ve = m_p.getParameter >("VerboseEvents"); - std::vector vn = m_p.getParameter >("VertexNumber"); - std::vector vt = m_p.getParameter >("VerboseTracks"); + G4int sv = m_p.getUntrackedParameter("SteppingVerbosity", 0); + G4double elim = m_p.getUntrackedParameter("StepVerboseThreshold", 0.1) * CLHEP::GeV; + std::vector ve = m_p.getUntrackedParameter >("VerboseEvents"); + std::vector vn = m_p.getUntrackedParameter >("VertexNumber"); + std::vector vt = m_p.getUntrackedParameter >("VerboseTracks"); if (sv > 0) { m_sVerbose.reset(new CMSSteppingVerbose(sv, elim, ve, vn, vt)); From c0014ef7e87be503f1f4d49ac69be143d7e81fc1 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Thu, 8 Aug 2019 18:30:50 +0200 Subject: [PATCH 7/7] cleanup --- SimG4Core/Application/python/g4SimHits_cfi.py | 8 ++++---- SimG4Core/Application/src/RunManagerMTWorker.cc | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/SimG4Core/Application/python/g4SimHits_cfi.py b/SimG4Core/Application/python/g4SimHits_cfi.py index 7b20a2343ceef..79f9f00baea75 100644 --- a/SimG4Core/Application/python/g4SimHits_cfi.py +++ b/SimG4Core/Application/python/g4SimHits_cfi.py @@ -80,10 +80,10 @@ Watchers = cms.VPSet(), HepMCProductLabel = cms.InputTag("generatorSmeared"), theLHCTlinkTag = cms.InputTag("LHCTransport"), - CustomUIsession = cms.PSet( - Type = cms.string("MessageLogger"), # alternatives: MessageLoggerThreadPrefix, FilePerThread - ThreadPrefix = cms.string("W"), # for MessageLoggerThreadPrefix - ThreadFile = cms.string("sim_output_thread"), # for FilePerThread + CustomUIsession = cms.untracked.PSet( + Type = cms.untracked.string("MessageLogger"), # alternatives: MessageLoggerThreadPrefix, FilePerThread + ThreadPrefix = cms.untracked.string("W"), # for MessageLoggerThreadPrefix + ThreadFile = cms.untracked.string("sim_output_thread"), # for FilePerThread ), MagneticField = cms.PSet( UseLocalMagFieldManager = cms.bool(False), diff --git a/SimG4Core/Application/src/RunManagerMTWorker.cc b/SimG4Core/Application/src/RunManagerMTWorker.cc index b593530c7bf2e..0caf1a0e9bfb5 100644 --- a/SimG4Core/Application/src/RunManagerMTWorker.cc +++ b/SimG4Core/Application/src/RunManagerMTWorker.cc @@ -158,7 +158,7 @@ RunManagerMTWorker::RunManagerMTWorker(const edm::ParameterSet& iConfig, edm::Co m_pStackingAction(iConfig.getParameter("StackingAction")), m_pTrackingAction(iConfig.getParameter("TrackingAction")), m_pSteppingAction(iConfig.getParameter("SteppingAction")), - m_pCustomUIsession(iConfig.getParameter("CustomUIsession")), + m_pCustomUIsession(iConfig.getUntrackedParameter("CustomUIsession")), m_p(iConfig), m_simEvent(nullptr), m_sVerbose(nullptr) { @@ -250,15 +250,15 @@ void RunManagerMTWorker::initializeThread(RunManagerMT& runManagerMaster, const // Initialize per-thread output G4Threading::G4SetThreadId(thisID); G4UImanager::GetUIpointer()->SetUpForAThread(thisID); - const std::string& uitype = m_pCustomUIsession.getParameter("Type"); + const std::string& uitype = m_pCustomUIsession.getUntrackedParameter("Type", "MessageLogger"); if (uitype == "MessageLogger") { m_tls->UIsession.reset(new CustomUIsession()); } else if (uitype == "MessageLoggerThreadPrefix") { - m_tls->UIsession.reset( - new CustomUIsessionThreadPrefix(m_pCustomUIsession.getParameter("ThreadPrefix"), thisID)); + m_tls->UIsession.reset(new CustomUIsessionThreadPrefix( + m_pCustomUIsession.getUntrackedParameter("ThreadPrefix", ""), thisID)); } else if (uitype == "FilePerThread") { m_tls->UIsession.reset( - new CustomUIsessionToFile(m_pCustomUIsession.getParameter("ThreadFile"), thisID)); + new CustomUIsessionToFile(m_pCustomUIsession.getUntrackedParameter("ThreadFile", ""), thisID)); } else { throw edm::Exception(edm::errors::Configuration) << "Invalid value of CustomUIsession.Type '" << uitype