59 #include "HepPDT/ParticleDataTable.hh" 62 #include "G4GeometryManager.hh" 63 #include "G4StateManager.hh" 64 #include "G4ApplicationState.hh" 65 #include "G4RunManagerKernel.hh" 66 #include "G4UImanager.hh" 68 #include "G4EventManager.hh" 71 #include "G4TransportationManager.hh" 72 #include "G4ParticleTable.hh" 74 #include "G4FieldManager.hh" 76 #include "G4GDMLParser.hh" 77 #include "G4SystemOfUnits.hh" 89 std::vector<std::shared_ptr<SimWatcher> >& oWatchers,
90 std::vector<std::shared_ptr<SimProducer> >& oProds
96 vector<ParameterSet> watchers = iP.
getParameter<vector<ParameterSet> >(
"Watchers");
98 for(vector<ParameterSet>::iterator itWatcher = watchers.begin();
99 itWatcher != watchers.end();
101 std::shared_ptr<SimWatcherMakerBase> maker(
104 if(maker.get()==
nullptr) {
106 <<
"Unable to find the requested Watcher";
109 std::shared_ptr<SimWatcher> watcherTemp;
110 std::shared_ptr<SimProducer> producerTemp;
111 maker->make(*itWatcher,iReg,watcherTemp,producerTemp);
112 oWatchers.push_back(watcherTemp);
114 oProds.push_back(producerTemp);
123 m_nonBeam(p.getParameter<
bool>(
"NonBeamEvent")),
125 m_managerInitialized(
false),
128 m_pUseMagneticField(p.getParameter<
bool>(
"UseMagneticField")),
130 m_PhysicsTablesDir(p.getParameter<
std::
string>(
"PhysicsTablesDirectory")),
131 m_StorePhysicsTables(p.getParameter<
bool>(
"StorePhysicsTables")),
132 m_RestorePhysicsTables(p.getParameter<
bool>(
"RestorePhysicsTables")),
133 m_EvtMgrVerbosity(p.getUntrackedParameter<
int>(
"G4EventManagerVerbosity",0)),
139 m_pStackingAction(p.getParameter<
edm::
ParameterSet>(
"StackingAction")),
140 m_pTrackingAction(p.getParameter<
edm::
ParameterSet>(
"TrackingAction")),
141 m_pSteppingAction(p.getParameter<
edm::
ParameterSet>(
"SteppingAction")),
143 m_G4Commands(p.getParameter<
std::vector<
std::
string> >(
"G4Commands")),
144 m_p(p), m_chordFinderSetter(
nullptr)
147 m_kernel =
new G4RunManagerKernel();
148 G4StateManager::GetStateManager()->SetExceptionHandler(
new ExceptionHandler());
170 std::vector<edm::ParameterSet> watchers
171 = p.
getParameter<std::vector<edm::ParameterSet> >(
"Watchers");
182 G4StateManager::GetStateManager()->SetNewState(G4State_Quit);
183 G4GeometryManager::GetInstance()->OpenGeometry();
194 <<
"[SimG4Core RunManager]\n" 195 <<
"The Geometry configuration is changed during the job execution\n" 196 <<
"this is not allowed, the geometry must stay unchanged\n";
202 <<
"[SimG4Core RunManager]\n" 203 <<
"The MagneticField configuration is changed during the job execution\n" 204 <<
"this is not allowed, the MagneticField must stay unchanged\n";
228 G4TransportationManager * tM =
229 G4TransportationManager::GetTransportationManager();
230 tM->SetFieldManager(fieldManager);
231 fieldBuilder.build( fieldManager, tM->GetPropagatorInField());
244 std::pair< std::vector<SensitiveTkDetector*>,
245 std::vector<SensitiveCaloDetector*> > sensDets =
246 m_attach->
create(*world,(*pDD),catalog_,
m_p,m_trackManager.get(),
253 <<
" RunManager: Sensitive Detector " 254 <<
"building finished; found " 256 <<
" Tk type Producers, and " 258 <<
" Calo type producers ";
266 std::unique_ptr<PhysicsListMakerBase>
269 if (physicsMaker.get()==
nullptr) {
271 <<
"Unable to find the Physics list requested";
278 <<
"Physics list construction failed!";
283 if(monopoleMass > 0.0) {
299 <<
"RunManager: start initialisation of PhysicsList";
318 <<
"G4RunManagerKernel initialization failed!";
323 std::ostringstream
dir;
324 dir << tableDir <<
'\0';
327 G4UImanager::GetUIpointer()->ApplyCommand(cmd);
337 std::vector<int> ve =
m_p.
getParameter<std::vector<int> >(
"VerboseEvents");
338 std::vector<int> vn =
m_p.
getParameter<std::vector<int> >(
"VertexNumber");
339 std::vector<int> vt =
m_p.
getParameter<std::vector<int> >(
"VerboseTracks");
347 G4cout <<
"RunManager: Requested UI commands: " << G4endl;
350 G4UImanager::GetUIpointer()->ApplyCommand(
m_G4Commands[it]);
356 gdml.SetRegionExport(
true);
357 gdml.SetEnergyCutsExport(
true);
379 G4StateManager::GetStateManager()->SetNewState(G4State_Quit);
397 std::stringstream ss;
398 ss <<
" RunManager::produce(): event " << inpevt.
id().
event()
399 <<
" with no G4PrimaryVertices\n" ;
405 <<
"RunManager::produce: start Event " << inpevt.
id().
event()
414 <<
" RunManager::produce: ended Event " << inpevt.
id().
event();
427 G4Event * evt =
new G4Event(evtid);
456 m_kernel->GetEventManager()->GetTrackingManager()->GetTrack();
457 t->SetTrackStatus(fStopAndKill) ;
466 m_kernel->GetEventManager()->GetStackManager()->clear() ;
467 m_kernel->GetEventManager()->GetTrackingManager()->EventAborted() ;
469 G4StateManager* stateManager = G4StateManager::GetStateManager();
470 stateManager->SetNewState(G4State_GeomClosed);
480 G4EventManager * eventManager =
m_kernel->GetEventManager();
488 eventManager->SetUserAction(userEventAction);
493 eventManager->SetUserAction(userTrackingAction);
498 eventManager->SetUserAction(userSteppingAction);
500 eventManager->SetUserAction(
new StackingAction(userTrackingAction,
505 <<
"No generator; initialized " 506 <<
"only RunAction!";
514 G4StateManager::GetStateManager()->SetNewState(G4State_GeomClosed);
588 <<
" RunManager WARNING : " 589 <<
"error opening file <" <<
m_FieldFile <<
"> for magnetic field";
591 double rmax = 9000*mm;
592 double zmax = 16000*mm;
597 int nr = (
int)(rmax/dr);
598 int nz = 2*(
int)(zmax/dz);
605 double cosf =
cos(phi);
606 double sinf =
sin(phi);
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
620 <<
" Z(mm)= " << z/mm <<
" Bz(tesla)= " << bfield[2]/tesla
621 <<
" Br(tesla)= " << (bfield[0]*cosf + bfield[1]*sinf)/tesla
622 <<
" Bphi(tesla)= " << (bfield[0]*sinf - bfield[1]*cosf)/tesla
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::HepMCProduct > m_HepMC
virtual const math::XYZTLorentzVector * genVertex() const
SimTrackManager * GetSimTrackManager()
void BeginOfRunAction(const G4Run *aRun) override
edm::ESWatcher< IdealMagneticFieldRecord > idealMagRcdWatcher_
const G4VPhysicalVolume * GetWorldVolume() const
RunManager(edm::ParameterSet const &p, edm::ConsumesCollector &&i)
virtual const double eventWeight() const
std::pair< std::vector< SensitiveTkDetector * >, std::vector< SensitiveCaloDetector * > > create(const DDDWorld &, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *, SimActivityRegistry ®) const
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
void abortRun(bool softAbort=false)
def create(alignables, pedeDump, additionalData, outputFile, config)
G4StepSignal g4StepSignal_
edm::EDGetTokenT< edm::LHCTransportLinkContainer > m_LHCtr
SimActivityRegistry m_registry
virtual const HepMC::GenEvent * genEvent() const
SimActivityRegistry::G4StepSignal m_g4StepSignal
HepPDT::ParticleDataTable ParticleDataTable
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< std::shared_ptr< SimProducer > > m_producers
void connect(Observer< const BeginOfJob * > *iObject)
void HepMC2G4(const HepMC::GenEvent *g, G4Event *e)
EndOfEventSignal endOfEventSignal_
Sin< T >::type sin(const T &t)
void initializeUserActions()
SimActivityRegistry::EndOfRunSignal m_endOfRunSignal
BeginOfRunSignal beginOfRunSignal_
SimActivityRegistry::EndOfEventSignal m_endOfEventSignal
static void createWatchers(const edm::ParameterSet &iP, SimActivityRegistry &iReg, std::vector< std::shared_ptr< SimWatcher > > &oWatchers, std::vector< std::shared_ptr< SimProducer > > &oProds)
edm::ESWatcher< IdealGeometryRecord > idealGeomRcdWatcher_
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
std::vector< SensitiveCaloDetector * > m_sensCaloDets
std::vector< SensitiveTkDetector * > m_sensTkDets
BeginOfJobSignal beginOfJobSignal_
U second(std::pair< T, U > const &p)
RunAction
list of unwanted particles (gluons and quarks)
SimRunInterface * m_runInterface
Cos< T >::type cos(const T &t)
bool m_RestorePhysicsTables
void hepEvent(const HepMC::GenEvent *r)
std::vector< std::shared_ptr< SimWatcher > > m_watchers
std::unique_ptr< CMSSteppingVerbose > m_sVerbose
void setGenEvent(const HepMC::GenEvent *inpevt)
BeginOfEventSignal beginOfEventSignal_
SimActivityRegistry::EndOfTrackSignal m_endOfTrackSignal
void resetGenParticleId(edm::Event &inpevt)
EndOfRunSignal endOfRunSignal_
edm::ParameterSet m_pStackingAction
unsigned int nTracks() const
void connect(Observer< const T * > *iObs)
does not take ownership of memory
edm::ParameterSet m_pEventAction
unsigned int nVertices() const
edm::ParameterSet m_pField
edm::ParameterSet m_pPhysics
edm::ParameterSet m_pSteppingAction
edm::ParameterSet m_g4overlap
const HepMC::GenEvent * GetEvent() const
T const * product() const
unsigned int nGenParts() const
RunAction * m_userRunAction
DDDWorldSignal dddWorldSignal_
void nonBeamEvent2G4(const HepMC::GenEvent *g, G4Event *e)
bool check(const edm::EventSetup &iSetup)
G4Event * generateEvent(edm::Event &inpevt)
void ReportRegions(const std::string &ss)
void DumpMagneticField(const G4Field *) const
SimActivityRegistry::BeginOfRunSignal m_beginOfRunSignal
sim::ChordFinderSetter * m_chordFinderSetter
void Connect(RunAction *)
std::vector< LHCTransportLink > LHCTransportLinkContainer
PrimaryTransformer * m_primaryTransformer
std::string m_PhysicsTablesDir
void PostUserTrackingAction(const G4Track *aTrack) override
bool m_StorePhysicsTables
std::unique_ptr< CustomUIsession > m_UIsession
EndOfTrackSignal endOfTrackSignal_
std::unique_ptr< DDG4ProductionCuts > m_prodCuts
edm::ParameterSet m_pRunAction
std::unique_ptr< SimTrackManager > m_trackManager
T const * product() const
edm::ParameterSet m_pTrackingAction
void collisionPoint(const math::XYZTLorentzVectorD &v)
std::vector< std::string > m_G4Commands
SimActivityRegistry::BeginOfEventSignal m_beginOfEventSignal
std::unique_ptr< PhysicsList > m_physicsList
bool m_managerInitialized
void initG4(const edm::EventSetup &es)
T get(const Candidate &c)
void EndOfRunAction(const G4Run *aRun) override
*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
BeginOfTrackSignal beginOfTrackSignal_
G4RunManagerKernel * m_kernel
void produce(edm::Event &inpevt, const edm::EventSetup &es)
SimActivityRegistry::BeginOfTrackSignal m_beginOfTrackSignal