CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/CondTools/RPC/src/RPCIDMapSH.cc

Go to the documentation of this file.
00001 /*
00002  *  See headers for a description
00003  *
00004  *  \author D. Pagano - Dip. Fis. Nucl. e Teo. & INFN Pavia
00005  */
00006 
00007 #include "CondTools/RPC/interface/RPCIDMapSH.h"
00008 #include "FWCore/ServiceRegistry/interface/Service.h"
00009 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011 #include <sys/time.h>
00012 #include "DataFormats/Provenance/interface/Timestamp.h"
00013 #include<iostream>
00014 
00015 popcon::RPCObPVSSmapData::RPCObPVSSmapData(const edm::ParameterSet& pset) :
00016   m_name(pset.getUntrackedParameter<std::string>("name","RpcData")),
00017   host(pset.getUntrackedParameter<std::string>("host", "source db host")),
00018   user(pset.getUntrackedParameter<std::string>("user", "source username")),
00019   passw(pset.getUntrackedParameter<std::string>("passw", "source password")),
00020   m_since(pset.getUntrackedParameter<unsigned long long>("since",5)),
00021   m_till(pset.getUntrackedParameter<unsigned long long>("till",0)){
00022 }
00023 
00024 popcon::RPCObPVSSmapData::~RPCObPVSSmapData()
00025 {
00026 }
00027 
00028 void popcon::RPCObPVSSmapData::getNewObjects() {
00029 
00030   std::cout << "------- " << m_name << " - > getNewObjects\n" 
00031             << "got offlineInfo"<< tagInfo().name 
00032             << ", size " << tagInfo().size << ", last object valid since " 
00033             << tagInfo().lastInterval.first << " token "   
00034             << tagInfo().lastPayloadToken << std::endl;
00035 
00036   std::cout << " ------ last entry info regarding the payload (if existing): " 
00037             << logDBEntry().usertext << "last record with the correct tag has been written in the db: "
00038             << logDBEntry().destinationDB << std::endl; 
00039   
00040 //  snc = tagInfo().lastInterval.first;
00041 
00042    std::cout << std::endl << "==========================================" << std::endl;
00043    std::cout << std::endl << "===============  PVSS MAP  ===============" << std::endl;
00044    std::cout << std::endl << "==========================================" << std::endl << std::endl;
00045    snc = m_since;
00046    std::cout << ">> Range mode [" << snc << ", " << m_till << "]" << std::endl;
00047    std::cout << std::endl << "=============================================" << std::endl << std::endl;
00048 
00049   
00050   RPCFw caen ( host, user, passw );
00051   std::vector<RPCObPVSSmap::Item> IDMapcheck;
00052 
00053 
00054   IDMapcheck = caen.createIDMAP();
00055   IDMapdata = new RPCObPVSSmap();
00056   RPCObPVSSmap::Item Ifill;
00057   std::vector<RPCObPVSSmap::Item>::iterator Iit;
00058   for(Iit = IDMapcheck.begin(); Iit != IDMapcheck.end(); Iit++)
00059     {
00060       Ifill = *(Iit);
00061       IDMapdata->ObIDMap_rpc.push_back(Ifill);
00062     }
00063   std::cout << " >> Final object size: " << IDMapdata->ObIDMap_rpc.size() << std::endl;
00064 
00065    if (IDMapdata->ObIDMap_rpc.size() > 0) {
00066      niov = snc;
00067    } else {
00068      niov = snc;
00069      std::cout << "NO DATA TO BE STORED" << std::endl;
00070    }
00071 
00072   ::timeval tv;
00073   tv.tv_sec = niov;
00074   tv.tv_usec = 0;
00075   edm::Timestamp tmstamp((unsigned long long)tv.tv_sec*1000000+(unsigned long long)tv.tv_usec);
00076   std::cout << "UNIX time = " << tmstamp.value() << std::endl;
00077   edm::TimeValue_t daqtime=0LL;
00078   daqtime=tv.tv_sec;
00079   daqtime=(daqtime<<32)+tv.tv_usec;
00080   edm::Timestamp daqstamp(daqtime);
00081   edm::TimeValue_t dtime = daqstamp.value();
00082   std::cout<<"DAQ time = " << dtime <<std::endl;
00083   niov = dtime;
00084   std::cout << "===> New IOV: since is = " << niov << std::endl;
00085   m_to_transfer.push_back(std::make_pair((RPCObPVSSmap*)IDMapdata,niov));
00086 }