CMS 3D CMS Logo

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) {}

◆ ~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.

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 }

References cond::persistency::Session::editRunInfo(), end, cond::persistency::RunInfoEditor::flush(), cond::persistency::RunInfoEditor::insertNew(), m_dbSession, RunInfo::m_run, and command_line::start.

Referenced by RunInfoHandler::getNewObjects().

◆ import()

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

Definition at line 47 of file RunInfoUpdate.cc.

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 }

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

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().

start
Definition: start.py:1
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
SiStripBadComponentsDQMServiceTemplate_cfg.lastRun
lastRun
Definition: SiStripBadComponentsDQMServiceTemplate_cfg.py:27
edm::LogInfo
Definition: MessageLogger.h:254
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
cond::persistency::IOVProxy::selectAll
IOVArray selectAll()
Definition: IOVProxy.cc:171
end
#define end
Definition: vmac.h:39
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
RunInfo
Definition: RunInfo.h:18
RunInfoUpdate::m_dbSession
cond::persistency::Session & m_dbSession
Definition: RunInfoUpdate.h:22
h
cond::persistency::Session::readIov
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
cond::persistency::IOVProxy
Definition: IOVProxy.h:92
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
RawToDigi_cff.sourceTag
sourceTag
Definition: RawToDigi_cff.py:78
cond::persistency::RunInfoEditor
Definition: RunInfoEditor.h:28
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
maxEntries
const unsigned int maxEntries
Definition: DimuonStatistics.cc:30