Skip to content

Commit

Permalink
Use equivalent random engine for all stream begin lumis
Browse files Browse the repository at this point in the history
Use identical clones of the random engine in order to setup the
hadronizer and decayer on each LuminosityBlock boundary.
  • Loading branch information
Dr15Jones committed Feb 10, 2020
1 parent c408913 commit d49909b
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions GeneratorInterface/Core/interface/ConcurrentHadronizerFilter.h
Expand Up @@ -396,10 +396,19 @@ namespace edm {
lhef::LHERunInfo* lheRunInfo = cache->hadronizer_.getLHERunInfo().get();
lheRunInfo->initLumi();

RandomEngineSentry<HAD> randomEngineSentry(&cache->hadronizer_, lumi.index());
RandomEngineSentry<DEC> randomEngineSentryDecay(cache->decayer_.get(), lumi.index());
//We need all copies to see same random # for begin lumi
Service<RandomNumberGenerator> rng;
auto enginePtr = rng->cloneEngine(lumi.index());
cache->hadronizer_.setRandomEngine(enginePtr.get());
cache->decayer_->setRandomEngine(enginePtr.get());

cache->hadronizer_.randomizeIndex(lumi, randomEngineSentry.randomEngine());
auto unsetH = [](HAD* h) { h->setRandomEngine(nullptr); };
auto unsetD = [](DEC* d) { d->setRandomEngine(nullptr); };

std::unique_ptr<HAD, decltype(unsetH)> randomEngineSentry(&cache->hadronizer_, unsetH);
std::unique_ptr<DEC, decltype(unsetD)> randomEngineSentryDecay(cache->decayer_.get(), unsetD);

cache->hadronizer_.randomizeIndex(lumi, enginePtr.get());

if (!cache->hadronizer_.readSettings(1))
throw edm::Exception(errors::Configuration)
Expand Down Expand Up @@ -514,6 +523,10 @@ namespace edm {
void ConcurrentHadronizerFilter<HAD, DEC>::globalEndLuminosityBlockProduce(LuminosityBlock& lumi,
EventSetup const&,
gen::LumiSummary const* iSummary) const {
//Advance the random number generator so next begin lumi starts with new seed
Service<RandomNumberGenerator> rng;
rng->getEngine(lumi.index()).flat();

lumi.put(std::move(iSummary->lumiInfo_));

// produce GenFilterInfo if HepMCFilter is called
Expand Down

0 comments on commit d49909b

Please sign in to comment.