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 ( cond::persistency::Session dbSession)
explicit

Definition at line 29 of file RunInfoUpdate.cc.

29  :
30  m_dbSession(dbSession){
31 }
cond::persistency::Session & m_dbSession
Definition: RunInfoUpdate.h:21
RunInfoUpdate::~RunInfoUpdate ( )

Definition at line 33 of file RunInfoUpdate.cc.

33 {}

Member Function Documentation

void RunInfoUpdate::appendNewRun ( const RunInfo run)

Definition at line 35 of file RunInfoUpdate.cc.

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

35  {
37  boost::posix_time::ptime start;
38  boost::posix_time::ptime end;
39  getRunTimeParams( runInfo, start, end );
40  edm::LogInfo( "RunInfoUpdate" ) << "[RunInfoUpdate::" << __func__ << "]: Checking run " <<runInfo.m_run<<" for insertion in Condition DB"<< std::endl;
41  runInfoWriter.insertNew( runInfo.m_run, start, end );
42  size_t newRuns = runInfoWriter.flush();
43  edm::LogInfo( "RunInfoUpdate" ) << "[RunInfoUpdate::" << __func__ << "]: "<<newRuns<<" new run(s) inserted."<< std::endl;
44 }
RunInfoEditor editRunInfo()
Definition: Session.cc:218
void insertNew(cond::Time_t runNumber, const boost::posix_time::ptime &start, const boost::posix_time::ptime &end)
#define end
Definition: vmac.h:39
cond::persistency::Session & m_dbSession
Definition: RunInfoUpdate.h:21
size_t RunInfoUpdate::import ( size_t  maxEntries,
const std::string &  tag,
cond::persistency::Session sourceSession 
)

Definition at line 47 of file RunInfoUpdate.cc.

References cond::persistency::IOVProxy::begin(), gather_cfg::cout, idDealer::editor, cond::persistency::Session::editRunInfo(), end, cond::persistency::IOVProxy::end(), cond::persistency::Session::fetchPayload(), cond::persistency::IOVProxy::find(), cond::persistency::RunInfoEditor::flush(), cond::persistency::RunInfoEditor::getLastInserted(), h, cond::persistency::RunInfoEditor::insert(), ntuplemaker::lastRun, m_dbSession, maxEntries, cond::persistency::Session::readIov(), and command_line::start.

47  {
49  std::cout << "# Loading tag "<<sourceTag<<"..."<<std::endl;
50  cond::persistency::IOVProxy runInfoTag = sourceSession.readIov( sourceTag, true );
51  editor = m_dbSession.editRunInfo();
53  std::cout <<"# Last run found in RunInfo db : "<<lastRun<<std::endl;
55  if( lastRun>0 ){
56  it = runInfoTag.find( lastRun+1 );
57  }
58  if( it == runInfoTag.end() || (*it).since==lastRun ){
59  std::cout <<"# No more run found to be imported."<<std::endl;
60  return 0;
61  }
62  size_t n_entries = 0;
63  while( it != runInfoTag.end() && n_entries<=maxEntries){
64  auto h = (*it).payloadId;
65  std::shared_ptr<RunInfo> runInfo = sourceSession.fetchPayload<RunInfo>( h );
66  if(runInfo->m_run != -1){
67  n_entries++;
68  std::cout <<"# Inserting run #"<<runInfo->m_run<<" (from since="<<(*it).since<<")" << std::endl;
69  boost::posix_time::ptime start;
70  boost::posix_time::ptime end;
71  getRunTimeParams( *runInfo, start, end );
72  editor.insert( runInfo->m_run, start, end );
73  } else {
74  std::cout <<"# Skipping fake run #" <<std::endl;
75  }
76  it++;
77  }
78  editor.flush();
79  return n_entries;
80 }
void insert(cond::Time_t runNumber, const boost::posix_time::ptime &start, const boost::posix_time::ptime &end)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
RunInfoEditor editRunInfo()
Definition: Session.cc:218
const unsigned int maxEntries
Iterator begin() const
Definition: IOVProxy.cc:289
IOVProxy readIov(const std::string &tag, bool full=false)
Definition: Session.cc:81
unsigned long long Time_t
Definition: Time.h:16
Iterator find(cond::Time_t time)
Definition: IOVProxy.cc:320
#define end
Definition: vmac.h:39
cond::persistency::Session & m_dbSession
Definition: RunInfoUpdate.h:21
Iterator end() const
Definition: IOVProxy.cc:297
std::shared_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:215

Member Data Documentation

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

Definition at line 21 of file RunInfoUpdate.h.

Referenced by appendNewRun(), and import().