26 #include "Randomize.hh"
53 class StaticRandomEngineSetUnset {
56 explicit StaticRandomEngineSetUnset(CLHEP::HepRandomEngine * engine);
57 ~StaticRandomEngineSetUnset();
58 CLHEP::HepRandomEngine* getEngine()
const;
60 CLHEP::HepRandomEngine* m_currentEngine;
61 CLHEP::HepRandomEngine* m_previousEngine;
68 StaticRandomEngineSetUnset
random(
nullptr);
72 produces<edm::SimTrackContainer>().setBranchAlias(
"SimTracks");
73 produces<edm::SimVertexContainer>().setBranchAlias(
"SimVertices");
74 produces<edm::PSimHitContainer>(
"TrackerHitsPixelBarrelLowTof");
75 produces<edm::PSimHitContainer>(
"TrackerHitsPixelBarrelHighTof");
76 produces<edm::PSimHitContainer>(
"TrackerHitsTIBLowTof");
77 produces<edm::PSimHitContainer>(
"TrackerHitsTIBHighTof");
78 produces<edm::PSimHitContainer>(
"TrackerHitsTIDLowTof");
79 produces<edm::PSimHitContainer>(
"TrackerHitsTIDHighTof");
80 produces<edm::PSimHitContainer>(
"TrackerHitsPixelEndcapLowTof");
81 produces<edm::PSimHitContainer>(
"TrackerHitsPixelEndcapHighTof");
82 produces<edm::PSimHitContainer>(
"TrackerHitsTOBLowTof");
83 produces<edm::PSimHitContainer>(
"TrackerHitsTOBHighTof");
84 produces<edm::PSimHitContainer>(
"TrackerHitsTECLowTof");
85 produces<edm::PSimHitContainer>(
"TrackerHitsTECHighTof");
87 produces<edm::PSimHitContainer>(
"TotemHitsT1");
88 produces<edm::PSimHitContainer>(
"TotemHitsT2Gem");
89 produces<edm::PSimHitContainer>(
"TotemHitsRP");
90 produces<edm::PSimHitContainer>(
"FP420SI");
91 produces<edm::PSimHitContainer>(
"BSCHits");
92 produces<edm::PSimHitContainer>(
"PLTHits");
93 produces<edm::PSimHitContainer>(
"BCM1FHits");
95 produces<edm::PCaloHitContainer>(
"EcalHitsEB");
96 produces<edm::PCaloHitContainer>(
"EcalHitsEE");
97 produces<edm::PCaloHitContainer>(
"EcalHitsES");
98 produces<edm::PCaloHitContainer>(
"HcalHits");
99 produces<edm::PCaloHitContainer>(
"CaloHitsTk");
100 produces<edm::PSimHitContainer>(
"MuonDTHits");
101 produces<edm::PSimHitContainer>(
"MuonCSCHits");
102 produces<edm::PSimHitContainer>(
"MuonRPCHits");
103 produces<edm::PSimHitContainer>(
"MuonGEMHits");
104 produces<edm::PCaloHitContainer>(
"CastorPL");
105 produces<edm::PCaloHitContainer>(
"CastorFI");
106 produces<edm::PCaloHitContainer>(
"CastorBU");
107 produces<edm::PCaloHitContainer>(
"CastorTU");
108 produces<edm::PCaloHitContainer>(
"EcalTBH4BeamHits");
109 produces<edm::PCaloHitContainer>(
"HcalTB06BeamHits");
110 produces<edm::PCaloHitContainer>(
"ZDCHITS");
111 produces<edm::PCaloHitContainer>(
"ChamberHits");
112 produces<edm::PCaloHitContainer>(
"FibreHits");
113 produces<edm::PCaloHitContainer>(
"WedgeHits");
118 for(Producers::iterator itProd = m_producers.begin();
119 itProd != m_producers.end(); ++itProd) {
121 (*itProd)->registerProducts(*
this);
130 StaticRandomEngineSetUnset
random(
nullptr);
137 StaticRandomEngineSetUnset
random(
nullptr);
141 return std::shared_ptr<int>();
145 iContext->
global()->endRun();
156 StaticRandomEngineSetUnset
random(
nullptr);
164 std::vector<SensitiveTkDetector*>& sTk =
166 std::vector<SensitiveCaloDetector*>& sCalo =
172 std::auto_ptr<edm::SimTrackContainer>
174 std::auto_ptr<edm::SimVertexContainer>
183 for (std::vector<SensitiveTkDetector*>::iterator it = sTk.begin();
184 it != sTk.end(); ++it) {
186 std::vector<std::string>
v = (*it)->getNames();
187 for (std::vector<std::string>::iterator
in = v.begin();
188 in!= v.end(); ++
in) {
190 std::auto_ptr<edm::PSimHitContainer>
192 (*it)->fillHits(*product,*
in);
196 for (std::vector<SensitiveCaloDetector*>::iterator it = sCalo.begin();
197 it != sCalo.end(); ++it) {
199 std::vector<std::string>
v = (*it)->getNames();
201 for (std::vector<std::string>::iterator
in = v.begin();
202 in!= v.end();
in++) {
204 std::auto_ptr<edm::PCaloHitContainer>
206 (*it)->fillHits(*product,*
in);
211 for(Producers::iterator itProd =
m_producers.begin();
214 (*itProd)->produce(e,es);
218 edm::LogInfo(
"SimG4CoreApplication") <<
" SimG4Exception caght !"
227 StaticRandomEngineSetUnset::StaticRandomEngineSetUnset(
233 <<
"The OscarMTProducer module requires the RandomNumberGeneratorService\n"
234 "which is not present in the configuration file. You must add the service\n"
235 "in the configuration file if you want to run OscarMTProducer";
237 m_currentEngine = &(rng->
getEngine(streamID));
239 m_previousEngine = G4Random::getTheEngine();
240 G4Random::setTheEngine(m_currentEngine);
243 StaticRandomEngineSetUnset::StaticRandomEngineSetUnset(
244 CLHEP::HepRandomEngine * engine)
246 m_currentEngine = engine;
247 m_previousEngine = G4Random::getTheEngine();
248 G4Random::setTheEngine(m_currentEngine);
251 StaticRandomEngineSetUnset::~StaticRandomEngineSetUnset()
253 G4Random::setTheEngine(m_previousEngine);
256 CLHEP::HepRandomEngine* StaticRandomEngineSetUnset::getEngine()
const
258 return m_currentEngine;
std::vector< PCaloHit > PCaloHitContainer
static std::shared_ptr< int > globalBeginRun(const edm::Run &iRun, const edm::EventSetup &iSetup, const OscarMTMasterThread *masterThread)
std::unique_ptr< RunManagerMTWorker > m_runManagerWorker
#define DEFINE_FWK_MODULE(type)
OscarMTProducer(edm::ParameterSet const &p, const OscarMTMasterThread *)
virtual ~OscarMTProducer()
void beginRun(const edm::EventSetup &iSetup) const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
virtual const char * what() const
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)
virtual void endRun(const edm::Run &r, const edm::EventSetup &c) override
std::vector< SimVertex > SimVertexContainer
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &) const =0
Use this engine in event methods.
StreamID streamID() const
std::vector< PSimHit > PSimHitContainer
static void globalEndJob(OscarMTMasterThread *masterThread)
std::vector< SimTrack > SimTrackContainer