|
|
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"
93 std::vector<std::shared_ptr<SimWatcher> >& oWatchers,
94 std::vector<std::shared_ptr<SimProducer> >& oProds) {
98 vector<ParameterSet> watchers = iP.
getParameter<vector<ParameterSet> >(
"Watchers");
100 for (vector<ParameterSet>::iterator itWatcher = watchers.begin(); itWatcher != watchers.end(); ++itWatcher) {
101 std::shared_ptr<SimWatcherMakerBase> maker(
103 if (maker.get() ==
nullptr) {
107 std::shared_ptr<SimWatcher> watcherTemp;
108 std::shared_ptr<SimProducer> producerTemp;
109 maker->make(*itWatcher, iReg, watcherTemp, producerTemp);
110 oWatchers.push_back(watcherTemp);
112 oProds.push_back(producerTemp);
122 m_nonBeam(
p.getParameter<
bool>(
"NonBeamEvent")),
123 m_primaryTransformer(nullptr),
124 m_managerInitialized(
false),
125 m_runInitialized(
false),
126 m_runTerminated(
false),
129 m_pUseMagneticField(
p.getParameter<
bool>(
"UseMagneticField")),
130 m_currentRun(nullptr),
131 m_currentEvent(nullptr),
133 m_PhysicsTablesDir(
p.getUntrackedParameter<
std::
string>(
"PhysicsTablesDirectory",
"")),
134 m_StorePhysicsTables(
p.getUntrackedParameter<
bool>(
"StorePhysicsTables",
false)),
135 m_RestorePhysicsTables(
p.getUntrackedParameter<
bool>(
"RestorePhysicsTables",
false)),
136 m_UseParametrisedEMPhysics(
p.getUntrackedParameter<
bool>(
"UseParametrisedEMPhysics")),
137 m_EvtMgrVerbosity(
p.getUntrackedParameter<
int>(
"G4EventManagerVerbosity", 0)),
150 m_kernel =
new G4RunManagerKernel();
151 G4StateManager::GetStateManager()->SetExceptionHandler(
new ExceptionHandler());
155 m_check =
p.getUntrackedParameter<
bool>(
"CheckGeometry",
false);
171 std::vector<edm::ParameterSet> watchers =
p.getParameter<std::vector<edm::ParameterSet> >(
"Watchers");
183 G4StateManager::GetStateManager()->SetNewState(G4State_Quit);
184 G4GeometryManager::GetInstance()->OpenGeometry();
194 <<
"The Geometry configuration is changed during the job execution\n"
195 <<
"this is not allowed, the geometry must stay unchanged\n";
203 <<
"RunManager: start initialising of geometry DD4Hep: " << geoFromDD4hep <<
"\n"
204 <<
" cutsPerRegion: " <<
cuts <<
" cutForProton: " << protonCut <<
"\n"
205 <<
" G4 verbosity: " << verb;
211 <<
"[SimG4Core RunManager]\n"
212 <<
"The MagneticField configuration is changed during the job execution\n"
213 <<
"this is not allowed, the MagneticField must stay unchanged\n";
236 const G4RegionStore* regStore = G4RegionStore::GetInstance();
237 const G4PhysicalVolumeStore*
pvs = G4PhysicalVolumeStore::GetInstance();
238 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
239 unsigned int numPV =
pvs->size();
240 unsigned int numLV = lvs->size();
241 unsigned int nn = regStore->size();
243 <<
"###RunManager: " << numPV <<
" PhysVolumes; " << numLV <<
" LogVolumes; " <<
nn <<
" Regions.";
245 m_kernel->DefineWorldVolume(pworld,
true);
256 G4TransportationManager* tM = G4TransportationManager::GetTransportationManager();
257 tM->SetFieldManager(fieldManager);
258 fieldBuilder.build(fieldManager, tM->GetPropagatorInField());
276 <<
" RunManager: Sensitive Detector "
278 <<
" Calo type producers ";
286 std::unique_ptr<PhysicsListMakerBase> physicsMaker(
288 if (physicsMaker.get() ==
nullptr) {
294 if (phys ==
nullptr) {
300 if (monopoleMass > 0.0) {
317 edm::LogInfo(
"SimG4CoreApplication") <<
"RunManager: start initialisation of PhysicsList";
324 if (
m_kernel->RunInitialization()) {
331 std::ostringstream
dir;
332 dir << tableDir <<
'\0';
335 G4UImanager::GetUIpointer()->ApplyCommand(
cmd);
350 m_sVerbose = std::make_unique<CMSSteppingVerbose>(
sv, elim, ve, vn, vt);
355 G4cout <<
"RunManager: Requested UI commands: " << G4endl;
358 G4UImanager::GetUIpointer()->ApplyCommand(
m_G4Commands[it]);
361 G4StateManager::GetStateManager()->SetNewState(G4State_Init);
365 gdml.SetRegionExport(
true);
366 gdml.SetEnergyCutsExport(
true);
374 if (
m_check || !regionFile.empty()) {
388 G4StateManager::GetStateManager()->SetNewState(G4State_Quit);
406 std::stringstream
ss;
407 ss <<
" RunManager::produce(): event " << inpevt.
id().
event() <<
" with no G4PrimaryVertices\n";
412 edm::LogInfo(
"SimG4CoreApplication") <<
"RunManager::produce: start Event " << inpevt.
id().
event() <<
" of weight "
419 edm::LogInfo(
"SimG4CoreApplication") <<
" RunManager::produce: ended Event " << inpevt.
id().
event();
435 G4Event* evt =
new G4Event(
evtid);
461 G4Track*
t =
m_kernel->GetEventManager()->GetTrackingManager()->GetTrack();
462 t->SetTrackStatus(fStopAndKill);
470 m_kernel->GetEventManager()->GetStackManager()->clear();
471 m_kernel->GetEventManager()->GetTrackingManager()->EventAborted();
473 G4StateManager* stateManager = G4StateManager::GetStateManager();
474 stateManager->SetNewState(G4State_GeomClosed);
483 G4EventManager* eventManager =
m_kernel->GetEventManager();
490 eventManager->SetUserAction(userEventAction);
494 eventManager->SetUserAction(userTrackingAction);
499 eventManager->SetUserAction(userSteppingAction);
505 <<
"No generator; initialized "
506 <<
"only RunAction!";
515 G4StateManager::GetStateManager()->SetNewState(G4State_GeomClosed);
591 <<
"error opening file <" <<
m_FieldFile <<
"> for magnetic field";
593 double rmax = 9000 * mm;
594 double zmax = 16000 * mm;
610 double point[4] = {0.0, 0.0, 0.0, 0.0};
611 double bfield[3] = {0.0, 0.0, 0.0};
613 fout << std::setprecision(6);
614 for (
int i = 0;
i <=
nr; ++
i) {
616 for (
int j = 0;
j <= nz; ++
j) {
620 field->GetFieldValue(
point, bfield);
621 fout <<
"R(mm)= " <<
r / mm <<
" phi(deg)= " <<
phi / degree <<
" Z(mm)= " <<
z / mm
622 <<
" Bz(tesla)= " << bfield[2] / tesla <<
" Br(tesla)= " << (bfield[0] * cosf + bfield[1] * sinf) / tesla
623 <<
" 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
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
void nonCentralEvent2G4(const HepMC::GenEvent *g, G4Event *e)
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
Log< level::Info, false > LogInfo
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
Log< level::Warning, false > LogWarning
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
SimActivityRegistry::G4StepSignal m_g4StepSignal
BeginOfTrackSignal beginOfTrackSignal_
edm::ParameterSet m_pTrackingAction
Log< level::Info, true > LogVerbatim
edm::ESWatcher< IdealMagneticFieldRecord > idealMagRcdWatcher_
G4RunManagerKernel * m_kernel
void connect(Observer< const BeginOfJob * > *iObject)
void initializeUserActions()
T getParameter(std::string const &) const
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