CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
OscarMTProducer Class Reference
Inheritance diagram for OscarMTProducer:
edm::stream::EDProducer< edm::GlobalCache< OscarMTMasterThread >, edm::RunCache< int > >

Public Types

typedef std::vector< std::shared_ptr< SimProducer > > Producers
 
- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< OscarMTMasterThread >, edm::RunCache< int > >
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Public Member Functions

void beginRun (const edm::Run &r, const edm::EventSetup &c) override
 
void endRun (const edm::Run &r, const edm::EventSetup &c) override
 
 OscarMTProducer (edm::ParameterSet const &p, const OscarMTMasterThread *)
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 
 ~OscarMTProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< OscarMTMasterThread >, edm::RunCache< int > >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static std::shared_ptr< int > globalBeginRun (const edm::Run &iRun, const edm::EventSetup &iSetup, const OscarMTMasterThread *masterThread)
 
static void globalEndJob (OscarMTMasterThread *masterThread)
 
static void globalEndRun (const edm::Run &iRun, const edm::EventSetup &iSetup, const RunContext *iContext)
 
static std::unique_ptr< OscarMTMasterThreadinitializeGlobalCache (const edm::ParameterSet &iConfig)
 

Private Attributes

omt::ThreadHandoff m_handoff
 
const OscarMTMasterThreadm_masterThread = nullptr
 
std::unique_ptr< RunManagerMTWorkerm_runManagerWorker
 
int m_verbose
 

Detailed Description

Definition at line 43 of file OscarMTProducer.cc.

Member Typedef Documentation

◆ Producers

typedef std::vector<std::shared_ptr<SimProducer> > OscarMTProducer::Producers

Definition at line 45 of file OscarMTProducer.cc.

Constructor & Destructor Documentation

◆ OscarMTProducer()

OscarMTProducer::OscarMTProducer ( edm::ParameterSet const &  p,
const OscarMTMasterThread ms 
)
explicit

Definition at line 103 of file OscarMTProducer.cc.

References AlCaHLTBitMon_ParallelJobs::p.

