File indexing completed on 2024-04-06 12:23:45
0001 #include "catch.hpp"
0002 #include "FWCore/TestProcessor/interface/TestProcessor.h"
0003 #include "FWCore/Utilities/interface/Exception.h"
0004 #include "DataFormats/NanoAOD/interface/FlatTable.h"
0005
0006 static constexpr auto s_tag = "[NanoAODDQM]";
0007
0008 TEST_CASE("Standard checks of NanoAODDQM", s_tag) {
0009 const std::string baseConfig{
0010 R"_(from FWCore.TestProcessor.TestProcess import *
0011 process = TestProcess()
0012 process.toTest = cms.EDProducer("NanoAODDQM",
0013 vplots = cms.PSet(
0014 TEST = cms.PSet(
0015 sels = cms.PSet( Good = cms.string("foo > 0 && abs(bar) > 1.3") ),
0016 plots = cms.VPSet(
0017 cms.PSet( name = cms.string("foo"), kind = cms.string("none"))
0018 )
0019 )
0020 )
0021 )
0022 process.add_(cms.Service("DQMStore"))
0023 process.moduleToTest(process.toTest)
0024 )_"};
0025
0026 edm::test::TestProcessor::Config config{baseConfig};
0027 SECTION("base configuration is OK") { REQUIRE_NOTHROW(edm::test::TestProcessor(config)); }
0028
0029 SECTION("No event data") {
0030 edm::test::TestProcessor tester(config);
0031
0032 REQUIRE_NOTHROW(tester.test());
0033 }
0034
0035 SECTION("With good event data") {
0036 auto token = config.produces<nanoaod::FlatTable>("test");
0037 edm::test::TestProcessor tester(config);
0038 auto table = std::make_unique<nanoaod::FlatTable>(1, "TEST", false);
0039 table->addColumn<float>("foo", std::vector<float>(1, 3.0f), "is foo");
0040 table->addColumn<float>("bar", std::vector<float>(1, 5.0f), "is bar");
0041 REQUIRE_NOTHROW(tester.test(std::make_pair(token, std::move(table))));
0042 }
0043
0044 SECTION("With wrong column name") {
0045 auto token = config.produces<nanoaod::FlatTable>("test");
0046 edm::test::TestProcessor tester(config);
0047 auto table = std::make_unique<nanoaod::FlatTable>(1, "TEST", false);
0048 table->addColumn<float>("Foo", std::vector<float>(1, 3.0f), "is foo");
0049 table->addColumn<float>("bar", std::vector<float>(1, 5.0f), "is bar");
0050 REQUIRE_THROWS_AS(tester.test(std::make_pair(token, std::move(table))), cms::Exception);
0051 }
0052
0053 SECTION("beginJob and endJob only") {
0054 edm::test::TestProcessor tester(config);
0055
0056 REQUIRE_NOTHROW(tester.testBeginAndEndJobOnly());
0057 }
0058
0059 SECTION("Run with no LuminosityBlocks") {
0060 edm::test::TestProcessor tester(config);
0061
0062 REQUIRE_NOTHROW(tester.testRunWithNoLuminosityBlocks());
0063 }
0064
0065 SECTION("LuminosityBlock with no Events") {
0066 edm::test::TestProcessor tester(config);
0067
0068 REQUIRE_NOTHROW(tester.testLuminosityBlockWithNoEvents());
0069 }
0070
0071 SECTION("Use Row Method") {
0072 const std::string baseConfig{
0073 R"_(from FWCore.TestProcessor.TestProcess import *
0074 process = TestProcess()
0075 process.toTest = cms.EDProducer("NanoAODDQM",
0076 vplots = cms.PSet(
0077 TEST = cms.PSet(
0078 sels = cms.PSet( Good = cms.string("foo > 0 && row == 0") ),
0079 plots = cms.VPSet(
0080 cms.PSet( name = cms.string("foo"), kind = cms.string("none"))
0081 )
0082 )
0083 )
0084 )
0085 process.add_(cms.Service("DQMStore"))
0086 process.moduleToTest(process.toTest)
0087 )_"};
0088
0089 edm::test::TestProcessor::Config config{baseConfig};
0090
0091 auto token = config.produces<nanoaod::FlatTable>("test");
0092 edm::test::TestProcessor tester(config);
0093 auto table = std::make_unique<nanoaod::FlatTable>(1, "TEST", false);
0094 table->addColumn<float>("foo", std::vector<float>(1, 3.0f), "is foo");
0095 REQUIRE_NOTHROW(tester.test(std::make_pair(token, std::move(table))));
0096 }
0097 }
0098
0099