CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
OscarMTProducer Class Reference

#include <OscarMTProducer.h>

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

const OscarMTMasterThreadm_masterThread = nullptr
 
std::unique_ptr< RunManagerMTWorkerm_runManagerWorker
 

Detailed Description

Definition at line 17 of file OscarMTProducer.h.

Member Typedef Documentation

◆ Producers

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

Definition at line 21 of file OscarMTProducer.h.

Constructor & Destructor Documentation

◆ OscarMTProducer()

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

Definition at line 64 of file OscarMTProducer.cc.

64  {
65  // Random number generation not allowed here
66  StaticRandomEngineSetUnset random(nullptr);
67 
68  m_runManagerWorker = std::make_unique<RunManagerMTWorker>(p, consumesCollector());
69  m_masterThread = ms;
70  m_masterThread->callConsumes(consumesCollector());
71 
72  // List of produced containers
73  produces<edm::SimTrackContainer>().setBranchAlias("SimTracks");
74  produces<edm::SimVertexContainer>().setBranchAlias("SimVertices");
75  produces<edm::PSimHitContainer>("TrackerHitsPixelBarrelLowTof");
76  produces<edm::PSimHitContainer>("TrackerHitsPixelBarrelHighTof");
77  produces<edm::PSimHitContainer>("TrackerHitsTIBLowTof");
78  produces<edm::PSimHitContainer>("TrackerHitsTIBHighTof");
79  produces<edm::PSimHitContainer>("TrackerHitsTIDLowTof");
80  produces<edm::PSimHitContainer>("TrackerHitsTIDHighTof");
81  produces<edm::PSimHitContainer>("TrackerHitsPixelEndcapLowTof");
82  produces<edm::PSimHitContainer>("TrackerHitsPixelEndcapHighTof");
83  produces<edm::PSimHitContainer>("TrackerHitsTOBLowTof");
84  produces<edm::PSimHitContainer>("TrackerHitsTOBHighTof");
85  produces<edm::PSimHitContainer>("TrackerHitsTECLowTof");
86  produces<edm::PSimHitContainer>("TrackerHitsTECHighTof");
87 
88  produces<edm::PSimHitContainer>("TotemHitsT1");
89  produces<edm::PSimHitContainer>("TotemHitsT2Gem");
90  produces<edm::PSimHitContainer>("TotemHitsRP");
91  produces<edm::PSimHitContainer>("CTPPSPixelHits");
92  produces<edm::PSimHitContainer>("CTPPSTimingHits");
93  produces<edm::PSimHitContainer>("FP420SI");
94  produces<edm::PSimHitContainer>("BSCHits");
95  produces<edm::PSimHitContainer>("PLTHits");
96  produces<edm::PSimHitContainer>("BCM1FHits");
97  produces<edm::PSimHitContainer>("BHMHits");
98  produces<edm::PSimHitContainer>("FastTimerHitsBarrel");
99  produces<edm::PSimHitContainer>("FastTimerHitsEndcap");
100 
101  produces<edm::PCaloHitContainer>("EcalHitsEB");
102  produces<edm::PCaloHitContainer>("EcalHitsEE");
103  produces<edm::PCaloHitContainer>("EcalHitsES");
104  produces<edm::PCaloHitContainer>("HcalHits");
105  produces<edm::PCaloHitContainer>("CaloHitsTk");
106  produces<edm::PCaloHitContainer>("HGCHitsEE");
107  produces<edm::PCaloHitContainer>("HGCHitsHEfront");
108  produces<edm::PCaloHitContainer>("HGCHitsHEback");
109 
110  produces<edm::PSimHitContainer>("MuonDTHits");
111  produces<edm::PSimHitContainer>("MuonCSCHits");
112  produces<edm::PSimHitContainer>("MuonRPCHits");
113  produces<edm::PSimHitContainer>("MuonGEMHits");
114  produces<edm::PSimHitContainer>("MuonME0Hits");
115  produces<edm::PCaloHitContainer>("CastorPL");
116  produces<edm::PCaloHitContainer>("CastorFI");
117  produces<edm::PCaloHitContainer>("CastorBU");
118  produces<edm::PCaloHitContainer>("CastorTU");
119  produces<edm::PCaloHitContainer>("EcalTBH4BeamHits");
120  produces<edm::PCaloHitContainer>("HcalTB06BeamHits");
121  produces<edm::PCaloHitContainer>("ZDCHITS");
122  produces<edm::PCaloHitContainer>("ChamberHits");
123  produces<edm::PCaloHitContainer>("FibreHits");
124  produces<edm::PCaloHitContainer>("WedgeHits");
125  produces<edm::PCaloHitContainer>("HFNoseHits");
126  produces<edm::PCaloHitContainer>("TotemHitsT2Scint");
127 
128  //register any products
129  auto& producers = m_runManagerWorker->producers();
130  for (auto& ptr : producers) {
131  ptr->registerProducts(producesCollector());
132  }
133  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer is constructed";
134 }

