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 "FWCore/ParameterSet/interface/ParameterSet.h"
0003 #include "CondTools/RunInfo/interface/RunSummaryHandler.h"
0004 #include "CondTools/RunInfo/interface/RunSummaryRead.h"
0005 
0006 #include <iostream>
0007 #include <vector>
0008 
0009 RunSummaryHandler::RunSummaryHandler(const edm::ParameterSet& pset)
0010     : m_name(pset.getUntrackedParameter<std::string>("name", "RunSummaryHandler")),
0011       // m_connect(pset.getUntrackedParameter<std::string>("OnlineConn","")),
0012 
0013       m_user(pset.getUntrackedParameter<std::string>("OnlineDBUser", "CMS_RUNINFO")),
0014       m_pass(pset.getUntrackedParameter<std::string>("OnlineDBPass", "********"))
0015 
0016 {
0017   m_connectionString = "oracle://cms_omds_lb/CMS_RUNINFO";
0018 }
0019 
0020 RunSummaryHandler::~RunSummaryHandler() {}
0021 
0022 void RunSummaryHandler::getNewObjects() {
0023   edm::LogInfo("RunSummaryHandler") << "------- " << m_name << " - > getNewObjects\n"
0024                                     <<
0025       //check whats already inside of database
0026       "got offlineInfo" << tagInfo().name << ", size " << tagInfo().size << ", last object valid since "
0027                                     << tagInfo().lastInterval.since << " token " << tagInfo().lastInterval.payloadId
0028                                     << std::endl;
0029 
0030   /*
0031      if (tagInfo().size>0) {
0032      Ref payload = lastPayload();
0033      //edm::LogInfo   ("RunSummaryHandler")<<"size of last payload  "<< 
0034      //   payload->..........size()<<std::endl;
0035      }
0036    */
0037   unsigned int snc;
0038 
0039   std::cerr << "Source implementation test ::getNewObjects : enter runnumber as a first since !  \n";
0040   std::cin >> snc;
0041 
0042   std::cout << "runnumber/first since = " << snc << std::endl;
0043 
0044   RunSummary* r = new RunSummary();
0045 
0046   //fill with null runsummary if empty run are found beetween the two last validones
0047 
0048   size_t n_empty_run = 0;
0049   if (tagInfo().size > 0 && (tagInfo().lastInterval.since + 1) < snc) {
0050     edm::LogInfo("RunSummaryHandler") << "------- "
0051                                       << "entering fake run from " << tagInfo().lastInterval.since + 1 << "to "
0052                                       << snc - 1 << "- > getNewObjects" << std::endl;
0053     n_empty_run = snc - tagInfo().lastInterval.since - 1;
0054     // for (size_t i=1; i<= n_empty_run ; i++){
0055 
0056     // r->summary.push_back(empty->fake_Run());
0057     // }
0058   }
0059 
0060   // transfer fake run for 1 to since for the first time
0061   if (tagInfo().size == 0) {
0062     m_to_transfer.push_back(std::make_pair((RunSummary*)(r->Fake_RunSummary()), 1));
0063   }
0064 
0065   // transfer also empty run if tag already existing
0066   if (n_empty_run != 0) {
0067     m_to_transfer.push_back(std::make_pair((RunSummary*)(r->Fake_RunSummary()), tagInfo().lastInterval.since + 1));
0068   }
0069 
0070   // reading from omds
0071   RunSummaryRead rn(m_connectionString, m_user, m_pass);
0072 
0073   *r = rn.readData("RUNSESSION_PARAMETER", "STRING_VALUE", (int)snc);
0074   m_to_transfer.push_back(std::make_pair((RunSummary*)r, snc));
0075   std::ostringstream ss;
0076   ss << "since =" << snc;
0077 
0078   m_userTextLog = ss.str() + ";";
0079 
0080   edm::LogInfo("RunSummaryHandler") << "------- " << m_name << " - > getNewObjects" << std::endl;
0081 }