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
 

Detailed Description

Definition at line 41 of file OscarMTProducer.cc.

Member Typedef Documentation

◆ Producers

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

Definition at line 43 of file OscarMTProducer.cc.

Constructor & Destructor Documentation

◆ OscarMTProducer()

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

Definition at line 100 of file OscarMTProducer.cc.

References AlCaHLTBitMon_ParallelJobs::p.

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

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

215  {
216  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::beginRun";
218  m_handoff.runAndWait([this, &es, token]() {
220  m_runManagerWorker->beginRun(es);
222  });
223  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::beginRun done";
224 }
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 226 of file OscarMTProducer.cc.

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

226  {
227  // Random number generation not allowed here
228  StaticRandomEngineSetUnset random(nullptr);
229  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::endRun";
231  m_handoff.runAndWait([this, token]() {
232  StaticRandomEngineSetUnset random(nullptr);
234  m_runManagerWorker->endRun();
235  });
236  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::endRun done";
237 }
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 194 of file OscarMTProducer.cc.

References OscarMTMasterThread::beginRun().

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

◆ globalEndJob()

void OscarMTProducer::globalEndJob ( OscarMTMasterThread masterThread)
static

Definition at line 210 of file OscarMTProducer.cc.

References OscarMTMasterThread::stopThread().

210  {
211  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::globalEndJob";
212  masterThread->stopThread();
213 }
Log< level::Info, true > LogVerbatim

◆ globalEndRun()

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

Definition at line 205 of file OscarMTProducer.cc.

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

205  {
206  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::globalEndRun";
207  iContext->global()->endRun();
208 }
Log< level::Info, true > LogVerbatim

◆ initializeGlobalCache()

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

Definition at line 186 of file OscarMTProducer.cc.

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

◆ produce()

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

Definition at line 239 of file OscarMTProducer.cc.

References MillePedeFileConverter_cfg::e, edm::ServiceRegistry::instance(), m_handoff, m_runManagerWorker, eostools::move(), Skims_PA_cff::name, LaserDQM_cfg::p1, SiStripOfflineCRack_cfg::p2, edm::ServiceRegistry::presentToken(), dumpMFGeometry_cfg::prod, HLT_2022v11_cff::producers, omt::ThreadHandoff::runAndWait(), unpackBuffers-CaloStage2::token, PbPb_ZMuSkimMuonDPG_cff::tracker, and findQualityFiles::v.

239  {
240  StaticRandomEngineSetUnset random(e.streamID());
241  auto engine = random.currentEngine();
242  edm::LogVerbatim("SimG4CoreApplication") << "Produce event " << e.id() << " stream " << e.streamID();
243  //edm::LogVerbatim("SimG4CoreApplication") << " rand= " << G4UniformRand();
244 
245  auto& sTk = m_runManagerWorker->sensTkDetectors();
246  auto& sCalo = m_runManagerWorker->sensCaloDetectors();
247 
248  std::unique_ptr<G4SimEvent> evt;
250  m_handoff.runAndWait([this, &e, &es, &evt, token, engine]() {
252  StaticRandomEngineSetUnset random(engine);
253  evt = m_runManagerWorker->produce(e, es, globalCache()->runManagerMaster());
254  });
255 
256  std::unique_ptr<edm::SimTrackContainer> p1(new edm::SimTrackContainer);
257  std::unique_ptr<edm::SimVertexContainer> p2(new edm::SimVertexContainer);
258  evt->load(*p1);
259  evt->load(*p2);
260 
261  e.put(std::move(p1));
262  e.put(std::move(p2));
263 
264  for (auto& tracker : sTk) {
265  const std::vector<std::string>& v = tracker->getNames();
266  for (auto& name : v) {
267  std::unique_ptr<edm::PSimHitContainer> product(new edm::PSimHitContainer);
268  tracker->fillHits(*product, name);
269  if (product != nullptr && !product->empty())
270  edm::LogVerbatim("SimG4CoreApplication") << "Produced " << product->size() << " tracker hits <" << name << ">";
271  e.put(std::move(product), name);
272  }
273  }
274  for (auto& calo : sCalo) {
275  const std::vector<std::string>& v = calo->getNames();
276  for (auto& name : v) {
277  std::unique_ptr<edm::PCaloHitContainer> product(new edm::PCaloHitContainer);
278  calo->fillHits(*product, name);
279  if (product != nullptr && !product->empty())
280  edm::LogVerbatim("SimG4CoreApplication") << "Produced " << product->size() << " calo hits <" << name << ">";
281  e.put(std::move(product), name);
282  }
283  }
284 
285  auto& producers = m_runManagerWorker->producers();
286  for (auto& prod : producers) {
287  prod.get()->produce(e, es);
288  }
289  edm::LogVerbatim("SimG4CoreApplication") << "Event is produced " << e.id() << " stream " << e.streamID();
290  //edm::LogVerbatim("SimG4CoreApplication") << " rand= " << G4UniformRand();
291 }
Log< level::Info, true > LogVerbatim
std::vector< PCaloHit > PCaloHitContainer
std::unique_ptr< RunManagerMTWorker > m_runManagerWorker
void runAndWait(F &&iF)
Definition: ThreadHandoff.h:42
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 60 of file OscarMTProducer.cc.

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

◆ m_masterThread

const OscarMTMasterThread* OscarMTProducer::m_masterThread = nullptr
private

Definition at line 62 of file OscarMTProducer.cc.

Referenced by beginRun().

◆ m_runManagerWorker

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

Definition at line 61 of file OscarMTProducer.cc.

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