26 #include "Randomize.hh" 53 class StaticRandomEngineSetUnset {
56 explicit StaticRandomEngineSetUnset(CLHEP::HepRandomEngine * engine);
57 ~StaticRandomEngineSetUnset();
59 CLHEP::HepRandomEngine* m_currentEngine;
60 CLHEP::HepRandomEngine* m_previousEngine;
67 StaticRandomEngineSetUnset
random(
nullptr);
71 produces<edm::SimTrackContainer>().setBranchAlias(
"SimTracks");
72 produces<edm::SimVertexContainer>().setBranchAlias(
"SimVertices");
73 produces<edm::PSimHitContainer>(
"TrackerHitsPixelBarrelLowTof");
74 produces<edm::PSimHitContainer>(
"TrackerHitsPixelBarrelHighTof");
75 produces<edm::PSimHitContainer>(
"TrackerHitsTIBLowTof");
76 produces<edm::PSimHitContainer>(
"TrackerHitsTIBHighTof");
77 produces<edm::PSimHitContainer>(
"TrackerHitsTIDLowTof");
78 produces<edm::PSimHitContainer>(
"TrackerHitsTIDHighTof");
79 produces<edm::PSimHitContainer>(
"TrackerHitsPixelEndcapLowTof");
80 produces<edm::PSimHitContainer>(
"TrackerHitsPixelEndcapHighTof");
81 produces<edm::PSimHitContainer>(
"TrackerHitsTOBLowTof");
82 produces<edm::PSimHitContainer>(
"TrackerHitsTOBHighTof");
83 produces<edm::PSimHitContainer>(
"TrackerHitsTECLowTof");
84 produces<edm::PSimHitContainer>(
"TrackerHitsTECHighTof");
86 produces<edm::PSimHitContainer>(
"TotemHitsT1");
87 produces<edm::PSimHitContainer>(
"TotemHitsT2Gem");
88 produces<edm::PSimHitContainer>(
"TotemHitsRP");
89 produces<edm::PSimHitContainer>(
"FP420SI");
90 produces<edm::PSimHitContainer>(
"BSCHits");
91 produces<edm::PSimHitContainer>(
"PLTHits");
92 produces<edm::PSimHitContainer>(
"BCM1FHits");
93 produces<edm::PSimHitContainer>(
"BHMHits");
94 produces<edm::PSimHitContainer>(
"FastTimerHitsBarrel");
95 produces<edm::PSimHitContainer>(
"FastTimerHitsEndcap");
97 produces<edm::PCaloHitContainer>(
"EcalHitsEB");
98 produces<edm::PCaloHitContainer>(
"EcalHitsEE");
99 produces<edm::PCaloHitContainer>(
"EcalHitsES");
100 produces<edm::PCaloHitContainer>(
"HcalHits");
101 produces<edm::PCaloHitContainer>(
"CaloHitsTk");
102 produces<edm::PCaloHitContainer>(
"HGCHitsEE");
103 produces<edm::PCaloHitContainer>(
"HGCHitsHEfront");
104 produces<edm::PCaloHitContainer>(
"HGCHitsHEback");
106 produces<edm::PSimHitContainer>(
"MuonDTHits");
107 produces<edm::PSimHitContainer>(
"MuonCSCHits");
108 produces<edm::PSimHitContainer>(
"MuonRPCHits");
109 produces<edm::PSimHitContainer>(
"MuonGEMHits");
110 produces<edm::PSimHitContainer>(
"MuonME0Hits");
111 produces<edm::PCaloHitContainer>(
"CastorPL");
112 produces<edm::PCaloHitContainer>(
"CastorFI");
113 produces<edm::PCaloHitContainer>(
"CastorBU");
114 produces<edm::PCaloHitContainer>(
"CastorTU");
115 produces<edm::PCaloHitContainer>(
"EcalTBH4BeamHits");
116 produces<edm::PCaloHitContainer>(
"HcalTB06BeamHits");
117 produces<edm::PCaloHitContainer>(
"ZDCHITS");
118 produces<edm::PCaloHitContainer>(
"ChamberHits");
119 produces<edm::PCaloHitContainer>(
"FibreHits");
120 produces<edm::PCaloHitContainer>(
"WedgeHits");
121 produces<edm::PCaloHitContainer>(
"HFNoseHits");
124 m_producers = m_runManagerWorker->producers();
126 for(Producers::iterator itProd = m_producers.begin();
127 itProd != m_producers.end(); ++itProd) {
129 (*itProd)->registerProducts(*
this);
138 StaticRandomEngineSetUnset
random(
nullptr);
145 StaticRandomEngineSetUnset
random(
nullptr);
149 return std::shared_ptr<int>();
153 iContext->
global()->endRun();
164 StaticRandomEngineSetUnset
random(
nullptr);
165 m_runManagerWorker->endRun();
172 <<
"Produce event " << e.
id() <<
" stream " << e.
streamID()
173 <<
" rand= " << G4UniformRand();
175 std::vector<SensitiveTkDetector*>& sTk =
176 m_runManagerWorker->sensTkDetectors();
177 std::vector<SensitiveCaloDetector*>& sCalo =
178 m_runManagerWorker->sensCaloDetectors();
180 try { m_runManagerWorker->produce(e, es, globalCache()->runManagerMaster()); }
187 <<
"SimG4CoreApplication exception in generation of event " 188 << e.
id() <<
" in stream " << e.
streamID() <<
" \n" 192 std::unique_ptr<edm::SimTrackContainer>
194 std::unique_ptr<edm::SimVertexContainer>
196 G4SimEvent * evt = m_runManagerWorker->simEvent();
205 const std::vector<std::string>&
v =
tracker->getNames();
206 for (
auto &
name : v) {
208 std::unique_ptr<edm::PSimHitContainer>
214 for (
auto & calo : sCalo) {
216 const std::vector<std::string>&
v = calo->getNames();
218 for (
auto &
name : v) {
220 std::unique_ptr<edm::PCaloHitContainer>
222 calo->fillHits(*product,
name);
227 for(
auto &
prod : m_producers) {
228 prod.get()->produce(e,es);
231 <<
"Event is produced " << e.
id() <<
" stream " << e.
streamID()
232 <<
" rand= " << G4UniformRand();
235 StaticRandomEngineSetUnset::StaticRandomEngineSetUnset(
241 <<
"The OscarMTProducer module requires the RandomNumberGeneratorService\n" 242 "which is not present in the configuration file. You must add the service\n" 243 "in the configuration file if you want to run OscarMTProducer";
245 m_currentEngine = &(rng->
getEngine(streamID));
247 m_previousEngine = G4Random::getTheEngine();
248 G4Random::setTheEngine(m_currentEngine);
251 StaticRandomEngineSetUnset::StaticRandomEngineSetUnset(
252 CLHEP::HepRandomEngine * engine)
254 m_currentEngine = engine;
255 m_previousEngine = G4Random::getTheEngine();
256 G4Random::setTheEngine(m_currentEngine);
259 StaticRandomEngineSetUnset::~StaticRandomEngineSetUnset()
261 G4Random::setTheEngine(m_previousEngine);
std::vector< PCaloHit > PCaloHitContainer
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
static std::shared_ptr< int > globalBeginRun(const edm::Run &iRun, const edm::EventSetup &iSetup, const OscarMTMasterThread *masterThread)
#define DEFINE_FWK_MODULE(type)
OscarMTProducer(edm::ParameterSet const &p, const OscarMTMasterThread *)
~OscarMTProducer() override
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
void beginRun(const edm::EventSetup &iSetup) const
const char * what() const override
void produce(edm::Event &e, const edm::EventSetup &c) override
static void globalEndRun(const edm::Run &iRun, const edm::EventSetup &iSetup, const RunContext *iContext)
void load(edm::SimTrackContainer &c) const
static std::unique_ptr< OscarMTMasterThread > initializeGlobalCache(const edm::ParameterSet &iConfig)
void endRun(const edm::Run &r, const edm::EventSetup &c) override
std::vector< SimVertex > SimVertexContainer
StreamID streamID() const
std::vector< PSimHit > PSimHitContainer
static void globalEndJob(OscarMTMasterThread *masterThread)
std::vector< SimTrack > SimTrackContainer