CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
RunManagerMTWorker Class Reference

#include <RunManagerMTWorker.h>

Classes

struct  TLSData
 

Public Member Functions

void abortEvent ()
 
void abortRun (bool softAbort=false)
 
void beginRun (const edm::EventSetup &)
 
void Connect (RunAction *)
 
void Connect (EventAction *)
 
void Connect (TrackingAction *)
 
void Connect (SteppingAction *)
 
void Connect (Phase2SteppingAction *)
 
void endRun ()
 
SimTrackManagergetSimTrackManager ()
 
int getThreadIndex () const
 
void initializeG4 (RunManagerMT *runManagerMaster, const edm::EventSetup &es)
 
TmpSimEventproduce (const edm::Event &inpevt, const edm::EventSetup &es, RunManagerMT &runManagerMaster)
 
std::vector< std::shared_ptr< SimProducer > > & producers ()
 
 RunManagerMTWorker (const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 
std::vector< SensitiveCaloDetector * > & sensCaloDetectors ()
 
std::vector< SensitiveTkDetector * > & sensTkDetectors ()
 
TmpSimEventsimEvent ()
 
 ~RunManagerMTWorker ()
 

Private Member Functions

void DumpMagneticField (const G4Field *, const std::string &) const
 
G4Event * generateEvent (const edm::Event &inpevt)
 
void initializeRun ()
 
void initializeTLS ()
 
void initializeUserActions ()
 
void resetGenParticleId (const edm::Event &inpevt)
 
void terminateRun ()
 

Private Attributes

bool m_dumpGDML {false}
 
bool m_dumpMF {false}
 
bool m_endOfRun {false}
 
std::unique_ptr< CMSSimEventManagerm_evtManager
 
std::vector< std::string > m_G4Commands
 
std::vector< std::string > m_G4CommandsEndRun
 
Generator m_generator
 
bool m_hasWatchers {false}
 
edm::EDGetTokenT< edm::HepMCProductm_InToken
 
bool m_isPhase2 {false}
 
edm::EDGetTokenT< edm::HepMCProductm_LHCToken
 
bool m_LHCTransport {false}
 
edm::ESGetToken< MagneticField, IdealMagneticFieldRecordm_MagField
 
bool m_nonBeam {false}
 
edm::ParameterSet m_p
 
edm::ParameterSet m_pEventAction
 
edm::ParameterSet m_pField
 
const MagneticFieldm_pMagField {nullptr}
 
edm::ParameterSet m_pRunAction
 
edm::ParameterSet m_pStackingAction
 
edm::ParameterSet m_pSteppingAction
 
edm::ParameterSet m_pTrackingAction
 
bool m_pUseMagneticField {true}
 
std::unordered_map< std::string, std::unique_ptr< SensitiveDetectorMakerBase > > m_sdMakers
 
TmpSimEvent m_simEvent
 
std::unique_ptr< CMSSteppingVerbosem_sVerbose
 
edm::EDGetTokenT< edm::LHCTransportLinkContainerm_theLHCTlinkToken
 
const int m_thread_index {-1}
 
TLSDatam_tls {nullptr}
 
CustomUIsessionm_UIsession {nullptr}
 
bool m_UseG4EventManager {true}
 

Detailed Description

Definition at line 51 of file RunManagerMTWorker.h.

Constructor & Destructor Documentation

◆ RunManagerMTWorker()

RunManagerMTWorker::RunManagerMTWorker ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)
explicit

Definition at line 153 of file RunManagerMTWorker.cc.

154  : m_generator(p.getParameter<edm::ParameterSet>("Generator")),
156  p.getParameter<edm::ParameterSet>("Generator").getParameter<edm::InputTag>("HepMCProductLabel"))),
157  m_theLHCTlinkToken(iC.consumes<edm::LHCTransportLinkContainer>(p.getParameter<edm::InputTag>("theLHCTlinkTag"))),
158  m_nonBeam(p.getParameter<bool>("NonBeamEvent")),
159  m_UseG4EventManager(p.getParameter<bool>("UseG4EventManager")),
160  m_pUseMagneticField(p.getParameter<bool>("UseMagneticField")),
161  m_LHCTransport(p.getParameter<bool>("LHCTransport")),
162  m_thread_index{(get_new_thread_index())},
163  m_pField(p.getParameter<edm::ParameterSet>("MagneticField")),
164  m_pRunAction(p.getParameter<edm::ParameterSet>("RunAction")),
165  m_pEventAction(p.getParameter<edm::ParameterSet>("EventAction")),
166  m_pStackingAction(p.getParameter<edm::ParameterSet>("StackingAction")),
167  m_pTrackingAction(p.getParameter<edm::ParameterSet>("TrackingAction")),
168  m_pSteppingAction(p.getParameter<edm::ParameterSet>("SteppingAction")),
169  m_G4Commands(p.getParameter<std::vector<std::string>>("G4Commands")),
170  m_G4CommandsEndRun(p.getParameter<std::vector<std::string>>("G4CommandsEndRun")),
171  m_p(p) {
172  int id = getThreadIndex();
173  edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker for the thread " << id;
174 
175  // Initialize per-thread output
176  G4Threading::G4SetThreadId(id);
177  G4UImanager::GetUIpointer()->SetUpForAThread(id);
178  auto iPset = p.getUntrackedParameter<edm::ParameterSet>("CustomUIsession");
179  const std::string& uitype = iPset.getUntrackedParameter<std::string>("Type");
180  if (uitype == "MessageLogger") {
182  } else if (uitype == "MessageLoggerThreadPrefix") {
183  m_UIsession = new CustomUIsessionThreadPrefix(iPset.getUntrackedParameter<std::string>("ThreadPrefix"), id);
184  } else if (uitype == "FilePerThread") {
185  m_UIsession = new CustomUIsessionToFile(iPset.getUntrackedParameter<std::string>("ThreadFile"), id);
186  } else {
187  throw cms::Exception("Configuration")
188  << "RunManagerMTWorker::initializeG4: Invalid value of CustomUIsession.Type '" << uitype
189  << "', valid are MessageLogger, MessageLoggerThreadPrefix, FilePerThread";
190  }
191  G4UImanager::GetUIpointer()->SetCoutDestination(m_UIsession);
192  //G4PhysListUtil::InitialiseParameters();
193  //G4LossTableManager::Instance();
194 
195  // sensitive detectors
196  std::vector<std::string> onlySDs = p.getParameter<std::vector<std::string>>("OnlySDs");
197  m_sdMakers = sim::sensitiveDetectorMakers(p, iC, onlySDs);
198 
199  // TLS and watchers
200  initializeTLS();
201  if (m_hasWatchers) {
202  for (auto& watcher : m_tls->watchers) {
203  watcher->registerConsumes(iC);
204  }
205  }
206  if (m_LHCTransport) {
207  m_LHCToken = iC.consumes<edm::HepMCProduct>(edm::InputTag("LHCTransport"));
208  }
209  if (m_pUseMagneticField) {
211  }
212  edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker is constructed for the thread " << id;
213  unsigned int k = 0;
214  for (std::unordered_map<std::string, std::unique_ptr<SensitiveDetectorMakerBase>>::const_iterator itr =
215  m_sdMakers.begin();
216  itr != m_sdMakers.end();
217  ++itr, ++k) {
218  edm::LogVerbatim("SimG4CoreApplication") << "SD[" << k << "] " << itr->first;
219  }
220 }
edm::ParameterSet m_pSteppingAction
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Log< level::Info, true > LogVerbatim
std::vector< std::shared_ptr< SimWatcher > > watchers
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
CustomUIsession * m_UIsession
std::vector< std::string > m_G4Commands
edm::EDGetTokenT< edm::HepMCProduct > m_InToken
std::vector< std::string > m_G4CommandsEndRun
edm::EDGetTokenT< edm::HepMCProduct > m_LHCToken
edm::ParameterSet m_pEventAction
edm::ParameterSet m_pRunAction
std::unordered_map< std::string, std::unique_ptr< SensitiveDetectorMakerBase > > m_sdMakers
edm::ParameterSet m_pTrackingAction
edm::ParameterSet m_pField
edm::EDGetTokenT< edm::LHCTransportLinkContainer > m_theLHCTlinkToken
std::unordered_map< std::string, std::unique_ptr< SensitiveDetectorMakerBase > > sensitiveDetectorMakers(edm::ParameterSet const &, edm::ConsumesCollector, std::vector< std::string > const &chosenMakers)
std::vector< LHCTransportLink > LHCTransportLinkContainer
edm::ParameterSet m_p
int getThreadIndex() const
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > m_MagField
edm::ParameterSet m_pStackingAction

