Skip to content

Commit 3663afc

Browse files
authored
Merge pull request #49095 from cms-AlCaDB/energy0_fix_review
Review: Allow defining valid range of Energy values for LHCInfoPerFill O2O
2 parents 1903dbf + 81305fd commit 3663afc

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

CondTools/RunInfo/interface/TestLHCInfoPerFillPopConSourceHandler.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
#include <string>
1111
#include <tuple>
1212

13+
/*
14+
* A mock PopCon source handler for testing LHCInfoPerFillPopCon logic without
15+
* external dependencies (e.g. OMS, subsystem DBs, destination DB).
16+
*/
17+
1318
class TestLHCInfoPerFillPopConSourceHandler : public LHCInfoPerFillPopConSourceHandler {
1419
public:
1520
TestLHCInfoPerFillPopConSourceHandler(edm::ParameterSet const& pset);
@@ -19,7 +24,7 @@ class TestLHCInfoPerFillPopConSourceHandler : public LHCInfoPerFillPopConSourceH
1924
std::map<unsigned short /*fillNr*/, cond::OMSServiceResult> mockLumiData;
2025
boost::posix_time::ptime mockExecutionTime;
2126

22-
Container& iovs() { return m_iovs; }
27+
const Container& iovs() const { return m_iovs; }
2328

2429
protected:
2530
std::unique_ptr<LHCInfoPerFill> findFillToProcess(cond::OMSService& oms,

CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzer_cfg.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@
9191
, """duringFill only: run-unique key for writing with OnlinePopCon
9292
(used for confirming proper upload)"""
9393
)
94-
95-
94+
# checking for invalid energy values, duringFill mode specific
9695
options.register('minEnergy', 450
9796
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
9897
, """duringFill only: [GeV] min value of the range of valid values (inclusive).
@@ -101,7 +100,7 @@
101100
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
102101
, """duringFill only: [GeV] max value of the range of valid values (inclusive).
103102
If the value is outside of this range the payload is not uploaded""")
104-
options.register('throwOnInvalid', False,
103+
options.register('throwOnInvalid', False, # Intended production setup: False for endFill, True for duringFill
105104
VarParsing.VarParsing.multiplicity.singleton,
106105
VarParsing.VarParsing.varType.bool,
107106
"duringFill only: If true, throw on invalid payloads; if false, filter them out.")
@@ -119,6 +118,8 @@
119118
raise ValueError("mode argument not provided. Supported modes are: duringFill endFill")
120119
if options.mode not in ("duringFill", "endFill"):
121120
raise ValueError("Wrong mode argument. Supported modes are: duringFill endFill")
121+
if options.throwOnInvalid and options.mode != "duringFill":
122+
raise ValueError("throwOnInvalid option can be True only in duringFill mode")
122123

123124
CondDBConnection = CondDB.clone( connect = cms.string( options.destinationConnection ) )
124125
CondDBConnection.DBParameters.messageLevel = cms.untracked.int32( options.messageLevel )

CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzer_cfg.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@
131131
The default payload is inserted after the last processed fill has ended
132132
and there's no ongoing stable beam yet. """
133133
)
134-
135-
134+
# checking for invalid values, duringFill mode specific
136135
# it's unlikely to ever use values different from the defaults, added as a parameter just in case
137136
options.register('minBetaStar', 0.1
138137
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
@@ -150,7 +149,7 @@
150149
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
151150
, """duringFill only: [urad] max value of the range of valid values (inclusive).
152151
If the value is outside of this range the payload is not uploaded""")
153-
options.register('throwOnInvalid', False,
152+
options.register('throwOnInvalid', False, # Intended production setup: False for endFill, True for duringFill
154153
VarParsing.VarParsing.multiplicity.singleton,
155154
VarParsing.VarParsing.varType.bool,
156155
"duringFill only: If true, throw on invalid payloads; if false, filter them out.")

CondTools/RunInfo/src/LHCInfoPerFillPopConSourceHandler.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,12 +521,8 @@ LHCInfoPerFillPopConSourceHandler::executeLumiQuery(const cond::OMSService& oms,
521521
query->filterEQ("beams_stable", "true");
522522
query->limit(cond::lhcInfoHelper::kLumisectionsQueryLimit);
523523

524-
bool executed = query->execute();
525-
if (executed) {
526-
return std::make_tuple(query->result(), true, std::move(query));
527-
} else {
528-
return std::make_tuple(cond::OMSServiceResult(), false, std::move(query));
529-
}
524+
bool success = query->execute();
525+
return {(success ? query->result() : cond::OMSServiceResult()), success, std::move(query)};
530526
}
531527

532528
void LHCInfoPerFillPopConSourceHandler::getLumiData(const cond::OMSService& oms,

CondTools/RunInfo/test/BuildFile.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
<test name="CondToolsLHCInfoAnalyzerTest" command="test_lhcInfo_analyzer.sh"/>
99
<test name="CondToolsPrintLHCInfoPerPayloads" command="test_printLHCInfoPerPayloads.sh"/>
1010
<ifarch value="x86_64">
11-
<test name="CondToolsLHCInfoNewPopConTest" command="test_lhcInfoNewPopCon.sh"/>
11+
<test name="CondToolsLHCInfoNewPopConTest" command="test_lhcInfoNewPopCon.sh"/>
1212
</ifarch>
13-
1413
<bin file="test_catch2_LHCInfoPerFillPopCon.cpp" name="TestLHCInfoPerFillPopCon">
1514
<use name="catch2"/>
1615
<use name="FWCore/ParameterSet"/>

CondTools/RunInfo/test/test_catch2_LHCInfoPerFillPopCon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ TEST_CASE("LHCInfoPerFillPopConSourceHandler.getNewObjects fills IOVs correctly
342342
boost::posix_time::time_from_string("2023-06-01 12:00:00")};
343343
std::vector<boost::posix_time::ptime> fillEndTimes = {boost::posix_time::time_from_string("2023-06-01 12:30:00")};
344344

345-
for (size_t i = 0; i < 3; ++i) {
345+
for (size_t i = 0; i < fillNumbers.size(); ++i) {
346346
auto fillPayload = std::make_shared<LHCInfoPerFill>();
347347
fillPayload->setFillNumber(fillNumbers[i]);
348348
fillPayload->setEnergy(energies[i]);

0 commit comments

Comments
 (0)