Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-20 02:14:49

0001 #include "FastSimulation/Utilities/interface/RandomEngineAndDistribution.h"
0002 
0003 #include "FWCore/ServiceRegistry/interface/Service.h"
0004 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
0005 #include "FWCore/Utilities/interface/Exception.h"
0006 
0007 #include "CLHEP/Random/RandomEngine.h"
0008 
0009 RandomEngineAndDistribution::RandomEngineAndDistribution(edm::StreamID const& streamID) : engine_(nullptr) {
0010   edm::Service<edm::RandomNumberGenerator> rng;
0011   if (!rng.isAvailable()) {
0012     throw cms::Exception("Configuration") << "RandomNumberGenerator service is not available.\n"
0013                                              "You must add the service in the configuration file\n"
0014                                              "or remove the module that requires it.";
0015   }
0016   engine_ = &rng->getEngine(streamID);
0017 }
0018 
0019 RandomEngineAndDistribution::RandomEngineAndDistribution(edm::LuminosityBlockIndex const& luminosityBlockIndex)
0020     : engine_(nullptr) {
0021   edm::Service<edm::RandomNumberGenerator> rng;
0022   if (!rng.isAvailable()) {
0023     throw cms::Exception("Configuration") << "RandomNumberGenerator service is not available.\n"
0024                                              "You must add the service in the configuration file\n"
0025                                              "or remove the module that requires it.";
0026   }
0027   engine_ = &rng->getEngine(luminosityBlockIndex);
0028 }
0029 
0030 RandomEngineAndDistribution::~RandomEngineAndDistribution() {}