Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:52:22

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/RPCUXCSH.h"
0008 #include "FWCore/ServiceRegistry/interface/Service.h"
0009 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 
0012 #include <iostream>
0013 
0014 popcon::RpcDataUXC::RpcDataUXC(const edm::ParameterSet& pset)
0015     : m_name(pset.getUntrackedParameter<std::string>("name", "RpcData")),
0016       host(pset.getUntrackedParameter<std::string>("host", "source db host")),
0017       user(pset.getUntrackedParameter<std::string>("user", "source username")),
0018       passw(pset.getUntrackedParameter<std::string>("passw", "source password")),
0019       m_since(pset.getUntrackedParameter<unsigned long long>("since", 5)),
0020       m_till(pset.getUntrackedParameter<unsigned long long>("till", 0)) {}
0021 
0022 popcon::RpcDataUXC::~RpcDataUXC() {}
0023 
0024 void popcon::RpcDataUXC::getNewObjects() {
0025   std::cout << "------- " << m_name << " - > getNewObjects\n"
0026             << "got offlineInfo" << tagInfo().name << ", size " << tagInfo().size << ", last object valid since "
0027             << tagInfo().lastInterval.since << " token " << tagInfo().lastInterval.payloadId << std::endl;
0028 
0029   std::cout << " ------ last entry info regarding the payload (if existing): " << logDBEntry().usertext
0030             << "last record with the correct tag has been written in the db: " << logDBEntry().destinationDB
0031             << std::endl;
0032 
0033   //  snc = tagInfo().lastInterval.first;
0034 
0035   std::cout << std::endl << "=============================================" << std::endl;
0036   std::cout << std::endl << "===================  UXC   ==================" << std::endl;
0037   std::cout << std::endl << "=============================================" << std::endl << std::endl;
0038   snc = m_since;
0039   std::cout << ">> Range mode [" << snc << ", " << m_till << "]" << std::endl;
0040   std::cout << std::endl << "=============================================" << std::endl << std::endl;
0041 
0042   RPCFw caen(host, user, passw);
0043   std::vector<RPCObUXC::Item> UXCcheck;
0044   UXCcheck = caen.createUXC(snc, m_till);
0045   UXCdata = new RPCObUXC();
0046   RPCObUXC::Item UXCfill;
0047   std::vector<RPCObUXC::Item>::iterator UXCit;
0048   for (UXCit = UXCcheck.begin(); UXCit != UXCcheck.end(); UXCit++) {
0049     UXCfill = *(UXCit);
0050     UXCdata->ObUXC_rpc.push_back(UXCfill);
0051   }
0052   std::cout << " >> Final object size: " << UXCdata->ObUXC_rpc.size() << std::endl;
0053 
0054   if (!UXCdata->ObUXC_rpc.empty()) {
0055     niov = snc;
0056   } else {
0057     niov = snc;
0058     std::cout << "NO DATA TO BE STORED" << std::endl;
0059   }
0060 
0061   ::timeval tv;
0062   tv.tv_sec = niov;
0063   tv.tv_usec = 0;
0064   edm::Timestamp tmstamp((unsigned long long)tv.tv_sec * 1000000 + (unsigned long long)tv.tv_usec);
0065   std::cout << "UNIX time = " << tmstamp.value() << std::endl;
0066 
0067   edm::TimeValue_t daqtime = 0LL;
0068   daqtime = tv.tv_sec;
0069   daqtime = (daqtime << 32) + tv.tv_usec;
0070   edm::Timestamp daqstamp(daqtime);
0071   edm::TimeValue_t dtime = daqstamp.value();
0072   std::cout << "DAQ time = " << dtime << std::endl;
0073 
0074   niov = dtime;
0075 
0076   std::cout << "===> New IOV: since is = " << niov << std::endl;
0077   m_to_transfer.push_back(std::make_pair((RPCObUXC*)UXCdata, niov));
0078 }