|
|
Go to the documentation of this file.
30 #include "HepPDT/ParticleDataTable.hh"
33 #include "G4GeometryManager.hh"
34 #include "G4StateManager.hh"
35 #include "G4ApplicationState.hh"
36 #include "G4MTRunManagerKernel.hh"
37 #include "G4UImanager.hh"
39 #include "G4EventManager.hh"
42 #include "G4TransportationManager.hh"
43 #include "G4ParticleTable.hh"
44 #include "G4CascadeInterface.hh"
45 #include "G4EmParameters.hh"
46 #include "G4HadronicParameters.hh"
47 #include "G4NuclearLevelData.hh"
49 #include "G4GDMLParser.hh"
50 #include "G4SystemOfUnits.hh"
52 #include "G4LogicalVolume.hh"
53 #include "G4LogicalVolumeStore.hh"
54 #include "G4PhysicalVolumeStore.hh"
55 #include "G4Region.hh"
56 #include "G4RegionStore.hh"
68 : m_managerInitialized(
false),
69 m_runTerminated(
false),
70 m_PhysicsTablesDir(
p.getUntrackedParameter<
std::
string>(
"PhysicsTablesDirectory",
"")),
71 m_StorePhysicsTables(
p.getUntrackedParameter<
bool>(
"StorePhysicsTables",
false)),
72 m_RestorePhysicsTables(
p.getUntrackedParameter<
bool>(
"RestorePhysicsTables",
false)),
87 m_kernel =
new G4MTRunManagerKernel();
88 G4StateManager::GetStateManager()->SetExceptionHandler(
new ExceptionHandler());
89 m_check =
p.getUntrackedParameter<
bool>(
"CheckGeometry",
false);
98 edm::LogWarning(
"SimG4CoreApplication") <<
"RunManagerMT::initG4 was already done - exit";
107 <<
"RunManagerMT: start initialising of geometry DD4Hep: " << geoFromDD4hep <<
"\n"
108 <<
" cutsPerRegion: " <<
cuts <<
" cutForProton: " << protonCut <<
"\n"
109 <<
" G4 verbosity: " << verb;
115 G4VPhysicalVolume*
world =
m_world.get()->GetWorldVolume();
119 <<
"RunManagerMT: Define cuts: " <<
cuts <<
" Geant4 run manager verbosity: " << verb;
121 const G4RegionStore* regStore = G4RegionStore::GetInstance();
122 const G4PhysicalVolumeStore*
pvs = G4PhysicalVolumeStore::GetInstance();
123 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
124 unsigned int numPV =
pvs->size();
125 unsigned int numLV = lvs->size();
126 unsigned int nn = regStore->size();
128 <<
"RunManagerMT: " << numPV <<
" physical volumes; " << numLV <<
" logical volumes; " <<
nn <<
" regions.";
135 G4StateManager::GetStateManager()->SetNewState(G4State_PreInit);
138 edm::LogVerbatim(
"SimG4CoreApplication") <<
"RunManagerMT: create PhysicsList";
140 std::unique_ptr<PhysicsListMakerBase> physicsMaker(
142 if (physicsMaker.get() ==
nullptr) {
148 if (phys ==
nullptr) {
154 G4HadronicParameters::Instance()->SetVerboseLevel(verb);
155 G4EmParameters::Instance()->SetVerbose(verb);
156 G4EmParameters::Instance()->SetWorkerVerbose(
std::max(verb - 1, 0));
160 if (monopoleMass > 0.0) {
175 edm::LogVerbatim(
"SimG4CoreApplication") <<
"RunManagerMT: start initialisation of PhysicsList for master";
181 edm::LogVerbatim(
"SimG4CoreApplication") <<
"RunManagerMT: PhysicsList and cuts are defined";
185 edm::LogVerbatim(
"SimG4CoreApplication") <<
"RunManagerMT: Requested UI commands: ";
188 G4UImanager::GetUIpointer()->ApplyCommand(
command);
192 G4StateManager::GetStateManager()->SetNewState(G4State_Init);
193 edm::LogVerbatim(
"SimG4CoreApplication") <<
"RunManagerMT: G4State is Init";
197 if (
m_kernel->RunInitialization()) {
204 std::ostringstream
dir;
208 G4UImanager::GetUIpointer()->ApplyCommand(
cmd);
212 G4NuclearLevelData::GetInstance()->UploadNuclearLevelData(84);
218 <<
"RunManagerMT: Physics is initilized, now initialise user actions, verb=" << verb;
224 if (!writeFile.empty()) {
226 gdml.SetRegionExport(
true);
227 gdml.SetEnergyCutsExport(
true);
228 gdml.Write(writeFile,
m_world->GetWorldVolume(),
true);
235 if (
m_check || !regionFile.empty()) {
239 G4StateManager::GetStateManager()->SetNewState(G4State_PreInit);
240 G4HadronicParameters::Instance()->SetVerboseLevel(
std::max(verb - 1, 0));
246 G4StateManager::GetStateManager()->SetNewState(G4State_GeomClosed);
251 G4cout <<
"RunManagerMT: initG4 done " << timer << G4endl;
266 G4GeometryManager::GetInstance()->OpenGeometry();
267 G4StateManager::GetStateManager()->SetNewState(G4State_Quit);
283 edm::LogVerbatim(
"SimG4CoreApplication") <<
"RunManagerMT:: terminateRun done";
std::unique_ptr< SimRunInterface > m_runInterface
edm::ParameterSet m_g4overlap
std::vector< std::string > m_G4Commands
const TkSoA *__restrict__ CAHitNtupletGeneratorKernelsGPU::QualityCuts cuts
void initializeUserActions()
CustomUIsession * m_UIsession
SimActivityRegistry m_registry
DDDWorldSignal dddWorldSignal_
T getUntrackedParameter(std::string const &, T const &) const
def create(alignables, pedeDump, additionalData, outputFile, config)
SimActivityRegistry::BeginOfRunSignal m_beginOfRunSignal
Log< level::Warning, false > LogWarning
RunAction
list of unwanted particles (gluons and quarks)
RunManagerMT(edm::ParameterSet const &)
Compact representation of the geometrical detector hierarchy.
const DDDWorld & world() const
edm::ParameterSet m_pPhysics
void connect(Observer< const T * > *iObs)
does not take ownership of memory
std::unique_ptr< PhysicsList > m_physicsList
void initG4(const DDCompactView *, const cms::DDCompactView *, const HepPDT::ParticleDataTable *)
EndOfRunSignal endOfRunSignal_
RunAction * m_userRunAction
SimActivityRegistry::EndOfRunSignal m_endOfRunSignal
Log< level::Info, true > LogVerbatim
bool m_managerInitialized
T getParameter(std::string const &) const
bool m_StorePhysicsTables
void EndOfRunAction(const G4Run *aRun) override
void Connect(RunAction *)
const std::string m_PhysicsTablesDir
std::unique_ptr< DDDWorld > m_world
bool m_RestorePhysicsTables
edm::ParameterSet m_pRunAction
BeginOfRunSignal beginOfRunSignal_
G4MTRunManagerKernel * m_kernel
HepPDT::ParticleDataTable ParticleDataTable
SensitiveDetectorCatalog m_catalog
void BeginOfRunAction(const G4Run *aRun) override