Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:47

0001 /*
0002  *  See header file for a description of this class.
0003  *
0004  *  $Date: 2008/02/15 18:14:49 $
0005  *  $Revision: 1.3 $
0006  *  \author Paolo Ronchese INFN Padova
0007  *
0008  */
0009 
0010 //-----------------------
0011 // This Class' Header --
0012 //-----------------------
0013 #include "CondTools/DT/interface/DTT0Handler.h"
0014 
0015 //-------------------------------
0016 // Collaborating Class Headers --
0017 //-------------------------------
0018 #include "CondFormats/DTObjects/interface/DTT0.h"
0019 
0020 //---------------
0021 // C++ Headers --
0022 //---------------
0023 #include <iostream>
0024 #include <fstream>
0025 
0026 //-------------------
0027 // Initializations --
0028 //-------------------
0029 
0030 //----------------
0031 // Constructors --
0032 //----------------
0033 DTT0Handler::DTT0Handler(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 DTT0Handler::~DTT0Handler() {}
0042 
0043 //--------------
0044 // Operations --
0045 //--------------
0046 void DTT0Handler::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   std::cout << "last: " << last << std::endl;
0051 
0052   //to access the information on last successful log entry for this tag:
0053   //  cond::LogDBEntry const & lde = logDBEntry();
0054 
0055   //to access the lastest payload (Ref is a smart pointer)
0056   //  Ref payload = lastPayload();
0057 
0058   /*
0059   int irun = event.id().run();
0060   int ievt = event.id().event();
0061   std::cout << "================ "
0062             << irun << " " << ievt << std::endl;
0063 
0064   std::map<std::string, popcon::PayloadIOV> mp = getOfflineInfo();
0065   std::map<std::string, popcon::PayloadIOV>::iterator iter = mp.begin();
0066   std::map<std::string, popcon::PayloadIOV>::iterator iend = mp.end();
0067   std::cout << "list of all tags: " << std::endl;
0068   while ( iter != iend ) {
0069     std::cout << "Tag: "                       << iter->first
0070               << " , last object valid since " << iter->second.last_since
0071               << " to "                        << iter->second.last_till
0072               << std::endl;
0073     iter++;
0074   }
0075 
0076   std::cout << "look for tag " << dataTag << std::endl;
0077   std::map<std::string, popcon::PayloadIOV>::iterator itag =
0078     mp.find( dataTag );
0079 */
0080 
0081   DTT0* t0 = new DTT0(dataTag);
0082 
0083   int status = 0;
0084   std::ifstream ifile(fileName.c_str());
0085   int whe;
0086   int sta;
0087   int sec;
0088   int qua;
0089   int lay;
0090   int cel;
0091   float t0mean;
0092   float t0rms;
0093   while (ifile >> whe >> sta >> sec >> qua >> lay >> cel >> t0mean >> t0rms) {
0094     status = t0->set(whe, sta, sec, qua, lay, cel, t0mean, t0rms, DTTimeUnits::counts);
0095     std::cout << whe << " " << sta << " " << sec << " " << qua << " " << lay << " " << cel << " " << t0mean << " "
0096               << t0rms << "  -> ";
0097     std::cout << "insert status: " << status << std::endl;
0098   }
0099 
0100   /*
0101   unsigned int runf = irun;
0102   unsigned int runl = 0xffffffff;
0103   popcon::IOVPair iop = { runf, runl };
0104   std::cout << "APPEND NEW OBJECT: "
0105             << runf << " " << runl << " " << t0 << std::endl;
0106   m_to_transfer->push_back( std::make_pair( t0, iop ) );
0107 */
0108 
0109   //for each payload provide IOV information (say in this case we use since)
0110   cond::Time_t snc = runNumber;
0111   if (runNumber > last)
0112     m_to_transfer.push_back(std::make_pair(t0, snc));
0113   else {
0114     std::cout << "More recent data already present - skipped" << std::endl;
0115     delete t0;
0116   }
0117 
0118   return;
0119 }
0120 
0121 std::string DTT0Handler::id() const { return dataTag; }