CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/FastSimulation/Utilities/src/RandomEngine.cc

Go to the documentation of this file.
00001 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
00002 #include "FastSimulation/Utilities/interface/RandomEngine.h"
00003 #include "IOMC/RandomEngine/src/TRandomAdaptor.h"
00004 
00005 RandomEngine::RandomEngine(edm::RandomNumberGenerator* rng) 
00006   : 
00007   rng_(rng),
00008   rootEngine_(0)
00009 {
00010   // The service engine
00011   engine_ = &(rng->getEngine());
00012   // Get the TRandom3 egine, to benefit from Root functional random generation
00013   if ( engine_->name() == "TRandom3" )
00014     rootEngine_ = ( (edm::TRandomAdaptor*) engine_ )->getRootEngine();
00015   // If no root engine, use the CLHEP wrapper.
00016   if ( !rootEngine_ ) { 
00017     flatDistribution_ = new CLHEP::RandFlat(*engine_);
00018     gaussianDistribution_ = new CLHEP::RandGaussQ(*engine_);
00019     poissonDistribution_ = new CLHEP::RandPoissonQ(*engine_);
00020   }
00021 }
00022 
00023 RandomEngine::~RandomEngine() 
00024 {
00025   if ( !rootEngine_ ) { 
00026     delete flatDistribution_;
00027     delete gaussianDistribution_;
00028     delete poissonDistribution_;  
00029   }
00030 }
00031 
00032 
00033 
00034