diff --git a/RecoHI/HiEgammaAlgos/interface/TxCalculator.h b/RecoHI/HiEgammaAlgos/interface/TxCalculator.h index 2373dba6dac7a..d96886672cb85 100644 --- a/RecoHI/HiEgammaAlgos/interface/TxCalculator.h +++ b/RecoHI/HiEgammaAlgos/interface/TxCalculator.h @@ -19,11 +19,12 @@ #include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" -#include "CLHEP/Random/RandFlat.h" - - #define PI 3.141592653 +namespace CLHEP { + class HepRandomEngine; +} + class TxCalculator { public: @@ -41,7 +42,7 @@ class TxCalculator private: edm::Handle recCollection; - CLHEP::RandFlat *theDice; + CLHEP::HepRandomEngine *theDice; double dRDistance(double eta1,double phi1,double eta2,double phi2) { diff --git a/RecoHI/HiEgammaAlgos/src/TxCalculator.cc b/RecoHI/HiEgammaAlgos/src/TxCalculator.cc index 89209ccc6bf2d..71c689bfe15dd 100644 --- a/RecoHI/HiEgammaAlgos/src/TxCalculator.cc +++ b/RecoHI/HiEgammaAlgos/src/TxCalculator.cc @@ -15,6 +15,8 @@ #include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/Utilities/interface/RandomNumberGenerator.h" +#include "CLHEP/Random/RandomEngine.h" + using namespace edm; using namespace reco; using namespace std; @@ -31,9 +33,7 @@ TxCalculator::TxCalculator (const edm::Event &iEvent, const edm::EventSetup &iSe "which is not present in the configuration file. You must add the service\n" "in the configuration file or remove the modules that require it."; } - CLHEP::HepRandomEngine& engine = rng->getEngine(); - theDice = new CLHEP::RandFlat(engine, 0, 1); - + theDice = &rng->getEngine(iEvent.streamID()); } @@ -98,7 +98,7 @@ double TxCalculator::getTx(const reco::Photon& cluster, double x, double thresho for(reco::TrackCollection::const_iterator recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++) { - double diceNum = theDice->fire(); + double diceNum = theDice->flat(); if ( (effRatio < 1 ) && ( diceNum > effRatio)) continue; @@ -135,7 +135,7 @@ double TxCalculator::getCTx(const reco::Photon& cluster, double x, double thresh for(reco::TrackCollection::const_iterator recTrack = recCollection->begin(); recTrack!= recCollection->end(); recTrack++) { - double diceNum = theDice->fire(); + double diceNum = theDice->flat(); if ( (effRatio < 1 ) && ( diceNum > effRatio)) continue; diff --git a/RecoJets/FFTJetProducers/plugins/FFTJetVertexAdder.cc b/RecoJets/FFTJetProducers/plugins/FFTJetVertexAdder.cc index 861e278ae71c6..a1471be26722f 100644 --- a/RecoJets/FFTJetProducers/plugins/FFTJetVertexAdder.cc +++ b/RecoJets/FFTJetProducers/plugins/FFTJetVertexAdder.cc @@ -81,8 +81,6 @@ class FFTJetVertexAdder : public edm::EDProducer const double errZ; const unsigned nVerticesToMake; - - CLHEP::RandGauss* rGauss_; }; // @@ -105,8 +103,7 @@ FFTJetVertexAdder::FFTJetVertexAdder(const edm::ParameterSet& ps) init_param(double, errX), init_param(double, errY), init_param(double, errZ), - init_param(unsigned, nVerticesToMake), - rGauss_(0) + init_param(unsigned, nVerticesToMake) { produces(outputLabel); } @@ -114,7 +111,6 @@ FFTJetVertexAdder::FFTJetVertexAdder(const edm::ParameterSet& ps) FFTJetVertexAdder::~FFTJetVertexAdder() { - delete rGauss_; } @@ -122,6 +118,9 @@ FFTJetVertexAdder::~FFTJetVertexAdder() void FFTJetVertexAdder::produce( edm::Event& iEvent, const edm::EventSetup& iSetup) { + edm::Service rng; + CLHEP::RandGauss rGauss(rng->getEngine(iEvent.streamID())); + // get PFCandidates std::auto_ptr pOutput(new reco::VertexCollection); @@ -162,9 +161,9 @@ void FFTJetVertexAdder::produce( for (unsigned iv=0; ivpush_back(reco::Vertex(position, err, chi2, nDof, 0)); } @@ -193,15 +192,12 @@ void FFTJetVertexAdder::produce( // ------------ method called once each job just before starting event loop void FFTJetVertexAdder::beginJob() { - if (!rGauss_) - { - edm::Service rng; - if ( !rng.isAvailable() ) - throw cms::Exception("FFTJetBadConfig") - << "ERROR in FFTJetVertexAdder:" - " failed to initialize the random number generator" - << std::endl; - rGauss_ = new CLHEP::RandGauss(rng->getEngine()); + edm::Service rng; + if ( !rng.isAvailable() ) { + throw cms::Exception("FFTJetBadConfig") + << "ERROR in FFTJetVertexAdder:" + " failed to initialize the random number generator" + << std::endl; } }