27 #include "Randomize.hh"
54 class StaticRandomEngineSetUnset {
57 explicit StaticRandomEngineSetUnset(CLHEP::HepRandomEngine* engine);
58 ~StaticRandomEngineSetUnset();
61 CLHEP::HepRandomEngine* m_currentEngine;
62 CLHEP::HepRandomEngine* m_previousEngine;
68 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 for (Producers::iterator itProd =
producers.begin(); itProd !=
producers.end(); ++itProd) {
132 (*itProd)->registerProducts(producesCollector());
134 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTProducer is constructed";
141 StaticRandomEngineSetUnset random(
nullptr);
142 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTProducer::initializeGlobalCache";
151 StaticRandomEngineSetUnset random(
nullptr);
153 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTProducer::globalBeginRun";
155 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTProducer::globalBeginRun done";
156 return std::shared_ptr<int>();
160 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTProducer::globalEndRun";
161 iContext->
global()->endRun();
165 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTProducer::globalEndJob";
172 edm::LogVerbatim(
"SimG4CoreApplication") <<
"OscarMTProducer::beginRun done";
177 StaticRandomEngineSetUnset random(
nullptr);
184 StaticRandomEngineSetUnset random(
e.streamID());
185 edm::LogVerbatim(
"SimG4CoreApplication") <<
"Produce event " <<
e.id() <<
" stream " <<
e.streamID();
186 LogDebug(
"SimG4CoreApplication") <<
"Before event rand= " << G4UniformRand();
191 std::unique_ptr<G4SimEvent> evt;
198 <<
"SimG4CoreApplication exception in generation of event " <<
e.id() <<
" in stream " <<
e.streamID() <<
" \n"
211 const std::vector<std::string>&
v =
tracker->getNames();
212 for (
auto&
name :
v) {
215 if (product !=
nullptr && !product->empty())
216 edm::LogVerbatim(
"SimG4CoreApplication") <<
"Produced " << product->size() <<
" traker hits <" <<
name <<
">";
220 for (
auto&
calo : sCalo) {
221 const std::vector<std::string>&
v =
calo->getNames();
223 for (
auto&
name :
v) {
226 if (product !=
nullptr && !product->empty())
227 edm::LogVerbatim(
"SimG4CoreApplication") <<
"Produced " << product->size() <<
" calo hits <" <<
name <<
">";
234 prod.get()->produce(
e, es);
236 edm::LogVerbatim(
"SimG4CoreApplication") <<
"Event is produced " <<
e.id() <<
" stream " <<
e.streamID();
237 LogDebug(
"SimG4CoreApplication") <<
"End of event rand= " << G4UniformRand();
240 StaticRandomEngineSetUnset::StaticRandomEngineSetUnset(
edm::StreamID const& streamID) {
244 <<
"The OscarMTProducer module requires the RandomNumberGeneratorService\n"
245 "which is not present in the configuration file. You must add the service\n"
246 "in the configuration file if you want to run OscarMTProducer";
248 m_currentEngine = &(rng->
getEngine(streamID));
250 m_previousEngine = G4Random::getTheEngine();
251 G4Random::setTheEngine(m_currentEngine);
254 StaticRandomEngineSetUnset::StaticRandomEngineSetUnset(CLHEP::HepRandomEngine* engine) {
255 m_currentEngine = engine;
256 m_previousEngine = G4Random::getTheEngine();
257 G4Random::setTheEngine(m_currentEngine);
260 StaticRandomEngineSetUnset::~StaticRandomEngineSetUnset() { G4Random::setTheEngine(m_previousEngine); }