Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /*
0002  *  See headers for a description
0003  *
0004  *  \author D. Pagano - Dip. Fis. Nucl. e Teo. & INFN Pavia
0005  */
0006 
0007 #include "CondTools/RPC/interface/RPCIDMapSH.h"
0008 #include "FWCore/ServiceRegistry/interface/Service.h"
0009 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 #include <sys/time.h>
0012 #include "DataFormats/Provenance/interface/Timestamp.h"
0013 #include <iostream>
0014 
0015 popcon::RPCObPVSSmapData::RPCObPVSSmapData(const edm::ParameterSet& pset)
0016     : m_name(pset.getUntrackedParameter<std::string>("name", "RpcData")),
0017       host(pset.getUntrackedParameter<std::string>("host", "source db host")),
0018       user(pset.getUntrackedParameter<std::string>("user", "source username")),
0019       passw(pset.getUntrackedParameter<std::string>("passw", "source password")),
0020       m_since(pset.getUntrackedParameter<unsigned long long>("since", 5)),
0021       m_till(pset.getUntrackedParameter<unsigned long long>("till", 0)) {}
0022 
0023 popcon::RPCObPVSSmapData::~RPCObPVSSmapData() {}
0024 
0025 void popcon::RPCObPVSSmapData::getNewObjects() {
0026   std::cout << "------- " << m_name << " - > getNewObjects\n"
0027             << "got offlineInfo" << tagInfo().name << ", size " << tagInfo().size << ", last object valid since "
0028             << tagInfo().lastInterval.since << " token " << tagInfo().lastInterval.payloadId << std::endl;
0029 
0030   std::cout << " ------ last entry info regarding the payload (if existing): " << logDBEntry().usertext
0031             << "last record with the correct tag has been written in the db: " << logDBEntry().destinationDB
0032             << std::endl;
0033 
0034   //  snc = tagInfo().lastInterval.first;
0035 
0036   std::cout << std::endl << "==========================================" << std::endl;
0037   std::cout << std::endl << "===============  PVSS MAP  ===============" << std::endl;
0038   std::cout << std::endl << "==========================================" << std::endl << std::endl;
0039   snc = m_since;
0040   std::cout << ">> Range mode [" << snc << ", " << m_till << "]" << std::endl;
0041   std::cout << std::endl << "=============================================" << std::endl << std::endl;
0042 
0043   RPCFw caen(host, user, passw);
0044   std::vector<RPCObPVSSmap::Item> IDMapcheck;
0045 
0046   IDMapcheck = caen.createIDMAP();
0047   IDMapdata = new RPCObPVSSmap();
0048   RPCObPVSSmap::Item Ifill;
0049   std::vector<RPCObPVSSmap::Item>::iterator Iit;
0050   for (Iit = IDMapcheck.begin(); Iit != IDMapcheck.end(); Iit++) {
0051     Ifill = *(Iit);
0052     IDMapdata->ObIDMap_rpc.push_back(Ifill);
0053   }
0054   std::cout << " >> Final object size: " << IDMapdata->ObIDMap_rpc.size() << std::endl;
0055 
0056   if (!IDMapdata->ObIDMap_rpc.empty()) {
0057     niov = snc;
0058   } else {
0059     niov = snc;
0060     std::cout << "NO DATA TO BE STORED" << std::endl;
0061   }
0062 
0063   ::timeval tv;
0064   tv.tv_sec = niov;
0065   tv.tv_usec = 0;
0066   edm::Timestamp tmstamp((unsigned long long)tv.tv_sec * 1000000 + (unsigned long long)tv.tv_usec);
0067   std::cout << "UNIX time = " << tmstamp.value() << std::endl;
0068   edm::TimeValue_t daqtime = 0LL;
0069   daqtime = tv.tv_sec;
0070   daqtime = (daqtime << 32) + tv.tv_usec;
0071   edm::Timestamp daqstamp(daqtime);
0072   edm::TimeValue_t dtime = daqstamp.value();
0073   std::cout << "DAQ time = " << dtime << std::endl;
0074   niov = dtime;
0075   std::cout << "===> New IOV: since is = " << niov << std::endl;
0076   m_to_transfer.push_back(std::make_pair((RPCObPVSSmap*)IDMapdata, niov));
0077 }