Skip to content

Commit 6f55d49

Browse files
committed
For perLS duringfill implement adding defaultPayload and skipping invalid payloads
implement adding defaultPayload in duringFill mode duringFill perLS: skip upload if invalid values Adjust duringFill unit tests remove duplicated kLumisectionsQueryLimit fix unit tests, print logs of failed lhcInfoNewPopCon test add connection strings as cfg parameters, fix frontier key parameter for perFill
1 parent 6abdcd6 commit 6f55d49

13 files changed

+285
-53
lines changed

CondTools/RunInfo/interface/LHCInfoHelper.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ namespace cond {
1111
// Large number of LS for the OMS query, covering around 25 hours
1212
static constexpr unsigned int kLumisectionsQueryLimit = 4000;
1313

14+
// last Run number and LS number of the specified Fill
15+
std::pair<int, unsigned short> getFillLastRunAndLS(const cond::OMSService& oms, unsigned short fillId);
16+
1417
// Returns lumi-type IOV from last LS of last Run of the specified Fill
1518
cond::Time_t getFillLastLumiIOV(const cond::OMSService& oms, unsigned short fillId);
1619

CondTools/RunInfo/interface/LHCInfoPerFillPopConSourceHandler.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ class LHCInfoPerFillPopConSourceHandler : public popcon::PopConSourceHandler<LHC
1111
void getNewObjects() override;
1212
std::string id() const override;
1313

14-
static constexpr unsigned int kLumisectionsQueryLimit = 4000;
15-
1614
private:
1715
void addEmptyPayload(cond::Time_t iov);
1816

CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ class LHCInfoPerLSPopConSourceHandler : public popcon::PopConSourceHandler<LHCIn
1818
void getNewObjects() override;
1919
std::string id() const override;
2020

21-
static constexpr unsigned int kLumisectionsQueryLimit = 4000;
22-
2321
private:
22+
void populateIovs();
23+
void filterInvalidPayloads();
24+
bool isPayloadValid(const LHCInfoPerLS& payload) const;
2425
void addEmptyPayload(cond::Time_t iov);
26+
void addDefaultPayload(cond::Time_t iov, unsigned short fill, const cond::OMSService& oms);
27+
void addDefaultPayload(cond::Time_t iov, unsigned short fill, int run, unsigned short lumi);
2528
bool makeFillPayload(std::unique_ptr<LHCInfoPerLS>& targetPayload, const cond::OMSServiceResult& queryResult);
2629
void addPayloadToBuffer(cond::OMSServiceResultRef& row);
2730
size_t bufferAllLS(const cond::OMSServiceResult& queryResult);
@@ -39,14 +42,27 @@ class LHCInfoPerLSPopConSourceHandler : public popcon::PopConSourceHandler<LHCIn
3942
boost::posix_time::ptime m_endTime;
4043
bool m_endFillMode = true;
4144
std::string m_name;
42-
//for reading from relational database source
45+
// for reading from relational database source
4346
std::string m_connectionString;
4447
std::string m_authpath;
4548
std::string m_omsBaseUrl;
46-
//Allows for basic test of durigFill mode when there is no Stable Beams in LHC
47-
//makes duringFill interpret the fills as ongoing fills and writing their last LS
48-
// (disabling the check if the last LS is in stable beams, although still only fill with stable beams are being processed)
49+
// Allows for basic test of durigFill mode when there is no Stable Beams in LHC
50+
// makes duringFill interpret fills as ongoing fill and writing their last LS
51+
// (disabling the check if the last LS is in stable beams,
52+
// although still only fills with stable beams are being processed
53+
// also, still only up to one payload will be written)
4954
const bool m_debugLogic;
55+
// values for the default payload which is inserted after the last processed fill
56+
// has ended and there's no ongoing stable beam yet:
57+
float m_defaultCrossingAngleX;
58+
float m_defaultCrossingAngleY;
59+
float m_defaultBetaStarX;
60+
float m_defaultBetaStarY;
61+
float m_minBetaStar; // meters
62+
float m_maxBetaStar; // meters
63+
float m_minCrossingAngle; // urad
64+
float m_maxCrossingAngle; // urad
65+
5066
std::unique_ptr<LHCInfoPerLS> m_fillPayload;
5167
std::shared_ptr<LHCInfoPerLS> m_prevPayload;
5268
cond::Time_t m_startFillTime;
@@ -57,8 +73,9 @@ class LHCInfoPerLSPopConSourceHandler : public popcon::PopConSourceHandler<LHCIn
5773
cond::Time_t m_endStableBeamTime;
5874
std::vector<std::pair<cond::Time_t, std::shared_ptr<LHCInfoPerLS>>> m_tmpBuffer;
5975
bool m_lastPayloadEmpty = false;
60-
//mapping of lumisections IDs (pairs of runnumber an LS number) found in OMS to the IDs they've been assignd from PPS DB
61-
//value pair(-1, -1) means lumisection corresponding to the key exists in OMS but no lumisection was matched from PPS
76+
// mapping of lumisections IDs (pairs of runnumber an LS number) found in OMS to
77+
// the IDs they've been assignd from PPS DB value pair(-1, -1) means lumisection
78+
// corresponding to the key exists in OMS but no lumisection was matched from PPS
6279
std::map<std::pair<cond::Time_t, unsigned int>, std::pair<cond::Time_t, unsigned int>> m_lsIdMap;
6380
};
6481

