Skip to content

Commit c77208f

Browse files
committed
valid range of Energy values for LHCInfoPerFill O2O + refacotring and
testing of perFill O2O Energy 0 check dont upload empty payklod to empty tags in duringfill mode of perFill O2O extract findFillToProcess from populateIovs in perFill O2O simple catch2 test of LHCInfoPerFill PopCon test: LHCInfoPerFillPopConSourceHandler.isPayloadValid works test: addPayloadToBuffer works refactor getLumiData, add inclusiveSearchTime arg to findFillToProcess catch2 tests code-format remove dead code: add empty payload in duringfill adjust expected value in test_lhcInfoNewPopCon.sh for perFill duringFill mode extract createSubsystemDbSessions from populateIovs refactor: extract getNextFillSearchTimestamp from populateIovs refactor: extract handleIfNewTagAndGetLastSince and fetchLastPayload from populateIovs add TestLHCInfoPerFillPopConSourceHandler with mocks Successfull populateIovs test mock execution time, successful duringFill test print additional info on invalid energy, rename throwIfInvalidPayload throw exc or filter out invalid payloads depending on throwOnInvalid in LHCInfoPer O2O duringFill mode
1 parent e13898f commit c77208f

11 files changed

+1028
-110
lines changed

CondTools/RunInfo/interface/LHCInfoPerFillPopConSourceHandler.h

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#pragma once
2+
13
#include "CondCore/PopCon/interface/PopConSourceHandler.h"
24
#include "CondFormats/RunInfo/interface/LHCInfoPerFill.h"
35
#include "CondTools/RunInfo/interface/OMSAccess.h"
@@ -11,31 +13,64 @@ class LHCInfoPerFillPopConSourceHandler : public popcon::PopConSourceHandler<LHC
1113
void getNewObjects() override;
1214
std::string id() const override;
1315

14-
private:
16+
bool isPayloadValid(const LHCInfoPerFill& payload) const;
17+
18+
protected:
19+
virtual std::unique_ptr<LHCInfoPerFill> findFillToProcess(cond::OMSService& oms,
20+
const boost::posix_time::ptime& nextFillSearchTime,
21+
bool inclusiveSearchTime);
1522
void addEmptyPayload(cond::Time_t iov);
1623

1724
// Add payload to buffer and store corresponding lumiid IOV in m_timestampToLumiid map
1825
void addPayloadToBuffer(cond::OMSServiceResultRef& row);
1926
void convertBufferedIovsToLumiid(std::map<cond::Time_t, cond::Time_t> timestampToLumiid);
2027

21-
size_t getLumiData(const cond::OMSService& oms,
22-
unsigned short fillId,
23-
const boost::posix_time::ptime& beginFillTime,
24-
const boost::posix_time::ptime& endFillTime);
28+
/**
29+
* @return A tuple containing:
30+
* - cond::OMSServiceResult: The result of the luminosity query.
31+
* - bool: Indicates whether the query was successful.
32+
* - std::unique_ptr<cond::OMSServiceQuery>: Owner object for the query.
33+
* Query result resources are tied to its lifetime so it needs to be kept in the same scope.
34+
*/
35+
virtual std::tuple<cond::OMSServiceResult, bool, std::unique_ptr<cond::OMSServiceQuery>> executeLumiQuery(
36+
const cond::OMSService& oms,
37+
unsigned short fillId,
38+
const boost::posix_time::ptime& beginFillTime,
39+
const boost::posix_time::ptime& endFillTime) const;
40+
41+
virtual void getLumiData(const cond::OMSService& oms,
42+
unsigned short fillId,
43+
const boost::posix_time::ptime& beginFillTime,
44+
const boost::posix_time::ptime& endFillTime);
45+
46+
virtual void getDipData(const cond::OMSService& oms,
47+
const boost::posix_time::ptime& beginFillTime,
48+
const boost::posix_time::ptime& endFillTime);
2549