◆ ~RunManagerMTWorker()

RunManagerMTWorker::~RunManagerMTWorker ( )

Definition at line 222 of file RunManagerMTWorker.cc.

References m_tls, and m_UIsession.

222  {
223  m_tls = nullptr;
224  delete m_UIsession;
225 }
CustomUIsession * m_UIsession

Member Function Documentation

◆ abortEvent()

void RunManagerMTWorker::abortEvent ( )

Definition at line 616 of file RunManagerMTWorker.cc.

References RunManagerMTWorker::TLSData::currentEvent, RunManagerMTWorker::TLSData::kernel, m_tls, TrackingAction::PostUserTrackingAction(), RunManagerMTWorker::TLSData::runTerminated, and submitPVValidationJobs::t.

Referenced by SimRunInterface::abortEvent(), and abortRun().

616  {
617  if (m_tls->runTerminated) {
618  return;
619  }
620  G4Track* t = m_tls->kernel->GetEventManager()->GetTrackingManager()->GetTrack();
621  t->SetTrackStatus(fStopAndKill);
622 
623  // CMS-specific act
624  //
625  TrackingAction* uta = static_cast<TrackingAction*>(m_tls->kernel->GetEventManager()->GetUserTrackingAction());
627 
628  m_tls->currentEvent->SetEventAborted();
629  m_tls->kernel->GetEventManager()->GetStackManager()->clear();
630  m_tls->kernel->GetEventManager()->GetTrackingManager()->EventAborted();
631 }
std::unique_ptr< G4Event > currentEvent
std::unique_ptr< G4RunManagerKernel > kernel
void PostUserTrackingAction(const G4Track *aTrack) override

◆ abortRun()

void RunManagerMTWorker::abortRun ( bool  softAbort = false)

Definition at line 633 of file RunManagerMTWorker.cc.

References abortEvent(), RunManagerMTWorker::TLSData::currentRun, m_tls, and terminateRun().

Referenced by SimRunInterface::abortRun().

633  {
634  if (!softAbort) {
635  abortEvent();
636  }
637  m_tls->currentRun = nullptr;
638  terminateRun();
639 }

◆ beginRun()

void RunManagerMTWorker::beginRun ( const edm::EventSetup es)

Definition at line 227 of file RunManagerMTWorker.cc.

References edm::EventSetup::getData(), getThreadIndex(), EcalPhiSymFlatTableProducers_cfi::id, m_hasWatchers, m_MagField, m_pMagField, m_pUseMagneticField, m_sdMakers, m_tls, and RunManagerMTWorker::TLSData::watchers.

227  {
228  int id = getThreadIndex();
229  edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker::beginRun for the thread " << id;
230  for (auto& maker : m_sdMakers) {
231  maker.second->beginRun(es);
232  }
233  if (m_pUseMagneticField) {
235  }
236  if (m_hasWatchers) {
237  for (auto& watcher : m_tls->watchers) {
238  watcher->beginRun(es);
239  }
240  }
241  edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker::beginRun done for the thread " << id;
242 }
Log< level::Info, true > LogVerbatim
std::vector< std::shared_ptr< SimWatcher > > watchers
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
std::unordered_map< std::string, std::unique_ptr< SensitiveDetectorMakerBase > > m_sdMakers
const MagneticField * m_pMagField
int getThreadIndex() const
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > m_MagField

◆ Connect() [1/5]

void RunManagerMTWorker::Connect ( RunAction runAction)

Definition at line 472 of file RunManagerMTWorker.cc.

References sim_act::Signaler< T >::connect(), RunAction::m_beginOfRunSignal, RunAction::m_endOfRunSignal, m_tls, and RunManagerMTWorker::TLSData::registry.

Referenced by SimRunInterface::Connect(), and initializeUserActions().

472  {
473  runAction->m_beginOfRunSignal.connect(m_tls->registry->beginOfRunSignal_);
474  runAction->m_endOfRunSignal.connect(m_tls->registry->endOfRunSignal_);
475 }
void connect(Observer< const T *> *iObs)
does not take ownership of memory
Definition: Signaler.h:55
SimActivityRegistry::EndOfRunSignal m_endOfRunSignal
Definition: RunAction.h:24
std::unique_ptr< SimActivityRegistry > registry
SimActivityRegistry::BeginOfRunSignal m_beginOfRunSignal
Definition: RunAction.h:23

◆ Connect() [2/5]

void RunManagerMTWorker::Connect ( EventAction eventAction)

Definition at line 477 of file RunManagerMTWorker.cc.

References sim_act::Signaler< T >::connect(), EventAction::m_beginOfEventSignal, EventAction::m_endOfEventSignal, m_tls, and RunManagerMTWorker::TLSData::registry.

477  {
478  eventAction->m_beginOfEventSignal.connect(m_tls->registry->beginOfEventSignal_);
479  eventAction->m_endOfEventSignal.connect(m_tls->registry->endOfEventSignal_);
480 }
void connect(Observer< const T *> *iObs)
does not take ownership of memory
Definition: Signaler.h:55
SimActivityRegistry::EndOfEventSignal m_endOfEventSignal
Definition: EventAction.h:37
std::unique_ptr< SimActivityRegistry > registry
SimActivityRegistry::BeginOfEventSignal m_beginOfEventSignal
Definition: EventAction.h:36

