CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Static 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
 
const edm::ParameterSetID m_psetID
 
std::unique_ptr< RunManagerMTWorkerm_runManagerWorker
 
int m_verbose
 

Static Private Attributes

static const OscarMTMasterThreads_masterThread = nullptr
 
static edm::ParameterSetID s_psetID {}
 

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 109 of file OscarMTProducer.cc.

References AlCaHLTBitMon_ParallelJobs::p.

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

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

240  {
241  if (s_psetID != m_psetID) {
242  throw cms::Exception("DiffOscarMTProducers")
243  << "At least two different OscarMTProducer instances have been"
244  "loaded into the job and they have different configurations.\n"
245  " All OscarMTProducers in a job must have exactly the same configuration.";
246  }
247  int id = m_runManagerWorker->getThreadIndex();
248  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::beginRun threadID=" << id;
250  m_handoff.runAndWait([this, &es, token]() {
252  m_runManagerWorker->beginRun(es);
254  });
255  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::beginRun done threadID=" << id;
256 }
Log< level::Info, true > LogVerbatim
RunManagerMT * runManagerMasterPtr() const
std::unique_ptr< RunManagerMTWorker > m_runManagerWorker
static edm::ParameterSetID s_psetID
void runAndWait(F &&iF)
Definition: ThreadHandoff.h:42
const OscarMTMasterThread * m_masterThread
const edm::ParameterSetID m_psetID
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 258 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.

258  {
259  StaticRandomEngineSetUnset random(nullptr);
260  int id = m_runManagerWorker->getThreadIndex();
261  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::endRun threadID=" << id;
263  m_handoff.runAndWait([this, token]() {
265  m_runManagerWorker->endRun();
266  });
267  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::endRun done threadID=" << id;
268 }
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 213 of file OscarMTProducer.cc.

References OscarMTMasterThread::beginRun().

215  {
216  // Random number generation not allowed here
217  StaticRandomEngineSetUnset random(nullptr);
218  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::globalBeginRun";
219  if (masterThread) {
220  masterThread->beginRun(iSetup);
221  }
222  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::globalBeginRun done";
223  return std::shared_ptr<int>();
224 }
Log< level::Info, true > LogVerbatim
void beginRun(const edm::EventSetup &iSetup) const

◆ globalEndJob()

void OscarMTProducer::globalEndJob ( OscarMTMasterThread masterThread)
static

Definition at line 233 of file OscarMTProducer.cc.

References OscarMTMasterThread::stopThread().

233  {
234  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::globalEndJob";
235  if (masterThread) {
236  masterThread->stopThread();
237  }
238 }
Log< level::Info, true > LogVerbatim

◆ globalEndRun()

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

Definition at line 226 of file OscarMTProducer.cc.

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

226  {
227  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::globalEndRun";
228  if (nullptr != iContext->global()) {
229  iContext->global()->endRun();
230  }
231 }
Log< level::Info, true > LogVerbatim

◆ initializeGlobalCache()

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

Definition at line 200 of file OscarMTProducer.cc.

References edm::ParameterSet::id(), runTheMatrix::ret, s_masterThread, and s_psetID.

200  {
201  // Random number generation not allowed here
202  StaticRandomEngineSetUnset random(nullptr);
203  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::initializeGlobalCache";
204  if (nullptr == s_masterThread) {
205  auto ret = std::make_unique<OscarMTMasterThread>(iConfig);
206  s_masterThread = ret.get();
207  s_psetID = iConfig.id();
208  return ret;
209  }
210  return {};
211 }
Log< level::Info, true > LogVerbatim
ret
prodAgent to be discontinued
static edm::ParameterSetID s_psetID
static const OscarMTMasterThread * s_masterThread
ParameterSetID id() const

◆ produce()

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

Definition at line 270 of file OscarMTProducer.cc.

References MillePedeFileConverter_cfg::e, mps_fire::i, l1ctLayer2EG_cff::id, edm::ServiceRegistry::instance(), TmpSimEvent::load(), m_handoff, m_masterThread, 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_2023v12_cff::producers, omt::ThreadHandoff::runAndWait(), OscarMTMasterThread::runManagerMaster(), unpackBuffers-CaloStage2::token, PbPb_ZMuSkimMuonDPG_cff::tracker, and findQualityFiles::v.

