File indexing completed on 2024-10-08 05:11:31
0001 #include "FWCore/TestProcessor/interface/TestProcessor.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include "FWCore/ServiceRegistry/interface/Service.h"
0004 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0005
0006 #define CATCH_CONFIG_MAIN
0007 #include "catch.hpp"
0008
0009
0010
0011 void runTestForAnalyzer(const std::string& baseConfig, const std::string& analyzerName) {
0012 edm::test::TestProcessor::Config config{baseConfig};
0013
0014 SECTION(analyzerName + " base configuration is OK") { REQUIRE_NOTHROW(edm::test::TestProcessor(config)); }
0015
0016 SECTION(analyzerName + " No Runs data") {
0017 edm::test::TestProcessor tester(config);
0018 REQUIRE_NOTHROW(tester.testWithNoRuns());
0019 }
0020
0021 SECTION(analyzerName + " beginJob and endJob only") {
0022 edm::test::TestProcessor tester(config);
0023 REQUIRE_NOTHROW(tester.testBeginAndEndJobOnly());
0024 }
0025
0026 SECTION("No event data") {
0027 edm::test::TestProcessor tester(config);
0028 REQUIRE_NOTHROW(tester.test());
0029 }
0030
0031 SECTION("Run with no LuminosityBlocks") {
0032 edm::test::TestProcessor tester(config);
0033 REQUIRE_NOTHROW(tester.testRunWithNoLuminosityBlocks());
0034 }
0035
0036 SECTION("LuminosityBlock with no Events") {
0037 edm::test::TestProcessor tester(config);
0038 REQUIRE_NOTHROW(tester.testLuminosityBlockWithNoEvents());
0039 }
0040 }
0041
0042
0043
0044 std::string generateBaseConfig(const std::string& analyzerName, const std::string& rootFileName) {
0045
0046 constexpr const char* rawString = R"_(from FWCore.TestProcessor.TestProcess import *
0047 process = TestProcess()
0048 process.load("MagneticField.Engine.uniformMagneticField_cfi")
0049 process.load("Configuration.Geometry.GeometryExtended2024Reco_cff")
0050 process.load("Alignment.CommonAlignmentProducer.FakeAlignmentSource_cfi")
0051 from DQM.TrackingMonitorSource.{}_cfi import {}
0052 process.trackAnalyzer = {}
0053 process.moduleToTest(process.trackAnalyzer)
0054 process.add_(cms.Service('DQMStore'))
0055 process.add_(cms.Service('MessageLogger'))
0056 process.add_(cms.Service('JobReportService'))
0057 process.add_(cms.Service('TFileService',fileName=cms.string('{}')))
0058 )_";
0059
0060
0061 return fmt::format(rawString, analyzerName, analyzerName, analyzerName, rootFileName);
0062 }
0063
0064
0065 TEST_CASE("ShortenedTrackResolution tests", "[ShortenedTrackResolution]") {
0066 const std::string baseConfig = generateBaseConfig("shortenedTrackResolution", "test1.root");
0067 runTestForAnalyzer(baseConfig, "ShortenedTrackResolution");
0068 }
0069
0070
0071 TEST_CASE("StandaloneTrackMonitor tests", "[StandaloneTrackMonitor]") {
0072 const std::string baseConfig = generateBaseConfig("standaloneTrackMonitorDefault", "test2.root");
0073 runTestForAnalyzer(baseConfig, "StandaloneTrackMonitor");
0074 }
0075
0076
0077 TEST_CASE("AlcaRecoTrackSelector tests", "[AlcaRecoTrackSelector]") {
0078 const std::string baseConfig = generateBaseConfig("alcaRecoTrackSelector", "tes3.root");
0079 runTestForAnalyzer(baseConfig, "AlcaRecoTrackSelector");
0080 }
0081
0082
0083
0084
0085
0086
0087
0088
0089 TEST_CASE("TrackMultiplicityFilter tests", "[TrackMultiplicityFilter]") {
0090 const std::string baseConfig = generateBaseConfig("trackMultiplicityFilter", "test_trackMultiplicityFilter.root");
0091 runTestForAnalyzer(baseConfig, "TrackMultiplicityFilter");
0092 }
0093
0094
0095
0096
0097
0098
0099
0100
0101 TEST_CASE("TrackTypeMonitor tests", "[TrackTypeMonitor]") {
0102 const std::string baseConfig = generateBaseConfig("trackTypeMonitor", "test_trackTypeMonitor.root");
0103 runTestForAnalyzer(baseConfig, "TrackTypeMonitor");
0104 }
0105
0106
0107 TEST_CASE("TtbarEventSelector tests", "[TtbarEventSelector]") {
0108 const std::string baseConfig = generateBaseConfig("ttbarEventSelector", "test_ttbarEventSelector.root");
0109 runTestForAnalyzer(baseConfig, "TtbarEventSelector");
0110 }
0111
0112
0113 TEST_CASE("TtbarTrackProducer tests", "[TtbarTrackProducer]") {
0114 const std::string baseConfig = generateBaseConfig("ttbarTrackProducer", "test_ttbarTrackProducer.root");
0115 runTestForAnalyzer(baseConfig, "TtbarTrackProducer");
0116 }
0117
0118
0119 TEST_CASE("V0EventSelector tests", "[V0EventSelector]") {
0120 const std::string baseConfig = generateBaseConfig("v0EventSelector", "test_v0EventSelector.root");
0121 runTestForAnalyzer(baseConfig, "V0EventSelector");
0122 }
0123
0124
0125 TEST_CASE("V0VertexTrackProducer tests", "[V0VertexTrackProducer]") {
0126 const std::string baseConfig = generateBaseConfig("v0VertexTrackProducer", "test_v0VertexTrackProducer.root");
0127 runTestForAnalyzer(baseConfig, "V0VertexTrackProducer");
0128 }
0129
0130
0131 TEST_CASE("WtoLNuSelector tests", "[WtoLNuSelector]") {
0132 const std::string baseConfig = generateBaseConfig("wtoLNuSelector", "test_wtoLNuSelector.root");
0133 runTestForAnalyzer(baseConfig, "WtoLNuSelector");
0134 }
0135
0136
0137 TEST_CASE("ZeeDetails tests", "[ZeeDetails]") {
0138 const std::string baseConfig = generateBaseConfig("zeeDetails", "test_zeeDetails.root");
0139 runTestForAnalyzer(baseConfig, "ZeeDetails");
0140 }
0141
0142
0143 TEST_CASE("ZtoEEElectronTrackProducer tests", "[ZtoEEElectronTrackProducer]") {
0144 const std::string baseConfig =
0145 generateBaseConfig("ztoEEElectronTrackProducer", "test_ztoEEElectronTrackProducer.root");
0146 runTestForAnalyzer(baseConfig, "ZtoEEElectronTrackProducer");
0147 }
0148
0149
0150 TEST_CASE("ZtoEEEventSelector tests", "[ZtoEEEventSelector]") {
0151 const std::string baseConfig = generateBaseConfig("ztoEEEventSelector", "test_ztoEEEventSelector.root");
0152 runTestForAnalyzer(baseConfig, "ZtoEEEventSelector");
0153 }
0154
0155
0156 TEST_CASE("ZtoMMEventSelector tests", "[ZtoMMEventSelector]") {
0157 const std::string baseConfig = generateBaseConfig("ztoMMEventSelector", "test_ztoMMEventSelector.root");
0158 runTestForAnalyzer(baseConfig, "ZtoMMEventSelector");
0159 }
0160
0161
0162 TEST_CASE("ZtoMMMuonTrackProducer tests", "[ZtoMMMuonTrackProducer]") {
0163 const std::string baseConfig = generateBaseConfig("ztoMMMuonTrackProducer", "test_ztoMMMuonTrackProducer.root");
0164 runTestForAnalyzer(baseConfig, "ZtoMMMuonTrackProducer");
0165 }