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: 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 
0082   DTPerformance* dtPerf = new DTPerformance(dataTag);
0083 
0084   int status = 0;
0085   std::ifstream ifile(fileName.c_str());
0086   int whe;
0087   int sta;
0088   int sec;
0089   int qua;
0090   float meanT0;
0091   float meanTtrig;
0092   float meanMtime;
0093   float meanNoise;
0094   float meanAfterPulse;
0095   float meanResolution;
0096   float meanEfficiency;
0097   while (ifile >> whe >> sta >> sec >> qua >> meanT0 >> meanTtrig >> meanMtime >> meanNoise >> meanAfterPulse >>
0098          meanResolution >> meanEfficiency) {
0099     status = dtPerf->set(whe,
0100                          sta,
0101                          sec,
0102                          qua,
0103                          meanT0,
0104                          meanTtrig,
0105                          meanMtime,
0106                          meanNoise,
0107                          meanAfterPulse,
0108                          meanResolution,
0109                          meanEfficiency,
0110                          DTTimeUnits::counts);
0111     std::cout << whe << " " << sta << " " << sec << " " << qua << std::endl
0112               << " === " << meanT0 << " " << meanTtrig << " " << meanMtime << " " << meanNoise << " " << meanAfterPulse
0113               << " " << meanResolution << " " << meanEfficiency << std::endl
0114               << "  -> ";
0115     std::cout << "insert status: " << status << std::endl;
0116   }
0117 
0118   /*
0119   unsigned int runf = irun;
0120   unsigned int runl = 0xffffffff;
0121   popcon::IOVPair iop = { runf, runl };
0122   std::cout << "APPEND NEW OBJECT: "
0123             << runf << " " << runl << " " << dtPerf << std::endl;
0124   m_to_transfer->push_back( std::make_pair( dtPerf, iop ) );
0125 */
0126 
0127   //for each payload provide IOV information (say in this case we use since)
0128   cond::Time_t snc = runNumber;
0129   if (runNumber > last)
0130     m_to_transfer.push_back(std::make_pair(dtPerf, snc));
0131   else
0132     std::cout << "More recent data already present - skipped" << std::endl;
0133 
0134   return;
0135 }
0136 
0137 std::string DTPerformanceHandler::id() const { return dataTag; }