Skip to content

Commit 51f24a9

Browse files
authored
Merge branch 'master' into mini_from_mini
2 parents 514a8ca + 3663afc commit 51f24a9

File tree

158 files changed

+13989
-6778
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+13989
-6778
lines changed

CondCore/EcalPlugins/plugins/EcalPedestals_PayloadInspector.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ namespace {
486486
l_tagname[1] = l_tagname[0];
487487
}
488488
run[1] = std::get<0>(lastiov);
489-
for (int irun = 0; irun < nIOVs; irun++) {
489+
for (int irun = 0; irun < 2; irun++) {
490490
std::shared_ptr<EcalPedestals> payload;
491491
if (irun == 0) {
492492
payload = this->fetchPayload(std::get<1>(firstiov));
@@ -606,7 +606,7 @@ namespace {
606606
}
607607
} // loop over cellid
608608
} // barrel data present
609-
if (payload->endcapItems().empty()) {
609+
if (!payload->endcapItems().empty()) {
610610
// looping over the EE channels
611611
for (int iz = -1; iz < 2; iz = iz + 2) { // -1 or +1
612612
for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++) {
@@ -824,9 +824,9 @@ namespace {
824824
return true;
825825
} // fill method
826826
}; // class EcalPedestalsBase
827-
using EcalPedestalsDiffOneTag = EcalPedestalsBase<cond::payloadInspector::SINGLE_IOV, 1, 0>;
827+
using EcalPedestalsDiffOneTag = EcalPedestalsBase<cond::payloadInspector::MULTI_IOV, 1, 0>;
828828
using EcalPedestalsDiffTwoTags = EcalPedestalsBase<cond::payloadInspector::SINGLE_IOV, 2, 0>;
829-
using EcalPedestalsRatioOneTag = EcalPedestalsBase<cond::payloadInspector::SINGLE_IOV, 1, 1>;
829+
using EcalPedestalsRatioOneTag = EcalPedestalsBase<cond::payloadInspector::MULTI_IOV, 1, 1>;
830830
using EcalPedestalsRatioTwoTags = EcalPedestalsBase<cond::payloadInspector::SINGLE_IOV, 2, 1>;
831831

832832
/*************************************************

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: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
/*
14+
* A mock PopCon source handler for testing LHCInfoPerFillPopCon logic without
15+
* external dependencies (e.g. OMS, subsystem DBs, destination DB).
16+
*/
17+
18+
class TestLHCInfoPerFillPopConSourceHandler : public LHCInfoPerFillPopConSourceHandler {
19+
public:
20+
TestLHCInfoPerFillPopConSourceHandler(edm::ParameterSet const& pset);
21+
~TestLHCInfoPerFillPopConSourceHandler() override = default;
22+
23+
std::vector<std::pair<cond::Time_t /*timestamp*/, std::shared_ptr<LHCInfoPerFill>>> mockOmsFills;
24+
std::map<unsigned short /*fillNr*/, cond::OMSServiceResult> mockLumiData;
25+
boost::posix_time::ptime mockExecutionTime;
26+
27+
const Container& iovs() const { return m_iovs; }
28+
29+
protected:
30+
std::unique_ptr<LHCInfoPerFill> findFillToProcess(cond::OMSService& oms,
31+
const boost::posix_time::ptime& nextFillSearchTime,
32+
bool inclusiveSearchTime) override;
33+
34+
cond::Time_t handleIfNewTagAndGetLastSince() override;
35+
36+
void fetchLastPayload() override {};
37+
38+
boost::posix_time::ptime getExecutionTime() const override;
39+
40+
std::tuple<cond::persistency::Session, cond::persistency::Session> createSubsystemDbSessions() const override;
41+
42+
void getDipData(const cond::OMSService& oms,
43+
const boost::posix_time::ptime& beginFillTime,
44+
const boost::posix_time::ptime& endFillTime) override {};
45+
46+
bool getCTPPSData(cond::persistency::Session& session,
47+
const boost::posix_time::ptime& beginFillTime,
48+
const boost::posix_time::ptime& endFillTime) override {
49+
return true;
50+
};
51+
52+
bool getEcalData(cond::persistency::Session& session,
53+
const boost::posix_time::ptime& lowerTime,
54+
const boost::posix_time::ptime& upperTime) override {
55+
return true;
56+
};
57+
58+
std::tuple<cond::OMSServiceResult, bool, std::unique_ptr<cond::OMSServiceQuery>> executeLumiQuery(
59+
const cond::OMSService& oms,
60+
unsigned short fillId,
61+
const boost::posix_time::ptime& beginFillTime,
62+
const boost::posix_time::ptime& endFillTime) const override;
63+
};

CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzer_cfg.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,19 @@
9191
, """duringFill only: run-unique key for writing with OnlinePopCon
9292
(used for confirming proper upload)"""
9393
)
94-
94+
# checking for invalid energy values, duringFill mode specific
95+
options.register('minEnergy', 450
96+
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
97+
, """duringFill only: [GeV] min value of the range of valid values (inclusive).
98+
If the value is outside of this range the payload is not uploaded""")
99+
options.register('maxEnergy', 8000.
100+
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
101+
, """duringFill only: [GeV] max value of the range of valid values (inclusive).
102+
If the value is outside of this range the payload is not uploaded""")
103+
options.register('throwOnInvalid', False, # Intended production setup: False for endFill, True for duringFill
104+
VarParsing.VarParsing.multiplicity.singleton,
105+
VarParsing.VarParsing.varType.bool,
106+
"duringFill only: If true, throw on invalid payloads; if false, filter them out.")
95107

96108
# so far there was no need to use option, added just in case
97109
options.register( 'authenticationPath'
@@ -106,6 +118,8 @@
106118
raise ValueError("mode argument not provided. Supported modes are: duringFill endFill")
107119
if options.mode not in ("duringFill", "endFill"):
108120
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")
109123

110124
CondDBConnection = CondDB.clone( connect = cms.string( options.destinationConnection ) )
111125
CondDBConnection.DBParameters.messageLevel = cms.untracked.int32( options.messageLevel )
@@ -173,7 +187,10 @@
173187
ecalConnectionString = cms.untracked.string(options.ecalConnection),
174188
omsBaseUrl = cms.untracked.string(options.oms),
175189
authenticationPath = cms.untracked.string(options.authenticationPath),
176-
debug=cms.untracked.bool(False)
190+
debug=cms.untracked.bool(False),
191+
minEnergy = cms.untracked.double(options.minEnergy),
192+
maxEnergy = cms.untracked.double(options.maxEnergy),
193+
throwOnInvalid = cms.untracked.bool(options.throwOnInvalid)
177194
),
178195
loggingOn = cms.untracked.bool(True),
179196
IsDestDbCheckedInQueryLog = cms.untracked.bool(False)

CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzer_cfg.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,25 +131,28 @@
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
139-
, """duringFill only: [meters] min value of the range of valid values.
138+
, """duringFill only: [meters] min value of the range of valid values (inclusive).
140139
If the value is outside of this range the payload is not uploaded""")
141140
options.register('maxBetaStar', 100.
142141
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
143-
, """duringFill only: [meters] min value of the range of valid values.
142+
, """duringFill only: [meters] max value of the range of valid values (inclusive).
144143
If the value is outside of this range the payload is not uploaded""")
145144
options.register('minCrossingAngle', 10.
146145
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
147-
, """duringFill only: [urad] min value of the range of valid values.
146+
, """duringFill only: [urad] min value of the range of valid values (inclusive).
148147
If the value is outside of this range the payload is not uploaded""")
149148
options.register('maxCrossingAngle', 500.
150149
, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float
151-
, """duringFill only: [urad] min value of the range of valid values.
150+
, """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""")
152+
options.register('throwOnInvalid', False, # Intended production setup: False for endFill, True for duringFill
153+
VarParsing.VarParsing.multiplicity.singleton,
154+
VarParsing.VarParsing.varType.bool,
155+
"duringFill only: If true, throw on invalid payloads; if false, filter them out.")
153156

154157
# as the previous options, so far there was no need to use option, added just in case
155158
options.register( 'authenticationPath'
@@ -164,6 +167,8 @@
164167
raise ValueError("mode argument not provided. Supported modes are: duringFill endFill")
165168
if options.mode not in ("duringFill", "endFill"):
166169
raise ValueError("Wrong mode argument. Supported modes are: duringFill endFill")
170+
if options.throwOnInvalid and options.mode != "duringFill":
171+
raise ValueError("throwOnInvalid option can be True only in duringFill mode")
167172

168173
CondDBConnection = CondDB.clone( connect = cms.string( options.destinationConnection ) )
169174
CondDBConnection.DBParameters.messageLevel = cms.untracked.int32( options.messageLevel )
@@ -241,6 +246,7 @@
241246
maxBetaStar = cms.untracked.double(options.maxBetaStar),
242247
minCrossingAngle = cms.untracked.double(options.minCrossingAngle),
243248
maxCrossingAngle = cms.untracked.double(options.maxCrossingAngle),
249+
throwOnInvalid = cms.untracked.bool(options.throwOnInvalid)
244250
),
245251
loggingOn = cms.untracked.bool(True),
246252
IsDestDbCheckedInQueryLog = cms.untracked.bool(False)

0 commit comments

Comments
 (0)