Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid printing statistics if hadronizer has not been initialized properly #25579

Merged
merged 1 commit into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions GeneratorInterface/Core/interface/GeneratorFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ namespace edm
Decayer* decayer_;
unsigned int nEventsInLumiBlock_;
unsigned int nThreads_{1};
bool initialized_ = false;
};

//------------------------------------------------------------------------
Expand Down Expand Up @@ -222,9 +223,11 @@ namespace edm
// the contained hadronizer that would report the integrated
// luminosity.

hadronizer_.statistics();
if(initialized_) {
hadronizer_.statistics();

if ( decayer_ ) decayer_->statistics();
if ( decayer_ ) decayer_->statistics();
}

std::unique_ptr<GenRunInfoProduct> griproduct(new GenRunInfoProduct(hadronizer_.getGenRunInfo()));
r.put(std::move(griproduct));
Expand Down Expand Up @@ -274,7 +277,7 @@ namespace edm

std::unique_ptr<GenLumiInfoHeader> genLumiInfoHeader(hadronizer_.getGenLumiInfoHeader());
lumi.put(std::move(genLumiInfoHeader));

initialized_ = true;
}

template <class HAD, class DEC>
Expand Down
5 changes: 5 additions & 0 deletions GeneratorInterface/Pythia8Interface/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@
<library file="ZJetsAnalyzer.cc,analyserhepmc/LeptonAnalyserHepMC.cc,analyserhepmc/JetInputHepMC.cc" name="ZJetsTestAnalyzer">
<flags EDM_PLUGIN="1"/>
</library>

<bin file="test_catch2_*.cc" name="testGeneratorInterfacePythia8InterfaceTP">
<use name="FWCore/TestProcessor"/>
<use name="catch2"/>
</bin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include "catch.hpp"
#include "FWCore/TestProcessor/interface/TestProcessor.h"
#include "FWCore/Utilities/interface/Exception.h"

static constexpr auto s_tag = "[Pythia8GeneratorFilter]";

TEST_CASE("Standard checks of Pythia8GeneratorFilter", s_tag) {
const std::string baseConfig{
R"_(from FWCore.TestProcessor.TestProcess import *
process = TestProcess()
process.load("Configuration.StandardSequences.SimulationRandomNumberGeneratorSeeds_cff")
process.RandomNumberGeneratorService.toTest = process.RandomNumberGeneratorService.generator.clone()
process.toTest = cms.EDFilter("Pythia8GeneratorFilter",
comEnergy = cms.double(7000.),
PythiaParameters = cms.PSet(
pythia8_example02 = cms.vstring('HardQCD:all = on',
'PhaseSpace:pTHatMin = 20.'),
parameterSets = cms.vstring('pythia8_example02')
)
)
process.moduleToTest(process.toTest)
)_"
};

edm::test::TestProcessor::Config config{ baseConfig };
SECTION("base configuration is OK") {
REQUIRE_NOTHROW(edm::test::TestProcessor(config));
}

SECTION("No event data") {
edm::test::TestProcessor tester(config);

REQUIRE_NOTHROW(tester.test());
}

SECTION("beginJob and endJob only") {
edm::test::TestProcessor tester(config);

REQUIRE_NOTHROW(tester.testBeginAndEndJobOnly());
}

SECTION("Run with no LuminosityBlocks") {
edm::test::TestProcessor tester(config);

REQUIRE_NOTHROW(tester.testRunWithNoLuminosityBlocks());
}

SECTION("LuminosityBlock with no Events") {
edm::test::TestProcessor tester(config);

REQUIRE_NOTHROW(tester.testLuminosityBlockWithNoEvents());
}

}

//Add additional TEST_CASEs to exercise the modules capabilities
2 changes: 2 additions & 0 deletions GeneratorInterface/Pythia8Interface/test/test_catch2_main.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define CATCH_CONFIG_MAIN
#include "catch.hpp"