104  : m_handoff{p.getUntrackedParameter<int>("workerThreadStackSize", 10 * 1024 * 1024)} {
105  m_verbose = p.getParameter<int>("EventVerbose");
106  // Random number generation not allowed here
107  StaticRandomEngineSetUnset random(nullptr);
108 
110  m_handoff.runAndWait([this, &p, token]() {
112  StaticRandomEngineSetUnset random(nullptr);
113  m_runManagerWorker = std::make_unique<RunManagerMTWorker>(p, consumesCollector());
114  });
115  m_masterThread = ms;
116  m_masterThread->callConsumes(consumesCollector());
117 
118  // List of produced containers
119  produces<edm::SimTrackContainer>().setBranchAlias("SimTracks");
120  produces<edm::SimVertexContainer>().setBranchAlias("SimVertices");
121  produces<edm::PSimHitContainer>("TrackerHitsPixelBarrelLowTof");
122  produces<edm::PSimHitContainer>("TrackerHitsPixelBarrelHighTof");
123  produces<edm::PSimHitContainer>("TrackerHitsTIBLowTof");
124  produces<edm::PSimHitContainer>("TrackerHitsTIBHighTof");
125  produces<edm::PSimHitContainer>("TrackerHitsTIDLowTof");
126  produces<edm::PSimHitContainer>("TrackerHitsTIDHighTof");
127  produces<edm::PSimHitContainer>("TrackerHitsPixelEndcapLowTof");
128  produces<edm::PSimHitContainer>("TrackerHitsPixelEndcapHighTof");
129  produces<edm::PSimHitContainer>("TrackerHitsTOBLowTof");
130  produces<edm::PSimHitContainer>("TrackerHitsTOBHighTof");
131  produces<edm::PSimHitContainer>("TrackerHitsTECLowTof");
132  produces<edm::PSimHitContainer>("TrackerHitsTECHighTof");
133 
134  produces<edm::PSimHitContainer>("TotemHitsT1");
135  produces<edm::PSimHitContainer>("TotemHitsT2Gem");
136  produces<edm::PSimHitContainer>("TotemHitsRP");
137  produces<edm::PSimHitContainer>("CTPPSPixelHits");
138  produces<edm::PSimHitContainer>("CTPPSTimingHits");
139  produces<edm::PSimHitContainer>("FP420SI");
140  produces<edm::PSimHitContainer>("BSCHits");
141  produces<edm::PSimHitContainer>("PLTHits");
142  produces<edm::PSimHitContainer>("BCM1FHits");
143  produces<edm::PSimHitContainer>("BHMHits");
144  produces<edm::PSimHitContainer>("FastTimerHitsBarrel");
145  produces<edm::PSimHitContainer>("FastTimerHitsEndcap");
146 
147  produces<edm::PCaloHitContainer>("EcalHitsEB");
148  produces<edm::PCaloHitContainer>("EcalHitsEE");
149  produces<edm::PCaloHitContainer>("EcalHitsES");
150  produces<edm::PCaloHitContainer>("HcalHits");
151  produces<edm::PCaloHitContainer>("CaloHitsTk");
152  produces<edm::PCaloHitContainer>("HGCHitsEE");
153  produces<edm::PCaloHitContainer>("HGCHitsHEfront");
154  produces<edm::PCaloHitContainer>("HGCHitsHEback");
155 
156  produces<edm::PSimHitContainer>("MuonDTHits");
157  produces<edm::PSimHitContainer>("MuonCSCHits");
158  produces<edm::PSimHitContainer>("MuonRPCHits");
159  produces<edm::PSimHitContainer>("MuonGEMHits");
160  produces<edm::PSimHitContainer>("MuonME0Hits");
161  produces<edm::PCaloHitContainer>("CastorPL");
162  produces<edm::PCaloHitContainer>("CastorFI");
163  produces<edm::PCaloHitContainer>("CastorBU");
164  produces<edm::PCaloHitContainer>("CastorTU");
165  produces<edm::PCaloHitContainer>("EcalTBH4BeamHits");
166  produces<edm::PCaloHitContainer>("HcalTB06BeamHits");
167  produces<edm::PCaloHitContainer>("ZDCHITS");
168  produces<edm::PCaloHitContainer>("ChamberHits");
169  produces<edm::PCaloHitContainer>("FibreHits");
170  produces<edm::PCaloHitContainer>("WedgeHits");
171  produces<edm::PCaloHitContainer>("HFNoseHits");
172  produces<edm::PCaloHitContainer>("TotemHitsT2Scint");
173 
174  //register any products
175  auto& producers = m_runManagerWorker->producers();
176  for (auto& ptr : producers) {
177  ptr->registerProducts(producesCollector());
178  }
179  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer is constructed";
180 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< RunManagerMTWorker > m_runManagerWorker
void runAndWait(F &&iF)
Definition: ThreadHandoff.h:42
const OscarMTMasterThread * m_masterThread
static ServiceRegistry & instance()
void callConsumes(edm::ConsumesCollector &&iC) const
omt::ThreadHandoff m_handoff
ServiceToken presentToken() const

◆ ~OscarMTProducer()

OscarMTProducer::~OscarMTProducer ( )
override

Member Function Documentation

◆ beginRun()

void OscarMTProducer::beginRun ( const edm::Run r,
const edm::EventSetup c 
)
override

Definition at line 219 of file OscarMTProducer.cc.

References l1ctLayer2EG_cff::id, edm::ServiceRegistry::instance(), m_handoff, m_masterThread, m_runManagerWorker, edm::ServiceRegistry::presentToken(), omt::ThreadHandoff::runAndWait(), OscarMTMasterThread::runManagerMasterPtr(), and unpackBuffers-CaloStage2::token.

219  {
220  int id = m_runManagerWorker->getThreadIndex();
221  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::beginRun threadID=" << id;
223  m_handoff.runAndWait([this, &es, token]() {
225  m_runManagerWorker->beginRun(es);
227  });
228  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::beginRun done threadID=" << id;
229 }
Log< level::Info, true > LogVerbatim
RunManagerMT * runManagerMasterPtr() const
std::unique_ptr< RunManagerMTWorker > m_runManagerWorker
void runAndWait(F &&iF)
Definition: ThreadHandoff.h:42
const OscarMTMasterThread * m_masterThread
static ServiceRegistry & instance()
omt::ThreadHandoff m_handoff
ServiceToken presentToken() const

◆ endRun()

void OscarMTProducer::endRun ( const edm::Run r,
const edm::EventSetup c 
)
override

Definition at line 231 of file OscarMTProducer.cc.

References l1ctLayer2EG_cff::id, edm::ServiceRegistry::instance(), m_handoff, m_runManagerWorker, edm::ServiceRegistry::presentToken(), omt::ThreadHandoff::runAndWait(), and unpackBuffers-CaloStage2::token.

231  {
232  StaticRandomEngineSetUnset random(nullptr);
233  int id = m_runManagerWorker->getThreadIndex();
234  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::endRun threadID=" << id;
236  m_handoff.runAndWait([this, token]() {
238  m_runManagerWorker->endRun();
239  });
240  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::endRun done threadID=" << id;
241 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< RunManagerMTWorker > m_runManagerWorker
void runAndWait(F &&iF)
Definition: ThreadHandoff.h:42
static ServiceRegistry & instance()
omt::ThreadHandoff m_handoff
ServiceToken presentToken() const

◆ globalBeginRun()

std::shared_ptr< int > OscarMTProducer::globalBeginRun ( const edm::Run iRun,
const edm::EventSetup iSetup,
const OscarMTMasterThread masterThread 
)
static

Definition at line 198 of file OscarMTProducer.cc.

References OscarMTMasterThread::beginRun().

200  {
201  // Random number generation not allowed here
202  StaticRandomEngineSetUnset random(nullptr);
203  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::globalBeginRun";
204  masterThread->beginRun(iSetup);
205  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::globalBeginRun done";
206  return std::shared_ptr<int>();
207 }
Log< level::Info, true > LogVerbatim
void beginRun(const edm::EventSetup &iSetup) const

◆ globalEndJob()

void OscarMTProducer::globalEndJob ( OscarMTMasterThread masterThread)
static

Definition at line 214 of file OscarMTProducer.cc.

References OscarMTMasterThread::stopThread().

214  {
215  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::globalEndJob";
216  masterThread->stopThread();
217 }
Log< level::Info, true > LogVerbatim

◆ globalEndRun()

void OscarMTProducer::globalEndRun ( const edm::Run iRun,
const edm::EventSetup iSetup,
const RunContext iContext 
)
static

Definition at line 209 of file OscarMTProducer.cc.

References edm::stream::RunContextT< R, G >::global().

209  {
210  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::globalEndRun";
211  iContext->global()->endRun();
212 }
Log< level::Info, true > LogVerbatim

◆ initializeGlobalCache()

std::unique_ptr< OscarMTMasterThread > OscarMTProducer::initializeGlobalCache ( const edm::ParameterSet iConfig)
static

Definition at line 190 of file OscarMTProducer.cc.

190  {
191  // Random number generation not allowed here
192  StaticRandomEngineSetUnset random(nullptr);
193  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::initializeGlobalCache";
194 
195  return std::make_unique<OscarMTMasterThread>(iConfig);
196 }
Log< level::Info, true > LogVerbatim

◆ produce()

void OscarMTProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 243 of file OscarMTProducer.cc.

References MillePedeFileConverter_cfg::e, mps_fire::i, l1ctLayer2EG_cff::id, edm::ServiceRegistry::instance(), G4SimEvent::load(), m_handoff, m_runManagerWorker, m_verbose, eostools::move(), Skims_PA_cff::name, groupFilesInBlocks::nn, LaserDQM_cfg::p1, SiStripOfflineCRack_cfg::p2, edm::ServiceRegistry::presentToken(), dumpMFGeometry_cfg::prod, HLT_2022v15_cff::producers, omt::ThreadHandoff::runAndWait(), unpackBuffers-CaloStage2::token, PbPb_ZMuSkimMuonDPG_cff::tracker, and findQualityFiles::v.

243  {
244  StaticRandomEngineSetUnset random(e.streamID());
245  auto engine = random.currentEngine();
246  int id = m_runManagerWorker->getThreadIndex();
247  if (0 < m_verbose) {
248  edm::LogVerbatim("SimG4CoreApplication")
249  << "Produce event " << e.id() << " stream " << e.streamID() << " threadID=" << id;
250  //edm::LogVerbatim("SimG4CoreApplication") << " rand= " << G4UniformRand();
251  }
252 
253  auto& sTk = m_runManagerWorker->sensTkDetectors();
254  auto& sCalo = m_runManagerWorker->sensCaloDetectors();
255 
256  G4SimEvent* evt = nullptr;
258  m_handoff.runAndWait([this, &e, &es, &evt, token, engine]() {
260  StaticRandomEngineSetUnset random(engine);
261  evt = m_runManagerWorker->produce(e, es, globalCache()->runManagerMaster());
262  });
263 
264  std::unique_ptr<edm::SimTrackContainer> p1(new edm::SimTrackContainer);
265  std::unique_ptr<edm::SimVertexContainer> p2(new edm::SimVertexContainer);
266  evt->load(*p1);
267  evt->load(*p2);
268 
269  if (0 < m_verbose) {
270  edm::LogVerbatim("SimG4CoreApplication") << "Produced " << p2->size() << " SimVertex objects";
271  if (1 < m_verbose) {
272  int nn = p2->size();
273  for (int i = 0; i < nn; ++i) {
274  edm::LogVerbatim("Vertex") << " " << (*p2)[i] << " " << (*p2)[i].processType();
275  }
276  }
277  edm::LogVerbatim("SimG4CoreApplication") << "Produced " << p1->size() << " SimTrack objects";
278  if (1 < m_verbose) {
279  int nn = p1->size();
280  for (int i = 0; i < nn; ++i) {
281  edm::LogVerbatim("Track") << " " << i << ". " << (*p1)[i] << " " << (*p1)[i].crossedBoundary() << " "
282  << (*p1)[i].getIDAtBoundary();
283  }
284  }
285  }
286  e.put(std::move(p1));
287  e.put(std::move(p2));
288 
289  for (auto& tracker : sTk) {
290  const std::vector<std::string>& v = tracker->getNames();
291  for (auto& name : v) {
292  std::unique_ptr<edm::PSimHitContainer> product(new edm::PSimHitContainer);
293  tracker->fillHits(*product, name);
294  if (0 < m_verbose && product != nullptr && !product->empty())
295  edm::LogVerbatim("SimG4CoreApplication") << "Produced " << product->size() << " tracker hits <" << name << ">";
296  e.put(std::move(product), name);
297  }
298  }
299  for (auto& calo : sCalo) {
300  const std::vector<std::string>& v = calo->getNames();
301  for (auto& name : v) {
302  std::unique_ptr<edm::PCaloHitContainer> product(new edm::PCaloHitContainer);
303  calo->fillHits(*product, name);
304  if (0 < m_verbose && product != nullptr && !product->empty())
305  edm::LogVerbatim("SimG4CoreApplication") << "Produced " << product->size() << " calo hits <" << name << ">";
306  e.put(std::move(product), name);
307  }
308  }
309 
310  auto& producers = m_runManagerWorker->producers();
311  for (auto& prod : producers) {
312  prod.get()->produce(e, es);
313  }
314  if (0 < m_verbose) {
315  edm::LogVerbatim("SimG4CoreApplication")
316  << "Event is produced event " << e.id() << " streamID=" << e.streamID() << " threadID=" << id;
317  //edm::LogVerbatim("SimG4CoreApplication") << " rand= " << G4UniformRand();
318  }
319 }
Log< level::Info, true > LogVerbatim
std::vector< PCaloHit > PCaloHitContainer
std::unique_ptr< RunManagerMTWorker > m_runManagerWorker
void runAndWait(F &&iF)
Definition: ThreadHandoff.h:42
void load(edm::SimTrackContainer &c) const
Definition: G4SimEvent.cc:36
static ServiceRegistry & instance()
std::vector< SimVertex > SimVertexContainer
std::vector< PSimHit > PSimHitContainer
omt::ThreadHandoff m_handoff
std::vector< SimTrack > SimTrackContainer
ServiceToken presentToken() const
def move(src, dest)
Definition: eostools.py:511
Definition: Common.h:9

Member Data Documentation

◆ m_handoff

omt::ThreadHandoff OscarMTProducer::m_handoff
private

Definition at line 62 of file OscarMTProducer.cc.

Referenced by beginRun(), endRun(), produce(), and ~OscarMTProducer().

◆ m_masterThread

const OscarMTMasterThread* OscarMTProducer::m_masterThread = nullptr
private

Definition at line 64 of file OscarMTProducer.cc.

Referenced by beginRun().

◆ m_runManagerWorker

std::unique_ptr<RunManagerMTWorker> OscarMTProducer::m_runManagerWorker
private

Definition at line 63 of file OscarMTProducer.cc.

Referenced by beginRun(), endRun(), produce(), and ~OscarMTProducer().

◆ m_verbose

int OscarMTProducer::m_verbose
private

Definition at line 65 of file OscarMTProducer.cc.

Referenced by produce().