CMS 3D CMS Logo

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