CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Private Attributes
RunInfoUpdate Class Reference

#include <RunInfoUpdate.h>

Public Member Functions

void appendNewRun (const RunInfo &run)
 
size_t import (size_t maxEntries, const std::string &tag, cond::persistency::Session &sourceSession)
 
 RunInfoUpdate (cond::persistency::Session &dbSession)
 
 ~RunInfoUpdate ()
 

Private Attributes

cond::persistency::Sessionm_dbSession
 

Detailed Description

Definition at line 12 of file RunInfoUpdate.h.

Constructor & Destructor Documentation

◆ RunInfoUpdate()

RunInfoUpdate::RunInfoUpdate ( cond::persistency::Session dbSession)
explicit

Definition at line 29 of file RunInfoUpdate.cc.

29 : m_dbSession(dbSession) {}
cond::persistency::Session & m_dbSession
Definition: RunInfoUpdate.h:22

◆ ~RunInfoUpdate()

RunInfoUpdate::~RunInfoUpdate ( )

Definition at line 31 of file RunInfoUpdate.cc.

31 {}

Member Function Documentation

◆ appendNewRun()

void RunInfoUpdate::appendNewRun ( const RunInfo run)

Definition at line 33 of file RunInfoUpdate.cc.

References cond::persistency::Session::editRunInfo(), mps_fire::end, cond::persistency::RunInfoEditor::flush(), cond::persistency::RunInfoEditor::insertNew(), m_dbSession, submitPVValidationJobs::runInfo, and command_line::start.

Referenced by RunInfoHandler::getNewObjects().

33  {
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 }
Definition: start.py:1
RunInfoEditor editRunInfo()
Definition: Session.cc:210
void insertNew(cond::Time_t runNumber, const boost::posix_time::ptime &start, const boost::posix_time::ptime &end)
Log< level::Info, false > LogInfo
cond::persistency::Session & m_dbSession
Definition: RunInfoUpdate.h:22

◆ import()

size_t RunInfoUpdate::import ( size_t  maxEntries,
const std::string &  tag,
cond::persistency::Session sourceSession 
)

Definition at line 47 of file RunInfoUpdate.cc.

References gather_cfg::cout, cond::persistency::Session::editRunInfo(), mps_fire::end, cond::persistency::Session::fetchPayload(), cond::persistency::RunInfoEditor::flush(), cond::persistency::RunInfoEditor::getLastInserted(), h, cond::persistency::RunInfoEditor::insert(), BeamSpotPI::lastRun, m_dbSession, cond::persistency::Session::readIov(), submitPVValidationJobs::runInfo, cond::persistency::IOVProxy::selectAll(), RawToDigi_cff::sourceTag, and command_line::start.

49  {
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 }
Definition: start.py:1
void insert(cond::Time_t runNumber, const boost::posix_time::ptime &start, const boost::posix_time::ptime &end)
RunInfoEditor editRunInfo()
Definition: Session.cc:210
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:213
unsigned long long Time_t
Definition: Time.h:14
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
cond::persistency::Session & m_dbSession
Definition: RunInfoUpdate.h:22
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

Member Data Documentation

◆ m_dbSession

cond::persistency::Session& RunInfoUpdate::m_dbSession
private

Definition at line 22 of file RunInfoUpdate.h.

Referenced by appendNewRun(), and import().