26-
void getDipData(const cond::OMSService& oms,
27-
const boost::posix_time::ptime& beginFillTime,
28-
const boost::posix_time::ptime& endFillTime);
50+
virtual bool getCTPPSData(cond::persistency::Session& session,
51+
const boost::posix_time::ptime& beginFillTime,
52+
const boost::posix_time::ptime& endFillTime);
2953

30-
bool getCTPPSData(cond::persistency::Session& session,
31-
const boost::posix_time::ptime& beginFillTime,
32-
const boost::posix_time::ptime& endFillTime);
54+
virtual bool getEcalData(cond::persistency::Session& session,
55+
const boost::posix_time::ptime& lowerTime,
56+
const boost::posix_time::ptime& upperTime);
3357

34-
bool getEcalData(cond::persistency::Session& session,
35-
const boost::posix_time::ptime& lowerTime,
36-
const boost::posix_time::ptime& upperTime);
58+
bool getCTPPSDataImpl(cond::persistency::Session& session,
59+
const boost::posix_time::ptime& beginFillTime,
60+
const boost::posix_time::ptime& endFillTime);
3761

38-
private:
62+
bool getEcalDataImpl(cond::persistency::Session& session,
63+
const boost::posix_time::ptime& lowerTime,
64+
const boost::posix_time::ptime& upperTime);
65+
66+
protected:
67+
virtual std::tuple<cond::persistency::Session, cond::persistency::Session> createSubsystemDbSessions() const;
68+
virtual cond::Time_t getNextFillSearchTimestamp(cond::Time_t lastSince) const;
69+
virtual cond::Time_t handleIfNewTagAndGetLastSince();
70+
virtual void fetchLastPayload();
71+
virtual boost::posix_time::ptime getExecutionTime() const;
72+
void populateIovs();
73+
void handleInvalidPayloads();
3974
bool m_debug;
4075
// starting date for sampling
4176
boost::posix_time::ptime m_startTime;
@@ -46,6 +81,11 @@ class LHCInfoPerFillPopConSourceHandler : public popcon::PopConSourceHandler<LHC
4681
std::string m_connectionString, m_ecalConnectionString;
4782
std::string m_authpath;
4883
std::string m_omsBaseUrl;
84+
85+
float m_minEnergy; // [GeV], applicable in duringFill mode only
86+
float m_maxEnergy; // [GeV], applicable in duringFill mode only
87+
bool m_throwOnInvalid = true;
88+
4989
std::unique_ptr<LHCInfoPerFill> m_fillPayload;
5090
std::shared_ptr<LHCInfoPerFill> m_prevPayload;
5191
std::vector<std::pair<cond::Time_t, std::shared_ptr<LHCInfoPerFill>>> m_tmpBuffer;

CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class LHCInfoPerLSPopConSourceHandler : public popcon::PopConSourceHandler<LHCIn
2020

2121
private:
2222
void populateIovs();
23-
void filterInvalidPayloads();
23+
void handleInvalidPayloads();
2424
bool isPayloadValid(const LHCInfoPerLS& payload) const;
2525
void addEmptyPayload(cond::Time_t iov);
2626
void addDefaultPayload(cond::Time_t iov, unsigned short fill, const cond::OMSService& oms);
@@ -62,15 +62,16 @@ class LHCInfoPerLSPopConSourceHandler : public popcon::PopConSourceHandler<LHCIn
6262
float m_maxBetaStar; // meters
6363
float m_minCrossingAngle; // urad
6464
float m_maxCrossingAngle; // urad
65+
bool m_throwOnInvalid; // duringFill: whether to throw exception or filter out invalid payloads
6566

