26 #include "Randomize.hh"
52 class StaticRandomEngineSetUnset {
55 explicit StaticRandomEngineSetUnset(CLHEP::HepRandomEngine* engine);
56 ~StaticRandomEngineSetUnset();
59 CLHEP::HepRandomEngine* m_currentEngine;
60 CLHEP::HepRandomEngine* m_previousEngine;
66 StaticRandomEngineSetUnset random(
nullptr);
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");
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");
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");
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");
131 ptr->registerProducts(producesCollector());
133 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTProducer is constructed";
140 StaticRandomEngineSetUnset random(
nullptr);
141 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTProducer::initializeGlobalCache";
143 return std::make_unique<OscarMTMasterThread>(iConfig);
150 StaticRandomEngineSetUnset random(
nullptr);
151 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTProducer::globalBeginRun";
153 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTProducer::globalBeginRun done";
154 return std::shared_ptr<int>();
158 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTProducer::globalEndRun";
159 iContext->
global()->endRun();
163 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTProducer::globalEndJob";
171 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTProducer::beginRun done";
176 StaticRandomEngineSetUnset random(
nullptr);
183 StaticRandomEngineSetUnset random(
e.streamID());
184 edm::LogVerbatim(
"SimG4CoreApplication") <<
"Produce event " <<
e.id() <<
" stream " <<
e.streamID();
190 std::unique_ptr<G4SimEvent> evt;
197 <<
"SimG4CoreApplication exception in generation of event " <<
e.id() <<
" in stream " <<
e.streamID() <<
" \n"
210 const std::vector<std::string>&
v =
tracker->getNames();
211 for (
auto&
name :
v) {
214 if (product !=
nullptr && !product->empty())
215 edm::LogVerbatim(
"SimG4CoreApplication") <<
"Produced " << product->size() <<
" tracker hits <" <<
name <<
">";
219 for (
auto&
calo : sCalo) {
220 const std::vector<std::string>&
v =
calo->getNames();
222 for (
auto&
name :
v) {
225 if (product !=
nullptr && !product->empty())
226 edm::LogVerbatim(
"SimG4CoreApplication") <<
"Produced " << product->size() <<
" calo hits <" <<
name <<
">";
233 prod.get()->produce(
e, es);
235 edm::LogVerbatim(
"SimG4CoreApplication") <<
"Event is produced " <<
e.id() <<
" stream " <<
e.streamID();
239 StaticRandomEngineSetUnset::StaticRandomEngineSetUnset(
edm::StreamID const& streamID) {
243 <<
"The OscarMTProducer module requires the RandomNumberGeneratorService\n"
244 "which is not present in the configuration file. You must add the service\n"
245 "in the configuration file if you want to run OscarMTProducer";
247 m_currentEngine = &(rng->
getEngine(streamID));
249 m_previousEngine = G4Random::getTheEngine();
250 G4Random::setTheEngine(m_currentEngine);
253 StaticRandomEngineSetUnset::StaticRandomEngineSetUnset(CLHEP::HepRandomEngine* engine) {
254 m_currentEngine = engine;
255 m_previousEngine = G4Random::getTheEngine();
256 G4Random::setTheEngine(m_currentEngine);
259 StaticRandomEngineSetUnset::~StaticRandomEngineSetUnset() { G4Random::setTheEngine(m_previousEngine); }