◆ Connect() [3/5]

void RunManagerMTWorker::Connect ( TrackingAction trackingAction)

Definition at line 482 of file RunManagerMTWorker.cc.

References sim_act::Signaler< T >::connect(), TrackingAction::m_beginOfTrackSignal, TrackingAction::m_endOfTrackSignal, m_tls, and RunManagerMTWorker::TLSData::registry.

482  {
483  trackingAction->m_beginOfTrackSignal.connect(m_tls->registry->beginOfTrackSignal_);
484  trackingAction->m_endOfTrackSignal.connect(m_tls->registry->endOfTrackSignal_);
485 }
void connect(Observer< const T *> *iObs)
does not take ownership of memory
Definition: Signaler.h:55
std::unique_ptr< SimActivityRegistry > registry
SimActivityRegistry::EndOfTrackSignal m_endOfTrackSignal
SimActivityRegistry::BeginOfTrackSignal m_beginOfTrackSignal

◆ Connect() [4/5]

void RunManagerMTWorker::Connect ( SteppingAction steppingAction)

Definition at line 487 of file RunManagerMTWorker.cc.

References sim_act::Signaler< T >::connect(), SteppingAction::m_g4StepSignal, m_tls, and RunManagerMTWorker::TLSData::registry.

487  {
488  steppingAction->m_g4StepSignal.connect(m_tls->registry->g4StepSignal_);
489 }
void connect(Observer< const T *> *iObs)
does not take ownership of memory
Definition: Signaler.h:55
SimActivityRegistry::G4StepSignal m_g4StepSignal
std::unique_ptr< SimActivityRegistry > registry

◆ Connect() [5/5]

void RunManagerMTWorker::Connect ( Phase2SteppingAction steppingAction)

Definition at line 491 of file RunManagerMTWorker.cc.

References sim_act::Signaler< T >::connect(), Phase2SteppingAction::m_g4StepSignal, m_tls, and RunManagerMTWorker::TLSData::registry.

491  {
492  steppingAction->m_g4StepSignal.connect(m_tls->registry->g4StepSignal_);
493 }
void connect(Observer< const T *> *iObs)
does not take ownership of memory
Definition: Signaler.h:55
SimActivityRegistry::G4StepSignal m_g4StepSignal
std::unique_ptr< SimActivityRegistry > registry

◆ DumpMagneticField()

void RunManagerMTWorker::DumpMagneticField ( const G4Field *  field,
const std::string &  file 
) const
private

Definition at line 679 of file RunManagerMTWorker.cc.

References funct::cos(), l1ctLayer1_cff::dr, PVValHelper::dz, geometryDiff::file, groupFilesInBlocks::fout, mps_fire::i, createfilelist::int, dqmiolumiharvest::j, EgHLTOffHistBins_cfi::nr, MillePedeFileConverter_cfg::out, phi, point, alignCSCRings::r, funct::sin(), z, ppsFastLocalSimulation_cfi::z0, and SiStripMonitorCluster_cfi::zmax.

Referenced by initializeG4().

679  {
680  std::ofstream fout(file.c_str(), std::ios::out);
681  if (fout.fail()) {
682  edm::LogWarning("SimG4CoreApplication")
683  << "MTWorker::DumpMagneticField: error opening file <" << file << "> for magnetic field";
684  } else {
685  // CMS magnetic field volume
686  double rmax = 9000 * CLHEP::mm;
687  double zmax = 24000 * CLHEP::mm;
688 
689  double dr = 1 * CLHEP::cm;
690  double dz = 5 * CLHEP::cm;
691 
692  int nr = (int)(rmax / dr);
693  int nz = 2 * (int)(zmax / dz);
694 
695  double r = 0.0;
696  double z0 = -zmax;
697  double z;
698 
699  double phi = 0.0;
700  double cosf = cos(phi);
701  double sinf = sin(phi);
702 
703  double point[4] = {0.0, 0.0, 0.0, 0.0};
704  double bfield[3] = {0.0, 0.0, 0.0};
705 
706  fout << std::setprecision(6);
707  for (int i = 0; i <= nr; ++i) {
708  z = z0;
709  for (int j = 0; j <= nz; ++j) {
710  point[0] = r * cosf;
711  point[1] = r * sinf;
712  point[2] = z;
713  field->GetFieldValue(point, bfield);
714  fout << "R(mm)= " << r / CLHEP::mm << " phi(deg)= " << phi / CLHEP::degree << " Z(mm)= " << z / CLHEP::mm
715  << " Bz(tesla)= " << bfield[2] / CLHEP::tesla
716  << " Br(tesla)= " << (bfield[0] * cosf + bfield[1] * sinf) / CLHEP::tesla
717  << " Bphi(tesla)= " << (bfield[0] * sinf - bfield[1] * cosf) / CLHEP::tesla << G4endl;
718  z += dz;
719  }
720  r += dr;
721  }
722 
723  fout.close();
724  }
725 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Log< level::Warning, false > LogWarning
*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
Definition: invegas.h:5

◆ endRun()

void RunManagerMTWorker::endRun ( )

Definition at line 244 of file RunManagerMTWorker.cc.

References getThreadIndex(), EcalPhiSymFlatTableProducers_cfi::id, and terminateRun().

244  {
245  int id = getThreadIndex();
246  edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker::endRun for the thread " << id;
247  terminateRun();
248 }
Log< level::Info, true > LogVerbatim
int getThreadIndex() const

◆ generateEvent()

G4Event * RunManagerMTWorker::generateEvent ( const edm::Event inpevt)
private

Definition at line 641 of file RunManagerMTWorker.cc.

References RunManagerMTWorker::TLSData::currentEvent, edm::EventID::event(), runTauDisplay::evtid, edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), Generator::HepMC2G4(), edm::EventBase::id(), m_generator, m_InToken, m_LHCToken, m_LHCTransport, m_nonBeam, m_tls, Generator::nonCentralEvent2G4(), resetGenParticleId(), and Generator::setGenEvent().

Referenced by produce().

