|
|
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 double th =
p.getParameter<
double>(
"ThresholdForGeometryExceptions") *
CLHEP::GeV;
89 G4StateManager::GetStateManager()->SetExceptionHandler(
new ExceptionHandler(th));
90 m_check =
p.getUntrackedParameter<
bool>(
"CheckGeometry",
false);
99 edm::LogWarning(
"SimG4CoreApplication") <<
"RunManagerMT::initG4 was already done - exit";
108 <<
"RunManagerMT: start initialising of geometry DD4Hep: " << geoFromDD4hep <<
"\n"
109 <<
" cutsPerRegion: " <<
cuts <<
" cutForProton: " << protonCut <<
"\n"
110 <<
" G4 verbosity: " << verb;
116 G4VPhysicalVolume*
world =
m_world.get()->GetWorldVolume();
120 <<
"RunManagerMT: Define cuts: " <<
cuts <<
" Geant4 run manager verbosity: " << verb;
122 const G4RegionStore* regStore = G4RegionStore::GetInstance();
123 const G4PhysicalVolumeStore*
pvs = G4PhysicalVolumeStore::GetInstance();
124 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
125 unsigned int numPV =
pvs->size();
126 unsigned int numLV = lvs->size();
127 unsigned int nn = regStore->size();
129 <<
"RunManagerMT: " << numPV <<
" physical volumes; " << numLV <<
" logical volumes; " <<
nn <<
" regions.";
136 G4StateManager::GetStateManager()->SetNewState(G4State_PreInit);
139 edm::LogVerbatim(
"SimG4CoreApplication") <<
"RunManagerMT: create PhysicsList";
141 std::unique_ptr<PhysicsListMakerBase> physicsMaker(
143 if (physicsMaker.get() ==
nullptr) {
149 if (phys ==
nullptr) {
155 G4HadronicParameters::Instance()->SetVerboseLevel(verb);
156 G4EmParameters::Instance()->SetVerbose(verb);
157 G4EmParameters::Instance()->SetWorkerVerbose(
std::max(verb - 1, 0));
161 if (monopoleMass > 0.0) {
176 edm::LogVerbatim(
"SimG4CoreApplication") <<
"RunManagerMT: start initialisation of PhysicsList for master";
182 edm::LogVerbatim(
"SimG4CoreApplication") <<
"RunManagerMT: PhysicsList and cuts are defined";
186 edm::LogVerbatim(
"SimG4CoreApplication") <<
"RunManagerMT: Requested UI commands: ";
189 G4UImanager::GetUIpointer()->ApplyCommand(
command);
193 G4StateManager::GetStateManager()->SetNewState(G4State_Init);
194 edm::LogVerbatim(
"SimG4CoreApplication") <<
"RunManagerMT: G4State is Init";
198 if (
m_kernel->RunInitialization()) {
205 std::ostringstream
dir;
209 G4UImanager::GetUIpointer()->ApplyCommand(
cmd);
213 G4NuclearLevelData::GetInstance()->UploadNuclearLevelData(84);
219 <<
"RunManagerMT: Physics is initilized, now initialise user actions, verb=" << verb;
225 if (!writeFile.empty()) {
227 gdml.SetRegionExport(
true);
228 gdml.SetEnergyCutsExport(
true);
229 gdml.Write(writeFile,
m_world->GetWorldVolume(),
true);
236 if (
m_check || !regionFile.empty()) {
240 G4StateManager::GetStateManager()->SetNewState(G4State_PreInit);
241 G4HadronicParameters::Instance()->SetVerboseLevel(
std::max(verb - 1, 0));
247 G4StateManager::GetStateManager()->SetNewState(G4State_GeomClosed);
252 G4cout <<
"RunManagerMT: initG4 done " << timer << G4endl;
267 G4GeometryManager::GetInstance()->OpenGeometry();
268 G4StateManager::GetStateManager()->SetNewState(G4State_Quit);
284 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