Skip to content

Commit 65bb3e8

Browse files
authored
Merge pull request #48027 from kyungminparkdrums/151X_noLumiECALdqmBugFix
[15_1_X] Fix ECAL DQM crash from ME formatter when there is no luminosity block
2 parents e84f688 + 3c40068 commit 65bb3e8

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

DQM/EcalCommon/plugins/EcalMEFormatter.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ void EcalMEFormatter::format_(DQMStore::IGetter &_igetter, bool _checkLumi) {
4343
if (_checkLumi && !mItr.second->getLumiFlag())
4444
continue;
4545
mItr.second->clear();
46+
47+
if (!checkElectronicsMap(false))
48+
return;
49+
4650
if (!mItr.second->retrieve(GetElectronicsMap(), _igetter, &failedPath)) {
4751
if (verbosity_ > 0)
4852
edm::LogWarning("EcalDQM") << "Could not find ME " << mItr.first << "@" << failedPath;

DQM/EcalCommon/test/BuildFile.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<bin file="testEcalCommon.cc" name="testEcalCommon">
2+
<use name="FWCore/TestProcessor"/>
3+
<use name="catch2"/>
4+
</bin>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include "FWCore/TestProcessor/interface/TestProcessor.h"
2+
#include "FWCore/Utilities/interface/Exception.h"
3+
#include "FWCore/ServiceRegistry/interface/Service.h"
4+
5+
#define CATCH_CONFIG_MAIN
6+
#include "catch.hpp"
7+
8+
// Function to run the catch2 tests
9+
//___________________________________________________________________________________________
10+
void runTestForAnalyzer(const std::string& baseConfig, const std::string& analyzerName) {
11+
edm::test::TestProcessor::Config config{baseConfig};
12+
13+
SECTION(analyzerName + " base configuration is OK") { REQUIRE_NOTHROW(edm::test::TestProcessor(config)); }
14+
15+
SECTION("Run with no LuminosityBlocks") {
16+
edm::test::TestProcessor tester(config);
17+
REQUIRE_NOTHROW(tester.testRunWithNoLuminosityBlocks());
18+
}
19+
}
20+
21+
// Function to generate base configuration string
22+
//___________________________________________________________________________________________
23+
std::string generateBaseConfig(const std::string& cfiName, const std::string& analyzerName) {
24+
// Define a raw string literal
25+
constexpr const char* rawString = R"_(from FWCore.TestProcessor.TestProcess import *
26+
from DQM.EcalCommon.{}_cfi import {}
27+
process = TestProcess()
28+
process.harvester = {}
29+
process.moduleToTest(process.harvester)
30+
process.add_(cms.Service('MessageLogger'))
31+
process.add_(cms.Service('JobReportService'))
32+
process.add_(cms.Service('DQMStore'))
33+
)_";
34+
35+
// Format the raw string literal using fmt::format
36+
return fmt::format(rawString, cfiName, analyzerName, analyzerName);
37+
}
38+
39+
//___________________________________________________________________________________________
40+
TEST_CASE("EcalMEFormatter tests", "[EcalMEFormatter]") {
41+
const std::string baseConfig = generateBaseConfig("EcalMEFormatter", "ecalMEFormatter");
42+
runTestForAnalyzer(baseConfig, "EcalMEFormatter");
43+
}

0 commit comments

Comments
 (0)