Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void momentumElectronBiasValidation(TString variable,
std::vector<TString> labels; // list of input labels
if (!checkArguments(
variable, path, alignmentWithLabel, outputType, radius, verbose, givenMin, givenMax, mode, files, labels))
return;
exit(EXIT_FAILURE);
else {
std::cout << "-> Number of files: " << files.size() << std::endl;
}
Expand Down
2 changes: 1 addition & 1 deletion Alignment/OfflineValidation/test/eopElecTreeWriter_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
else:
print( "NO REFIT")

process.load("Alignment.OfflineValidation.eopElecTreeWriter_cfi")
process.load("Alignment.OfflineValidation.energyOverMomentumTreeElec_cfi")

if REFIT:
print( "REFIT")
Expand Down
190 changes: 123 additions & 67 deletions Alignment/OfflineValidation/test/testTrackAnalyzers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,35 @@
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "Alignment/OfflineValidation/interface/TkAlStyle.h"

#define CATCH_CONFIG_MAIN
#include "catch.hpp"

TEST_CASE("GeneralPurposeTrackAnalyzer tests", "[GeneralPurposeTrackAnalyzer]") {
//The python configuration
const std::string baseConfig{
R"_(from FWCore.TestProcessor.TestProcess import *
from Alignment.OfflineValidation.generalPurposeTrackAnalyzer_cfi import generalPurposeTrackAnalyzer
process = TestProcess()
process.trackAnalyzer = generalPurposeTrackAnalyzer
process.moduleToTest(process.trackAnalyzer)
process.add_(cms.Service('MessageLogger'))
process.add_(cms.Service('JobReportService'))
process.add_(cms.Service('TFileService',fileName=cms.string('tesTrackAnalyzer1.root')))
)_"};

// Function to run the catch2 tests
//___________________________________________________________________________________________
void runTestForAnalyzer(const std::string& baseConfig, const std::string& analyzerName) {
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(analyzerName + " base configuration is OK") { REQUIRE_NOTHROW(edm::test::TestProcessor(config)); }

SECTION(analyzerName + " No Runs data") {
edm::test::TestProcessor tester(config);
REQUIRE_NOTHROW(tester.testWithNoRuns());
}

SECTION("beginJob and endJob only") {
SECTION(analyzerName + " beginJob and endJob only") {
edm::test::TestProcessor tester(config);
REQUIRE_NOTHROW(tester.testBeginAndEndJobOnly());
}

// Add more sections as needed

//SECTION("No event data") {
// edm::test::TestProcessor tester(config);
// REQUIRE_NOTHROW(tester.test());
//}

// SECTION("Run with no LuminosityBlocks") {
// edm::test::TestProcessor tester(config);
// REQUIRE_NOTHROW(tester.testRunWithNoLuminosityBlocks());
Expand All @@ -43,65 +42,122 @@ process.add_(cms.Service('TFileService',fileName=cms.string('tesTrackAnalyzer1.r
// }
}

TEST_CASE("DMRChecker tests", "[DMRChecker]") {
//The python configuration
const std::string baseConfig{
R"_(from FWCore.TestProcessor.TestProcess import *
from Alignment.OfflineValidation.dmrChecker_cfi import dmrChecker
// Function to generate base configuration string
//___________________________________________________________________________________________
std::string generateBaseConfig(const std::string& analyzerName, const std::string& rootFileName) {
// Define a raw string literal
const char* rawString = R"_(from FWCore.TestProcessor.TestProcess import *
from Alignment.OfflineValidation.{}_cfi import {}
process = TestProcess()
process.dmrAnalyzer = dmrChecker
process.moduleToTest(process.dmrAnalyzer)
process.trackAnalyzer = {}
process.moduleToTest(process.trackAnalyzer)
process.add_(cms.Service('MessageLogger'))
process.add_(cms.Service('JobReportService'))
process.add_(cms.Service('TFileService',fileName=cms.string('tesTrackAnalyzer2.root')))
)_"};
process.add_(cms.Service('TFileService',fileName=cms.string('{}')))
)_";

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());
// }
// Format the raw string literal using fmt::format
return fmt::format(rawString, analyzerName, analyzerName, analyzerName, rootFileName);
}

SECTION("beginJob and endJob only") {
edm::test::TestProcessor tester(config);
REQUIRE_NOTHROW(tester.testBeginAndEndJobOnly());
}
//___________________________________________________________________________________________
TEST_CASE("GeneralPurposeTrackAnalyzer tests", "[GeneralPurposeTrackAnalyzer]") {
const std::string baseConfig = generateBaseConfig("generalPurposeTrackAnalyzer", "tesTrackAnalyzer0.root");
runTestForAnalyzer(baseConfig, "GeneralPurposeTrackAnalyzer");
}

// SECTION("Run with no LuminosityBlocks") {
// edm::test::TestProcessor tester(config);
// REQUIRE_NOTHROW(tester.testRunWithNoLuminosityBlocks());
// }
//___________________________________________________________________________________________
TEST_CASE("GeneralPurposeVertexAnalyzer tests", "[GeneralPurposeVertexAnalyzer]") {
const std::string baseConfig = generateBaseConfig("generalPurposeVertexAnalyzer", "tesVertexAnalyzer1.root");
runTestForAnalyzer(baseConfig, "GeneralPurposeVertexAnalyzer");
}

// SECTION("LuminosityBlock with no Events") {
// edm::test::TestProcessor tester(config);
// REQUIRE_NOTHROW(tester.testLuminosityBlockWithNoEvents());
// }
//___________________________________________________________________________________________
TEST_CASE("DMRChecker tests", "[DMRChecker]") {
const std::string baseConfig = generateBaseConfig("dmrChecker", "tesTrackAnalyzer2.root");
runTestForAnalyzer(baseConfig, "DMRChecker");
}

//___________________________________________________________________________________________
TEST_CASE("JetHTAnalyzer tests", "[JetHTAnalyzer]") {
//The python configuration
edm::test::TestProcessor::Config config{
R"_(import FWCore.ParameterSet.Config as cms
from FWCore.TestProcessor.TestProcess import *
from Alignment.OfflineValidation.jetHTAnalyzer_cfi import jetHTAnalyzer
process = TestProcess()
process.JetHTAnalyzer = jetHTAnalyzer
process.moduleToTest(process.JetHTAnalyzer)
process.add_(cms.Service('JobReportService'))
process.add_(cms.Service('TFileService',fileName=cms.string('tesTrackAnalyzer3.root')))
)_"};
const std::string baseConfig = generateBaseConfig("jetHTAnalyzer", "tesTrackAnalyzer3.root");
runTestForAnalyzer(baseConfig, "JetHTAnalyzer");
}

SECTION("base configuration is OK") { REQUIRE_NOTHROW(edm::test::TestProcessor(config)); }
//___________________________________________________________________________________________
TEST_CASE("DiMuonValidation tests", "[DiMuonValidation]") {
const std::string baseConfig = generateBaseConfig("diMuonValidation", "tesTrackAnalyzer4.root");
runTestForAnalyzer(baseConfig, "DiMuonValidation");
}

SECTION("beginJob and endJob only") {
edm::test::TestProcessor tester(config);
REQUIRE_NOTHROW(tester.testBeginAndEndJobOnly());
}
//___________________________________________________________________________________________
TEST_CASE("CosmicSplitterValidation tests", "[CosmicsSplitterValidation]") {
const std::string baseConfig = generateBaseConfig("cosmicSplitterValidation", "tesTrackAnalyzer5.root");
runTestForAnalyzer(baseConfig, "CosmicSplitterValidation");
}

// SECTION("No event data") {
// edm::test::TestProcessor tester(config);
// REQUIRE_NOTHROW(tester.test());
//}
//___________________________________________________________________________________________
TEST_CASE("DiElectronVertexValidation tests", "[DiElectronVertexValidation]") {
const std::string baseConfig = generateBaseConfig("diElectronVertexValidation", "tesTrackAnalyzer6.root");
runTestForAnalyzer(baseConfig, "DiElectronVertexValidation");
}

//___________________________________________________________________________________________
TEST_CASE("DiMuonVertexValidation tests", "[DiMuonVertexValidation]") {
const std::string baseConfig = generateBaseConfig("diMuonVertexValidation", "tesTrackAnalyzer7.root");
runTestForAnalyzer(baseConfig, "DiMuonVertexValidation");
}

//___________________________________________________________________________________________
TEST_CASE("EopElecTreeWriter tests", "[EopElecTreeWriter]") {
const std::string baseConfig = generateBaseConfig("eopElecTreeWriter", "tesTrackAnalyzer8.root");
runTestForAnalyzer(baseConfig, "EopElecTreeWriter");
}

//___________________________________________________________________________________________
TEST_CASE("EopTreeWriter tests", "[EopTreeWriter]") {
const std::string baseConfig = generateBaseConfig("eopTreeWriter", "tesTrackAnalyzer9.root");
runTestForAnalyzer(baseConfig, "EopTreeWriter");
}

//___________________________________________________________________________________________
TEST_CASE("OverlapValidation tests", "[OverlapValidation]") {
const std::string baseConfig = generateBaseConfig("overlapValidation", "tesTrackAnalyzer10.root");
runTestForAnalyzer(baseConfig, "OverlapValidation");
}

//___________________________________________________________________________________________
TEST_CASE("PixelBaryCentreAnalyzer tests", "[PixelBaryCentreAnalyzer]") {
const std::string baseConfig = generateBaseConfig("pixelBaryCentreAnalyzer", "tesTrackAnalyzer11.root");
runTestForAnalyzer(baseConfig, "PixelBaryCentreAnalyzer");
}

//___________________________________________________________________________________________
TEST_CASE("PrimaryVertexValidation tests", "[PrimaryVertexValidation]") {
const std::string baseConfig = generateBaseConfig("primaryVertexValidation", "tesTrackAnalyzer12.root");
runTestForAnalyzer(baseConfig, "PrimaryVertexValidation");
}

//___________________________________________________________________________________________
TEST_CASE("SplitVertexResolution tests", "[SplitVertexResolution]") {
const std::string baseConfig = generateBaseConfig("splitVertexResolution", "tesTrackAnalyzer13.root");
runTestForAnalyzer(baseConfig, "SplitVertexResolution");
}

//___________________________________________________________________________________________
TEST_CASE("TrackerGeometryIntoNtuples tests", "[TrackerGeometryIntoNtuples]") {
const std::string baseConfig = generateBaseConfig("trackerGeometryIntoNtuples", "tesTrackAnalyzer14.root");
runTestForAnalyzer(baseConfig, "TrackerGeometryIntoNtuples");
}

//___________________________________________________________________________________________
TEST_CASE("TrackerOfflineValidation tests", "[TrackerOfflineValidation]") {
const std::string baseConfig = generateBaseConfig("TrackerOfflineValidation", "tesTrackAnalyzer15.root");
runTestForAnalyzer(baseConfig, "TrackerOfflineValidation");
}

//___________________________________________________________________________________________
TEST_CASE("TrackerGeometryCompare tests", "[TrackerGeometryCompare]") {
const std::string baseConfig = generateBaseConfig("trackerGeometryCompare", "tesTrackAnalyzer16.root");
runTestForAnalyzer(baseConfig, "trackerGeometryCompare");
}