CondTools/RunInfo/interface/LHCInfoPopConSourceHandler.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ class LHCInfoPopConSourceHandler : public popcon::PopConSourceHandler<LHCInfo> {
1818
void getNewObjects() override;
1919
std::string id() const override;
2020

21-
static constexpr unsigned int kLumisectionsQueryLimit = 4000; // enough for fills not exceeding 25h
22-
2321
private:
2422
void addEmptyPayload(cond::Time_t iov);
2523

CondTools/RunInfo/plugins/BuildFile.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
<flags EDM_PLUGIN="1"/>
6060
</library>
6161

62+
<library file="LHCInfoPerLSWriter.cc" name="LHCInfoPerLSWriter">
63+
<flags EDM_PLUGIN="1"/>
64+
</library>
65+
6266
<library file="LHCInfoPerFillAnalyzer.cc" name="LHCInfoPerFillAnalyzer">
6367
<flags EDM_PLUGIN="1"/>
6468
</library>

CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzer_cfg.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,25 @@
5757
default to empty string which sets no restriction"""
5858
)
5959

60+
options.register( 'sourceConnection'
61+
, "oracle://cms_orcon_adg/CMS_RUNTIME_LOGGER"
62+
, VarParsing.VarParsing.multiplicity.singleton
63+
, VarParsing.VarParsing.varType.string
64+
, """beam data source connection string (aka PPS db)"""
65+
)
66+
options.register( 'ecalConnection'
67+
, "oracle://cms_orcon_adg/CMS_DCS_ENV_PVSS_COND"
68+
, VarParsing.VarParsing.multiplicity.singleton
69+
, VarParsing.VarParsing.varType.string
70+
, """ecal data source connection string"""
71+
)
72+
options.register( 'oms'
73+
, "http://vocms0184.cern.ch/agg/api/v1"
74+
, VarParsing.VarParsing.multiplicity.singleton
75+
, VarParsing.VarParsing.varType.string
76+
, """OMS base URL"""
77+
)
78+
6079
#duringFill mode specific:
6180
options.register( 'lastLumiFile'
6281
, ''
@@ -137,7 +156,7 @@
137156
tag = cms.string( options.tag ),
138157
onlyAppendUpdatePolicy = cms.untracked.bool(True)
139158
)),
140-
frontierKey = cms.untracked.string('wrong-key')
159+
frontierKey = cms.untracked.string(options.frontierKey)
141160
)
142161

143162

@@ -150,9 +169,9 @@
150169
endTime = cms.untracked.string(options.endTime),
151170
endFill = cms.untracked.bool(options.mode == "endFill"),
152171
name = cms.untracked.string("LHCInfoPerFillPopConSourceHandler"),
153-
connectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_RUNTIME_LOGGER"),
154-
ecalConnectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_DCS_ENV_PVSS_COND"),
155-
omsBaseUrl = cms.untracked.string("http://vocms0184.cern.ch/agg/api/v1"),
172+
connectionString = cms.untracked.string(options.sourceConnection),
173+
ecalConnectionString = cms.untracked.string(options.ecalConnection),
174+
omsBaseUrl = cms.untracked.string(options.oms),
156175
authenticationPath = cms.untracked.string(options.authenticationPath),
157176
debug=cms.untracked.bool(False)
158177
),

CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzer_cfg.py

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@
5757
default to empty string which sets no restriction"""
5858
)
5959