References OscarMTMasterThread::callConsumes(), m_masterThread, m_runManagerWorker, AlCaHLTBitMon_ParallelJobs::p, and HLT_FULL_cff::producers.

◆ ~OscarMTProducer()

OscarMTProducer::~OscarMTProducer ( )
override

Definition at line 136 of file OscarMTProducer.cc.

136 {}

Member Function Documentation

◆ beginRun()

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

Definition at line 167 of file OscarMTProducer.cc.

167  {
168  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::beginRun";
169  m_runManagerWorker->beginRun(es);
171  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::beginRun done";
172 }

References m_masterThread, m_runManagerWorker, and OscarMTMasterThread::runManagerMasterPtr().

◆ endRun()

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

Definition at line 174 of file OscarMTProducer.cc.

174  {
175  // Random number generation not allowed here
176  StaticRandomEngineSetUnset random(nullptr);
177  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::endRun";
178  m_runManagerWorker->endRun();
179  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::endRun done";
180 }

References m_runManagerWorker.

◆ globalBeginRun()

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

Definition at line 146 of file OscarMTProducer.cc.

148  {
149  // Random number generation not allowed here
150  StaticRandomEngineSetUnset random(nullptr);
151  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::globalBeginRun";
152  masterThread->beginRun(iSetup);
153  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::globalBeginRun done";
154  return std::shared_ptr<int>();
155 }

References OscarMTMasterThread::beginRun().

◆ globalEndJob()

void OscarMTProducer::globalEndJob ( OscarMTMasterThread masterThread)
static

Definition at line 162 of file OscarMTProducer.cc.

162  {
163  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::globalEndJob";
164  masterThread->stopThread();
165 }

References OscarMTMasterThread::stopThread().

◆ globalEndRun()

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

Definition at line 157 of file OscarMTProducer.cc.

157  {
158  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::globalEndRun";
159  iContext->global()->endRun();
160 }

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

◆ initializeGlobalCache()

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

Definition at line 138 of file OscarMTProducer.cc.

138  {
139  // Random number generation not allowed here
140  StaticRandomEngineSetUnset random(nullptr);
141  edm::LogVerbatim("SimG4CoreApplication") << "OscarMTProducer::initializeGlobalCache";
142 
143  return std::make_unique<OscarMTMasterThread>(iConfig);
144 }

◆ produce()

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

Definition at line 182 of file OscarMTProducer.cc.

