CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/CondTools/RunInfo/src/RunInfoHandler.cc

Go to the documentation of this file.
00001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00003 #include "CondTools/RunInfo/interface/RunInfoHandler.h"
00004 #include "CondTools/RunInfo/interface/RunInfoRead.h"
00005 #include<iostream>
00006 #include<vector>
00007 
00008 RunInfoHandler::RunInfoHandler(const edm::ParameterSet& pset) :
00009   m_name(pset.getUntrackedParameter<std::string>("name","RunInfoHandler"))
00010   ,m_user(pset.getUntrackedParameter<std::string>("OnlineDBUser","CMS_RUNINFO_R")) 
00011   ,m_pass(pset.getUntrackedParameter<std::string>("OnlineDBPass","PASSWORD")) {
00012   m_connectionString= "oracle://cms_omds_lb/CMS_RUNINFO";
00013 }
00014 
00015 RunInfoHandler::~RunInfoHandler() {}
00016 
00017 void RunInfoHandler::getNewObjects() {
00018   //check whats already inside of database
00019   edm::LogInfo   ("RunInfoHandler") << "------- " << m_name 
00020                                     << " - > getNewObjects\n" 
00021                                     << "got offlineInfo " << tagInfo().name 
00022                                     << ", size " << tagInfo().size 
00023                                     << ", last object valid since " 
00024                                     << tagInfo().lastInterval.first 
00025                                     << " token " << tagInfo().lastPayloadToken 
00026                                     << std::endl;
00027   unsigned int snc;
00028   std::cerr << "Source implementation test ::getNewObjects : enter runnumber as a first since !\n";
00029   std::cin >> snc;
00030   std::cout <<"runnumber/first since = " << snc << std::endl;
00031   RunInfo* r = new RunInfo(); 
00032   
00033   //fill with null runinfo if empty run are found beetween the two last valid ones 
00034   size_t n_empty_run = 0;
00035   if(tagInfo().size > 0  && (tagInfo().lastInterval.first+1) < snc) {
00036     n_empty_run = snc - tagInfo().lastInterval.first - 1; 
00037     edm::LogInfo   ("RunInfoHandler") << "------- " << "entering fake run from " 
00038                                       << tagInfo().lastInterval.first + 1 
00039                                       <<  "to " << snc - 1 << "- > getNewObjects" 
00040                                       << std::endl;
00041     n_empty_run = snc - tagInfo().lastInterval.first - 1; 
00042   } 
00043   // transfer fake run for 1 to since for the first time
00044   if (tagInfo().size == 0 && snc != 1) {
00045     m_to_transfer.push_back(std::make_pair((RunInfo*) (r->Fake_RunInfo()),1));
00046   }
00047   if (n_empty_run != 0) {
00048     m_to_transfer.push_back(std::make_pair((RunInfo*) (r->Fake_RunInfo()),tagInfo().lastInterval.first + 1));
00049   }
00050   
00051   //reading from omds
00052   RunInfoRead rn(m_connectionString, m_user, m_pass);
00053   *r = rn.readData("RUNSESSION_PARAMETER", "STRING_VALUE",(int)snc);
00054   m_to_transfer.push_back(std::make_pair((RunInfo*)r,snc));
00055   std::ostringstream ss;
00056   ss << "since =" << snc;
00057   m_userTextLog = ss.str() + ";";
00058   edm::LogInfo   ("RunInfoHandler") << "------- " << m_name << " - > getNewObjects" << std::endl;
00059 }