|
|
Go to the documentation of this file.
56 #include "HepPDT/ParticleDataTable.hh"
59 #include "G4GeometryManager.hh"
60 #include "G4StateManager.hh"
61 #include "G4ApplicationState.hh"
62 #include "G4RunManagerKernel.hh"
63 #include "G4UImanager.hh"
65 #include "G4EventManager.hh"
68 #include "G4TransportationManager.hh"
69 #include "G4ParticleTable.hh"
71 #include "G4FieldManager.hh"
73 #include "G4LogicalVolume.hh"
74 #include "G4LogicalVolumeStore.hh"
75 #include "G4PhysicalVolumeStore.hh"
76 #include "G4Region.hh"
77 #include "G4RegionStore.hh"
79 #include "G4GDMLParser.hh"
80 #include "G4SystemOfUnits.hh"
91 std::vector<std::shared_ptr<SimWatcher> >& oWatchers,
92 std::vector<std::shared_ptr<SimProducer> >& oProds) {
96 vector<ParameterSet> watchers = iP.
getParameter<vector<ParameterSet> >(
"Watchers");
98 for (vector<ParameterSet>::iterator itWatcher = watchers.begin(); itWatcher != watchers.end(); ++itWatcher) {
99 std::shared_ptr<SimWatcherMakerBase> maker(
101 if (maker.get() ==
nullptr) {
105 std::shared_ptr<SimWatcher> watcherTemp;
106 std::shared_ptr<SimProducer> producerTemp;
107 maker->make(*itWatcher, iReg, watcherTemp, producerTemp);
108 oWatchers.push_back(watcherTemp);
110 oProds.push_back(producerTemp);
120 m_nonBeam(
p.getParameter<
bool>(
"NonBeamEvent")),
121 m_primaryTransformer(nullptr),
122 m_managerInitialized(
false),
123 m_runInitialized(
false),
124 m_runTerminated(
false),
127 m_pUseMagneticField(
p.getParameter<
bool>(
"UseMagneticField")),
128 m_currentRun(nullptr),
129 m_currentEvent(nullptr),
131 m_PhysicsTablesDir(
p.getUntrackedParameter<
std::
string>(
"PhysicsTablesDirectory",
"")),
132 m_StorePhysicsTables(
p.getUntrackedParameter<
bool>(
"StorePhysicsTables",
false)),
133 m_RestorePhysicsTables(
p.getUntrackedParameter<
bool>(
"RestorePhysicsTables",
false)),
134 m_UseParametrisedEMPhysics(
p.getUntrackedParameter<
bool>(
"UseParametrisedEMPhysics")),
135 m_EvtMgrVerbosity(
p.getUntrackedParameter<
int>(
"G4EventManagerVerbosity", 0)),
145 m_G4Commands(
p.getParameter<
std::vector<
std::
string> >(
"G4Commands")),
148 m_kernel =
new G4RunManagerKernel();
149 G4StateManager::GetStateManager()->SetExceptionHandler(
new ExceptionHandler());
153 m_check =
p.getUntrackedParameter<
bool>(
"CheckGeometry",
false);
169 std::vector<edm::ParameterSet> watchers =
p.getParameter<std::vector<edm::ParameterSet> >(
"Watchers");
181 G4StateManager::GetStateManager()->SetNewState(G4State_Quit);
182 G4GeometryManager::GetInstance()->OpenGeometry();
192 <<
"The Geometry configuration is changed during the job execution\n"
193 <<
"this is not allowed, the geometry must stay unchanged\n";
201 <<
"RunManager: start initialising of geometry DD4Hep: " << geoFromDD4hep <<
"\n"
202 <<
" cutsPerRegion: " <<
cuts <<
" cutForProton: " << protonCut <<
"\n"
203 <<
" G4 verbosity: " << verb;
209 <<
"[SimG4Core RunManager]\n"
210 <<
"The MagneticField configuration is changed during the job execution\n"
211 <<
"this is not allowed, the MagneticField must stay unchanged\n";
234 const G4RegionStore* regStore = G4RegionStore::GetInstance();
235 const G4PhysicalVolumeStore*
pvs = G4PhysicalVolumeStore::GetInstance();
236 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
237 unsigned int numPV =
pvs->size();
238 unsigned int numLV = lvs->size();
239 unsigned int nn = regStore->size();
241 <<
"###RunManager: " << numPV <<
" PhysVolumes; " << numLV <<
" LogVolumes; " <<
nn <<
" Regions.";
243 m_kernel->DefineWorldVolume(pworld,
true);
254 G4TransportationManager* tM = G4TransportationManager::GetTransportationManager();
255 tM->SetFieldManager(fieldManager);
256 fieldBuilder.build(fieldManager, tM->GetPropagatorInField());
274 <<
" RunManager: Sensitive Detector "
276 <<
" Calo type producers ";
284 std::unique_ptr<PhysicsListMakerBase> physicsMaker(
286 if (physicsMaker.get() ==
nullptr) {
292 if (phys ==
nullptr) {
298 if (monopoleMass > 0.0) {
315 edm::LogInfo(
"SimG4CoreApplication") <<
"RunManager: start initialisation of PhysicsList";
322 if (
m_kernel->RunInitialization()) {
329 std::ostringstream
dir;
330 dir << tableDir <<
'\0';
333 G4UImanager::GetUIpointer()->ApplyCommand(
cmd);
353 G4cout <<
"RunManager: Requested UI commands: " << G4endl;
356 G4UImanager::GetUIpointer()->ApplyCommand(
m_G4Commands[it]);
359 G4StateManager::GetStateManager()->SetNewState(G4State_Init);
363 gdml.SetRegionExport(
true);
364 gdml.SetEnergyCutsExport(
true);
372 if (
m_check || !regionFile.empty()) {
386 G4StateManager::GetStateManager()->SetNewState(G4State_Quit);
404 std::stringstream
ss;
405 ss <<
" RunManager::produce(): event " << inpevt.
id().
event() <<
" with no G4PrimaryVertices\n";
410 edm::LogInfo(
"SimG4CoreApplication") <<
"RunManager::produce: start Event " << inpevt.
id().
event() <<
" of weight "
417 edm::LogInfo(
"SimG4CoreApplication") <<
" RunManager::produce: ended Event " << inpevt.
id().
event();
433 G4Event* evt =
new G4Event(
evtid);
459 G4Track*
t =
m_kernel->GetEventManager()->GetTrackingManager()->GetTrack();
460 t->SetTrackStatus(fStopAndKill);
468 m_kernel->GetEventManager()->GetStackManager()->clear();
469 m_kernel->GetEventManager()->GetTrackingManager()->EventAborted();
471 G4StateManager* stateManager = G4StateManager::GetStateManager();
472 stateManager->SetNewState(G4State_GeomClosed);
481 G4EventManager* eventManager =
m_kernel->GetEventManager();
488 eventManager->SetUserAction(userEventAction);
492 eventManager->SetUserAction(userTrackingAction);
497 eventManager->SetUserAction(userSteppingAction);
503 <<
"No generator; initialized "
504 <<
"only RunAction!";
513 G4StateManager::GetStateManager()->SetNewState(G4State_GeomClosed);
589 <<
"error opening file <" <<
m_FieldFile <<
"> for magnetic field";
591 double rmax = 9000 * mm;
592 double zmax = 16000 * mm;
608 double point[4] = {0.0, 0.0, 0.0, 0.0};
609 double bfield[3] = {0.0, 0.0, 0.0};
611 fout << std::setprecision(6);
612 for (
int i = 0;
i <=
nr; ++
i) {
614 for (
int j = 0;
j <= nz; ++
j) {
618 field->GetFieldValue(
point, bfield);
619 fout <<
"R(mm)= " <<
r / mm <<
" phi(deg)= " <<
phi / degree <<
" Z(mm)= " <<
z / mm
620 <<
" Bz(tesla)= " << bfield[2] / tesla <<
" Br(tesla)= " << (bfield[0] * cosf + bfield[1] * sinf) / tesla
621 <<
" Bphi(tesla)= " << (bfield[0] * sinf - bfield[1] * cosf) / tesla << G4endl;
virtual const double eventWeight() const
void hepEvent(const HepMC::GenEvent *r)
bool check(const edm::EventSetup &iSetup)
T const * product() const
edm::ParameterSet m_g4overlap
edm::ESWatcher< IdealGeometryRecord > idealGeomRcdWatcher_
std::vector< LHCTransportLink > LHCTransportLinkContainer
void nonBeamEvent2G4(const HepMC::GenEvent *g, G4Event *e)
edm::ParameterSet m_pEventAction
T const * product() const
T const * product() const
std::vector< SensitiveCaloDetector * > m_sensCaloDets
std::unique_ptr< CMSSteppingVerbose > m_sVerbose
unsigned int nVertices() const
PrimaryTransformer * m_primaryTransformer
edm::ParameterSet m_pPhysics
SimActivityRegistry::BeginOfEventSignal m_beginOfEventSignal
std::vector< SensitiveTkDetector * > m_sensTkDets
SimActivityRegistry::EndOfEventSignal m_endOfEventSignal
edm::ParameterSet m_pSteppingAction
EndOfEventSignal endOfEventSignal_
void produce(edm::Event &inpevt, const edm::EventSetup &es)
void PostUserTrackingAction(const G4Track *aTrack) override
CustomUIsession * m_UIsession
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
virtual const math::XYZTLorentzVector * genVertex() const
bool m_UseParametrisedEMPhysics
SimRunInterface * m_runInterface
U second(std::pair< T, U > const &p)
bool m_managerInitialized
DDDWorldSignal dddWorldSignal_
void initG4(const edm::EventSetup &es)
T getUntrackedParameter(std::string const &, T const &) const
std::pair< std::vector< SensitiveTkDetector * >, std::vector< SensitiveCaloDetector * > > create(const edm::EventSetup &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *, SimActivityRegistry ®) const
RunAction * m_userRunAction
def create(alignables, pedeDump, additionalData, outputFile, config)
G4StepSignal g4StepSignal_
static void createWatchers(const edm::ParameterSet &iP, SimActivityRegistry &iReg, std::vector< std::shared_ptr< SimWatcher > > &oWatchers, std::vector< std::shared_ptr< SimProducer > > &oProds)
SimActivityRegistry::BeginOfRunSignal m_beginOfRunSignal
edm::ParameterSet m_pField
SimActivityRegistry m_registry
std::unique_ptr< PhysicsList > m_physicsList
Sin< T >::type sin(const T &t)
std::string m_PhysicsTablesDir
RunAction
list of unwanted particles (gluons and quarks)
unsigned int nTracks() const
void Connect(RunAction *)
Cos< T >::type cos(const T &t)
void DumpMagneticField(const G4Field *) const
std::vector< std::shared_ptr< SimWatcher > > m_watchers
std::vector< std::shared_ptr< SimProducer > > m_producers
Compact representation of the geometrical detector hierarchy.
void resetGenParticleId(edm::Event &inpevt)
SimActivityRegistry::EndOfTrackSignal m_endOfTrackSignal
void setGenEvent(const HepMC::GenEvent *inpevt)
unsigned int nGenParts() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
G4Event * generateEvent(edm::Event &inpevt)
std::vector< std::string > m_G4Commands
void connect(Observer< const T * > *iObs)
does not take ownership of memory
bool m_StorePhysicsTables
G4VPhysicalVolume * GetWorldVolume() const
EndOfTrackSignal endOfTrackSignal_
std::unique_ptr< SimTrackManager > m_trackManager
edm::EDGetTokenT< edm::LHCTransportLinkContainer > m_LHCtr
edm::EDGetTokenT< edm::HepMCProduct > m_HepMC
EventNumber_t event() const
BeginOfEventSignal beginOfEventSignal_
EndOfRunSignal endOfRunSignal_
edm::ParameterSet m_pRunAction
const HepMC::GenEvent * GetEvent() const
void collisionPoint(const math::XYZTLorentzVectorD &v)
BeginOfJobSignal beginOfJobSignal_
SimTrackManager * GetSimTrackManager()
bool m_RestorePhysicsTables
SimActivityRegistry::BeginOfTrackSignal m_beginOfTrackSignal
RunManager(edm::ParameterSet const &p, edm::ConsumesCollector &&i)
SimActivityRegistry::EndOfRunSignal m_endOfRunSignal
T getParameter(std::string const &) const
SimActivityRegistry::G4StepSignal m_g4StepSignal
BeginOfTrackSignal beginOfTrackSignal_
edm::ParameterSet m_pTrackingAction
edm::ESWatcher< IdealMagneticFieldRecord > idealMagRcdWatcher_
G4RunManagerKernel * m_kernel
void connect(Observer< const BeginOfJob * > *iObject)
void initializeUserActions()
void EndOfRunAction(const G4Run *aRun) override
edm::ParameterSet m_pStackingAction
void HepMC2G4(const HepMC::GenEvent *g, G4Event *e)
virtual const HepMC::GenEvent * genEvent() const
BeginOfRunSignal beginOfRunSignal_
*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
HepPDT::ParticleDataTable ParticleDataTable
void abortRun(bool softAbort=false)
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
void BeginOfRunAction(const G4Run *aRun) override