CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/IOMC/RandomEngine/src/RandomEngineStateProducer.cc

Go to the documentation of this file.
00001 
00002 #include "IOMC/RandomEngine/src/RandomEngineStateProducer.h"
00003 
00004 #include "FWCore/Framework/interface/Event.h"
00005 #include "FWCore/Framework/interface/LuminosityBlock.h"
00006 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00007 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00008 #include "FWCore/ServiceRegistry/interface/Service.h"
00009 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
00010 #include "SimDataFormats/RandomEngine/interface/RandomEngineStates.h"
00011 
00012 #include <memory>
00013 
00014 RandomEngineStateProducer::RandomEngineStateProducer(edm::ParameterSet const&) {
00015   produces<edm::RandomEngineStates, edm::InLumi>("beginLumi");
00016   produces<edm::RandomEngineStates>();
00017 }
00018 
00019 RandomEngineStateProducer::~RandomEngineStateProducer() {
00020 }
00021 
00022 void
00023 RandomEngineStateProducer::produce(edm::Event& ev, edm::EventSetup const&) {
00024   edm::Service<edm::RandomNumberGenerator> randomService;
00025   if(randomService.isAvailable()) {
00026     std::auto_ptr<edm::RandomEngineStates> states(new edm::RandomEngineStates);
00027     states->setRandomEngineStates(randomService->getEventCache());
00028     ev.put(states);
00029   }
00030 }
00031 
00032 void
00033 RandomEngineStateProducer::beginLuminosityBlock(edm::LuminosityBlock& lb, edm::EventSetup const&) {
00034   edm::Service<edm::RandomNumberGenerator> randomService;
00035   if(randomService.isAvailable()) {
00036     std::auto_ptr<edm::RandomEngineStates> states(new edm::RandomEngineStates);
00037     states->setRandomEngineStates(randomService->getLumiCache());
00038     lb.put(states, "beginLumi");
00039   }
00040 }
00041 
00042 void
00043 RandomEngineStateProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
00044   edm::ParameterSetDescription desc;
00045   descriptions.add("randomEngineStateProducer", desc);
00046 }