21 #include "CLHEP/Random/Random.h"
43 class StaticRandomEngineSetUnset {
46 explicit StaticRandomEngineSetUnset(CLHEP::HepRandomEngine * engine);
47 ~StaticRandomEngineSetUnset();
48 CLHEP::HepRandomEngine* getEngine()
const;
50 CLHEP::HepRandomEngine* m_currentEngine;
51 CLHEP::HepRandomEngine* m_previousEngine;
58 StaticRandomEngineSetUnset
random(
nullptr);
63 produces<edm::SimTrackContainer>().setBranchAlias(
"SimTracks");
64 produces<edm::SimVertexContainer>().setBranchAlias(
"SimVertices");
65 produces<edm::PSimHitContainer>(
"TrackerHitsPixelBarrelLowTof");
66 produces<edm::PSimHitContainer>(
"TrackerHitsPixelBarrelHighTof");
67 produces<edm::PSimHitContainer>(
"TrackerHitsTIBLowTof");
68 produces<edm::PSimHitContainer>(
"TrackerHitsTIBHighTof");
69 produces<edm::PSimHitContainer>(
"TrackerHitsTIDLowTof");
70 produces<edm::PSimHitContainer>(
"TrackerHitsTIDHighTof");
71 produces<edm::PSimHitContainer>(
"TrackerHitsPixelEndcapLowTof");
72 produces<edm::PSimHitContainer>(
"TrackerHitsPixelEndcapHighTof");
73 produces<edm::PSimHitContainer>(
"TrackerHitsTOBLowTof");
74 produces<edm::PSimHitContainer>(
"TrackerHitsTOBHighTof");
75 produces<edm::PSimHitContainer>(
"TrackerHitsTECLowTof");
76 produces<edm::PSimHitContainer>(
"TrackerHitsTECHighTof");
78 produces<edm::PSimHitContainer>(
"TotemHitsT1");
79 produces<edm::PSimHitContainer>(
"TotemHitsT2Gem");
80 produces<edm::PSimHitContainer>(
"TotemHitsRP");
81 produces<edm::PSimHitContainer>(
"FP420SI");
82 produces<edm::PSimHitContainer>(
"BSCHits");
83 produces<edm::PSimHitContainer>(
"PLTHits");
85 produces<edm::PCaloHitContainer>(
"EcalHitsEB");
86 produces<edm::PCaloHitContainer>(
"EcalHitsEE");
87 produces<edm::PCaloHitContainer>(
"EcalHitsES");
88 produces<edm::PCaloHitContainer>(
"HcalHits");
89 produces<edm::PCaloHitContainer>(
"CaloHitsTk");
90 produces<edm::PSimHitContainer>(
"MuonDTHits");
91 produces<edm::PSimHitContainer>(
"MuonCSCHits");
92 produces<edm::PSimHitContainer>(
"MuonRPCHits");
93 produces<edm::PSimHitContainer>(
"MuonGEMHits");
94 produces<edm::PCaloHitContainer>(
"CastorPL");
95 produces<edm::PCaloHitContainer>(
"CastorFI");
96 produces<edm::PCaloHitContainer>(
"CastorBU");
97 produces<edm::PCaloHitContainer>(
"CastorTU");
98 produces<edm::PCaloHitContainer>(
"EcalTBH4BeamHits");
99 produces<edm::PCaloHitContainer>(
"HcalTB06BeamHits");
100 produces<edm::PCaloHitContainer>(
"ZDCHITS");
101 produces<edm::PCaloHitContainer>(
"ChamberHits");
102 produces<edm::PCaloHitContainer>(
"FibreHits");
103 produces<edm::PCaloHitContainer>(
"WedgeHits");
111 for(Producers::iterator itProd =
m_producers.begin();
114 (*itProd)->registerProducts(*
this);
128 StaticRandomEngineSetUnset
random(
nullptr);
136 std::vector<SensitiveTkDetector*>& sTk =
m_runManager->sensTkDetectors();
137 std::vector<SensitiveCaloDetector*>& sCalo =
m_runManager->sensCaloDetectors();
152 for (std::vector<SensitiveTkDetector*>::iterator it = sTk.begin(); it != sTk.end(); it++)
154 std::vector<std::string>
v = (*it)->getNames();
155 for (std::vector<std::string>::iterator
in = v.begin();
in!= v.end();
in++)
158 (*it)->fillHits(*product,*
in);
162 for (std::vector<SensitiveCaloDetector*>::iterator it = sCalo.begin(); it != sCalo.end(); it++)
164 std::vector<std::string>
v = (*it)->getNames();
165 for (std::vector<std::string>::iterator
in = v.begin();
in!= v.end();
in++)
168 (*it)->fillHits(*product,*
in);
173 for(Producers::iterator itProd =
m_producers.begin();
176 (*itProd)->produce(e,es);
182 edm::LogInfo(
"SimG4CoreApplication") <<
" SimG4Exception caght !" << simg4ex.
what() << std::endl ;
190 StaticRandomEngineSetUnset::StaticRandomEngineSetUnset(
edm::StreamID const& streamID) {
195 <<
"The OscarProducer module requires the RandomNumberGeneratorService\n"
196 "which is not present in the configuration file. You must add the service\n"
197 "in the configuration file if you want to run OscarProducer";
199 m_currentEngine = &(rng->
getEngine(streamID));
201 m_previousEngine = CLHEP::HepRandom::getTheEngine();
202 CLHEP::HepRandom::setTheEngine(m_currentEngine);
205 StaticRandomEngineSetUnset::StaticRandomEngineSetUnset(CLHEP::HepRandomEngine * engine) {
207 m_currentEngine = engine;
209 m_previousEngine = CLHEP::HepRandom::getTheEngine();
210 CLHEP::HepRandom::setTheEngine(m_currentEngine);
213 StaticRandomEngineSetUnset::~StaticRandomEngineSetUnset() {
214 CLHEP::HepRandom::setTheEngine(m_previousEngine);
217 CLHEP::HepRandomEngine*
218 StaticRandomEngineSetUnset::getEngine()
const {
return m_currentEngine; }
std::unique_ptr< RunManager > m_runManager
std::vector< PCaloHit > PCaloHitContainer
OscarProducer(edm::ParameterSet const &p)
#define DEFINE_FWK_MODULE(type)
virtual void beginRun(const edm::Run &r, const edm::EventSetup &c) override
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
static const std::string kGEANT
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
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