60+
options.register( 'sourceConnection'
61+
, "oracle://cms_orcon_adg/CMS_RUNTIME_LOGGER"
62+
, VarParsing.VarParsing.multiplicity.singleton
63+
, VarParsing.VarParsing.varType.string
64+
, """beam data source connection string (aka PPS db)
65+
It's the source of crossing angle and beta * data"""
66+
)
67+
options.register( 'oms'
68+
, "http://vocms0184.cern.ch/agg/api/v1"
69+
, VarParsing.VarParsing.multiplicity.singleton
70+
, VarParsing.VarParsing.varType.string
71+
, """OMS base URL"""
72+
)
73+
6074
#duringFill mode specific:
6175
options.register( 'lastLumiFile'
6276
, ''
@@ -72,14 +86,72 @@
7286
, """duringFill only: run-unique key for writing with OnlinePopCon
7387
(used for confirming proper upload)"""
7488
)
89+
options.register('offsetLS'
90+
, 2
91+
, VarParsing.VarParsing.multiplicity.singleton
92+
, VarParsing.VarParsing.varType.int
93+
, """duringFill only: offset between lastLumi (last LS processed by HLT or overriden by lastLumiFile)
94+
and the IOV of the payload to be uploaded"""
95+
)
7596
options.register( 'debugLogic'
7697
, False
7798
, VarParsing.VarParsing.multiplicity.singleton
7899
, VarParsing.VarParsing.varType.bool
79100
, """duringFill only: Enables debug logic, meant to be used only for tests"""
80101
)
102+
options.register( 'defaultXangleX'
103+
, 160.0 # urad
104+
, VarParsing.VarParsing.multiplicity.singleton
105+
, VarParsing.VarParsing.varType.float
106+
, """duringFill only: crossingAngleX value (in urad) for the default payload.
107+
The default payload is inserted after the last processed fill has ended
108+
and there's no ongoing stable beam yet. """
109+
)
110+
options.register( 'defaultXangleY'
111+
, 0.0 # urad
112+
, VarParsing.VarParsing.multiplicity.singleton
113+
, VarParsing.VarParsing.varType.float
114+
, """duringFill only: crossingAngleY value (in urad) for the default payload.
115+
The default payload is inserted after the last processed fill has ended
116+
and there's no ongoing stable beam yet. """
117+
)
118+
options.register( 'defaultBetaX'
119+
, 0.3 # meters
120+
, VarParsing.VarParsing.multiplicity.singleton
121+
, VarParsing.VarParsing.varType.float
122+
, """duringFill only: betaStarX value (in meters) for the default payload.
123+
The default payload is inserted after the last processed fill has ended
124+
and there's no ongoing stable beam yet. """
125+
)
126+
options.register( 'defaultBetaY'
127+
, 0.3 # meters
128+
, VarParsing.VarParsing.multiplicity.singleton
129+
, VarParsing.VarParsing.varType.float
130+
, """duringFill only: betaStarY value (in meters) for the default payload.
131+
The default payload is inserted after the last processed fill has ended
132+
and there's no ongoing stable beam yet. """
133+
)
134+
135+
136+
# it's unlikely to ever use values different from the defaults, added as a parameter just in case
137+
options.register('minBetaStar', 0.1
138+
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
139+
, """duringFill only: [meters] min value of the range of valid values.
140+
If the value is outside of this range the payload is not uploaded""")
141+
options.register('maxBetaStar', 100.
142+
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
143+
, """duringFill only: [meters] min value of the range of valid values.
144+
If the value is outside of this range the payload is not uploaded""")
145+
options.register('minCrossingAngle', 10.
146+
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
147+
, """duringFill only: [urad] min value of the range of valid values.
148+
If the value is outside of this range the payload is not uploaded""")
149+
options.register('maxCrossingAngle', 500.
150+
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
151+
, """duringFill only: [urad] min value of the range of valid values.
152+
If the value is outside of this range the payload is not uploaded""")
81153