270  {
271  StaticRandomEngineSetUnset random(e.streamID());
272  auto engine = random.currentEngine();
273  int id = m_runManagerWorker->getThreadIndex();
274  if (0 < m_verbose) {
275  edm::LogVerbatim("SimG4CoreApplication")
276  << "Produce event " << e.id() << " stream " << e.streamID() << " threadID=" << id;
277  //edm::LogVerbatim("SimG4CoreApplication") << " rand= " << G4UniformRand();
278  }
279 
280  auto& sTk = m_runManagerWorker->sensTkDetectors();
281  auto& sCalo = m_runManagerWorker->sensCaloDetectors();
282 
283  TmpSimEvent* evt = nullptr;
285  m_handoff.runAndWait([this, &e, &es, &evt, token, engine]() {
287  StaticRandomEngineSetUnset random(engine);
288  evt = m_runManagerWorker->produce(e, es, m_masterThread->runManagerMaster());
289  });
290 
291  std::unique_ptr<edm::SimTrackContainer> p1(new edm::SimTrackContainer);
292  std::unique_ptr<edm::SimVertexContainer> p2(new edm::SimVertexContainer);
293  evt->load(*p1);
294  evt->load(*p2);
295 
296  if (0 < m_verbose) {
297  edm::LogVerbatim("SimG4CoreApplication") << "Produced " << p2->size() << " SimVertex objects";
298  if (1 < m_verbose) {
299  int nn = p2->size();
300  for (int i = 0; i < nn; ++i) {
301  edm::LogVerbatim("Vertex") << " " << (*p2)[i] << " " << (*p2)[i].processType();
302  }
303  }
304  edm::LogVerbatim("SimG4CoreApplication") << "Produced " << p1->size() << " SimTrack objects";
305  if (1 < m_verbose) {
306  int nn = p1->size();
307  for (int i = 0; i < nn; ++i) {
308  edm::LogVerbatim("Track") << " " << i << ". " << (*p1)[i] << " " << (*p1)[i].crossedBoundary() << " "
309  << (*p1)[i].getIDAtBoundary();
310  }
311  }
312  }
313  e.put(std::move(p1));
314  e.put(std::move(p2));
315 
316  for (auto& tracker : sTk) {
317  const std::vector<std::string>& v = tracker->getNames();
318  for (auto& name : v) {
319  std::unique_ptr<edm::PSimHitContainer> product(new edm::PSimHitContainer);
320  tracker->fillHits(*product, name);
321  if (0 < m_verbose && product != nullptr && !product->empty())
322  edm::LogVerbatim("SimG4CoreApplication") << "Produced " << product->size() << " tracker hits <" << name << ">";
323  e.put(std::move(product), name);
324  }
325  }
326  for (auto& calo : sCalo) {
327  const std::vector<std::string>& v = calo->getNames();
328  for (auto& name : v) {
329  std::unique_ptr<edm::PCaloHitContainer> product(new edm::PCaloHitContainer);
330  calo->fillHits(*product, name);
331  if (0 < m_verbose && product != nullptr && !product->empty())
332  edm::LogVerbatim("SimG4CoreApplication") << "Produced " << product->size() << " calo hits <" << name << ">";
333  e.put(std::move(product), name);
334  }
335  }
336 
337  auto& producers = m_runManagerWorker->producers();
338  for (auto& prod : producers) {
339  prod.get()->produce(e, es);
340  }
341  if (0 < m_verbose) {
342  edm::LogVerbatim("SimG4CoreApplication")
343  << "Event is produced event " << e.id() << " streamID=" << e.streamID() << " threadID=" << id;
344  //edm::LogWarning("SimG4CoreApplication") << "EventID=" << e.id() << " rand=" << G4UniformRand();
345  }
346 }
Log< level::Info, true > LogVerbatim
std::vector< PCaloHit > PCaloHitContainer
std::unique_ptr< RunManagerMTWorker > m_runManagerWorker
void runAndWait(F &&iF)
Definition: ThreadHandoff.h:42
RunManagerMT & runManagerMaster() const
const OscarMTMasterThread * m_masterThread
static ServiceRegistry & instance()
void load(edm::SimTrackContainer &c) const
Definition: TmpSimEvent.cc:29
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
private

Definition at line 64 of file OscarMTProducer.cc.

Referenced by beginRun(), and produce().

◆ m_psetID

const edm::ParameterSetID OscarMTProducer::m_psetID
private

Definition at line 65 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 66 of file OscarMTProducer.cc.

Referenced by produce().

◆ s_masterThread

const OscarMTMasterThread * OscarMTProducer::s_masterThread = nullptr
staticprivate

Definition at line 67 of file OscarMTProducer.cc.

Referenced by initializeGlobalCache().

◆ s_psetID

edm::ParameterSetID OscarMTProducer::s_psetID {}
staticprivate

Definition at line 68 of file OscarMTProducer.cc.

Referenced by beginRun(), and initializeGlobalCache().