6667
std::unique_ptr<LHCInfoPerLS> m_fillPayload;
6768
std::shared_ptr<LHCInfoPerLS> m_prevPayload;
68-
cond::Time_t m_startFillTime;
69-
cond::Time_t m_endFillTime;
70-
cond::Time_t m_prevEndFillTime = 0;
71-
cond::Time_t m_prevStartFillTime;
72-
cond::Time_t m_startStableBeamTime;
73-
cond::Time_t m_endStableBeamTime;
69+
cond::Time_t m_startFillTime{};
70+
cond::Time_t m_endFillTime{};
71+
cond::Time_t m_prevEndFillTime{};
72+
cond::Time_t m_prevStartFillTime{};
73+
cond::Time_t m_startStableBeamTime{};
74+
cond::Time_t m_endStableBeamTime{};
7475
std::vector<std::pair<cond::Time_t, std::shared_ptr<LHCInfoPerLS>>> m_tmpBuffer;
7576
bool m_lastPayloadEmpty = false;
7677
// mapping of lumisections IDs (pairs of runnumber an LS number) found in OMS to
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#pragma once
2+
3+
#include "CondFormats/RunInfo/interface/LHCInfoPerFill.h"
4+
#include "CondTools/RunInfo/interface/LHCInfoPerFillPopConSourceHandler.h"
5+
#include "CondTools/RunInfo/interface/OMSAccess.h"
6+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
7+
8+
#include <map>
9+
#include <memory>
10+
#include <string>
11+
#include <tuple>
12+
13+
class TestLHCInfoPerFillPopConSourceHandler : public LHCInfoPerFillPopConSourceHandler {
14+
public:
15+
TestLHCInfoPerFillPopConSourceHandler(edm::ParameterSet const& pset);
16+
~TestLHCInfoPerFillPopConSourceHandler() override = default;
17+
18+
std::vector<std::pair<cond::Time_t /*timestamp*/, std::shared_ptr<LHCInfoPerFill>>> mockOmsFills;
19+
std::map<unsigned short /*fillNr*/, cond::OMSServiceResult> mockLumiData;
20+
boost::posix_time::ptime mockExecutionTime;
21+
22+
Container& iovs() { return m_iovs; }
23+
24+
protected:
25+
std::unique_ptr<LHCInfoPerFill> findFillToProcess(cond::OMSService& oms,
26+
const boost::posix_time::ptime& nextFillSearchTime,
27+
bool inclusiveSearchTime) override;
28+
29+
cond::Time_t handleIfNewTagAndGetLastSince() override;
30+
31+
void fetchLastPayload() override {};
32+
33+
boost::posix_time::ptime getExecutionTime() const override;
34+
35+
std::tuple<cond::persistency::Session, cond::persistency::Session> createSubsystemDbSessions() const override;
36+
37+
void getDipData(const cond::OMSService& oms,
38+
const boost::posix_time::ptime& beginFillTime,
39+
const boost::posix_time::ptime& endFillTime) override {};
40+
41+
bool getCTPPSData(cond::persistency::Session& session,
42+
const boost::posix_time::ptime& beginFillTime,
43+
const boost::posix_time::ptime& endFillTime) override {
44+
return true;
45+
};
46+
47+
bool getEcalData(cond::persistency::Session& session,
48+
const boost::posix_time::ptime& lowerTime,
49+
const boost::posix_time::ptime& upperTime) override {
50+
return true;
51+
};
52+
53+
std::tuple<cond::OMSServiceResult, bool, std::unique_ptr<cond::OMSServiceQuery>> executeLumiQuery(
54+
const cond::OMSService& oms,
55+
unsigned short fillId,
56+
const boost::posix_time::ptime& beginFillTime,
57+
const boost::posix_time::ptime& endFillTime) const override;
58+
};

CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzer_cfg.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,19 @@
9393
)
9494

9595

