Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:20

0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 #include "CondTools/RunInfo/interface/RunInfoHandler.h"
0003 #include "CondTools/RunInfo/interface/RunInfoRead.h"
0004 #include "CondTools/RunInfo/interface/RunInfoUpdate.h"
0005 #include <iostream>
0006 #include <vector>
0007 
0008 RunInfoHandler::RunInfoHandler(const edm::ParameterSet& pset)
0009     : m_since(pset.getParameter<unsigned long long>("runNumber")),
0010       m_name(pset.getUntrackedParameter<std::string>("name", "RunInfoHandler")),
0011       m_runinfo_schema(pset.getUntrackedParameter<std::string>("RunInfoSchema", "CMS_RUNINFO")),
0012       m_dcsenv_schema(pset.getUntrackedParameter<std::string>("DCSEnvSchema", "CMS_DCS_ENV_PVSS_COND")),
0013       m_connectionString(pset.getParameter<std::string>("connect")),
0014       m_connectionPset(pset.getParameter<edm::ParameterSet>("DBParameters")) {}
0015 
0016 RunInfoHandler::~RunInfoHandler() {}
0017 
0018 void RunInfoHandler::getNewObjects() {
0019   //check whats already inside of database
0020   edm::LogInfo("RunInfoHandler") << "["
0021                                  << "RunInfoHandler::" << __func__ << "]:" << m_name << ": "
0022                                  << "Destination Tag Info: name " << tagInfo().name << ", size " << tagInfo().size
0023                                  << ", last object valid since " << tagInfo().lastInterval.since << ", hash "
0024                                  << tagInfo().lastInterval.payloadId << std::endl;
0025   edm::LogInfo("RunInfoHandler") << "["
0026                                  << "RunInfoHandler::" << __func__ << "]:" << m_name
0027                                  << ": runnumber/first since = " << m_since << std::endl;
0028 
0029   //check if a transfer is needed:
0030   //if the new run number is smaller than or equal to the latest IOV, exit.
0031   //This is needed as now the IOV Editor does not always protect for insertions:
0032   //ANY and VALIDATION sychronizations are allowed to write in the past.
0033   if (tagInfo().size > 0 && tagInfo().lastInterval.since >= m_since) {
0034     edm::LogWarning("RunInfoHandler") << "["
0035                                       << "RunInfoHandler::" << __func__ << "]:" << m_name << ": "
0036                                       << "last IOV " << tagInfo().lastInterval.since
0037                                       << (tagInfo().lastInterval.since == m_since ? " is equal to" : " is larger than")
0038                                       << " the run proposed for insertion " << m_since << ". No transfer needed."
0039                                       << std::endl;
0040     return;
0041   }
0042 
0043   RunInfo* r = new RunInfo();
0044 
0045   //fill with null runinfo if empty run are found beetween the two last valid ones
0046   size_t n_empty_run = 0;
0047   if (tagInfo().size > 0 && (tagInfo().lastInterval.since + 1) < m_since) {
0048     n_empty_run = m_since - tagInfo().lastInterval.since - 1;
0049     edm::LogInfo("RunInfoHandler") << "["
0050                                    << "RunInfoHandler::" << __func__ << "]:" << m_name << ": "
0051                                    << "entering fake run from " << tagInfo().lastInterval.since + 1 << " to "
0052                                    << m_since - 1 << std::endl;
0053   }
0054   std::ostringstream ss;
0055   // transfer fake run for 1 to since for the first time
0056   if (tagInfo().size == 0 && m_since != 1) {
0057     m_to_transfer.push_back(std::make_pair((RunInfo*)(r->Fake_RunInfo()), 1));
0058     ss << "fake run number: " << 1 << ", ";
0059   }
0060   if (n_empty_run != 0) {
0061     m_to_transfer.push_back(std::make_pair((RunInfo*)(r->Fake_RunInfo()), tagInfo().lastInterval.since + 1));
0062     ss << "fake run number: " << tagInfo().lastInterval.since + 1 << ", ";
0063   }
0064 
0065   //reading from omds
0066   RunInfoRead rn(m_connectionString, m_connectionPset);
0067   *r = rn.readData(m_runinfo_schema, m_dcsenv_schema, (int)m_since);
0068   m_to_transfer.push_back(std::make_pair((RunInfo*)r, m_since));
0069   ss << "run number: " << m_since << ";";
0070   m_userTextLog = ss.str();
0071   edm::LogInfo("RunInfoHandler") << "["
0072                                  << "RunInfoHandler::" << __func__ << "]:" << m_name << ": END." << std::endl;
0073   // update runinfo table in conditions db
0074   RunInfoUpdate updater(dbSession());
0075   updater.appendNewRun(*r);
0076 }