182  {
183  StaticRandomEngineSetUnset random(e.streamID());
184  edm::LogVerbatim("SimG4CoreApplication") << "Produce event " << e.id() << " stream " << e.streamID();
185  //edm::LogVerbatim("SimG4CoreApplication") << " rand= " << G4UniformRand();
186 
187  auto& sTk = m_runManagerWorker->sensTkDetectors();
188  auto& sCalo = m_runManagerWorker->sensCaloDetectors();
189 
190  std::unique_ptr<G4SimEvent> evt;
191  try {
192  evt = m_runManagerWorker->produce(e, es, globalCache()->runManagerMaster());
193  } catch (const SimG4Exception& simg4ex) {
194  edm::LogWarning("SimG4CoreApplication") << "SimG4Exception caght! " << simg4ex.what();
195 
197  << "SimG4CoreApplication exception in generation of event " << e.id() << " in stream " << e.streamID() << " \n"
198  << simg4ex.what();
199  }
200 
201  std::unique_ptr<edm::SimTrackContainer> p1(new edm::SimTrackContainer);
202  std::unique_ptr<edm::SimVertexContainer> p2(new edm::SimVertexContainer);
203  evt->load(*p1);
204  evt->load(*p2);
205 
206  e.put(std::move(p1));
207  e.put(std::move(p2));
208 
209  for (auto& tracker : sTk) {
210  const std::vector<std::string>& v = tracker->getNames();
211  for (auto& name : v) {
212  std::unique_ptr<edm::PSimHitContainer> product(new edm::PSimHitContainer);
213  tracker->fillHits(*product, name);
214  if (product != nullptr && !product->empty())
215  edm::LogVerbatim("SimG4CoreApplication") << "Produced " << product->size() << " tracker hits <" << name << ">";
216  e.put(std::move(product), name);
217  }
218  }
219  for (auto& calo : sCalo) {
220  const std::vector<std::string>& v = calo->getNames();
221 
222  for (auto& name : v) {
223  std::unique_ptr<edm::PCaloHitContainer> product(new edm::PCaloHitContainer);
224  calo->fillHits(*product, name);
225  if (product != nullptr && !product->empty())
226  edm::LogVerbatim("SimG4CoreApplication") << "Produced " << product->size() << " calo hits <" << name << ">";
227  e.put(std::move(product), name);
228  }
229  }
230 
231  auto& producers = m_runManagerWorker->producers();
232  for (auto& prod : producers) {
233  prod.get()->produce(e, es);
234  }
235  edm::LogVerbatim("SimG4CoreApplication") << "Event is produced " << e.id() << " stream " << e.streamID();
236  //edm::LogVerbatim("SimG4CoreApplication") << " rand= " << G4UniformRand();
237 }

References MillePedeFileConverter_cfg::e, edm::errors::EventCorruption, Exception, m_runManagerWorker, eostools::move(), Skims_PA_cff::name, p1, p2, dumpMFGeometry_cfg::prod, HLT_FULL_cff::producers, PbPb_ZMuSkimMuonDPG_cff::tracker, findQualityFiles::v, and SimG4Exception::what().

Member Data Documentation

◆ m_masterThread

const OscarMTMasterThread* OscarMTProducer::m_masterThread = nullptr
private

Definition at line 39 of file OscarMTProducer.h.

Referenced by beginRun(), and OscarMTProducer().

◆ m_runManagerWorker

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

Definition at line 38 of file OscarMTProducer.h.

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

SimG4Exception
Definition: SimG4Exception.h:13
edm::errors::EventCorruption
Definition: EDMException.h:43
HLT_FULL_cff.producers
producers
Definition: HLT_FULL_cff.py:13113
findQualityFiles.v
v
Definition: findQualityFiles.py:179
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
dumpMFGeometry_cfg.prod
prod
Definition: dumpMFGeometry_cfg.py:24
p2
double p2[4]
Definition: TauolaWrapper.h:90
OscarMTProducer::m_runManagerWorker
std::unique_ptr< RunManagerMTWorker > m_runManagerWorker
Definition: OscarMTProducer.h:38
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
OscarMTMasterThread::stopThread
void stopThread()
Definition: OscarMTMasterThread.cc:159
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
OscarMTMasterThread::runManagerMasterPtr
RunManagerMT * runManagerMasterPtr() const
Definition: OscarMTMasterThread.h:49
p1
double p1[4]
Definition: TauolaWrapper.h:89
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::SimTrackContainer
std::vector< SimTrack > SimTrackContainer
Definition: SimTrackContainer.h:12
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Exception
Definition: hltDiff.cc:245
edm::PCaloHitContainer
std::vector< PCaloHit > PCaloHitContainer
Definition: PCaloHitContainer.h:8
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
OscarMTMasterThread::beginRun
void beginRun(const edm::EventSetup &iSetup) const
Definition: OscarMTMasterThread.cc:120
OscarMTProducer::m_masterThread
const OscarMTMasterThread * m_masterThread
Definition: OscarMTProducer.h:39
edm::PSimHitContainer
std::vector< PSimHit > PSimHitContainer
Definition: PSimHitContainer.h:11
calo
Definition: Common.h:9
edm::Log
Definition: MessageLogger.h:70
SimG4Exception::what
const char * what() const override
Definition: SimG4Exception.h:17
edm::SimVertexContainer
std::vector< SimVertex > SimVertexContainer
Definition: SimVertexContainer.h:12
OscarMTMasterThread::callConsumes
void callConsumes(edm::ConsumesCollector &&iC) const
Definition: OscarMTMasterThread.cc:107
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37