Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:47

0001 /*
0002  *  See header file for a description of this class.
0003  *
0004  *  \author Paolo Ronchese INFN Padova
0005  *
0006  */
0007 
0008 //-----------------------
0009 // This Class' Header --
0010 //-----------------------
0011 #include "CondTools/DT/interface/DTLVStatusHandler.h"
0012 
0013 //-------------------------------
0014 // Collaborating Class Headers --
0015 //-------------------------------
0016 #include "CondFormats/DTObjects/interface/DTLVStatus.h"
0017 
0018 #include "CondCore/CondDB/interface/ConnectionPool.h"
0019 
0020 #include "RelationalAccess/ISchema.h"
0021 #include "RelationalAccess/ITable.h"
0022 #include "RelationalAccess/ICursor.h"
0023 #include "RelationalAccess/IQuery.h"
0024 #include "CoralBase/AttributeList.h"
0025 #include "CoralBase/AttributeSpecification.h"
0026 #include "CoralBase/Attribute.h"
0027 
0028 //---------------
0029 // C++ Headers --
0030 //---------------
0031 
0032 #include <iostream>
0033 
0034 //-------------------
0035 // Initializations --
0036 //-------------------
0037 
0038 //----------------
0039 // Constructors --
0040 //----------------
0041 DTLVStatusHandler::DTLVStatusHandler(const edm::ParameterSet& ps)
0042     : dataTag(ps.getParameter<std::string>("tag")),
0043       onlineConnect(ps.getParameter<std::string>("onlineDB")),
0044       onlineAuthentication(ps.getParameter<std::string>("onlineAuthentication")),
0045       bufferConnect(ps.getParameter<std::string>("bufferDB")),
0046       omds_session(),
0047       buff_session() {
0048   std::cout << " PopCon application for DT DCS data (CCB status) export " << std::endl;
0049 }
0050 
0051 //--------------
0052 // Destructor --
0053 //--------------
0054 DTLVStatusHandler::~DTLVStatusHandler() {}
0055 
0056 //--------------
0057 // Operations --
0058 //--------------
0059 void DTLVStatusHandler::getNewObjects() {
0060   // online DB connection
0061   std::cout << "configure omds DbConnection" << std::endl;
0062   cond::persistency::ConnectionPool connection;
0063   connection.setAuthenticationPath(onlineAuthentication);
0064   connection.configure();
0065   std::cout << "create omds DbSession" << std::endl;
0066   omds_session = connection.createSession(onlineConnect);
0067   std::cout << "start omds transaction" << std::endl;
0068   omds_session.transaction().start();
0069   std::cout << "" << std::endl;
0070 
0071   // buffer DB connection
0072   std::cout << "create buffer DbSession" << std::endl;
0073   cond::persistency::Session buff_session = connection.createSession(bufferConnect);
0074   std::cout << "start buffer transaction" << std::endl;
0075   buff_session.transaction().start();
0076 
0077   // offline info
0078 
0079   //to access the information on the tag inside the offline database:
0080   cond::TagInfo_t const& ti = tagInfo();
0081   cond::Time_t last = ti.lastInterval.since;
0082   std::cout << "latest DCS data (CCB status) already copied for run: " << last << std::endl;
0083 
0084   if (last == 0) {
0085     DTLVStatus* dummyConf = new DTLVStatus(dataTag);
0086     cond::Time_t snc = 1;
0087     m_to_transfer.push_back(std::make_pair(dummyConf, snc));
0088   }
0089 
0090   //to access the information on last successful log entry for this tag:
0091   //  cond::LogDBEntry const & lde = logDBEntry();
0092 
0093   //to access the lastest payload (Ref is a smart pointer)
0094   //  Ref payload = lastPayload();
0095 
0096   unsigned lastRun = last;
0097   std::cout << "check for new runs since " << lastRun << std::endl;
0098 
0099   buff_session.transaction().commit();
0100   buff_session.close();
0101   omds_session.close();
0102 
0103   return;
0104 }
0105 
0106 std::string DTLVStatusHandler::id() const { return dataTag; }