CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
< OscarMTMasterThread
initializeGlobalCache (const edm::ParameterSet &iConfig)
 

Private Attributes

omt::ThreadHandoff m_handoff
 
const OscarMTMasterThreadm_masterThread = nullptr
 
std::unique_ptr
< RunManagerMTWorker
m_runManagerWorker
 

Detailed Description

Definition at line 43 of file OscarMTProducer.cc.

Member Typedef Documentation

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

Definition at line 45 of file OscarMTProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 102 of file OscarMTProducer.cc.

References OscarMTMasterThread::callConsumes(), edm::ParameterSet::getUntrackedParameter(), edm::ServiceRegistry::instance(), m_handoff, m_masterThread, m_runManagerWorker, AlCaHLTBitMon_ParallelJobs::p, edm::ServiceRegistry::presentToken(), HLT_FULL_cff::producers, omt::ThreadHandoff::runAndWait(), and unpackBuffers-CaloStage2::token.

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

Member Function Documentation

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

Definition at line 217 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.

217  {
218  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::beginRun";
220  m_handoff.runAndWait([this, &es, token]() {
222  m_runManagerWorker->beginRun(es);
224  });
225  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::beginRun done";
226 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< RunManagerMTWorker > m_runManagerWorker
void runAndWait(F &&iF)
Definition: ThreadHandoff.h:42
ServiceToken presentToken() const
const OscarMTMasterThread * m_masterThread
static ServiceRegistry & instance()
RunManagerMT * runManagerMasterPtr() const
omt::ThreadHandoff m_handoff
void OscarMTProducer::endRun ( const edm::Run r,
const edm::EventSetup c 
)
override

Definition at line 228 of file OscarMTProducer.cc.

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

228  {
229  // Random number generation not allowed here
230  StaticRandomEngineSetUnset random(nullptr);
231  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::endRun";
233  m_handoff.runAndWait([this, token]() {
234  StaticRandomEngineSetUnset random(nullptr);
236  m_runManagerWorker->endRun();
237  });
238  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::endRun done";
239 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< RunManagerMTWorker > m_runManagerWorker
void runAndWait(F &&iF)
Definition: ThreadHandoff.h:42
ServiceToken presentToken() const
static ServiceRegistry & instance()
omt::ThreadHandoff m_handoff
std::shared_ptr< int > OscarMTProducer::globalBeginRun ( const edm::Run iRun,
const edm::EventSetup iSetup,
const OscarMTMasterThread masterThread 
)
static

Definition at line 196 of file OscarMTProducer.cc.

References OscarMTMasterThread::beginRun().

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

Definition at line 212 of file OscarMTProducer.cc.

References OscarMTMasterThread::stopThread().

212  {
213  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::globalEndJob";
214  masterThread->stopThread();
215 }
Log< level::Info, true > LogVerbatim
void OscarMTProducer::globalEndRun ( const edm::Run iRun,
const edm::EventSetup iSetup,
const RunContext iContext 
)
static

Definition at line 207 of file OscarMTProducer.cc.

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

207  {
208  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::globalEndRun";
209  iContext->global()->endRun();
210 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< OscarMTMasterThread > OscarMTProducer::initializeGlobalCache ( const edm::ParameterSet iConfig)
static

Definition at line 188 of file OscarMTProducer.cc.

References iConfig.

188  {
189  // Random number generation not allowed here
190  StaticRandomEngineSetUnset random(nullptr);
191  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::initializeGlobalCache";
192 
193  return std::make_unique<OscarMTMasterThread>(iConfig);
194 }
Log< level::Info, true > LogVerbatim
void OscarMTProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 241 of file OscarMTProducer.cc.

References edm::errors::EventCorruption, Exception, edm::EventBase::id(), edm::ServiceRegistry::instance(), m_handoff, m_runManagerWorker, eostools::move(), mergeVDriftHistosByStation::name, fireworks::p1, fireworks::p2, edm::ServiceRegistry::presentToken(), HLT_FULL_cff::producers, edm::Event::put(), omt::ThreadHandoff::runAndWait(), edm::Event::streamID(), unpackBuffers-CaloStage2::token, findQualityFiles::v, and SimG4Exception::what().

241  {
242  StaticRandomEngineSetUnset random(e.streamID());
243  auto engine = random.currentEngine();
244  edm::LogVerbatim("SimG4CoreApplication") << "Produce event " << e.id() << " stream " << e.streamID();
245  //edm::LogVerbatim("SimG4CoreApplication") << " rand= " << G4UniformRand();
246 
247  auto& sTk = m_runManagerWorker->sensTkDetectors();
248  auto& sCalo = m_runManagerWorker->sensCaloDetectors();
249 
250  std::unique_ptr<G4SimEvent> evt;
251  try {
253  m_handoff.runAndWait([this, &e, &es, &evt, token, engine]() {
255  StaticRandomEngineSetUnset random(engine);
256  evt = m_runManagerWorker->produce(e, es, globalCache()->runManagerMaster());
257  });
258  } catch (const SimG4Exception& simg4ex) {
259  edm::LogWarning("SimG4CoreApplication") << "SimG4Exception caght! " << simg4ex.what();
260 
262  << "SimG4CoreApplication exception in generation of event " << e.id() << " in stream " << e.streamID() << " \n"
263  << simg4ex.what();
264  }
265 
266  std::unique_ptr<edm::SimTrackContainer> p1(new edm::SimTrackContainer);
267  std::unique_ptr<edm::SimVertexContainer> p2(new edm::SimVertexContainer);
268  evt->load(*p1);
269  evt->load(*p2);
270 
271  e.put(std::move(p1));
272  e.put(std::move(p2));
273 
274  for (auto& tracker : sTk) {
275  const std::vector<std::string>& v = tracker->getNames();
276  for (auto& name : v) {
277  std::unique_ptr<edm::PSimHitContainer> product(new edm::PSimHitContainer);
278  tracker->fillHits(*product, name);
279  if (product != nullptr && !product->empty())
280  edm::LogVerbatim("SimG4CoreApplication") << "Produced " << product->size() << " tracker hits <" << name << ">";
281  e.put(std::move(product), name);
282  }
283  }
284  for (auto& calo : sCalo) {
285  const std::vector<std::string>& v = calo->getNames();
286 
287  for (auto& name : v) {
288  std::unique_ptr<edm::PCaloHitContainer> product(new edm::PCaloHitContainer);
289  calo->fillHits(*product, name);
290  if (product != nullptr && !product->empty())
291  edm::LogVerbatim("SimG4CoreApplication") << "Produced " << product->size() << " calo hits <" << name << ">";
292  e.put(std::move(product), name);
293  }
294  }
295 
296  auto& producers = m_runManagerWorker->producers();
297  for (auto& prod : producers) {
298  prod.get()->produce(e, es);
299  }
300  edm::LogVerbatim("SimG4CoreApplication") << "Event is produced " << e.id() << " stream " << e.streamID();
301  //edm::LogVerbatim("SimG4CoreApplication") << " rand= " << G4UniformRand();
302 }
Log< level::Info, true > LogVerbatim
std::vector< PCaloHit > PCaloHitContainer
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const TString p2
Definition: fwPaths.cc:13
std::unique_ptr< RunManagerMTWorker > m_runManagerWorker
void runAndWait(F &&iF)
Definition: ThreadHandoff.h:42
ServiceToken presentToken() const
def move
Definition: eostools.py:511
static ServiceRegistry & instance()
const TString p1
Definition: fwPaths.cc:12
std::vector< SimVertex > SimVertexContainer
edm::EventID id() const
Definition: EventBase.h:59
StreamID streamID() const
Definition: Event.h:98
std::vector< PSimHit > PSimHitContainer
omt::ThreadHandoff m_handoff
Log< level::Warning, false > LogWarning
std::vector< SimTrack > SimTrackContainer
const char * what() const override

Member Data Documentation

omt::ThreadHandoff OscarMTProducer::m_handoff
private

Definition at line 62 of file OscarMTProducer.cc.

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

const OscarMTMasterThread* OscarMTProducer::m_masterThread = nullptr
private

Definition at line 64 of file OscarMTProducer.cc.

Referenced by beginRun(), and OscarMTProducer().

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

Definition at line 63 of file OscarMTProducer.cc.

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