641  {
642  m_tls->currentEvent.reset();
643 
644  // 64 bits event ID in CMSSW converted into Geant4 event ID
645  G4int evtid = (G4int)inpevt.id().event();
646  G4Event* evt = new G4Event(evtid);
647 
649  inpevt.getByToken(m_InToken, HepMCEvt);
650 
651  m_generator.setGenEvent(HepMCEvt->GetEvent());
652 
653  // required to reset the GenParticle Id for particles transported
654  // along the beam pipe to their original value for SimTrack creation
655  resetGenParticleId(inpevt);
656 
657  if (!m_nonBeam) {
658  m_generator.HepMC2G4(HepMCEvt->GetEvent(), evt);
659  if (m_LHCTransport) {
661  inpevt.getByToken(m_LHCToken, LHCMCEvt);
662  m_generator.nonCentralEvent2G4(LHCMCEvt->GetEvent(), evt);
663  }
664  } else {
665  m_generator.nonCentralEvent2G4(HepMCEvt->GetEvent(), evt);
666  }
667 
668  return evt;
669 }
void nonCentralEvent2G4(const HepMC::GenEvent *g, G4Event *e)
Definition: Generator.cc:553
std::unique_ptr< G4Event > currentEvent
void HepMC2G4(const HepMC::GenEvent *g, G4Event *e)
Definition: Generator.cc:112
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:526
edm::EDGetTokenT< edm::HepMCProduct > m_InToken
edm::EDGetTokenT< edm::HepMCProduct > m_LHCToken
void resetGenParticleId(const edm::Event &inpevt)
edm::EventID id() const
Definition: EventBase.h:63
void setGenEvent(const HepMC::GenEvent *inpevt)
Definition: Generator.h:24
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
EventNumber_t event() const
Definition: EventID.h:40

◆ getSimTrackManager()

SimTrackManager * RunManagerMTWorker::getSimTrackManager ( )

Definition at line 495 of file RunManagerMTWorker.cc.

References initializeTLS(), m_tls, and RunManagerMTWorker::TLSData::trackManager.

Referenced by SimRunInterface::SimRunInterface().

495  {
496  initializeTLS();
497  return m_tls->trackManager.get();
498 }
std::unique_ptr< SimTrackManager > trackManager

◆ getThreadIndex()

int RunManagerMTWorker::getThreadIndex ( ) const
inline

Definition at line 78 of file RunManagerMTWorker.h.

References m_thread_index.

Referenced by beginRun(), endRun(), initializeG4(), initializeRun(), initializeTLS(), produce(), and terminateRun().

78 { return m_thread_index; }

◆ initializeG4()

void RunManagerMTWorker::initializeG4 ( RunManagerMT runManagerMaster,
const edm::EventSetup es 
)

Definition at line 274 of file RunManagerMTWorker.cc.

References applyOnce, applyOnceGDML, sim::attachSD(), sim::FieldBuilder::build(), RunManagerMT::catalog(), mps_check::command, DumpMagneticField(), Exception, f, g, RunManagerMT::G4Commands(), ecalTB2006H4_GenSimDigiReco_cfg::G4cout, edm::ParameterSet::getParameter(), getThreadIndex(), edm::ParameterSet::getUntrackedParameter(), DDDWorld::GetWorldVolume(), initializeTLS(), initializeUserActions(), RunManagerMT::isPhase2(), RunManagerMTWorker::TLSData::kernel, m_dumpGDML, m_dumpMF, m_evtManager, m_isPhase2, m_p, m_pField, m_pMagField, m_pUseMagneticField, m_sdMakers, m_simEvent, m_sVerbose, m_tls, m_UseG4EventManager, RunManagerMT::physicsListForWorker(), RunManagerMTWorker::TLSData::registry, RunManagerMTWorker::TLSData::sensCaloDets, RunManagerMTWorker::TLSData::sensTkDets, AlCaHLTBitMon_QueryRunRegistry::string, pfDeepBoostedJetPreprocessParams_cfi::sv, RunManagerMTWorker::TLSData::threadInitialized, RunManagerMTWorker::TLSData::trackManager, verbose, and RunManagerMT::world().