96+
options.register('minEnergy', 450
97+
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
98+
, """duringFill only: [GeV] min value of the range of valid values (inclusive).
99+
If the value is outside of this range the payload is not uploaded""")
100+
options.register('maxEnergy', 8000.
101+
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
102+
, """duringFill only: [GeV] max value of the range of valid values (inclusive).
103+
If the value is outside of this range the payload is not uploaded""")
104+
options.register('throwOnInvalid', False,
105+
VarParsing.VarParsing.multiplicity.singleton,
106+
VarParsing.VarParsing.varType.bool,
107+
"duringFill only: If true, throw on invalid payloads; if false, filter them out.")
108+
96109
# so far there was no need to use option, added just in case
97110
options.register( 'authenticationPath'
98111
, ""
@@ -173,7 +186,10 @@
173186
ecalConnectionString = cms.untracked.string(options.ecalConnection),
174187
omsBaseUrl = cms.untracked.string(options.oms),
175188
authenticationPath = cms.untracked.string(options.authenticationPath),
176-
debug=cms.untracked.bool(False)
189+
debug=cms.untracked.bool(False),
190+
minEnergy = cms.untracked.double(options.minEnergy),
191+
maxEnergy = cms.untracked.double(options.maxEnergy),
192+
throwOnInvalid = cms.untracked.bool(options.throwOnInvalid)
177193
),
178194
loggingOn = cms.untracked.bool(True),
179195
IsDestDbCheckedInQueryLog = cms.untracked.bool(False)

CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzer_cfg.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,24 @@
136136
# it's unlikely to ever use values different from the defaults, added as a parameter just in case
137137
options.register('minBetaStar', 0.1
138138
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
139-
, """duringFill only: [meters] min value of the range of valid values.
139+
, """duringFill only: [meters] min value of the range of valid values (inclusive).
140140
If the value is outside of this range the payload is not uploaded""")
141141
options.register('maxBetaStar', 100.
142142
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
143-
, """duringFill only: [meters] min value of the range of valid values.
143+
, """duringFill only: [meters] max value of the range of valid values (inclusive).
144144
If the value is outside of this range the payload is not uploaded""")
145145
options.register('minCrossingAngle', 10.
146146
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
147-
, """duringFill only: [urad] min value of the range of valid values.
147+
, """duringFill only: [urad] min value of the range of valid values (inclusive).
148148
If the value is outside of this range the payload is not uploaded""")
149149
options.register('maxCrossingAngle', 500.
150150
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
151-
, """duringFill only: [urad] min value of the range of valid values.
151+
, """duringFill only: [urad] max value of the range of valid values (inclusive).
152152
If the value is outside of this range the payload is not uploaded""")
153+
options.register('throwOnInvalid', False,
154+
VarParsing.VarParsing.multiplicity.singleton,
155+
VarParsing.VarParsing.varType.bool,
156+
"duringFill only: If true, throw on invalid payloads; if false, filter them out.")
153157

154158
# as the previous options, so far there was no need to use option, added just in case
155159
options.register( 'authenticationPath'
@@ -164,6 +168,8 @@
164168
raise ValueError("mode argument not provided. Supported modes are: duringFill endFill")
165169
if options.mode not in ("duringFill", "endFill"):
166170
raise ValueError("Wrong mode argument. Supported modes are: duringFill endFill")
171+
if options.throwOnInvalid and options.mode != "duringFill":
172+
raise ValueError("throwOnInvalid option can be True only in duringFill mode")
167173

168174
CondDBConnection = CondDB.clone( connect = cms.string( options.destinationConnection ) )
169175
CondDBConnection.DBParameters.messageLevel = cms.untracked.int32( options.messageLevel )
@@ -241,6 +247,7 @@
241247
maxBetaStar = cms.untracked.double(options.maxBetaStar),
242248
minCrossingAngle = cms.untracked.double(options.minCrossingAngle),
243249
maxCrossingAngle = cms.untracked.double(options.maxCrossingAngle),
250+
throwOnInvalid = cms.untracked.bool(options.throwOnInvalid)
244251
),
245252
loggingOn = cms.untracked.bool(True),
246253
IsDestDbCheckedInQueryLog = cms.untracked.bool(False)

0 commit comments

Comments
 (0)