Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-07 06:12:39

0001 #include "CondTools/RunInfo/interface/LHCInfoHelper.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 
0004 //*****************************************************************
0005 // Returns lumi-type IOV (packed using cond::time::lumiTime) from
0006 // last LS of last Run of the specified Fill
0007 //*****************************************************************
0008 
0009 std::pair<int, unsigned short> cond::lhcInfoHelper::getFillLastRunAndLS(const cond::OMSService& oms,
0010                                                                         unsigned short fillId) {
0011   // Define query
0012   auto query = oms.query("lumisections");
0013   query->addOutputVars({"lumisection_number", "run_number"});
0014   query->filterEQ("fill_number", fillId);
0015   query->limit(cond::lhcInfoHelper::kLumisectionsQueryLimit);
0016 
0017   // Execute query
0018   if (!query->execute()) {
0019     throw cms::Exception("OMSQueryFailure")
0020         << "OMS query of fill " << fillId << " failed, status:" << query->status() << "\n";
0021   }
0022 
0023   // Get query result
0024   auto queryResult = query->result();
0025   if (queryResult.empty()) {
0026     throw cms::Exception("OMSQueryFailure") << "OMS query of fill " << fillId << " returned empty result!\n";
0027   }
0028 
0029   // Return the final IOV
0030   auto lastRun = queryResult.back().get<int>("run_number");
0031   auto lastLumi = queryResult.back().get<unsigned short>("lumisection_number");
0032   return std::make_pair(lastRun, lastLumi);
0033 }
0034 
0035 cond::Time_t cond::lhcInfoHelper::getFillLastLumiIOV(const cond::OMSService& oms, unsigned short fillId) {
0036   auto [lastRun, lastLumi] = getFillLastRunAndLS(oms, fillId);
0037   return cond::time::lumiTime(lastRun, lastLumi);
0038 }