274  {
276  return;
277 
278  G4Timer timer;
279  timer.Start();
280 
281  // I guess everything initialized here should be in thread_local storage
282  initializeTLS();
283 
284  int thisID = getThreadIndex();
285  edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker::initializeG4 in thread " << thisID << " is started";
286 
287  // Initialize worker part of shared resources (geometry, physics)
288  G4WorkerThread::BuildGeometryAndPhysicsVector();
289 
290  // Create worker run manager
291  m_tls->kernel.reset(G4WorkerRunManagerKernel::GetRunManagerKernel());
292  if (nullptr == m_tls->kernel) {
293  m_tls->kernel = std::make_unique<G4WorkerRunManagerKernel>();
294  }
295 
296  // Define G4 exception handler
297  double th = m_p.getParameter<double>("ThresholdForGeometryExceptions") * CLHEP::GeV;
298  bool tr = m_p.getParameter<bool>("TraceExceptions");
299  G4StateManager::GetStateManager()->SetExceptionHandler(new ExceptionHandler(th, tr));
300 
301  // Set the geometry for the worker, share from master
302  auto worldPV = runManagerMaster->world().GetWorldVolume();
303  m_tls->kernel->WorkerDefineWorldVolume(worldPV);
304  G4TransportationManager* tM = G4TransportationManager::GetTransportationManager();
305  tM->SetWorldForTracking(worldPV);
306 
307  // we need the track manager now
308  int verbose = m_p.getParameter<int>("EventVerbose");
309  m_tls->trackManager = std::make_unique<SimTrackManager>(&m_simEvent, verbose);
310 
311  // setup the magnetic field
312  if (m_pUseMagneticField) {
313  const GlobalPoint g(0.f, 0.f, 0.f);
314 
315  sim::FieldBuilder fieldBuilder(m_pMagField, m_pField);
316 
317  CMSFieldManager* fieldManager = new CMSFieldManager();
318  tM->SetFieldManager(fieldManager);
319  fieldBuilder.build(fieldManager, tM->GetPropagatorInField());
320 
321  std::string fieldFile = m_p.getUntrackedParameter<std::string>("FileNameField", "");
322  if (!fieldFile.empty()) {
323  std::call_once(applyOnce, [this]() { m_dumpMF = true; });
324  if (m_dumpMF) {
325  edm::LogVerbatim("SimG4CoreApplication")
326  << "RunManagerMTWorker::InitializeG4: Dump magnetic field to file " << fieldFile;
327  DumpMagneticField(tM->GetFieldManager()->GetDetectorField(), fieldFile);
328  }
329  }
330  }
331 
332  // attach sensitive detector
333  auto sensDets = sim::attachSD(
334  m_sdMakers, es, runManagerMaster->catalog(), m_p, m_tls->trackManager.get(), *(m_tls->registry.get()));
335 
336  m_tls->sensTkDets = sensDets.first;
337  m_tls->sensCaloDets = sensDets.second;
338 
339  edm::LogVerbatim("SimG4CoreApplication")
340  << "RunManagerMTWorker::InitializeG4: Sensitive Detectors are built in thread " << thisID << " found "
341  << m_tls->sensTkDets.size() << " Tk type SD, and " << m_tls->sensCaloDets.size() << " Calo type SD";
342 
343  // geometry dump
344  G4String writeFile = (G4String)m_p.getUntrackedParameter<std::string>("FileNameGDML");
345  if (!writeFile.empty()) {
346  std::call_once(applyOnceGDML, [this]() { m_dumpGDML = true; });
347  edm::LogVerbatim("SimG4CoreApplication") << "DumpGDML:" << m_dumpGDML;
348  if (m_dumpGDML) {
349  G4int thID = G4Threading::G4GetThreadId();
350  edm::LogVerbatim("SimG4CoreApplication") << "ThreadID=" << thID;
351  G4Threading::G4SetThreadId(-1);
352  G4GDMLParser gdml;
353  gdml.SetRegionExport(true);
354  gdml.SetEnergyCutsExport(true);
355  gdml.SetSDExport(true);
356  gdml.Write(writeFile, worldPV, true);
357  G4Threading::G4SetThreadId(thID);
358  }
359  }
360 
361  // Enable couple transportation
362  bool scorer = m_p.getParameter<bool>("UseCommandBaseScorer");
363  if (scorer) {
364  G4ScoringManager* scManager = G4ScoringManager::GetScoringManager();
365  scManager->SetVerboseLevel(1);
366  }
367 
368  // Set the physics list for the worker, share from master
369  PhysicsList* physicsList = runManagerMaster->physicsListForWorker();
370  m_isPhase2 = runManagerMaster->isPhase2();
371 
372  edm::LogVerbatim("SimG4CoreApplication")
373  << "RunManagerMTWorker::InitializeG4: start initialisation of PhysicsList for the thread " << thisID;
374 
375  // Geant4 UI commands in PreInit state
376  if (!runManagerMaster->G4Commands().empty()) {
377  G4cout << "RunManagerMTWorker::InitializeG4: Requested UI commands: " << G4endl;
378  for (const std::string& command : runManagerMaster->G4Commands()) {
379  G4cout << " " << command << G4endl;
380  G4UImanager::GetUIpointer()->ApplyCommand(command);
381  }
382  }
383  G4StateManager::GetStateManager()->SetNewState(G4State_Init);
384 
385  physicsList->InitializeWorker();
386  m_tls->kernel->SetPhysics(physicsList);
387  m_tls->kernel->InitializePhysics();
388 
389  if (!m_tls->kernel->RunInitialization()) {
390  throw cms::Exception("Configuration")
391  << "RunManagerMTWorker::InitializeG4: Geant4 kernel initialization failed in thread " << thisID;
392  }
393 
394  //tell all interesting parties that we are beginning the job
395  BeginOfJob aBeginOfJob(&es);
396  m_tls->registry->beginOfJobSignal_(&aBeginOfJob);
397 
398  G4int sv = m_p.getUntrackedParameter<int>("SteppingVerbosity");
399 
400  if (sv > 0) {
401  G4double elim = m_p.getUntrackedParameter<double>("StepVerboseThreshold", 0.1) * CLHEP::GeV;
402  std::vector<int> ve = m_p.getUntrackedParameter<std::vector<int>>("VerboseEvents");
403  std::vector<int> vn = m_p.getUntrackedParameter<std::vector<int>>("VertexNumber");
404  std::vector<int> vt = m_p.getUntrackedParameter<std::vector<int>>("VerboseTracks");
405  m_sVerbose = std::make_unique<CMSSteppingVerbose>(sv, elim, ve, vn, vt);
406  }
407  if (!m_UseG4EventManager)
408  m_evtManager = std::make_unique<CMSSimEventManager>(m_p);
410 
411  G4StateManager::GetStateManager()->SetNewState(G4State_Idle);
412 
413  timer.Stop();
414  edm::LogVerbatim("SimG4CoreApplication")
415  << "RunManagerMTWorker::initializeG4 done for the thread " << thisID << " " << timer;
416  m_tls->threadInitialized = true;
417 }
Log< level::Info, true > LogVerbatim
static std::once_flag applyOnceGDML
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
bool verbose
std::unique_ptr< CMSSteppingVerbose > m_sVerbose
std::vector< SensitiveTkDetector * > sensTkDets
G4VPhysicalVolume * GetWorldVolume() const
Definition: DDDWorld.h:24
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
Definition: Activities.doc:4
std::unique_ptr< G4RunManagerKernel > kernel
std::unique_ptr< CMSSimEventManager > m_evtManager
T getUntrackedParameter(std::string const &, T const &) const
std::unique_ptr< SimActivityRegistry > registry
std::unique_ptr< SimTrackManager > trackManager
std::vector< SensitiveCaloDetector * > sensCaloDets
std::unordered_map< std::string, std::unique_ptr< SensitiveDetectorMakerBase > > m_sdMakers
double f[11][100]
const SensitiveDetectorCatalog & catalog() const
Definition: RunManagerMT.h:71
bool isPhase2() const
Definition: RunManagerMT.h:79
std::pair< std::vector< SensitiveTkDetector * >, std::vector< SensitiveCaloDetector * > > attachSD(const std::unordered_map< std::string, std::unique_ptr< SensitiveDetectorMakerBase >> &, const edm::EventSetup &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *, SimActivityRegistry &reg)
const DDDWorld & world() const
Definition: RunManagerMT.h:69
static std::once_flag applyOnce
edm::ParameterSet m_pField
list command
Definition: mps_check.py:25
const std::vector< std::string > & G4Commands() const
Definition: RunManagerMT.h:73
const MagneticField * m_pMagField
edm::ParameterSet m_p
void DumpMagneticField(const G4Field *, const std::string &) const
int getThreadIndex() const
PhysicsList * physicsListForWorker() const
Definition: RunManagerMT.h:77

◆ initializeRun()

void RunManagerMTWorker::initializeRun ( )
private

Definition at line 512 of file RunManagerMTWorker.cc.

References RunManagerMTWorker::TLSData::currentRun, getThreadIndex(), EcalPhiSymFlatTableProducers_cfi::id, m_tls, and RunManagerMTWorker::TLSData::userRunAction.

Referenced by produce().

