CMS 3D CMS Logo

RunInfoUpdate.cc
Go to the documentation of this file.
4 
5 namespace {
6  boost::posix_time::ptime parseTimeFromIsoString(const std::string& isoString) {
7  boost::posix_time::time_input_facet* tif = new boost::posix_time::time_input_facet;
8  tif->set_iso_extended_format();
9  std::istringstream iss(isoString);
10  iss.imbue(std::locale(std::locale::classic(), tif));
11  boost::posix_time::ptime ret;
12  iss >> ret;
13  return ret;
14  }
15 
16  void getRunTimeParams(const RunInfo& runInfo, boost::posix_time::ptime& start, boost::posix_time::ptime& end) {
17  std::string startStr = runInfo.m_start_time_str;
18  if (startStr != "null") {
19  start = parseTimeFromIsoString(startStr);
20  }
21  end = start;
22  std::string stopStr = runInfo.m_stop_time_str;
23  if (stopStr != "null") {
24  end = parseTimeFromIsoString(stopStr);
25  }
26  }
27 } // namespace
28 
29 RunInfoUpdate::RunInfoUpdate(cond::persistency::Session& dbSession) : m_dbSession(dbSession) {}
30 
32 
35  boost::posix_time::ptime start;
36  boost::posix_time::ptime end;
37  getRunTimeParams(runInfo, start, end);
38  edm::LogInfo("RunInfoUpdate") << "[RunInfoUpdate::" << __func__ << "]: Checking run " << runInfo.m_run
39  << " for insertion in Condition DB" << std::endl;
40  runInfoWriter.insertNew(runInfo.m_run, start, end);
41  size_t newRuns = runInfoWriter.flush();
42  edm::LogInfo("RunInfoUpdate") << "[RunInfoUpdate::" << __func__ << "]: " << newRuns << " new run(s) inserted."
43  << std::endl;
44 }
45 
46 // only used in import command tool
48  const std::string& sourceTag,
49  cond::persistency::Session& sourceSession) {
51  std::cout << "# Loading tag " << sourceTag << "..." << std::endl;
52  cond::persistency::IOVProxy runInfoTag = sourceSession.readIov(sourceTag);
53  auto iovs = runInfoTag.selectAll();
54  editor = m_dbSession.editRunInfo();
56  std::cout << "# Last run found in RunInfo db : " << lastRun << std::endl;
57  auto it = iovs.begin();
58  if (lastRun > 0) {
59  it = iovs.find(lastRun + 1);
60  }
61  if (it == iovs.end() || (*it).since == lastRun) {
62  std::cout << "# No more run found to be imported." << std::endl;
63  return 0;
64  }
65  size_t n_entries = 0;
66  while (it != iovs.end() && n_entries <= maxEntries) {
67  auto h = (*it).payloadId;
68  std::shared_ptr<RunInfo> runInfo = sourceSession.fetchPayload<RunInfo>(h);
69  if (runInfo->m_run != -1) {
70  n_entries++;
71  std::cout << "# Inserting run #" << runInfo->m_run << " (from since=" << (*it).since << ")" << std::endl;
72  boost::posix_time::ptime start;
73  boost::posix_time::ptime end;
74  getRunTimeParams(*runInfo, start, end);
75  editor.insert(runInfo->m_run, start, end);
76  } else {
77  std::cout << "# Skipping fake run #" << std::endl;
78  }
79  it++;
80  }
81  editor.flush();
82  return n_entries;
83 }
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:373
start
Definition: start.py:1
MessageLogger.h
RunInfoUpdate::appendNewRun
void appendNewRun(const RunInfo &run)
Definition: RunInfoUpdate.cc:33
RunInfoUpdate::import
size_t import(size_t maxEntries, const std::string &tag, cond::persistency::Session &sourceSession)
Definition: RunInfoUpdate.cc:47
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
gather_cfg.cout
cout
Definition: gather_cfg.py:144
cond::persistency::RunInfoEditor::insert
void insert(cond::Time_t runNumber, const boost::posix_time::ptime &start, const boost::posix_time::ptime &end)
Definition: RunInfoEditor.cc:49
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
cond::persistency::IOVProxy::selectAll
IOVArray selectAll()
Definition: IOVProxy.cc:175
cond::persistency::RunInfoEditor::getLastInserted
cond::Time_t getLastInserted()
Definition: RunInfoEditor.cc:40
cond::persistency::Session::fetchPayload
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:213
cond::persistency::RunInfoEditor::flush
size_t flush()
Definition: RunInfoEditor.cc:63
RunInfoUpdate.h
RunInfo
Definition: RunInfo.h:18
RunInfoUpdate::m_dbSession
cond::persistency::Session & m_dbSession
Definition: RunInfoUpdate.h:22
mps_fire.end
end
Definition: mps_fire.py:242
h
cond::persistency::Session::readIov
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BeamSpotPI::lastRun
Definition: BeamSpotPayloadInspectorHelper.h:39
cond::persistency::IOVProxy
Definition: IOVProxy.h:92
RunInfoUpdate::RunInfoUpdate
RunInfoUpdate(cond::persistency::Session &dbSession)
Definition: RunInfoUpdate.cc:29
cond::persistency::Session
Definition: Session.h:63
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
RunInfoUpdate::~RunInfoUpdate
~RunInfoUpdate()
Definition: RunInfoUpdate.cc:31
RawToDigi_cff.sourceTag
sourceTag
Definition: RawToDigi_cff.py:78
cond::persistency::RunInfoEditor
Definition: RunInfoEditor.h:28
submitPVValidationJobs.runInfo
dictionary runInfo
Definition: submitPVValidationJobs.py:1013
cond::persistency::RunInfoEditor::insertNew
void insertNew(cond::Time_t runNumber, const boost::posix_time::ptime &start, const boost::posix_time::ptime &end)
Definition: RunInfoEditor.cc:56
command_line.start
start
Definition: command_line.py:167
cond::persistency::Session::editRunInfo
RunInfoEditor editRunInfo()
Definition: Session.cc:210
Session.h
maxEntries
const unsigned int maxEntries
Definition: DimuonStatistics.cc:30