Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:20

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 #include "Alignment/OfflineValidation/interface/TkAlStyle.h"
0006 
0007 #define CATCH_CONFIG_MAIN
0008 #include "catch.hpp"
0009 
0010 // Function to run the catch2 tests
0011 //___________________________________________________________________________________________
0012 void runTestForAnalyzer(const std::string& baseConfig, const std::string& analyzerName) {
0013   edm::test::TestProcessor::Config config{baseConfig};
0014 
0015   SECTION(analyzerName + " base configuration is OK") { REQUIRE_NOTHROW(edm::test::TestProcessor(config)); }
0016 
0017   SECTION(analyzerName + " No Runs data") {
0018     edm::test::TestProcessor tester(config);
0019     REQUIRE_NOTHROW(tester.testWithNoRuns());
0020   }
0021 
0022   SECTION(analyzerName + " beginJob and endJob only") {
0023     edm::test::TestProcessor tester(config);
0024     REQUIRE_NOTHROW(tester.testBeginAndEndJobOnly());
0025   }
0026 
0027   // Add more sections as needed
0028 
0029   //SECTION("No event data") {
0030   //  edm::test::TestProcessor tester(config);
0031   //  REQUIRE_NOTHROW(tester.test());
0032   //}
0033 
0034   // SECTION("Run with no LuminosityBlocks") {
0035   //   edm::test::TestProcessor tester(config);
0036   //   REQUIRE_NOTHROW(tester.testRunWithNoLuminosityBlocks());
0037   // }
0038 
0039   // SECTION("LuminosityBlock with no Events") {
0040   //   edm::test::TestProcessor tester(config);
0041   //   REQUIRE_NOTHROW(tester.testLuminosityBlockWithNoEvents());
0042   // }
0043 }
0044 
0045 // Function to generate base configuration string
0046 //___________________________________________________________________________________________
0047 std::string generateBaseConfig(const std::string& analyzerName, const std::string& rootFileName) {
0048   // Define a raw string literal
0049   constexpr const char* rawString = R"_(from FWCore.TestProcessor.TestProcess import *
0050 from Alignment.OfflineValidation.{}_cfi import {}
0051 process = TestProcess()
0052 process.trackAnalyzer = {}
0053 process.moduleToTest(process.trackAnalyzer)
0054 process.add_(cms.Service('MessageLogger'))
0055 process.add_(cms.Service('JobReportService'))
0056 process.add_(cms.Service('TFileService',fileName=cms.string('{}')))
0057     )_";
0058 
0059   // Format the raw string literal using fmt::format
0060   return fmt::format(rawString, analyzerName, analyzerName, analyzerName, rootFileName);
0061 }
0062 
0063 //___________________________________________________________________________________________
0064 TEST_CASE("GeneralPurposeTrackAnalyzer tests", "[GeneralPurposeTrackAnalyzer]") {
0065   const std::string baseConfig = generateBaseConfig("generalPurposeTrackAnalyzer", "tesTrackAnalyzer0.root");
0066   runTestForAnalyzer(baseConfig, "GeneralPurposeTrackAnalyzer");
0067 }
0068 
0069 //___________________________________________________________________________________________
0070 TEST_CASE("GeneralPurposeVertexAnalyzer tests", "[GeneralPurposeVertexAnalyzer]") {
0071   const std::string baseConfig = generateBaseConfig("generalPurposeVertexAnalyzer", "tesVertexAnalyzer1.root");
0072   runTestForAnalyzer(baseConfig, "GeneralPurposeVertexAnalyzer");
0073 }
0074 
0075 //___________________________________________________________________________________________
0076 TEST_CASE("DMRChecker tests", "[DMRChecker]") {
0077   const std::string baseConfig = generateBaseConfig("dmrChecker", "tesTrackAnalyzer2.root");
0078   runTestForAnalyzer(baseConfig, "DMRChecker");
0079 }
0080 
0081 //___________________________________________________________________________________________
0082 TEST_CASE("JetHTAnalyzer tests", "[JetHTAnalyzer]") {
0083   const std::string baseConfig = generateBaseConfig("jetHTAnalyzer", "tesTrackAnalyzer3.root");
0084   runTestForAnalyzer(baseConfig, "JetHTAnalyzer");
0085 }
0086 
0087 //___________________________________________________________________________________________
0088 TEST_CASE("DiMuonValidation tests", "[DiMuonValidation]") {
0089   const std::string baseConfig = generateBaseConfig("diMuonValidation", "tesTrackAnalyzer4.root");
0090   runTestForAnalyzer(baseConfig, "DiMuonValidation");
0091 }
0092 
0093 //___________________________________________________________________________________________
0094 TEST_CASE("CosmicSplitterValidation tests", "[CosmicsSplitterValidation]") {
0095   const std::string baseConfig = generateBaseConfig("cosmicSplitterValidation", "tesTrackAnalyzer5.root");
0096   runTestForAnalyzer(baseConfig, "CosmicSplitterValidation");
0097 }
0098 
0099 //___________________________________________________________________________________________
0100 TEST_CASE("DiElectronVertexValidation tests", "[DiElectronVertexValidation]") {
0101   const std::string baseConfig = generateBaseConfig("diElectronVertexValidation", "tesTrackAnalyzer6.root");
0102   runTestForAnalyzer(baseConfig, "DiElectronVertexValidation");
0103 }
0104 
0105 //___________________________________________________________________________________________
0106 TEST_CASE("DiMuonVertexValidation tests", "[DiMuonVertexValidation]") {
0107   const std::string baseConfig = generateBaseConfig("diMuonVertexValidation", "tesTrackAnalyzer7.root");
0108   runTestForAnalyzer(baseConfig, "DiMuonVertexValidation");
0109 }
0110 
0111 //___________________________________________________________________________________________
0112 TEST_CASE("EopElecTreeWriter tests", "[EopElecTreeWriter]") {
0113   const std::string baseConfig = generateBaseConfig("eopElecTreeWriter", "tesTrackAnalyzer8.root");
0114   runTestForAnalyzer(baseConfig, "EopElecTreeWriter");
0115 }
0116 
0117 //___________________________________________________________________________________________
0118 TEST_CASE("EopTreeWriter tests", "[EopTreeWriter]") {
0119   const std::string baseConfig = generateBaseConfig("eopTreeWriter", "tesTrackAnalyzer9.root");
0120   runTestForAnalyzer(baseConfig, "EopTreeWriter");
0121 }
0122 
0123 //___________________________________________________________________________________________
0124 TEST_CASE("OverlapValidation tests", "[OverlapValidation]") {
0125   const std::string baseConfig = generateBaseConfig("overlapValidation", "tesTrackAnalyzer10.root");
0126   runTestForAnalyzer(baseConfig, "OverlapValidation");
0127 }
0128 
0129 //___________________________________________________________________________________________
0130 TEST_CASE("PixelBaryCentreAnalyzer tests", "[PixelBaryCentreAnalyzer]") {
0131   const std::string baseConfig = generateBaseConfig("pixelBaryCentreAnalyzer", "tesTrackAnalyzer11.root");
0132   runTestForAnalyzer(baseConfig, "PixelBaryCentreAnalyzer");
0133 }
0134 
0135 //___________________________________________________________________________________________
0136 TEST_CASE("PrimaryVertexValidation tests", "[PrimaryVertexValidation]") {
0137   const std::string baseConfig = generateBaseConfig("primaryVertexValidation", "tesTrackAnalyzer12.root");
0138   runTestForAnalyzer(baseConfig, "PrimaryVertexValidation");
0139 }
0140 
0141 //___________________________________________________________________________________________
0142 TEST_CASE("SplitVertexResolution tests", "[SplitVertexResolution]") {
0143   const std::string baseConfig = generateBaseConfig("splitVertexResolution", "tesTrackAnalyzer13.root");
0144   runTestForAnalyzer(baseConfig, "SplitVertexResolution");
0145 }
0146 
0147 //___________________________________________________________________________________________
0148 TEST_CASE("TrackerGeometryIntoNtuples tests", "[TrackerGeometryIntoNtuples]") {
0149   const std::string baseConfig = generateBaseConfig("trackerGeometryIntoNtuples", "tesTrackAnalyzer14.root");
0150   runTestForAnalyzer(baseConfig, "TrackerGeometryIntoNtuples");
0151 }
0152 
0153 //___________________________________________________________________________________________
0154 TEST_CASE("TrackerOfflineValidation tests", "[TrackerOfflineValidation]") {
0155   const std::string baseConfig = generateBaseConfig("TrackerOfflineValidation", "tesTrackAnalyzer15.root");
0156   runTestForAnalyzer(baseConfig, "TrackerOfflineValidation");
0157 }
0158 
0159 //___________________________________________________________________________________________
0160 TEST_CASE("TrackerGeometryCompare tests", "[TrackerGeometryCompare]") {
0161   const std::string baseConfig = generateBaseConfig("trackerGeometryCompare", "tesTrackAnalyzer16.root");
0162   runTestForAnalyzer(baseConfig, "trackerGeometryCompare");
0163 }
0164 
0165 //___________________________________________________________________________________________
0166 TEST_CASE("ShortenedTrackValidation tests", "[ShortenedTrackValidation]") {
0167   const std::string baseConfig = generateBaseConfig("shortenedTrackValidation", "tesTrackAnalyzer17.root");
0168   runTestForAnalyzer(baseConfig, "shortenedTrackValidation");
0169 }
0170 
0171 //___________________________________________________________________________________________
0172 TEST_CASE("SagittaBiasNtuplizer tests", "[SagittaBiasNtuplizer]") {
0173   const std::string baseConfig = generateBaseConfig("sagittaBiasNtuplizer", "tesTrackAnalyzer18.root");
0174   runTestForAnalyzer(baseConfig, "sagittaBiasNtuplizer");
0175 }