File indexing completed on 2024-04-06 12:13:51
0001 #include "catch.hpp"
0002 #include "FWCore/TestProcessor/interface/TestProcessor.h"
0003 #include "FWCore/Utilities/interface/Exception.h"
0004 #include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h"
0005
0006 static constexpr auto s_tag = "[ExternalLHEProducer]";
0007
0008 TEST_CASE("Standard checks of ExternalLHEProducer", s_tag) {
0009 const std::string baseConfig{
0010 R"_(from FWCore.TestProcessor.TestProcess import *
0011 process = TestProcess()
0012 process.externalLHEProducer = cms.EDProducer('ExternalLHEProducer',
0013 scriptName = cms.FileInPath("GeneratorInterface/LHEInterface/test/run_dummy_script.sh"),
0014 outputFile = cms.string("dummy.lhe"),
0015 numberOfParameters = cms.uint32(1),
0016 args = cms.vstring('value'),
0017 nEvents = cms.untracked.uint32(5),
0018 storeXML = cms.untracked.bool(False),
0019 generateConcurrently = cms.untracked.bool(False)
0020 )
0021 process.moduleToTest(process.externalLHEProducer)
0022 process.RandomNumberGeneratorService = cms.Service('RandomNumberGeneratorService',
0023 externalLHEProducer = cms.PSet(
0024 initialSeed = cms.untracked.uint32(563)
0025 )
0026 )
0027
0028 )_"};
0029
0030 edm::test::TestProcessor::Config config{baseConfig};
0031 SECTION("base configuration is OK") { REQUIRE_NOTHROW(edm::test::TestProcessor(config)); }
0032
0033 SECTION("All events") {
0034 edm::test::TestProcessor tester(config);
0035
0036
0037 {
0038 auto event = tester.test();
0039 auto const& prod = event.get<LHEEventProduct>();
0040 REQUIRE(prod->hepeup().NUP == 12);
0041 }
0042 REQUIRE_NOTHROW(tester.test());
0043 REQUIRE_NOTHROW(tester.test());
0044 REQUIRE_NOTHROW(tester.test());
0045 REQUIRE_NOTHROW(tester.test());
0046 }
0047
0048 SECTION("All events: generateConcurrently") {
0049 edm::test::TestProcessor::Config config{baseConfig + "\nprocess.externalLHEProducer.generateConcurrently = True\n"};
0050 edm::test::TestProcessor tester(config);
0051
0052
0053 {
0054 auto event = tester.test();
0055 auto const& prod = event.get<LHEEventProduct>();
0056 REQUIRE(prod->hepeup().NUP == 12);
0057 }
0058 REQUIRE_NOTHROW(tester.test());
0059 REQUIRE_NOTHROW(tester.test());
0060 REQUIRE_NOTHROW(tester.test());
0061 REQUIRE_NOTHROW(tester.test());
0062 }
0063
0064 SECTION("Missing events") {
0065 edm::test::TestProcessor tester(config);
0066
0067
0068 REQUIRE_NOTHROW(tester.test());
0069 REQUIRE_NOTHROW(tester.test());
0070 REQUIRE_NOTHROW(tester.test());
0071 REQUIRE_NOTHROW(tester.test());
0072 REQUIRE_THROWS_AS(tester.testEndRun(), cms::Exception);
0073 }
0074
0075 SECTION("beginJob and endJob only") {
0076 edm::test::TestProcessor tester(config);
0077
0078 REQUIRE_NOTHROW(tester.testBeginAndEndJobOnly());
0079 }
0080
0081 SECTION("Run with no LuminosityBlocks") {
0082 edm::test::TestProcessor tester(config);
0083
0084 REQUIRE_THROWS_AS(tester.testRunWithNoLuminosityBlocks(), cms::Exception);
0085 }
0086
0087 SECTION("LuminosityBlock with no Events") {
0088 edm::test::TestProcessor tester(config);
0089
0090 REQUIRE_THROWS_AS(tester.testLuminosityBlockWithNoEvents(), cms::Exception);
0091 }
0092 }
0093
0094