CMS 3D CMS Logo

RunManagerMTWorker.cc
Go to the documentation of this file.
12 
14 
24 
31 
36 
40 
43 
45 
47 
51 
52 #include "G4Event.hh"
53 #include "G4Run.hh"
54 #include "G4SystemOfUnits.hh"
55 #include "G4Threading.hh"
56 #include "G4UImanager.hh"
57 #include "G4WorkerThread.hh"
58 #include "G4WorkerRunManagerKernel.hh"
59 #include "G4StateManager.hh"
60 #include "G4TransportationManager.hh"
61 #include "G4Field.hh"
62 #include "G4FieldManager.hh"
63 
64 #include <atomic>
65 #include <thread>
66 #include <sstream>
67 #include <vector>
68 
69 static std::once_flag applyOnce;
70 thread_local bool RunManagerMTWorker::dumpMF = false;
71 
72 // from https://hypernews.cern.ch/HyperNews/CMS/get/edmFramework/3302/2.html
73 namespace {
74  std::atomic<int> thread_counter{0};
75 
76  int get_new_thread_index() { return thread_counter++; }
77 
78  thread_local int s_thread_index = get_new_thread_index();
79 
80  int getThreadIndex() { return s_thread_index; }
81 
82  void createWatchers(const edm::ParameterSet& iP,
83  SimActivityRegistry* iReg,
84  std::vector<std::shared_ptr<SimWatcher> >& oWatchers,
85  std::vector<std::shared_ptr<SimProducer> >& oProds) {
86  if (!iP.exists("Watchers")) {
87  return;
88  }
89 
90  std::vector<edm::ParameterSet> watchers = iP.getParameter<std::vector<edm::ParameterSet> >("Watchers");
91 
92  for (auto& watcher : watchers) {
93  std::unique_ptr<SimWatcherMakerBase> maker(
94  SimWatcherFactory::get()->create(watcher.getParameter<std::string>("type")));
95  if (maker == nullptr) {
97  << "Unable to find the requested Watcher <" << watcher.getParameter<std::string>("type");
98  }
99  std::shared_ptr<SimWatcher> watcherTemp;
100  std::shared_ptr<SimProducer> producerTemp;
101  maker->make(watcher, *(iReg), watcherTemp, producerTemp);
102  oWatchers.push_back(watcherTemp);
103  if (producerTemp) {
104  oProds.push_back(producerTemp);
105  }
106  }
107  }
108 
109  std::atomic<int> active_tlsdata{0};
110  std::atomic<bool> tls_shutdown_timeout{false};
111  std::atomic<int> n_tls_shutdown_task{0};
112 } // namespace
113 
115  std::unique_ptr<G4RunManagerKernel> kernel; //must be deleted last
116  std::unique_ptr<RunAction> userRunAction;
117  std::unique_ptr<SimRunInterface> runInterface;
118  std::unique_ptr<SimActivityRegistry> registry;
119  std::unique_ptr<SimTrackManager> trackManager;
120  std::vector<SensitiveTkDetector*> sensTkDets;
121  std::vector<SensitiveCaloDetector*> sensCaloDets;
122  std::vector<std::shared_ptr<SimWatcher> > watchers;
123  std::vector<std::shared_ptr<SimProducer> > producers;
124  //G4Run can only be deleted if there is a G4RunManager
125  // on the thread where the G4Run is being deleted,
126  // else it causes a segmentation fault
127  G4Run* currentRun = nullptr;
128  std::unique_ptr<G4Event> currentEvent;
130  bool threadInitialized = false;
131  bool runTerminated = false;
132 
133  TLSData() { ++active_tlsdata; }
134 
135  ~TLSData() { --active_tlsdata; }
136 };
137 
138 //This can not be a smart pointer since we must delete some of the members
139 // before leaving main() else we get a segmentation fault caused by accessing
140 // other 'singletons' after those singletons have been deleted. Instead we
141 // atempt to delete all TLS at RunManagerMTWorker destructor. If that fails for
142 // some reason, it is better to leak than cause a crash.
144 
146  : m_generator(iConfig.getParameter<edm::ParameterSet>("Generator")),
147  m_InToken(iC.consumes<edm::HepMCProduct>(
148  iConfig.getParameter<edm::ParameterSet>("Generator").getParameter<edm::InputTag>("HepMCProductLabel"))),
149  m_theLHCTlinkToken(
150  iC.consumes<edm::LHCTransportLinkContainer>(iConfig.getParameter<edm::InputTag>("theLHCTlinkTag"))),
151  m_nonBeam(iConfig.getParameter<bool>("NonBeamEvent")),
152  m_pUseMagneticField(iConfig.getParameter<bool>("UseMagneticField")),
153  m_EvtMgrVerbosity(iConfig.getUntrackedParameter<int>("G4EventManagerVerbosity", 0)),
154  m_pField(iConfig.getParameter<edm::ParameterSet>("MagneticField")),
155  m_pRunAction(iConfig.getParameter<edm::ParameterSet>("RunAction")),
156  m_pEventAction(iConfig.getParameter<edm::ParameterSet>("EventAction")),
157  m_pStackingAction(iConfig.getParameter<edm::ParameterSet>("StackingAction")),
158  m_pTrackingAction(iConfig.getParameter<edm::ParameterSet>("TrackingAction")),
159  m_pSteppingAction(iConfig.getParameter<edm::ParameterSet>("SteppingAction")),
160  m_pCustomUIsession(iConfig.getUntrackedParameter<edm::ParameterSet>("CustomUIsession")),
161  m_p(iConfig),
162  m_simEvent(nullptr),
163  m_sVerbose(nullptr) {
164  std::vector<edm::ParameterSet> watchers = iConfig.getParameter<std::vector<edm::ParameterSet> >("Watchers");
165  m_hasWatchers = (watchers.empty()) ? false : true;
166  initializeTLS();
167 }
168 
170  if (m_tls && !m_tls->runTerminated) {
171  terminateRun();
172  }
173 
174  ++n_tls_shutdown_task;
175  resetTLS();
176 
177  {
178  //make sure all tasks are done before continuing
179  timespec s;
180  s.tv_sec = 0;
181  s.tv_nsec = 10000;
182  while (n_tls_shutdown_task != 0) {
183  nanosleep(&s, nullptr);
184  }
185  }
186 }
187 
189  //delete m_tls;
190  m_tls = nullptr;
191 
192  if (active_tlsdata != 0 and not tls_shutdown_timeout) {
193  ++n_tls_shutdown_task;
194  //need to run tasks on each thread which has set the tls
195  auto task = edm::make_functor_task(tbb::task::allocate_root(), []() { resetTLS(); });
196  tbb::task::enqueue(*task);
197  timespec s;
198  s.tv_sec = 0;
199  s.tv_nsec = 10000;
200  //we do not want this thread to be used for a new task since it
201  // has already cleared its structures. In order to fill all TBB
202  // threads we wait for all TLSes to clear
203  int count = 0;
204  while (active_tlsdata.load() != 0 and ++count < 1000) {
205  nanosleep(&s, nullptr);
206  }
207  if (count >= 1000) {
208  tls_shutdown_timeout = true;
209  }
210  }
211  --n_tls_shutdown_task;
212 }
213 
215 
217  if (m_tls) {
218  return;
219  }
220 
221  m_tls = new TLSData();
222  m_tls->registry.reset(new SimActivityRegistry());
223 
224  edm::Service<SimActivityRegistry> otherRegistry;
225  //Look for an outside SimActivityRegistry
226  // this is used by the visualization code
227  int thisID = getThreadIndex();
228  if (otherRegistry) {
229  m_tls->registry->connect(*otherRegistry);
230  if (thisID > 0) {
232  << "SimActivityRegistry service (i.e. visualization) is not supported for more than 1 thread. "
233  << " \n If this use case is needed, RunManagerMTWorker has to be updated.";
234  }
235  }
236  if (m_hasWatchers) {
238  }
239 }
240 
242  // I guess everything initialized here should be in thread_local storage
243  initializeTLS();
244 
245  int thisID = getThreadIndex();
246 
247  edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker::initializeThread " << thisID;
248 
249  // Initialize per-thread output
250  G4Threading::G4SetThreadId(thisID);
251  G4UImanager::GetUIpointer()->SetUpForAThread(thisID);
252  const std::string& uitype = m_pCustomUIsession.getUntrackedParameter<std::string>("Type", "MessageLogger");
253  if (uitype == "MessageLogger") {
254  new CustomUIsession();
255  } else if (uitype == "MessageLoggerThreadPrefix") {
257  } else if (uitype == "FilePerThread") {
259  } else {
261  << "Invalid value of CustomUIsession.Type '" << uitype
262  << "', valid are MessageLogger, MessageLoggerThreadPrefix, FilePerThread";
263  }
264 
265  // Initialize worker part of shared resources (geometry, physics)
266  G4WorkerThread::BuildGeometryAndPhysicsVector();
267 
268  // Create worker run manager
269  m_tls->kernel.reset(G4WorkerRunManagerKernel::GetRunManagerKernel());
270  if (!m_tls->kernel) {
271  m_tls->kernel.reset(new G4WorkerRunManagerKernel());
272  }
273 
274  // Define G4 exception handler
275  G4StateManager::GetStateManager()->SetExceptionHandler(new ExceptionHandler());
276 
277  // Set the geometry for the worker, share from master
278  auto worldPV = runManagerMaster.world().GetWorldVolume();
279  m_tls->kernel->WorkerDefineWorldVolume(worldPV);
280  G4TransportationManager* tM = G4TransportationManager::GetTransportationManager();
281  tM->SetWorldForTracking(worldPV);
282 
283  // we need the track manager now
284  m_tls->trackManager.reset(new SimTrackManager());
285 
286  // setup the magnetic field
287  if (m_pUseMagneticField) {
288  const GlobalPoint g(0., 0., 0.);
289 
291  es.get<IdealMagneticFieldRecord>().get(pMF);
292 
293  sim::FieldBuilder fieldBuilder(pMF.product(), m_pField);
294  CMSFieldManager* fieldManager = new CMSFieldManager();
295  tM->SetFieldManager(fieldManager);
296  fieldBuilder.build(fieldManager, tM->GetPropagatorInField());
297 
298  std::string fieldFile = m_p.getUntrackedParameter<std::string>("FileNameField", "");
299  if (!fieldFile.empty()) {
300  std::call_once(applyOnce, []() { dumpMF = true; });
301  if (dumpMF) {
302  edm::LogVerbatim("SimG4CoreApplication") << " RunManagerMTWorker: Dump magnetic field to file " << fieldFile;
303  DumpMagneticField(tM->GetFieldManager()->GetDetectorField(), fieldFile);
304  }
305  }
306  }
307 
308  // attach sensitive detector
309  AttachSD attach;
310  auto sensDets =
311  attach.create(es, runManagerMaster.catalog(), m_p, m_tls->trackManager.get(), *(m_tls->registry.get()));
312 
313  m_tls->sensTkDets.swap(sensDets.first);
314  m_tls->sensCaloDets.swap(sensDets.second);
315 
316  edm::LogVerbatim("SimG4CoreApplication")
317  << " RunManagerMTWorker: Sensitive Detector building finished; found " << m_tls->sensTkDets.size()
318  << " Tk type Producers, and " << m_tls->sensCaloDets.size() << " Calo type producers ";
319 
320  // Set the physics list for the worker, share from master
321  PhysicsList* physicsList = runManagerMaster.physicsListForWorker();
322 
323  edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker: start initialisation of PhysicsList for the thread";
324 
325  // Geant4 UI commands in PreInit state
326  if (!runManagerMaster.G4Commands().empty()) {
327  G4cout << "RunManagerMTWorker: Requested UI commands: " << G4endl;
328  for (const std::string& command : runManagerMaster.G4Commands()) {
329  G4cout << " " << command << G4endl;
330  G4UImanager::GetUIpointer()->ApplyCommand(command);
331  }
332  }
333  G4StateManager::GetStateManager()->SetNewState(G4State_Init);
334 
335  physicsList->InitializeWorker();
336  m_tls->kernel->SetPhysics(physicsList);
337  m_tls->kernel->InitializePhysics();
338 
339  const bool kernelInit = m_tls->kernel->RunInitialization();
340  if (!kernelInit) {
341  throw edm::Exception(edm::errors::Configuration) << "RunManagerMTWorker: Geant4 kernel initialization failed";
342  }
343  //tell all interesting parties that we are beginning the job
344  BeginOfJob aBeginOfJob(&es);
345  m_tls->registry->beginOfJobSignal_(&aBeginOfJob);
346 
347  G4int sv = m_p.getUntrackedParameter<int>("SteppingVerbosity", 0);
348  G4double elim = m_p.getUntrackedParameter<double>("StepVerboseThreshold", 0.1) * CLHEP::GeV;
349  std::vector<int> ve = m_p.getUntrackedParameter<std::vector<int> >("VerboseEvents");
350  std::vector<int> vn = m_p.getUntrackedParameter<std::vector<int> >("VertexNumber");
351  std::vector<int> vt = m_p.getUntrackedParameter<std::vector<int> >("VerboseTracks");
352 
353  if (sv > 0) {
354  m_sVerbose.reset(new CMSSteppingVerbose(sv, elim, ve, vn, vt));
355  }
357 
358  edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker::initializeThread done for the thread " << thisID;
359 
360  G4StateManager::GetStateManager()->SetNewState(G4State_Idle);
361 }
362 
364  m_tls->runInterface.reset(new SimRunInterface(this, false));
365  m_tls->userRunAction.reset(new RunAction(m_pRunAction, m_tls->runInterface.get(), false));
366  m_tls->userRunAction->SetMaster(false);
367  Connect(m_tls->userRunAction.get());
368 
369  G4EventManager* eventManager = m_tls->kernel->GetEventManager();
370  eventManager->SetVerboseLevel(m_EvtMgrVerbosity);
371 
372  EventAction* userEventAction =
374  Connect(userEventAction);
375  eventManager->SetUserAction(userEventAction);
376 
377  TrackingAction* userTrackingAction = new TrackingAction(userEventAction, m_pTrackingAction, m_sVerbose.get());
378  Connect(userTrackingAction);
379  eventManager->SetUserAction(userTrackingAction);
380 
381  SteppingAction* userSteppingAction =
382  new SteppingAction(userEventAction, m_pSteppingAction, m_sVerbose.get(), m_hasWatchers);
383  Connect(userSteppingAction);
384  eventManager->SetUserAction(userSteppingAction);
385 
386  eventManager->SetUserAction(new StackingAction(userTrackingAction, m_pStackingAction, m_sVerbose.get()));
387 }
388 
390  runAction->m_beginOfRunSignal.connect(m_tls->registry->beginOfRunSignal_);
391  runAction->m_endOfRunSignal.connect(m_tls->registry->endOfRunSignal_);
392 }
393 
395  eventAction->m_beginOfEventSignal.connect(m_tls->registry->beginOfEventSignal_);
396  eventAction->m_endOfEventSignal.connect(m_tls->registry->endOfEventSignal_);
397 }
398 
400  trackingAction->m_beginOfTrackSignal.connect(m_tls->registry->beginOfTrackSignal_);
401  trackingAction->m_endOfTrackSignal.connect(m_tls->registry->endOfTrackSignal_);
402 }
403 
405  steppingAction->m_g4StepSignal.connect(m_tls->registry->g4StepSignal_);
406 }
407 
409  initializeTLS();
410  return m_tls->trackManager.get();
411 }
412 std::vector<SensitiveTkDetector*>& RunManagerMTWorker::sensTkDetectors() {
413  initializeTLS();
414  return m_tls->sensTkDets;
415 }
416 std::vector<SensitiveCaloDetector*>& RunManagerMTWorker::sensCaloDetectors() {
417  initializeTLS();
418  return m_tls->sensCaloDets;
419 }
420 std::vector<std::shared_ptr<SimProducer> >& RunManagerMTWorker::producers() {
421  initializeTLS();
422  return m_tls->producers;
423 }
424 
426  m_tls->currentRun = new G4Run();
427  G4StateManager::GetStateManager()->SetNewState(G4State_GeomClosed);
428  if (m_tls->userRunAction) {
429  m_tls->userRunAction->BeginOfRunAction(m_tls->currentRun);
430  }
431 }
432 
434  if (!m_tls || m_tls->runTerminated) {
435  return;
436  }
437  if (m_tls->userRunAction) {
438  m_tls->userRunAction->EndOfRunAction(m_tls->currentRun);
439  m_tls->userRunAction.reset();
440  }
441  m_tls->currentEvent.reset();
442  m_simEvent = nullptr;
443 
444  if (m_tls->kernel) {
445  m_tls->kernel->RunTermination();
446  }
447 
448  m_tls->runTerminated = true;
449 }
450 
451 std::unique_ptr<G4SimEvent> RunManagerMTWorker::produce(const edm::Event& inpevt,
452  const edm::EventSetup& es,
453  RunManagerMT& runManagerMaster) {
454  // The initialization and begin/end run is a bit convoluted due to
455  // - Geant4 deals per-thread
456  // - OscarMTProducer deals per-stream
457  // and framework/TBB is free to schedule work in streams to the
458  // threads as it likes.
459  //
460  // We have to do the per-thread initialization, and per-thread
461  // per-run initialization here by ourselves.
462 
463  if (!(m_tls && m_tls->threadInitialized)) {
464  LogDebug("SimG4CoreApplication") << "RunManagerMTWorker::produce(): stream " << inpevt.streamID() << " thread "
465  << getThreadIndex() << " initializing";
466  initializeThread(runManagerMaster, es);
467  m_tls->threadInitialized = true;
468  }
469  // Initialize run
470  if (inpevt.id().run() != m_tls->currentRunNumber) {
471  if (m_tls->currentRunNumber != 0 && !m_tls->runTerminated) {
472  // If previous run in this thread was not terminated via endRun() call, terminate it now
473  terminateRun();
474  }
475  initializeRun();
476  m_tls->currentRunNumber = inpevt.id().run();
477  }
478  m_tls->runInterface->setRunManagerMTWorker(this); // For UserActions
479 
480  m_tls->currentEvent.reset(generateEvent(inpevt));
481 
482  auto simEvent = std::make_unique<G4SimEvent>();
483  m_simEvent = simEvent.get();
486  if (m_generator.genVertex() != nullptr) {
487  auto genVertex = m_generator.genVertex();
488  m_simEvent->collisionPoint(math::XYZTLorentzVectorD(genVertex->x() / CLHEP::cm,
489  genVertex->y() / CLHEP::cm,
490  genVertex->z() / CLHEP::cm,
491  genVertex->t() / CLHEP::second));
492  }
493  if (m_tls->currentEvent->GetNumberOfPrimaryVertex() == 0) {
494  std::stringstream ss;
495  ss << "RunManagerMTWorker::produce(): event " << inpevt.id().event() << " with no G4PrimaryVertices \n";
496  throw SimG4Exception(ss.str());
497 
498  } else {
499  if (!m_tls->kernel) {
500  std::stringstream ss;
501  ss << " RunManagerMT::produce(): "
502  << " no G4WorkerRunManagerKernel yet for thread index" << getThreadIndex() << ", id " << std::hex
503  << std::this_thread::get_id() << " \n";
504  throw SimG4Exception(ss.str());
505  }
506 
507  edm::LogVerbatim("SimG4CoreApplication")
508  << " RunManagerMTWorker::produce: start Event " << inpevt.id().event() << " stream id " << inpevt.streamID()
509  << " thread index " << getThreadIndex() << " of weight " << m_simEvent->weight() << " with "
510  << m_simEvent->nTracks() << " tracks and " << m_simEvent->nVertices() << " vertices, generated by "
511  << m_simEvent->nGenParts() << " particles ";
512 
513  m_tls->kernel->GetEventManager()->ProcessOneEvent(m_tls->currentEvent.get());
514 
515  edm::LogVerbatim("SimG4CoreApplication") << " RunManagerMTWorker::produce: ended Event " << inpevt.id().event();
516  }
517 
518  //remove memory only needed during event processing
519  m_tls->currentEvent.reset();
520 
521  for (auto& sd : m_tls->sensCaloDets) {
522  sd->reset();
523  }
524 
525  m_simEvent = nullptr;
526  return simEvent;
527 }
528 
530  if (m_tls->runTerminated) {
531  return;
532  }
533  G4Track* t = m_tls->kernel->GetEventManager()->GetTrackingManager()->GetTrack();
534  t->SetTrackStatus(fStopAndKill);
535 
536  // CMS-specific act
537  //
538  TrackingAction* uta = static_cast<TrackingAction*>(m_tls->kernel->GetEventManager()->GetUserTrackingAction());
540 
541  m_tls->currentEvent->SetEventAborted();
542  m_tls->kernel->GetEventManager()->GetStackManager()->clear();
543  m_tls->kernel->GetEventManager()->GetTrackingManager()->EventAborted();
544 }
545 
546 void RunManagerMTWorker::abortRun(bool softAbort) {
547  if (!softAbort) {
548  abortEvent();
549  }
550  m_tls->currentRun = nullptr;
551  terminateRun();
552 }
553 
555  m_tls->currentEvent.reset();
556  m_simEvent = nullptr;
557 
558  // 64 bits event ID in CMSSW converted into Geant4 event ID
559  G4int evtid = (G4int)inpevt.id().event();
560  G4Event* evt = new G4Event(evtid);
561 
563 
564  inpevt.getByToken(m_InToken, HepMCEvt);
565 
566  m_generator.setGenEvent(HepMCEvt->GetEvent());
567 
568  // required to reset the GenParticle Id for particles transported
569  // along the beam pipe
570  // to their original value for SimTrack creation
571  resetGenParticleId(inpevt);
572 
573  if (!m_nonBeam) {
574  m_generator.HepMC2G4(HepMCEvt->GetEvent(), evt);
575  } else {
576  m_generator.nonBeamEvent2G4(HepMCEvt->GetEvent(), evt);
577  }
578 
579  return evt;
580 }
581 
584  inpevt.getByToken(m_theLHCTlinkToken, theLHCTlink);
585  if (theLHCTlink.isValid()) {
586  m_tls->trackManager->setLHCTransportLink(theLHCTlink.product());
587  }
588 }
589 
590 void RunManagerMTWorker::DumpMagneticField(const G4Field* field, const std::string& file) const {
591  std::ofstream fout(file.c_str(), std::ios::out);
592  if (fout.fail()) {
593  edm::LogWarning("SimG4CoreApplication")
594  << " RunManager WARNING : error opening file <" << file << "> for magnetic field";
595  } else {
596  // CMS magnetic field volume
597  double rmax = 9000 * mm;
598  double zmax = 24000 * mm;
599 
600  double dr = 1 * cm;
601  double dz = 5 * cm;
602 
603  int nr = (int)(rmax / dr);
604  int nz = 2 * (int)(zmax / dz);
605 
606  double r = 0.0;
607  double z0 = -zmax;
608  double z;
609 
610  double phi = 0.0;
611  double cosf = cos(phi);
612  double sinf = sin(phi);
613 
614  double point[4] = {0.0, 0.0, 0.0, 0.0};
615  double bfield[3] = {0.0, 0.0, 0.0};
616 
617  fout << std::setprecision(6);
618  for (int i = 0; i <= nr; ++i) {
619  z = z0;
620  for (int j = 0; j <= nz; ++j) {
621  point[0] = r * cosf;
622  point[1] = r * sinf;
623  point[2] = z;
624  field->GetFieldValue(point, bfield);
625  fout << "R(mm)= " << r / mm << " phi(deg)= " << phi / degree << " Z(mm)= " << z / mm
626  << " Bz(tesla)= " << bfield[2] / tesla << " Br(tesla)= " << (bfield[0] * cosf + bfield[1] * sinf) / tesla
627  << " Bphi(tesla)= " << (bfield[0] * sinf - bfield[1] * cosf) / tesla << G4endl;
628  z += dz;
629  }
630  r += dr;
631  }
632 
633  fout.close();
634  }
635 }
Generator::eventWeight
virtual const double eventWeight() const
Definition: Generator.h:32
FieldBuilder.h
G4SimEvent::hepEvent
void hepEvent(const HepMC::GenEvent *r)
Definition: G4SimEvent.h:23
RunManagerMTWorker::m_theLHCTlinkToken
edm::EDGetTokenT< edm::LHCTransportLinkContainer > m_theLHCTlinkToken
Definition: RunManagerMTWorker.h:84
RunManagerMTWorker::m_tls
static thread_local TLSData * m_tls
Definition: RunManagerMTWorker.h:100
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
RunManagerMTWorker::sensTkDetectors
std::vector< SensitiveTkDetector * > & sensTkDetectors()
Definition: RunManagerMTWorker.cc:412
SimTrackManager
Definition: SimTrackManager.h:35
Handle.h
RunManagerMTWorker::TLSData::trackManager
std::unique_ptr< SimTrackManager > trackManager
Definition: RunManagerMTWorker.cc:119
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
RunAction.h
TrackingAction.h
RunManagerMTWorker::abortRun
void abortRun(bool softAbort=false)
Definition: RunManagerMTWorker.cc:546
edm::LHCTransportLinkContainer
std::vector< LHCTransportLink > LHCTransportLinkContainer
Definition: LHCTransportLinkContainer.h:8
Generator::nonBeamEvent2G4
void nonBeamEvent2G4(const HepMC::GenEvent *g, G4Event *e)
Definition: Generator.cc:527
ESTransientHandle.h
MessageLogger.h
SteppingAction.h
EventAction
Definition: EventAction.h:23
RunManagerMTWorker::m_simEvent
G4SimEvent * m_simEvent
Definition: RunManagerMTWorker.h:104
SensitiveCaloDetector.h
CustomUIsessionThreadPrefix
Definition: CustomUIsessionThreadPrefix.h:13
edm::Handle::product
T const * product() const
Definition: Handle.h:70
RunManagerMTWorker::TLSData::producers
std::vector< std::shared_ptr< SimProducer > > producers
Definition: RunManagerMTWorker.cc:123
ExceptionHandler
Definition: ExceptionHandler.h:19
G4SimEvent::nVertices
unsigned int nVertices() const
Definition: G4SimEvent.h:21
ESHandle.h
BeginOfJob.h
EventAction::m_beginOfEventSignal
SimActivityRegistry::BeginOfEventSignal m_beginOfEventSignal
Definition: EventAction.h:43
EventAction::m_endOfEventSignal
SimActivityRegistry::EndOfEventSignal m_endOfEventSignal
Definition: EventAction.h:44
runTauDisplay.evtid
evtid
Definition: runTauDisplay.py:293
RunManagerMTWorker::TLSData::watchers
std::vector< std::shared_ptr< SimWatcher > > watchers
Definition: RunManagerMTWorker.cc:122
RunManagerMTWorker::resetTLS
static void resetTLS()
Definition: RunManagerMTWorker.cc:188
CMSFieldManager.h
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackingAction::PostUserTrackingAction
void PostUserTrackingAction(const G4Track *aTrack) override
Definition: TrackingAction.cc:43
math::XYZTLorentzVectorD
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
SimG4Exception
Definition: SimG4Exception.h:13
Generator::genVertex
virtual const math::XYZTLorentzVector * genVertex() const
Definition: Generator.h:31
CMSFieldManager
Definition: CMSFieldManager.h:24
RunManagerMTWorker.h
FunctorTask.h
RunManagerMTWorker::m_generator
Generator m_generator
Definition: RunManagerMTWorker.h:82
edm::make_functor_task
FunctorTask< F > * make_functor_task(ALLOC &&iAlloc, F f)
Definition: FunctorTask.h:47
RunManagerMTWorker::abortEvent
void abortEvent()
Definition: RunManagerMTWorker.cc:529
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
EventAction.h
SteppingAction
Definition: SteppingAction.h:30
RunManagerMTWorker::simEvent
G4SimEvent * simEvent()
Definition: RunManagerMTWorker.h:55
CMSSteppingVerbose
Definition: CMSSteppingVerbose.h:25
RunManagerMTWorker::m_pEventAction
edm::ParameterSet m_pEventAction
Definition: RunManagerMTWorker.h:93
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
RunManagerMTWorker::Connect
void Connect(RunAction *)
Definition: RunManagerMTWorker.cc:389
AttachSD::create
std::pair< std::vector< SensitiveTkDetector * >, std::vector< SensitiveCaloDetector * > > create(const edm::EventSetup &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *, SimActivityRegistry &reg) const
Definition: AttachSD.cc:15
RunManagerMTWorker::m_EvtMgrVerbosity
int m_EvtMgrVerbosity
Definition: RunManagerMTWorker.h:89
beamerCreator.create
def create(alignables, pedeDump, additionalData, outputFile, config)
Definition: beamerCreator.py:44
CastorDigiValidation.StackingAction
StackingAction
Definition: CastorDigiValidation.py:136
mps_check.command
list command
Definition: mps_check.py:25
RunManagerMTWorker::m_pCustomUIsession
edm::ParameterSet m_pCustomUIsession
Definition: RunManagerMTWorker.h:97
edm::Handle< edm::HepMCProduct >
createWatchers
static void createWatchers(const edm::ParameterSet &iP, SimActivityRegistry &iReg, std::vector< std::shared_ptr< SimWatcher > > &oWatchers, std::vector< std::shared_ptr< SimProducer > > &oProds)
Definition: RunManager.cc:89
RunAction::m_beginOfRunSignal
SimActivityRegistry::BeginOfRunSignal m_beginOfRunSignal
Definition: RunAction.h:23
RunManagerMTWorker::GetSimTrackManager
SimTrackManager * GetSimTrackManager()
Definition: RunManagerMTWorker.cc:408
RunManagerMTWorker::~RunManagerMTWorker
~RunManagerMTWorker()
Definition: RunManagerMTWorker.cc:169
RunManagerMTWorker::sensCaloDetectors
std::vector< SensitiveCaloDetector * > & sensCaloDetectors()
Definition: RunManagerMTWorker.cc:416
SensitiveTkDetector.h
DDDWorld.h
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
g4SimHits_cfi.RunAction
RunAction
list of unwanted particles (gluons and quarks)
Definition: g4SimHits_cfi.py:211
SimActivityRegistry.h
G4SimEvent::nTracks
unsigned int nTracks() const
Definition: G4SimEvent.h:20
RunManagerMTWorker::TLSData::sensCaloDets
std::vector< SensitiveCaloDetector * > sensCaloDets
Definition: RunManagerMTWorker.cc:121
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
RunManagerMT::catalog
const SensitiveDetectorCatalog & catalog() const
Definition: RunManagerMT.h:77
TrackingAction
Definition: TrackingAction.h:16
RunManagerMTWorker::m_p
edm::ParameterSet m_p
Definition: RunManagerMTWorker.h:98
RunManagerMTWorker::initializeThread
void initializeThread(RunManagerMT &runManagerMaster, const edm::EventSetup &es)
Definition: RunManagerMTWorker.cc:241
alignCSCRings.s
s
Definition: alignCSCRings.py:92
RunManagerMTWorker::initializeUserActions
void initializeUserActions()
Definition: RunManagerMTWorker.cc:363
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
RunManagerMTWorker::m_hasWatchers
bool m_hasWatchers
Definition: RunManagerMTWorker.h:88
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
RunManagerMTWorker::TLSData::currentRun
G4Run * currentRun
Definition: RunManagerMTWorker.cc:127
SiStripMonitorCluster_cfi.zmax
zmax
Definition: SiStripMonitorCluster_cfi.py:201
g4SimHits_cfi.CustomUIsession
CustomUIsession
Definition: g4SimHits_cfi.py:84
RunManagerMTWorker::TLSData::currentEvent
std::unique_ptr< G4Event > currentEvent
Definition: RunManagerMTWorker.cc:128
Service.h
TrackValidation_cff.task
task
Definition: TrackValidation_cff.py:252
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:226
DDAxes::z
RunManagerMT::world
const DDDWorld & world() const
Definition: RunManagerMT.h:75
IdealMagneticFieldRecord.h
edm::ESHandle< MagneticField >
TrackingAction::m_endOfTrackSignal
SimActivityRegistry::EndOfTrackSignal m_endOfTrackSignal
Definition: TrackingAction.h:29
Generator::setGenEvent
void setGenEvent(const HepMC::GenEvent *inpevt)
Definition: Generator.h:24
CustomUIsessionToFile
Definition: CustomUIsessionToFile.h:19
CustomUIsession.h
RunManagerMTWorker::DumpMagneticField
void DumpMagneticField(const G4Field *, const std::string &) const
Definition: RunManagerMTWorker.cc:590
G4SimEvent::nGenParts
unsigned int nGenParts() const
Definition: G4SimEvent.h:22
BeginOfJob
Definition: BeginOfJob.h:8
RunManagerMTWorker::m_pStackingAction
edm::ParameterSet m_pStackingAction
Definition: RunManagerMTWorker.h:94
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
PhysicsList
Definition: PhysicsList.h:7
HLTMuonOfflineAnalyzer_cfi.z0
z0
Definition: HLTMuonOfflineAnalyzer_cfi.py:98
Point3DBase< float, GlobalTag >
OrderedSet.t
t
Definition: OrderedSet.py:90
edm::EventID::run
RunNumber_t run() const
Definition: EventID.h:38
g4SimHits_cfi.EventAction
EventAction
Definition: g4SimHits_cfi.py:214
sim_act::Signaler::connect
void connect(Observer< const T * > *iObs)
does not take ownership of memory
Definition: Signaler.h:55
g4SimHits_cfi.TrackingAction
TrackingAction
Definition: g4SimHits_cfi.py:255
RunManagerMTWorker::initializeRun
void initializeRun()
Definition: RunManagerMTWorker.cc:425
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:674
RunManagerMTWorker::generateEvent
G4Event * generateEvent(const edm::Event &inpevt)
Definition: RunManagerMTWorker.cc:554
SimG4Exception.h
RunManagerMT
Definition: RunManagerMT.h:55
RunManagerMTWorker::m_pSteppingAction
edm::ParameterSet m_pSteppingAction
Definition: RunManagerMTWorker.h:96
RunManagerMTWorker::terminateRun
void terminateRun()
Definition: RunManagerMTWorker.cc:433
RunAction
Definition: RunAction.h:15
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
RunManagerMTWorker::TLSData::kernel
std::unique_ptr< G4RunManagerKernel > kernel
Definition: RunManagerMTWorker.cc:115
edm::ParameterSet
Definition: ParameterSet.h:36
EgHLTOffHistBins_cfi.nr
nr
Definition: EgHLTOffHistBins_cfi.py:4
RunManagerMTWorker::m_pField
edm::ParameterSet m_pField
Definition: RunManagerMTWorker.h:91
DDDWorld::GetWorldVolume
G4VPhysicalVolume * GetWorldVolume() const
Definition: DDDWorld.h:24
Event.h
ParameterSet
Definition: Functions.h:16
RunManagerMT.h
RunManagerMTWorker::TLSData::runTerminated
bool runTerminated
Definition: RunManagerMTWorker.cc:131
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
SimWatcherFactory.h
G4SimEvent.h
GeV
const double GeV
Definition: MathUtil.h:16
thread_safety_macros.h
StackingAction.h
groupFilesInBlocks.fout
fout
Definition: groupFilesInBlocks.py:162
RunManagerMTWorker::TLSData::runInterface
std::unique_ptr< SimRunInterface > runInterface
Definition: RunManagerMTWorker.cc:117
edm::EventID::event
EventNumber_t event() const
Definition: EventID.h:40
edm::Service
Definition: Service.h:30
createfilelist.int
int
Definition: createfilelist.py:10
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
RunManagerMT::G4Commands
const std::vector< std::string > & G4Commands() const
Definition: RunManagerMT.h:79
RunManagerMTWorker::m_nonBeam
bool m_nonBeam
Definition: RunManagerMTWorker.h:86
edm::LogVerbatim
Definition: MessageLogger.h:297
RunManagerMTWorker::TLSData::threadInitialized
bool threadInitialized
Definition: RunManagerMTWorker.cc:130
RunManagerMTWorker::produce
std::unique_ptr< G4SimEvent > produce(const edm::Event &inpevt, const edm::EventSetup &es, RunManagerMT &runManagerMaster)
Definition: RunManagerMTWorker.cc:451
IdealGeometryRecord.h
MagneticField.h
RunManagerMTWorker::m_sVerbose
std::unique_ptr< CMSSteppingVerbose > m_sVerbose
Definition: RunManagerMTWorker.h:105
edm::EventSetup
Definition: EventSetup.h:57
CastorDigiValidation.SteppingAction
SteppingAction
Definition: CastorDigiValidation.py:147
RunManagerMTWorker::TLSData::~TLSData
~TLSData()
Definition: RunManagerMTWorker.cc:135
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
RunManagerMTWorker::endRun
void endRun()
Definition: RunManagerMTWorker.cc:214
get
#define get
RunManagerMTWorker::resetGenParticleId
void resetGenParticleId(const edm::Event &inpevt)
Definition: RunManagerMTWorker.cc:582
CustomUIsessionToFile.h
G4SimEvent::collisionPoint
void collisionPoint(const math::XYZTLorentzVectorD &v)
Definition: G4SimEvent.h:27
AttachSD.h
TrackingAction::m_beginOfTrackSignal
SimActivityRegistry::BeginOfTrackSignal m_beginOfTrackSignal
Definition: TrackingAction.h:28
alignCSCRings.r
r
Definition: alignCSCRings.py:93
RunAction::m_endOfRunSignal
SimActivityRegistry::EndOfRunSignal m_endOfRunSignal
Definition: RunAction.h:24
DDAxes::phi
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
edm::Event::streamID
StreamID streamID() const
Definition: Event.h:97
SteppingAction::m_g4StepSignal
SimActivityRegistry::G4StepSignal m_g4StepSignal
Definition: SteppingAction.h:37
ExceptionHandler.h
SimActivityRegistry
Definition: SimActivityRegistry.h:43
CMSSteppingVerbose.h
RunManagerMT::physicsListForWorker
PhysicsList * physicsListForWorker() const
Definition: RunManagerMT.h:84
SimRunInterface.h
PVValHelper::dz
Definition: PVValidationHelpers.h:50
RunManagerMTWorker::m_InToken
edm::EDGetTokenT< edm::HepMCProduct > m_InToken
Definition: RunManagerMTWorker.h:83
RunManagerMTWorker::TLSData::TLSData
TLSData()
Definition: RunManagerMTWorker.cc:133
RunManagerMTWorker::TLSData::registry
std::unique_ptr< SimActivityRegistry > registry
Definition: RunManagerMTWorker.cc:118
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
Exception
Definition: hltDiff.cc:246
applyOnce
static std::once_flag applyOnce
Definition: RunManagerMTWorker.cc:69
edm::EventBase::id
edm::EventID id() const
Definition: EventBase.h:59
CustomUIsessionThreadPrefix.h
G4SimEvent::weight
void weight(float w)
Definition: G4SimEvent.h:25
RunManagerMTWorker::TLSData
Definition: RunManagerMTWorker.cc:114
EventSetup.h
RunManagerMTWorker::producers
std::vector< std::shared_ptr< SimProducer > > & producers()
Definition: RunManagerMTWorker.cc:420
RunManagerMTWorker::RunManagerMTWorker
RunManagerMTWorker(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&i)
Definition: RunManagerMTWorker.cc:145
sd
double sd
Definition: CascadeWrapper.h:113
Generator::HepMC2G4
void HepMC2G4(const HepMC::GenEvent *g, G4Event *e)
Definition: Generator.cc:101
RunManagerMTWorker::TLSData::userRunAction
std::unique_ptr< RunAction > userRunAction
Definition: RunManagerMTWorker.cc:116
AttachSD
Definition: AttachSD.h:17
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
HepMCProduct
RunManagerMTWorker::TLSData::sensTkDets
std::vector< SensitiveTkDetector * > sensTkDets
Definition: RunManagerMTWorker.cc:120
RunManagerMTWorker::initializeTLS
void initializeTLS()
Definition: RunManagerMTWorker.cc:216
ConsumesCollector.h
ParameterSet.h
RunManagerMTWorker::m_pTrackingAction
edm::ParameterSet m_pTrackingAction
Definition: RunManagerMTWorker.h:95
Generator::genEvent
virtual const HepMC::GenEvent * genEvent() const
Definition: Generator.h:30
RunManagerMTWorker::dumpMF
static thread_local bool dumpMF
Definition: RunManagerMTWorker.h:102
HepMCProduct.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
ecalTB2006H4_GenSimDigiReco_cfg.G4cout
G4cout
Definition: ecalTB2006H4_GenSimDigiReco_cfg.py:303
point
*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
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
edm::errors::Configuration
Definition: EDMException.h:36
RunManagerMTWorker::m_pUseMagneticField
bool m_pUseMagneticField
Definition: RunManagerMTWorker.h:87
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
RunManagerMTWorker::TLSData::currentRunNumber
edm::RunNumber_t currentRunNumber
Definition: RunManagerMTWorker.cc:129
PhysicsList.h
g
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
RunManagerMTWorker::m_pRunAction
edm::ParameterSet m_pRunAction
Definition: RunManagerMTWorker.h:92
sim::FieldBuilder
Definition: FieldBuilder.h:15
SimRunInterface
Definition: SimRunInterface.h:18