512  {
513  m_tls->currentRun = new G4Run();
514  G4StateManager::GetStateManager()->SetNewState(G4State_GeomClosed);
515  if (nullptr != m_tls->userRunAction) {
516  m_tls->userRunAction->BeginOfRunAction(m_tls->currentRun);
517  }
518  int id = getThreadIndex();
519  edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker::initializeRun done for thread " << id;
520 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< RunAction > userRunAction
int getThreadIndex() const

◆ initializeTLS()

void RunManagerMTWorker::initializeTLS ( )
private

Definition at line 250 of file RunManagerMTWorker.cc.

References createWatchers(), Exception, getThreadIndex(), m_hasWatchers, m_p, m_tls, RunManagerMTWorker::TLSData::producers, RunManagerMTWorker::TLSData::registry, and RunManagerMTWorker::TLSData::watchers.

Referenced by getSimTrackManager(), initializeG4(), producers(), sensCaloDetectors(), and sensTkDetectors().

250  {
251  if (nullptr != m_tls) {
252  return;
253  }
254 
255  m_tls = new TLSData();
256  m_tls->registry = std::make_unique<SimActivityRegistry>();
257 
258  edm::Service<SimActivityRegistry> otherRegistry;
259  //Look for an outside SimActivityRegistry
260  // this is used by the visualization code
261  int thisID = getThreadIndex();
262  if (otherRegistry) {
263  m_tls->registry->connect(*otherRegistry);
264  if (thisID > 0) {
265  throw cms::Exception("Configuration")
266  << "RunManagerMTWorker::initializeTLS : "
267  << "SimActivityRegistry service (i.e. visualization) is not supported for more than 1 thread. "
268  << " \n If this use case is needed, RunManagerMTWorker has to be updated.";
269  }
270  }
272 }
std::vector< std::shared_ptr< SimWatcher > > watchers
std::unique_ptr< SimActivityRegistry > registry
std::vector< std::shared_ptr< SimProducer > > producers
static void createWatchers(const edm::ParameterSet &iP, SimActivityRegistry &iReg, std::vector< std::shared_ptr< SimWatcher >> &oWatchers, std::vector< std::shared_ptr< SimProducer >> &oProds)
edm::ParameterSet m_p
int getThreadIndex() const

◆ initializeUserActions()

void RunManagerMTWorker::initializeUserActions ( )
private

Definition at line 419 of file RunManagerMTWorker.cc.

References Connect(), dd4hep_cff::dd4hep, g4SimHits_cfi::EventAction, edm::ParameterSet::getParameter(), RunManagerMTWorker::TLSData::kernel, m_evtManager, m_hasWatchers, m_isPhase2, m_p, m_pEventAction, m_pRunAction, m_pStackingAction, m_pSteppingAction, m_pTrackingAction, m_sVerbose, m_tls, m_UseG4EventManager, RunManagerMTWorker::TLSData::runInterface, CastorDigiValidation::StackingAction, CastorDigiValidation::SteppingAction, g4SimHits_cfi::TrackingAction, RunManagerMTWorker::TLSData::trackManager, and RunManagerMTWorker::TLSData::userRunAction.

Referenced by initializeG4().

419  {
420  m_tls->runInterface = std::make_unique<SimRunInterface>(this, false);
421  m_tls->userRunAction = std::make_unique<RunAction>(m_pRunAction, m_tls->runInterface.get(), false);
422  m_tls->userRunAction->SetMaster(false);
423  Connect(m_tls->userRunAction.get());
424 
425  G4int ver = m_p.getParameter<int>("EventVerbose");
426  G4EventManager* eventManager = m_tls->kernel->GetEventManager();
427  eventManager->SetVerboseLevel(ver);
428 
429  auto userEventAction =
431  Connect(userEventAction);
432  if (m_UseG4EventManager) {
433  eventManager->SetUserAction(userEventAction);
434  } else {
435  m_evtManager->SetUserAction(userEventAction);
436  }
437 
438  auto userTrackingAction = new TrackingAction(m_tls->trackManager.get(), m_sVerbose.get(), m_pTrackingAction);
439  Connect(userTrackingAction);
440  if (m_UseG4EventManager) {
441  eventManager->SetUserAction(userTrackingAction);
442  } else {
443  m_evtManager->SetUserAction(userTrackingAction);
444  }
445 
446  // different stepping actions for Run2,3 and Phase2
447  G4UserSteppingAction* userSteppingAction;
448  bool dd4hep = m_p.getParameter<bool>("g4GeometryDD4hepSource");
449  if (m_isPhase2) {
451  Connect(ptr);
452  userSteppingAction = (G4UserSteppingAction*)ptr;
453  } else {
455  Connect(ptr);
456  userSteppingAction = (G4UserSteppingAction*)ptr;
457  }
458  if (m_UseG4EventManager) {
459  eventManager->SetUserAction(userSteppingAction);
460  } else {
461  m_evtManager->SetUserAction(userSteppingAction);
462  }
463 
464  auto userStackingAction = new StackingAction(userTrackingAction, m_pStackingAction, m_sVerbose.get());
465  if (m_UseG4EventManager) {
466  eventManager->SetUserAction(userStackingAction);
467  } else {
468  m_evtManager->SetUserAction(userStackingAction);
469  }
470 }
edm::ParameterSet m_pSteppingAction
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::unique_ptr< SimRunInterface > runInterface
std::unique_ptr< CMSSteppingVerbose > m_sVerbose
std::unique_ptr< G4RunManagerKernel > kernel
std::unique_ptr< CMSSimEventManager > m_evtManager
edm::ParameterSet m_pEventAction
std::unique_ptr< SimTrackManager > trackManager
edm::ParameterSet m_pRunAction
std::unique_ptr< RunAction > userRunAction
edm::ParameterSet m_pTrackingAction
edm::ParameterSet m_p
edm::ParameterSet m_pStackingAction
void Connect(RunAction *)

◆ produce()

TmpSimEvent * RunManagerMTWorker::produce ( const edm::Event inpevt,
const edm::EventSetup es,
RunManagerMT runManagerMaster 
)

Definition at line 552 of file RunManagerMTWorker.cc.

References cms::cuda::assert(), TmpSimEvent::clear(), TmpSimEvent::collisionPoint(), RunManagerMTWorker::TLSData::currentEvent, RunManagerMTWorker::TLSData::currentRunNumber, edm::EventID::event(), Generator::eventWeight(), Exception, generateEvent(), Generator::genEvent(), Generator::genVertex(), getThreadIndex(), edm::EventBase::id(), initializeRun(), RunManagerMTWorker::TLSData::kernel, m_evtManager, m_generator, m_simEvent, m_tls, m_UseG4EventManager, TmpSimEvent::nTracks(), edm::EventID::run(), RunManagerMTWorker::TLSData::runTerminated, edm::second(), RunManagerMTWorker::TLSData::sensCaloDets, TmpSimEvent::setHepEvent(), TmpSimEvent::setWeight(), edm::Event::streamID(), terminateRun(), RunManagerMTWorker::TLSData::threadInitialized, and TmpSimEvent::weight().

554  {
555  // We have to do the per-thread initialization, and per-thread
556  // per-run initialization here by ourselves.
557 
558  edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker::produce: start EventID=" << inpevt.id().event();
559 
560  assert(m_tls != nullptr and m_tls->threadInitialized);
561  // Initialize run
562  if (inpevt.id().run() != m_tls->currentRunNumber) {
563  edm::LogVerbatim("SimG4CoreApplication")
564  << "RunManagerMTWorker::produce: RunID= " << inpevt.id().run() << " TLS RunID= " << m_tls->currentRunNumber;
565  if (m_tls->currentRunNumber != 0 && !m_tls->runTerminated) {
566  // If previous run in this thread was not terminated via endRun() call,
567  // then terminate it now
568  terminateRun();
569  }
570  initializeRun();
571  m_tls->currentRunNumber = inpevt.id().run();
572  }
573 
574  // event and primary
575  m_tls->currentEvent.reset(generateEvent(inpevt));
576  m_simEvent.clear();
579 
580  if (m_generator.genVertex() != nullptr) {
581  auto genVertex = m_generator.genVertex();
582  m_simEvent.collisionPoint(math::XYZTLorentzVectorD(genVertex->x() / CLHEP::cm,
583  genVertex->y() / CLHEP::cm,
584  genVertex->z() / CLHEP::cm,
585  genVertex->t() / CLHEP::second));
586  }
587  if (m_tls->currentEvent->GetNumberOfPrimaryVertex() == 0) {
588  throw cms::Exception("EventCorruption")
589  << "RunManagerMTWorker::produce: event " << inpevt.id().event() << " with no G4PrimaryVertices"
590  << " StreamID=" << inpevt.streamID() << " threadIndex=" << getThreadIndex();
591 
592  } else {
593  edm::LogVerbatim("SimG4CoreApplication")
594  << "RunManagerMTWorker::produce: start EventID=" << inpevt.id().event() << " StreamID=" << inpevt.streamID()
595  << " threadIndex=" << getThreadIndex() << " weight=" << m_simEvent.weight()
596  << " Nprimary: " << m_tls->currentEvent->GetNumberOfPrimaryVertex() << " vertices and " << m_simEvent.nTracks()
597  << " particles";
598  // process event
599  if (m_UseG4EventManager) {
600  m_tls->kernel->GetEventManager()->ProcessOneEvent(m_tls->currentEvent.get());
601  } else {
602  m_evtManager->ProcessOneEvent(m_tls->currentEvent.get());
603  }
604  }
605 
606  // remove memory only needed during event processing
607  m_tls->currentEvent.reset();
608  for (auto& sd : m_tls->sensCaloDets) {
609  sd->reset();
610  }
611 
612  edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker::produce: ended Event " << inpevt.id().event();
613  return &m_simEvent;
614 }
Log< level::Info, true > LogVerbatim
void setHepEvent(const HepMC::GenEvent *r)
Definition: TmpSimEvent.h:23
virtual const HepMC::GenEvent * genEvent() const
Definition: Generator.h:30
std::unique_ptr< G4Event > currentEvent
unsigned int nTracks() const
Definition: TmpSimEvent.h:20
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
void setWeight(float w)
Definition: TmpSimEvent.h:25
void clear()
Definition: TmpSimEvent.cc:18
virtual const math::XYZTLorentzVector * genVertex() const
Definition: Generator.h:31
assert(be >=bs)
float weight() const
Definition: TmpSimEvent.h:26
std::unique_ptr< G4RunManagerKernel > kernel
std::unique_ptr< CMSSimEventManager > m_evtManager
U second(std::pair< T, U > const &p)
std::vector< SensitiveCaloDetector * > sensCaloDets
void collisionPoint(const math::XYZTLorentzVectorD &v)
Definition: TmpSimEvent.h:27
edm::EventID id() const
Definition: EventBase.h:63
StreamID streamID() const
Definition: Event.h:98
RunNumber_t run() const
Definition: EventID.h:38
G4Event * generateEvent(const edm::Event &inpevt)
virtual const double eventWeight() const
Definition: Generator.h:32
int getThreadIndex() const
EventNumber_t event() const
Definition: EventID.h:40

◆ producers()

std::vector< std::shared_ptr< SimProducer > > & RunManagerMTWorker::producers ( )

Definition at line 507 of file RunManagerMTWorker.cc.

References initializeTLS(), m_tls, and RunManagerMTWorker::TLSData::producers.

507  {
508  initializeTLS();
509  return m_tls->producers;
510 }
std::vector< std::shared_ptr< SimProducer > > producers

◆ resetGenParticleId()

void RunManagerMTWorker::resetGenParticleId ( const edm::Event inpevt)
private

Definition at line 671 of file RunManagerMTWorker.cc.

References edm::Event::getByToken(), edm::HandleBase::isValid(), m_theLHCTlinkToken, m_tls, edm::Handle< T >::product(), and RunManagerMTWorker::TLSData::trackManager.

Referenced by generateEvent().

671  {
673  inpevt.getByToken(m_theLHCTlinkToken, theLHCTlink);
674  if (theLHCTlink.isValid()) {
675  m_tls->trackManager->setLHCTransportLink(theLHCTlink.product());
676  }
677 }
T const * product() const
Definition: Handle.h:70
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:526
std::unique_ptr< SimTrackManager > trackManager
edm::EDGetTokenT< edm::LHCTransportLinkContainer > m_theLHCTlinkToken
bool isValid() const
Definition: HandleBase.h:70

◆ sensCaloDetectors()

std::vector< SensitiveCaloDetector * > & RunManagerMTWorker::sensCaloDetectors ( )

Definition at line 503 of file RunManagerMTWorker.cc.

References initializeTLS(), m_tls, and RunManagerMTWorker::TLSData::sensCaloDets.

503  {
504  initializeTLS();
505  return m_tls->sensCaloDets;
506 }
std::vector< SensitiveCaloDetector * > sensCaloDets

◆ sensTkDetectors()

std::vector< SensitiveTkDetector * > & RunManagerMTWorker::sensTkDetectors ( )

Definition at line 499 of file RunManagerMTWorker.cc.

References initializeTLS(), m_tls, and RunManagerMTWorker::TLSData::sensTkDets.

499  {
500  initializeTLS();
501  return m_tls->sensTkDets;
502 }
std::vector< SensitiveTkDetector * > sensTkDets

◆ simEvent()

TmpSimEvent* RunManagerMTWorker::simEvent ( )
inline

Definition at line 77 of file RunManagerMTWorker.h.

References m_simEvent.

Referenced by SimRunInterface::simEvent().

77 { return &m_simEvent; }

◆ terminateRun()

void RunManagerMTWorker::terminateRun ( )
private

Definition at line 522 of file RunManagerMTWorker.cc.

References applyOnceEnd, mps_check::command, RunManagerMTWorker::TLSData::currentEvent, RunManagerMTWorker::TLSData::currentRun, getThreadIndex(), EcalPhiSymFlatTableProducers_cfi::id, RunManagerMTWorker::TLSData::kernel, m_endOfRun, m_G4CommandsEndRun, m_tls, RunManagerMTWorker::TLSData::runTerminated, AlCaHLTBitMon_QueryRunRegistry::string, and RunManagerMTWorker::TLSData::userRunAction.

Referenced by abortRun(), endRun(), and produce().

522  {
523  int id = getThreadIndex();
524  edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker::terminateRun for thread " << id;
525  if (nullptr == m_tls || m_tls->runTerminated) {
526  return;
527  }
528 
529  // Geant4 UI commands after the run
530  if (!m_G4CommandsEndRun.empty()) {
531  std::call_once(applyOnceEnd, [this]() { m_endOfRun = true; });
532  if (m_endOfRun) {
533  edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker: Requested end of run UI commands: ";
534  for (const std::string& command : m_G4CommandsEndRun) {
535  edm::LogVerbatim("SimG4CoreApplication") << " " << command;
536  G4UImanager::GetUIpointer()->ApplyCommand(command);
537  }
538  }
539  }
540  if (m_tls->userRunAction) {
541  m_tls->userRunAction->EndOfRunAction(m_tls->currentRun);
542  m_tls->userRunAction.reset();
543  }
544  m_tls->currentEvent.reset();
545  if (m_tls->kernel) {
546  m_tls->kernel->RunTermination();
547  }
548  m_tls->runTerminated = true;
549  edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker::terminateRun done for thread " << id;
550 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< G4Event > currentEvent
std::vector< std::string > m_G4CommandsEndRun
std::unique_ptr< G4RunManagerKernel > kernel
static std::once_flag applyOnceEnd
std::unique_ptr< RunAction > userRunAction
list command
Definition: mps_check.py:25
int getThreadIndex() const

Member Data Documentation

◆ m_dumpGDML

bool RunManagerMTWorker::m_dumpGDML {false}
private

Definition at line 104 of file RunManagerMTWorker.h.

Referenced by initializeG4().

◆ m_dumpMF

bool RunManagerMTWorker::m_dumpMF {false}
private

Definition at line 103 of file RunManagerMTWorker.h.

Referenced by initializeG4().

◆ m_endOfRun

bool RunManagerMTWorker::m_endOfRun {false}
private

Definition at line 105 of file RunManagerMTWorker.h.

Referenced by terminateRun().

◆ m_evtManager

std::unique_ptr<CMSSimEventManager> RunManagerMTWorker::m_evtManager
private

Definition at line 125 of file RunManagerMTWorker.h.

Referenced by initializeG4(), initializeUserActions(), and produce().

◆ m_G4Commands

std::vector<std::string> RunManagerMTWorker::m_G4Commands
private

Definition at line 116 of file RunManagerMTWorker.h.

◆ m_G4CommandsEndRun

std::vector<std::string> RunManagerMTWorker::m_G4CommandsEndRun
private

Definition at line 117 of file RunManagerMTWorker.h.

Referenced by terminateRun().

◆ m_generator

Generator RunManagerMTWorker::m_generator
private

Definition at line 91 of file RunManagerMTWorker.h.

Referenced by generateEvent(), and produce().

◆ m_hasWatchers

bool RunManagerMTWorker::m_hasWatchers {false}
private

Definition at line 101 of file RunManagerMTWorker.h.

Referenced by beginRun(), initializeTLS(), and initializeUserActions().

◆ m_InToken

edm::EDGetTokenT<edm::HepMCProduct> RunManagerMTWorker::m_InToken
private

Definition at line 92 of file RunManagerMTWorker.h.

Referenced by generateEvent().

◆ m_isPhase2

bool RunManagerMTWorker::m_isPhase2 {false}
private

Definition at line 106 of file RunManagerMTWorker.h.

Referenced by initializeG4(), and initializeUserActions().

◆ m_LHCToken

edm::EDGetTokenT<edm::HepMCProduct> RunManagerMTWorker::m_LHCToken
private

Definition at line 93 of file RunManagerMTWorker.h.

Referenced by generateEvent().

◆ m_LHCTransport

bool RunManagerMTWorker::m_LHCTransport {false}
private

Definition at line 102 of file RunManagerMTWorker.h.

Referenced by generateEvent().

◆ m_MagField

edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> RunManagerMTWorker::m_MagField
private

Definition at line 95 of file RunManagerMTWorker.h.

Referenced by beginRun().

◆ m_nonBeam

bool RunManagerMTWorker::m_nonBeam {false}
private

Definition at line 98 of file RunManagerMTWorker.h.

Referenced by generateEvent().

◆ m_p

edm::ParameterSet RunManagerMTWorker::m_p
private

Definition at line 118 of file RunManagerMTWorker.h.

Referenced by initializeG4(), initializeTLS(), and initializeUserActions().

◆ m_pEventAction

edm::ParameterSet RunManagerMTWorker::m_pEventAction
private

Definition at line 112 of file RunManagerMTWorker.h.

Referenced by initializeUserActions().

◆ m_pField

edm::ParameterSet RunManagerMTWorker::m_pField
private

Definition at line 110 of file RunManagerMTWorker.h.

Referenced by initializeG4().

◆ m_pMagField

const MagneticField* RunManagerMTWorker::m_pMagField {nullptr}
private

Definition at line 96 of file RunManagerMTWorker.h.

Referenced by beginRun(), and initializeG4().

◆ m_pRunAction

edm::ParameterSet RunManagerMTWorker::m_pRunAction
private

Definition at line 111 of file RunManagerMTWorker.h.

Referenced by initializeUserActions().

◆ m_pStackingAction

edm::ParameterSet RunManagerMTWorker::m_pStackingAction
private

Definition at line 113 of file RunManagerMTWorker.h.

Referenced by initializeUserActions().

◆ m_pSteppingAction

edm::ParameterSet RunManagerMTWorker::m_pSteppingAction
private

Definition at line 115 of file RunManagerMTWorker.h.

Referenced by initializeUserActions().

◆ m_pTrackingAction

edm::ParameterSet RunManagerMTWorker::m_pTrackingAction
private

Definition at line 114 of file RunManagerMTWorker.h.

Referenced by initializeUserActions().

◆ m_pUseMagneticField

bool RunManagerMTWorker::m_pUseMagneticField {true}
private

Definition at line 100 of file RunManagerMTWorker.h.

Referenced by beginRun(), and initializeG4().

◆ m_sdMakers

std::unordered_map<std::string, std::unique_ptr<SensitiveDetectorMakerBase> > RunManagerMTWorker::m_sdMakers
private

Definition at line 127 of file RunManagerMTWorker.h.

Referenced by beginRun(), and initializeG4().

◆ m_simEvent

TmpSimEvent RunManagerMTWorker::m_simEvent
private

Definition at line 124 of file RunManagerMTWorker.h.

Referenced by initializeG4(), produce(), and simEvent().

◆ m_sVerbose

std::unique_ptr<CMSSteppingVerbose> RunManagerMTWorker::m_sVerbose
private

Definition at line 126 of file RunManagerMTWorker.h.

Referenced by initializeG4(), and initializeUserActions().

◆ m_theLHCTlinkToken

edm::EDGetTokenT<edm::LHCTransportLinkContainer> RunManagerMTWorker::m_theLHCTlinkToken
private

Definition at line 94 of file RunManagerMTWorker.h.

Referenced by resetGenParticleId().

◆ m_thread_index

const int RunManagerMTWorker::m_thread_index {-1}
private

Definition at line 108 of file RunManagerMTWorker.h.

Referenced by getThreadIndex().

◆ m_tls

TLSData* RunManagerMTWorker::m_tls {nullptr}
private

◆ m_UIsession

CustomUIsession* RunManagerMTWorker::m_UIsession {nullptr}
private

Definition at line 123 of file RunManagerMTWorker.h.

Referenced by ~RunManagerMTWorker().

◆ m_UseG4EventManager

bool RunManagerMTWorker::m_UseG4EventManager {true}
private

Definition at line 99 of file RunManagerMTWorker.h.

Referenced by initializeG4(), initializeUserActions(), and produce().