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  *  $Date: 2009/01/27 12:08:40 $
0005  *  $Revision: 1.1.2.1 $
0006  *  \author Paolo Ronchese INFN Padova
0007  *
0008  */
0009 
0010 //-----------------------
0011 // This Class' Header --
0012 //-----------------------
0013 #include "CondTools/DT/interface/DTTPGParametersHandler.h"
0014 
0015 //-------------------------------
0016 // Collaborating Class Headers --
0017 //-------------------------------
0018 #include "CondFormats/DTObjects/interface/DTTPGParameters.h"
0019 
0020 //---------------
0021 // C++ Headers --
0022 //---------------
0023 #include <iostream>
0024 #include <fstream>
0025 
0026 //-------------------
0027 // Initializations --
0028 //-------------------
0029 
0030 //----------------
0031 // Constructors --
0032 //----------------
0033 DTTPGParametersHandler::DTTPGParametersHandler(const edm::ParameterSet& ps)
0034     : dataTag(ps.getParameter<std::string>("tag")),
0035       fileName(ps.getParameter<std::string>("file")),
0036       runNumber(ps.getParameter<unsigned int>("run")) {}
0037 
0038 //--------------
0039 // Destructor --
0040 //--------------
0041 DTTPGParametersHandler::~DTTPGParametersHandler() {}
0042 
0043 //--------------
0044 // Operations --
0045 //--------------
0046 void DTTPGParametersHandler::getNewObjects() {
0047   //to access the information on the tag inside the offline database:
0048   cond::TagInfo_t const& ti = tagInfo();
0049   cond::Time_t last = ti.lastInterval.since;
0050 
0051   //to access the information on last successful log entry for this tag:
0052   //  cond::LogDBEntry const & lde = logDBEntry();
0053 
0054   //to access the lastest payload (Ref is a smart pointer)
0055   //  Ref payload = lastPayload();
0056 
0057   /*
0058   int irun = event.id().run();
0059   int ievt = event.id().event();
0060   std::cout << "================ "
0061             << irun << " " << ievt << std::endl;
0062 
0063   std::map<std::string, popcon::PayloadIOV> mp = getOfflineInfo();
0064   std::map<std::string, popcon::PayloadIOV>::iterator iter = mp.begin();
0065   std::map<std::string, popcon::PayloadIOV>::iterator iend = mp.end();
0066   std::cout << "list of all tags: " << std::endl;
0067   while ( iter != iend ) {
0068     std::cout << "Tag: "                       << iter->first
0069               << " , last object valid since " << iter->second.last_since
0070               << " to "                        << iter->second.last_till
0071               << std::endl;
0072     iter++;
0073   }
0074 
0075   std::cout << "look for tag " << dataTag << std::endl;
0076   std::map<std::string, popcon::PayloadIOV>::iterator itag =
0077     mp.find( dataTag );
0078 */
0079 
0080   DTTPGParameters* tSync = new DTTPGParameters(dataTag);
0081 
0082   int status = 0;
0083   std::ifstream ifile(fileName.c_str());
0084   //  int cx = 32;
0085   //  ifile >> cx;
0086   //  tSync->setClock( cx );
0087   int whe;
0088   int sta;
0089   int sec;
0090   int cl;
0091   float ph;
0092   while (ifile >> whe >> sta >> sec >> cl >> ph) {
0093     status = tSync->set(whe, sta, sec, cl, ph, DTTimeUnits::ns);
0094     std::cout << whe << " " << sta << " " << sec << " " << cl << " " << ph << "  -> ";
0095     std::cout << "insert status: " << status << std::endl;
0096   }
0097 
0098   /*
0099   unsigned int runf = irun;
0100   unsigned int runl = 0xffffffff;
0101   popcon::IOVPair iop = { runf, runl };
0102   std::cout << "APPEND NEW OBJECT: "
0103             << runf << " " << runl << " " << tSync << std::endl;
0104   m_to_transfer->push_back( std::make_pair( tSync, iop ) );
0105 */
0106 
0107   //for each payload provide IOV information (say in this case we use since)
0108   cond::Time_t snc = runNumber;
0109   if (runNumber > last)
0110     m_to_transfer.push_back(std::make_pair(tSync, snc));
0111   else {
0112     std::cout << "More recent data already present - skipped" << std::endl;
0113     delete tSync;
0114   }
0115 
0116   return;
0117 }
0118 
0119 std::string DTTPGParametersHandler::id() const { return dataTag; }