Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Condition DB modules for HLT workflow: clean up old lumi information source from DAQ #32885

Merged
merged 1 commit into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CondCore/DBOutputService/interface/OnlineDBOutputService.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ namespace cond {
cond::Time_t m_runNumber;
size_t m_latencyInLumisections;
std::string m_omsServiceUrl;
std::string m_lastLumiUrl;
std::string m_lastLumiFile;
std::string m_preLoadConnectionString;
bool m_debug;
Expand Down
39 changes: 10 additions & 29 deletions CondCore/DBOutputService/src/OnlineDBOutputService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ static size_t getHtmlCallback(void* contents, size_t size, size_t nmemb, void* p
return size * nmemb;
}

bool getInfoFromDAQ(const std::string& urlString, std::string& info) {
bool getInfoFromService(const std::string& urlString, std::string& info) {
CURL* curl;
CURLcode res;
std::string htmlBuffer;
Expand Down Expand Up @@ -58,7 +58,7 @@ namespace cond {
cond::Time_t getLastLumiFromOMS(const std::string& omsServiceUrl) {
cond::Time_t lastLumiProcessed = cond::time::MIN_VAL;
std::string info("");
if (!getInfoFromDAQ(omsServiceUrl, info))
if (!getInfoFromService(omsServiceUrl, info))
throw Exception("Can't get data from OMS Service.");
std::istringstream sinfo(info);
std::string srun;
Expand All @@ -80,22 +80,13 @@ namespace cond {
cond::service::OnlineDBOutputService::OnlineDBOutputService(const edm::ParameterSet& iConfig,
edm::ActivityRegistry& iAR)
: PoolDBOutputService(iConfig, iAR),
m_runNumber(iConfig.getUntrackedParameter<unsigned long long>("runNumber", 0)),
m_runNumber(iConfig.getUntrackedParameter<unsigned long long>("runNumber", 1)),
m_latencyInLumisections(iConfig.getUntrackedParameter<unsigned int>("latency", 1)),
m_omsServiceUrl(iConfig.getUntrackedParameter<std::string>("omsServiceUrl", "")),
m_lastLumiUrl(iConfig.getUntrackedParameter<std::string>("lastLumiUrl", "")),
m_preLoadConnectionString(iConfig.getUntrackedParameter<std::string>("preLoadConnectionString", "")),
m_debug(iConfig.getUntrackedParameter<bool>("debugLogging", false)) {
if (m_omsServiceUrl.empty()) {
if (!m_lastLumiUrl.empty()) {
startTransaction();
auto lastRun = PoolDBOutputService::session().getLastRun();
if (lastRun.isOnGoing()) {
m_runNumber = lastRun.run;
}
} else {
m_lastLumiFile = iConfig.getUntrackedParameter<std::string>("lastLumiFile", "");
}
m_lastLumiFile = iConfig.getUntrackedParameter<std::string>("lastLumiFile", "");
}
}

Expand All @@ -110,23 +101,13 @@ cond::Time_t cond::service::OnlineDBOutputService::getLastLumiProcessed() {
<< " Current run: " << cond::time::unpack(lastLumiProcessed).first
<< " lumi id:" << cond::time::unpack(lastLumiProcessed).second;
} else {
if (!m_lastLumiUrl.empty()) {
std::string info("");
if (!getInfoFromDAQ(m_lastLumiUrl, info))
throw Exception("Can't get last Lumisection from DAQ.");
unsigned int lastL = boost::lexical_cast<unsigned int>(info);
lastLumiProcessed = cond::time::lumiTime(m_runNumber, lastL);
logger().logInfo() << "Last lumi: " << lastLumiProcessed << " Current run: " << m_runNumber
<< " lumi id:" << lastL;
if (!m_lastLumiFile.empty()) {
lastLumiProcessed = cond::getLatestLumiFromFile(m_lastLumiFile);
auto upkTime = cond::time::unpack(lastLumiProcessed);
logger().logInfo() << "Last lumi: " << lastLumiProcessed << " Current run: " << upkTime.first
<< " lumi id:" << upkTime.second;
} else {
if (m_lastLumiFile.empty()) {
throw Exception("File name for last lumi has not been provided.");
} else {
lastLumiProcessed = cond::getLatestLumiFromFile(m_lastLumiFile);
auto upkTime = cond::time::unpack(lastLumiProcessed);
logger().logInfo() << "Last lumi: " << lastLumiProcessed << " Current run: " << upkTime.first
<< " lumi id:" << upkTime.second;
}
lastLumiProcessed = cond::time::lumiTime(m_runNumber, 1);
}
}
return lastLumiProcessed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
messageLevel = cms.untracked.int32(2),
authenticationPath = cms.untracked.string('.')
),
#timetype = cms.untracked.string('runnumber'),
jobName = cms.untracked.string("TestLumiBasedUpdate"),
autoCommit = cms.untracked.bool(True),
connect = cms.string('sqlite_file:test_lumi.db'),
preLoadConnectionString = cms.untracked.string('sqlite_file:test_lumi.db'),
#omsServiceUrl = cms.untracked.string('http://cmsoms-services.cms:9949/urn:xdaq-application:lid=100/getRunAndLumiSection'),
lastLumiFile = cms.untracked.string('lastLumi.txt'),
#lastLumiFile = cms.untracked.string('lastLumi.txt'),
toPut = cms.VPSet(cms.PSet(
record = cms.string('PedestalsRcd'),
tag = cms.string('mytest'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
connect = cms.string('oracle://cms_orcoff_prep/CMS_CONDITIONS'),
preLoadConnectionString = cms.untracked.string('frontier://FrontierPrep/CMS_CONDITIONS'),
runNumber = cms.untracked.uint64(options.runNumber),
lastLumiFile = cms.untracked.string('last_lumi.txt'),
#lastLumiFile = cms.untracked.string('last_lumi.txt'),
writeTransactionDelay = cms.untracked.uint32(options.transDelay),
autoCommit = cms.untracked.bool(True),
saveLogsOnDB = cms.untracked.bool(True),
Expand All @@ -50,7 +50,6 @@
)

process.mytest = cms.EDAnalyzer("LumiBasedUpdateAnalyzer",
lastLumiFile = cms.untracked.string('last_lumi.txt'),
record = cms.string('PedestalsRcd')
)

Expand Down
29 changes: 4 additions & 25 deletions CondCore/DBOutputService/test/stubs/LumiBasedUpdateAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@
#include <iostream>

LumiBasedUpdateAnalyzer::LumiBasedUpdateAnalyzer(const edm::ParameterSet& iConfig)
: m_record(iConfig.getParameter<std::string>("record")) {
m_lastLumiFile = iConfig.getUntrackedParameter<std::string>("lastLumiFile", "");
std::cout << "LumiBasedUpdateAnalyzer::LumiBasedUpdateAnalyzer" << std::endl;
m_prevLumi = 0;
m_prevLumiTime = std::chrono::steady_clock::now();
m_omsServiceUrl = iConfig.getUntrackedParameter<std::string>("omsServiceUrl", "");
edm::Service<cond::service::OnlineDBOutputService> mydbservice;
}
: m_record(iConfig.getParameter<std::string>("record")) {}
LumiBasedUpdateAnalyzer::~LumiBasedUpdateAnalyzer() {
std::cout << "LumiBasedUpdateAnalyzer::~LumiBasedUpdateAnalyzer" << std::endl;
}
Expand All @@ -33,23 +26,9 @@ void LumiBasedUpdateAnalyzer::analyze(const edm::Event& evt, const edm::EventSet
m_tagLocks = true;
}
::sleep(2);
unsigned int irun = evt.id().run();
cond::Time_t lastLumi = cond::time::MIN_VAL;
if (!m_omsServiceUrl.empty()) {
lastLumi = cond::getLastLumiFromOMS(m_omsServiceUrl);
} else {
lastLumi = cond::getLatestLumiFromFile(m_lastLumiFile);
if (lastLumi == m_prevLumi) {
mydbservice->logger().logInfo() << "Last lumi:" << lastLumi << " Prev lumi:" << m_prevLumi;
mydbservice->logger().end(1);
return;
}
m_prevLumi = lastLumi;
m_prevLumiTime = std::chrono::steady_clock::now();
}
unsigned int lumiId = cond::time::unpack(lastLumi).second;
mydbservice->logger().logInfo() << "Last lumi: " << lastLumi << " run: " << cond::time::unpack(lastLumi).first
<< " lumiid:" << lumiId;
//unsigned int irun = evt.id().run();
unsigned int irun = evt.getLuminosityBlock().run();
unsigned int lumiId = evt.getLuminosityBlock().luminosityBlock();
std::string tag = mydbservice->tag(m_record);
std::cout << "tag " << tag << std::endl;
std::cout << "run " << irun << std::endl;
Expand Down
4 changes: 0 additions & 4 deletions CondCore/DBOutputService/test/stubs/LumiBasedUpdateAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ class LumiBasedUpdateAnalyzer : public edm::EDAnalyzer {

private:
std::string m_record;
std::string m_lastLumiFile;
cond::Time_t m_prevLumi;
std::chrono::time_point<std::chrono::steady_clock> m_prevLumiTime;
std::string m_omsServiceUrl;
bool m_tagLocks;
// ----------member data ---------------------------
};
Expand Down