30 #include "HepPDT/defs.h"
31 #include "HepPDT/TableBuilder.hh"
32 #include "HepPDT/ParticleDataTable.hh"
34 #include "G4GeometryManager.hh"
35 #include "G4StateManager.hh"
36 #include "G4ApplicationState.hh"
37 #include "G4MTRunManagerKernel.hh"
38 #include "G4UImanager.hh"
40 #include "G4EventManager.hh"
43 #include "G4TransportationManager.hh"
44 #include "G4ParticleTable.hh"
46 #include "G4FieldManager.hh"
47 #include "G4CascadeInterface.hh"
49 #include "G4GDMLParser.hh"
50 #include "G4SystemOfUnits.hh"
60 m_managerInitialized(
false),
61 m_runTerminated(
false),
62 m_pUseMagneticField(p.getParameter<bool>(
"UseMagneticField")),
63 m_PhysicsTablesDir(p.getParameter<std::
string>(
"PhysicsTablesDirectory")),
64 m_StorePhysicsTables(p.getParameter<bool>(
"StorePhysicsTables")),
65 m_RestorePhysicsTables(p.getParameter<bool>(
"RestorePhysicsTables")),
66 m_pField(p.getParameter<edm::
ParameterSet>(
"MagneticField")),
67 m_pPhysics(p.getParameter<edm::
ParameterSet>(
"Physics")),
68 m_pRunAction(p.getParameter<edm::
ParameterSet>(
"RunAction")),
69 m_G4Commands(p.getParameter<std::vector<std::
string> >(
"G4Commands")),
73 G4RunManagerKernel *kernel = G4MTRunManagerKernel::GetRunManagerKernel();
74 if(!kernel)
m_kernel =
new G4MTRunManagerKernel();
76 m_kernel =
dynamic_cast<G4MTRunManagerKernel *
>(kernel);
83 if(
"" != m_FieldFile) { m_FieldFile +=
".txt"; }
89 G4StateManager::GetStateManager()->SetNewState(G4State_Quit);
90 G4GeometryManager::GetInstance()->OpenGeometry();
115 G4TransportationManager * tM =
116 G4TransportationManager::GetTransportationManager();
118 tM->GetPropagatorInField());
125 std::unique_ptr<PhysicsListMakerBase>
128 if (physicsMaker.get()==0) {
129 throw SimG4Exception(
"Unable to find the Physics list requested");
152 G4CascadeInterface::Initialize();
162 throw SimG4Exception(
"G4RunManagerKernel initialization failed!");
167 std::ostringstream
dir;
171 G4UImanager::GetUIpointer()->ApplyCommand(cmd);
178 edm::LogInfo(
"SimG4CoreApplication") <<
"RunManagerMT:: Requests UI: "
180 G4UImanager::GetUIpointer()->ApplyCommand(
m_G4Commands[it]);
187 G4StateManager::GetStateManager()->SetNewState(G4State_GeomClosed);
207 G4StateManager::GetStateManager()->SetNewState(G4State_Quit);
228 <<
" RunManager WARNING : "
229 <<
"error opening file <" <<
m_FieldFile <<
"> for magnetic field";
231 double rmax = 9000*mm;
232 double zmax = 16000*mm;
237 int nr = (int)(rmax/dr);
238 int nz = 2*(int)(zmax/dz);
245 double cosf =
cos(phi);
246 double sinf =
sin(phi);
248 double point[4] = {0.0,0.0,0.0,0.0};
249 double bfield[3] = {0.0,0.0,0.0};
251 fout << std::setprecision(6);
252 for(
int i=0;
i<=nr; ++
i) {
254 for(
int j=0;
j<=nz; ++
j) {
258 field->GetFieldValue(point, bfield);
259 fout <<
"R(mm)= " << r/mm <<
" phi(deg)= " << phi/degree
260 <<
" Z(mm)= " << z/mm <<
" Bz(tesla)= " << bfield[2]/tesla
261 <<
" Br(tesla)= " << (bfield[0]*cosf + bfield[1]*sinf)/tesla
262 <<
" Bphi(tesla)= " << (bfield[0]*sinf - bfield[1]*cosf)/tesla
void Connect(RunAction *)
const std::string m_PhysicsTablesDir
bool m_managerInitialized
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
G4MTRunManagerKernel * m_kernel
SensitiveDetectorCatalog m_catalog
edm::ParameterSet m_pRunAction
HepPDT::ParticleDataTable ParticleDataTable
void initG4(const DDCompactView *pDD, const MagneticField *pMF, const HepPDT::ParticleDataTable *fPDGTable)
Sin< T >::type sin(const T &t)
SimActivityRegistry::EndOfRunSignal m_endOfRunSignal
sim::FieldBuilder * m_fieldBuilder
BeginOfRunSignal beginOfRunSignal_
std::vector< std::string > m_G4Commands
void initializeUserActions()
type of data representation of DDCompactView
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
RunManagerMT(edm::ParameterSet const &p)
void build(G4FieldManager *fM=nullptr, G4PropagatorInField *fP=nullptr, ChordFinderSetter *setter=nullptr)
Cos< T >::type cos(const T &t)
const bool m_pUseMagneticField
void EndOfRunAction(const G4Run *aRun)
EndOfRunSignal endOfRunSignal_
void DumpMagneticField(const G4Field *) const
void connect(Observer< const T * > *iObs)
does not take ownership of memory
bool m_StorePhysicsTables
std::unique_ptr< PhysicsList > m_physicsList
edm::ParameterSet m_pField
std::unique_ptr< DDDWorld > m_world
edm::ParameterSet m_pPhysics
void BeginOfRunAction(const G4Run *aRun)
DDDWorldSignal dddWorldSignal_
bool m_RestorePhysicsTables
std::unique_ptr< sim::ChordFinderSetter > m_chordFinderSetter
SimActivityRegistry::BeginOfRunSignal m_beginOfRunSignal
std::unique_ptr< SimRunInterface > m_runInterface
volatile std::atomic< bool > shutdown_flag false
RunAction * m_userRunAction
T get(const Candidate &c)
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
SimActivityRegistry m_registry