Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-10-16 05:03:43

0001 /*
0002  *  See header file for a description of this class.
0003  *
0004  *  $Date: 2008/02/15 18:14:45 $
0005  *  $Revision: 1.3 $
0006  *  \author Paolo Ronchese INFN Padova
0007  *
0008  */
0009 
0010 //-----------------------
0011 // This Class' Header --
0012 //-----------------------
0013 #include "CondTools/DT/interface/DTPerformanceHandler.h"
0014 
0015 //-------------------------------
0016 // Collaborating Class Headers --
0017 //-------------------------------
0018 #include "CondFormats/DTObjects/interface/DTPerformance.h"
0019 
0020 //---------------
0021 // C++ Headers --
0022 //---------------
0023 #include <iostream>
0024 #include <fstream>
0025 
0026 //-------------------
0027 // Initializations --
0028 //-------------------
0029 
0030 //----------------
0031 // Constructors --
0032 //----------------
0033 DTPerformanceHandler::DTPerformanceHandler(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 DTPerformanceHandler::~DTPerformanceHandler() {}
0042 
0043 //--------------
0044 // Operations --
0045 //--------------
0046 void DTPerformanceHandler::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 //  edm::Service<cond::service::PoolDBOutputService> dbservice;
0064 
0065   std::map<std::string, popcon::PayloadIOV> mp = getOfflineInfo();
0066   std::map<std::string, popcon::PayloadIOV>::iterator iter = mp.begin();
0067   std::map<std::string, popcon::PayloadIOV>::iterator iend = mp.end();
0068   std::cout << "list of all tags: " << std::endl;
0069   while ( iter != iend ) {
0070     std::cout << "Tag: "                       << iter->first
0071               << " , last object valid since " << iter->second.last_since
0072               << " to "                        << iter->second.last_till
0073               << std::endl;
0074     iter++;
0075   }
0076 
0077   std::cout << "look for tag " << dataTag << std::endl;
0078   std::map<std::string, popcon::PayloadIOV>::iterator itag =
0079     mp.find( dataTag );
0080 */
0081   if (runNumber <= last) {
0082     std::cout << "More recent data already present - skipped" << std::endl;
0083     return;
0084   }
0085 
0086   DTPerformance* dtPerf = new DTPerformance(dataTag);
0087 
0088   int status = 0;
0089   std::ifstream ifile(fileName.c_str());
0090   int whe;
0091   int sta;
0092   int sec;
0093   int qua;
0094   float meanT0;
0095   float meanTtrig;
0096   float meanMtime;
0097   float meanNoise;
0098   float meanAfterPulse;
0099   float meanResolution;
0100   float meanEfficiency;
0101   while (ifile >> whe >> sta >> sec >> qua >> meanT0 >> meanTtrig >> meanMtime >> meanNoise >> meanAfterPulse >>
0102          meanResolution >> meanEfficiency) {
0103     status = dtPerf->set(whe,
0104                          sta,
0105                          sec,
0106                          qua,
0107                          meanT0,
0108                          meanTtrig,
0109                          meanMtime,
0110                          meanNoise,
0111                          meanAfterPulse,
0112                          meanResolution,
0113                          meanEfficiency,
0114                          DTTimeUnits::counts);
0115     std::cout << whe << " " << sta << " " << sec << " " << qua << std::endl
0116               << " === " << meanT0 << " " << meanTtrig << " " << meanMtime << " " << meanNoise << " " << meanAfterPulse
0117               << " " << meanResolution << " " << meanEfficiency << std::endl
0118               << "  -> ";
0119     std::cout << "insert status: " << status << std::endl;
0120   }
0121 
0122   /*
0123   unsigned int runf = irun;
0124   unsigned int runl = 0xffffffff;
0125   popcon::IOVPair iop = { runf, runl };
0126   std::cout << "APPEND NEW OBJECT: "
0127             << runf << " " << runl << " " << dtPerf << std::endl;
0128   m_to_transfer->push_back( std::make_pair( dtPerf, iop ) );
0129 */
0130 
0131   //for each payload provide IOV information (say in this case we use since)
0132   m_to_transfer.emplace_back(dtPerf, runNumber);
0133 }
0134 
0135 std::string DTPerformanceHandler::id() const { return dataTag; }