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 = 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 
163  produces<edm::PSimHitContainer>("MuonDTHits");
164  produces<edm::PSimHitContainer>("MuonCSCHits");
165  produces<edm::PSimHitContainer>("MuonRPCHits");
166  produces<edm::PSimHitContainer>("MuonGEMHits");
167  produces<edm::PSimHitContainer>("MuonME0Hits");
168  produces<edm::PCaloHitContainer>("CastorPL");
169  produces<edm::PCaloHitContainer>("CastorFI");
170  produces<edm::PCaloHitContainer>("CastorBU");
171  produces<edm::PCaloHitContainer>("CastorTU");
172  produces<edm::PCaloHitContainer>("EcalTBH4BeamHits");
173  produces<edm::PCaloHitContainer>("HcalTB06BeamHits");
174  produces<edm::PCaloHitContainer>("ZDCHITS");
175  produces<edm::PCaloHitContainer>("ChamberHits");
176  produces<edm::PCaloHitContainer>("FibreHits");
177  produces<edm::PCaloHitContainer>("WedgeHits");
178  produces<edm::PCaloHitContainer>("HFNoseHits");
179  produces<edm::PCaloHitContainer>("TotemHitsT2Scint");
180 
181  //register any products
182  auto& producers = m_runManagerWorker->producers();
183  for (auto& ptr : producers) {
184  ptr->registerProducts(producesCollector());
185  }
186  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer is constructed";
187 }
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 237 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.

237  {
238  if (s_psetID != m_psetID) {
239  throw cms::Exception("DiffOscarMTProducers")
240  << "At least two different OscarMTProducer instances have been"
241  "loaded into the job and they have different configurations.\n"
242  " All OscarMTProducers in a job must have exactly the same configuration.";
243  }
244  int id = m_runManagerWorker->getThreadIndex();
245  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::beginRun threadID=" << id;
247  m_handoff.runAndWait([this, &es, token]() {
249  m_runManagerWorker->beginRun(es);
251  });
252  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::beginRun done threadID=" << id;
253 }
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 255 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.

255  {
256  StaticRandomEngineSetUnset random(nullptr);
257  int id = m_runManagerWorker->getThreadIndex();
258  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::endRun threadID=" << id;
260  m_handoff.runAndWait([this, token]() {
262  m_runManagerWorker->endRun();
263  });
264  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::endRun done threadID=" << id;
265 }
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 210 of file OscarMTProducer.cc.

References OscarMTMasterThread::beginRun().

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

◆ globalEndJob()

void OscarMTProducer::globalEndJob ( OscarMTMasterThread masterThread)
static

Definition at line 230 of file OscarMTProducer.cc.

References OscarMTMasterThread::stopThread().

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

◆ globalEndRun()

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

Definition at line 223 of file OscarMTProducer.cc.

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

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

◆ initializeGlobalCache()

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

Definition at line 197 of file OscarMTProducer.cc.

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

197  {
198  // Random number generation not allowed here
199  StaticRandomEngineSetUnset random(nullptr);
200  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::initializeGlobalCache";
201  if (nullptr == s_masterThread) {
202  auto ret = std::make_unique<OscarMTMasterThread>(iConfig);
203  s_masterThread = ret.get();
204  s_psetID = iConfig.id();
205  return ret;
206  }
207  return {};
208 }
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 267 of file OscarMTProducer.cc.

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

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