82-
# so far there was no need to use option, added just in case
154+
# as the previous options, so far there was no need to use option, added just in case
83155
options.register( 'authenticationPath'
84156
, ""
85157
, VarParsing.VarParsing.multiplicity.singleton
@@ -135,7 +207,7 @@
135207
if not options.lastLumiFile else "" ),
136208
# runNumber = cms.untracked.uint64(384468), #not used in production, the last LS processed is set as the 1st LS of this
137209
#run if the omsServiceUrl is empty and file specified in lastLumiFile is empty
138-
latency = cms.untracked.uint32(2),
210+
latency = cms.untracked.uint32(options.offsetLS),
139211
timetype = cms.untracked.string(timetype),
140212
toPut = cms.VPSet(cms.PSet(
141213
record = cms.string('LHCInfoPerLSRcd'),
@@ -156,11 +228,19 @@
156228
endTime = cms.untracked.string(options.endTime),
157229
endFill = cms.untracked.bool(options.mode == "endFill"),
158230
name = cms.untracked.string("LHCInfoPerLSPopConSourceHandler"),
159-
connectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_RUNTIME_LOGGER"),
160-
omsBaseUrl = cms.untracked.string("http://vocms0184.cern.ch/agg/api/v1"),
231+
connectionString = cms.untracked.string(options.sourceConnection),
232+
omsBaseUrl = cms.untracked.string(options.oms),
161233
authenticationPath = cms.untracked.string(options.authenticationPath),
162234
debug=cms.untracked.bool(False), # Additional logs
163235
debugLogic=cms.untracked.bool(options.debugLogic),
236+
defaultCrossingAngleX = cms.untracked.double(options.defaultXangleX),
237+
defaultCrossingAngleY = cms.untracked.double(options.defaultXangleY),
238+
defaultBetaStarX = cms.untracked.double(options.defaultBetaX),
239+
defaultBetaStarY = cms.untracked.double(options.defaultBetaY),
240+
minBetaStar = cms.untracked.double(options.minBetaStar),
241+
maxBetaStar = cms.untracked.double(options.maxBetaStar),
242+
minCrossingAngle = cms.untracked.double(options.minCrossingAngle),
243+
maxCrossingAngle = cms.untracked.double(options.maxCrossingAngle),
164244
),
165245
loggingOn = cms.untracked.bool(True),
166246
IsDestDbCheckedInQueryLog = cms.untracked.bool(False)

CondTools/RunInfo/src/LHCInfoHelper.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
// Returns lumi-type IOV (packed using cond::time::lumiTime) from
66
// last LS of last Run of the specified Fill
77
//*****************************************************************
8-
cond::Time_t cond::lhcInfoHelper::getFillLastLumiIOV(const cond::OMSService& oms, unsigned short fillId) {
8+
9+
std::pair<int, unsigned short> cond::lhcInfoHelper::getFillLastRunAndLS(const cond::OMSService& oms,
10+
unsigned short fillId) {
911
// Define query
1012
auto query = oms.query("lumisections");
1113
query->addOutputVars({"lumisection_number", "run_number"});
@@ -27,5 +29,10 @@ cond::Time_t cond::lhcInfoHelper::getFillLastLumiIOV(const cond::OMSService& oms
2729
// Return the final IOV
2830
auto lastRun = queryResult.back().get<int>("run_number");
2931
auto lastLumi = queryResult.back().get<unsigned short>("lumisection_number");
30-
return cond::time::lumiTime(lastRun, lastLumi);
32+
return std::make_pair(lastRun, lastLumi);
3133
}
34+
35+
cond::Time_t cond::lhcInfoHelper::getFillLastLumiIOV(const cond::OMSService& oms, unsigned short fillId) {
36+
auto [lastRun, lastLumi] = getFillLastRunAndLS(oms, fillId);
37+
return cond::time::lumiTime(lastRun, lastLumi);
38+
}

CondTools/RunInfo/src/LHCInfoPerFillPopConSourceHandler.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,11 @@ void LHCInfoPerFillPopConSourceHandler::getNewObjects() {
235235
cond::Time_t lastSince = tagInfo().lastInterval.since;
236236
if (tagInfo().isEmpty()) {
237237
// for a new or empty tag in endFill mode, an empty payload should be added on top with since=1
238-
if (m_endFillMode) {
239-
addEmptyPayload(1);
240-
lastSince = 1;
238+
addEmptyPayload(1);
239+
lastSince = 1;
240+
if (!m_endFillMode) {
241+
edm::LogInfo(m_name) << "Empty or new tag: uploading a default payload and ending the job";
242+
return;
241243
}
242244
} else {
243245
edm::LogInfo(m_name) << "The last Iov in tag " << tagInfo().name << " valid since " << lastSince << "from "
@@ -384,8 +386,6 @@ void LHCInfoPerFillPopConSourceHandler::getNewObjects() {
384386

385387
std::string LHCInfoPerFillPopConSourceHandler::id() const { return m_name; }
386388

387-
static constexpr unsigned int kLumisectionsQueryLimit = 4000;
388-
389389
void LHCInfoPerFillPopConSourceHandler::addEmptyPayload(cond::Time_t iov) {
390390
bool add = false;
391391
if (m_iovs.empty()) {
@@ -448,7 +448,7 @@ size_t LHCInfoPerFillPopConSourceHandler::getLumiData(const cond::OMSService& om
448448
query->filterEQ("fill_number", fillId);
449449
query->filterGT("start_time", beginFillTime).filterLT("start_time", endFillTime);
450450
query->filterEQ("beams_stable", "true");
451-
query->limit(kLumisectionsQueryLimit);
451+
query->limit(cond::lhcInfoHelper::kLumisectionsQueryLimit);
452452
if (query->execute()) {
453453
auto queryResult = query->result();
454454
edm::LogInfo(m_name) << "Found " << queryResult.size() << " lumisections with STABLE BEAM during the fill "

0 commit comments

Comments
 (0)