23 #include "Randomize.hh"
51 class StaticRandomEngineSetUnset {
54 explicit StaticRandomEngineSetUnset(CLHEP::HepRandomEngine * engine);
55 ~StaticRandomEngineSetUnset();
57 CLHEP::HepRandomEngine* m_currentEngine;
58 CLHEP::HepRandomEngine* m_previousEngine;
65 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>(
"FP420SI");
92 produces<edm::PSimHitContainer>(
"BSCHits");
93 produces<edm::PSimHitContainer>(
"PLTHits");
94 produces<edm::PSimHitContainer>(
"BCM1FHits");
95 produces<edm::PSimHitContainer>(
"BHMHits");
96 produces<edm::PSimHitContainer>(
"FastTimerHitsBarrel");
97 produces<edm::PSimHitContainer>(
"FastTimerHitsEndcap");
99 produces<edm::PCaloHitContainer>(
"EcalHitsEB");
100 produces<edm::PCaloHitContainer>(
"EcalHitsEE");
101 produces<edm::PCaloHitContainer>(
"EcalHitsES");
102 produces<edm::PCaloHitContainer>(
"HcalHits");
103 produces<edm::PCaloHitContainer>(
"CaloHitsTk");
104 produces<edm::PCaloHitContainer>(
"HGCHitsEE");
105 produces<edm::PCaloHitContainer>(
"HGCHitsHEfront");
106 produces<edm::PCaloHitContainer>(
"HGCHitsHEback");
108 produces<edm::PSimHitContainer>(
"MuonDTHits");
109 produces<edm::PSimHitContainer>(
"MuonCSCHits");
110 produces<edm::PSimHitContainer>(
"MuonRPCHits");
111 produces<edm::PSimHitContainer>(
"MuonGEMHits");
112 produces<edm::PSimHitContainer>(
"MuonME0Hits");
114 produces<edm::PCaloHitContainer>(
"CastorPL");
115 produces<edm::PCaloHitContainer>(
"CastorFI");
116 produces<edm::PCaloHitContainer>(
"CastorBU");
117 produces<edm::PCaloHitContainer>(
"CastorTU");
118 produces<edm::PCaloHitContainer>(
"EcalTBH4BeamHits");
119 produces<edm::PCaloHitContainer>(
"HcalTB06BeamHits");
120 produces<edm::PCaloHitContainer>(
"ZDCHITS");
121 produces<edm::PCaloHitContainer>(
"ChamberHits");
122 produces<edm::PCaloHitContainer>(
"FibreHits");
123 produces<edm::PCaloHitContainer>(
"WedgeHits");
128 for(Producers::iterator itProd = m_producers.begin();
129 itProd != m_producers.end(); ++itProd) {
131 (*itProd)->registerProducts(*
this);
145 StaticRandomEngineSetUnset
random(
nullptr);
159 std::vector<SensitiveTkDetector*>& sTk =
161 std::vector<SensitiveCaloDetector*>& sCalo =
168 std::unique_ptr<edm::SimTrackContainer>
170 std::unique_ptr<edm::SimVertexContainer>
179 for (std::vector<SensitiveTkDetector*>::iterator it = sTk.begin();
180 it != sTk.end(); ++it) {
182 std::vector<std::string>
v = (*it)->getNames();
183 for (std::vector<std::string>::iterator
in = v.begin();
184 in!= v.end(); ++
in) {
186 std::unique_ptr<edm::PSimHitContainer>
188 (*it)->fillHits(*product,*
in);
192 for (std::vector<SensitiveCaloDetector*>::iterator it = sCalo.begin();
193 it != sCalo.end(); ++it) {
195 std::vector<std::string>
v = (*it)->getNames();
197 for (std::vector<std::string>::iterator
in = v.begin();
198 in!= v.end();
in++) {
200 std::unique_ptr<edm::PCaloHitContainer>
202 (*it)->fillHits(*product,*
in);
207 for(Producers::iterator itProd =
m_producers.begin();
210 (*itProd)->produce(e,es);
215 edm::LogInfo(
"SimG4CoreApplication") <<
"SimG4Exception caght! "
220 <<
"SimG4CoreApplication exception in generation of event "
221 << e.
id() <<
" in stream " << e.
streamID() <<
" \n"
226 StaticRandomEngineSetUnset::StaticRandomEngineSetUnset(
232 <<
"The OscarProducer module requires the RandomNumberGeneratorService\n"
233 "which is not present in the configuration file. You must add the service\n"
234 "in the configuration file if you want to run OscarProducer";
236 m_currentEngine = &(rng->
getEngine(streamID));
242 m_previousEngine = G4Random::getTheEngine();
243 G4Random::setTheEngine(m_currentEngine);
246 StaticRandomEngineSetUnset::StaticRandomEngineSetUnset(
247 CLHEP::HepRandomEngine * engine)
249 m_currentEngine = engine;
250 m_previousEngine = G4Random::getTheEngine();
251 G4Random::setTheEngine(m_currentEngine);
254 StaticRandomEngineSetUnset::~StaticRandomEngineSetUnset()
256 G4Random::setTheEngine(m_previousEngine);
T getParameter(std::string const &) const
std::unique_ptr< RunManager > m_runManager
std::vector< PCaloHit > PCaloHitContainer
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
virtual void endRun(const edm::Run &r, const edm::EventSetup &c) override
edm::Service< edm::RandomNumberGenerator > rng
OscarProducer(edm::ParameterSet const &p)
#define DEFINE_FWK_MODULE(type)
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
virtual void beginRun(const edm::Run &r, const edm::EventSetup &c) override
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
static const std::string kGEANT
usesResource(TFileService::kSharedResource)
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
static const std::string kCLHEPRandomEngine
virtual const char * what() const
void load(edm::SimTrackContainer &c) const
std::vector< SimVertex > SimVertexContainer
StreamID streamID() const
std::vector< PSimHit > PSimHitContainer
std::vector< SimTrack > SimTrackContainer
std::unique_ptr< CustomUIsession > m_UIsession