diff --git a/CondTools/RunInfo/plugins/LHCInfoPerFillPopConAnalyzer.cc b/CondTools/RunInfo/plugins/LHCInfoPerFillPopConAnalyzer.cc index 45b40b6c3b87c..cce7fd953dfc9 100644 --- a/CondTools/RunInfo/plugins/LHCInfoPerFillPopConAnalyzer.cc +++ b/CondTools/RunInfo/plugins/LHCInfoPerFillPopConAnalyzer.cc @@ -360,9 +360,16 @@ class LHCInfoPerFillPopConSourceHandler : public popcon::PopConSourceHandlerfillNumber() and !ongoingFill) { if (m_endFillMode) { addEmptyPayload(endFillTime); @@ -398,24 +405,37 @@ class LHCInfoPerFillPopConSourceHandler : public popcon::PopConSourceHandler("start_time"); + auto startTime = row.get("start_time"); auto delivLumi = row.get("delivered_lumi"); auto recLumi = row.get("recorded_lumi"); + auto runNumber = std::stoull(row.get("run_number")); + auto lsNumber = std::stoul(row.get("lumisection_number")); + auto lumiid = cond::time::lumiTime(runNumber, lsNumber); + LHCInfoPerFill* thisLumiSectionInfo = m_fillPayload->cloneFill(); - if (m_endFillMode) { - m_tmpBuffer.emplace_back(std::make_pair(cond::time::from_boost(lumiTime), thisLumiSectionInfo)); - } else { - m_tmpBuffer.emplace_back( - std::make_pair(cond::time::lumiTime(std::stoull(row.get("run_number")), - std::stoul(row.get("lumisection_number"))), - thisLumiSectionInfo)); + m_tmpBuffer.emplace_back(std::make_pair(cond::time::from_boost(startTime), thisLumiSectionInfo)); + if (!m_endFillMode) { + m_timestampToLumiid.insert(std::make_pair(cond::time::from_boost(startTime), lumiid)); } LHCInfoPerFill& payload = *thisLumiSectionInfo; payload.setDelivLumi(delivLumi); payload.setRecLumi(recLumi); } + void convertBufferedIovsToLumiid(std::map timestampToLumiid) { + for (auto& item : m_tmpBuffer) { + // Check if the lumiid IOV corresponding to the timestamp is present in the map + if (timestampToLumiid.find(item.first) == timestampToLumiid.end()) { + throw cms::Exception("LHCInfoPerFillPopConSourceHandler") + << "Can't find corresponding lumiid IOV for timestamp " << item.first << "\n"; + } + // Update the buffer with the lumiid-type IOV + item.first = timestampToLumiid.at(item.first); + } + } + size_t getLumiData(const cond::OMSService& oms, unsigned short fillId, const boost::posix_time::ptime& beginFillTime, @@ -740,4 +760,6 @@ class LHCInfoPerFillPopConSourceHandler : public popcon::PopConSourceHandler m_prevPayload; std::vector>> m_tmpBuffer; bool m_lastPayloadEmpty = false; + // to hold correspondance between timestamp-type IOVs and lumiid-type IOVs + std::map m_timestampToLumiid; }; diff --git a/CondTools/RunInfo/src/LHCInfoHelper.cc b/CondTools/RunInfo/src/LHCInfoHelper.cc index 5ce44e21981ba..54503068b8924 100644 --- a/CondTools/RunInfo/src/LHCInfoHelper.cc +++ b/CondTools/RunInfo/src/LHCInfoHelper.cc @@ -20,8 +20,9 @@ cond::Time_t cond::lhcInfoHelper::getFillLastLumiIOV(const cond::OMSService& oms // Get query result auto queryResult = query->result(); - if (queryResult.empty()) + if (queryResult.empty()) { throw cms::Exception("OMSQueryFailure") << "OMS query of fill " << fillId << " returned empty result!\n"; + } // Return the final IOV auto lastRun = queryResult.back().get("run_number");