CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CondTools/DT/src/DTPerformanceHandler.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2008/09/29 13:12:46 $
00005  *  $Revision: 1.4 $
00006  *  \author Paolo Ronchese INFN Padova
00007  *
00008  */
00009 
00010 //-----------------------
00011 // This Class' Header --
00012 //-----------------------
00013 #include "CondTools/DT/interface/DTPerformanceHandler.h"
00014 
00015 //-------------------------------
00016 // Collaborating Class Headers --
00017 //-------------------------------
00018 #include "CondFormats/DTObjects/interface/DTPerformance.h"
00019 
00020 //---------------
00021 // C++ Headers --
00022 //---------------
00023 #include <iostream>
00024 #include <fstream>
00025 
00026 //-------------------
00027 // Initializations --
00028 //-------------------
00029 
00030 
00031 //----------------
00032 // Constructors --
00033 //----------------
00034 DTPerformanceHandler::DTPerformanceHandler( const edm::ParameterSet& ps ):
00035  dataTag(   ps.getParameter<std::string>  (  "tag" ) ),
00036  fileName(  ps.getParameter<std::string>  ( "file" ) ),
00037  runNumber( ps.getParameter<unsigned int> (  "run" ) ) {
00038 }
00039 
00040 //--------------
00041 // Destructor --
00042 //--------------
00043 DTPerformanceHandler::~DTPerformanceHandler() {
00044 }
00045 
00046 //--------------
00047 // Operations --
00048 //--------------
00049 void DTPerformanceHandler::getNewObjects() {
00050 
00051   //to access the information on the tag inside the offline database:
00052   cond::TagInfo const & ti = tagInfo();
00053   unsigned int last = ti.lastInterval.first;
00054 
00055   //to access the information on last successful log entry for this tag:
00056 //  cond::LogDBEntry const & lde = logDBEntry();     
00057 
00058   //to access the lastest payload (Ref is a smart pointer)
00059 //  Ref payload = lastPayload();
00060 
00061 /*
00062   int irun = event.id().run();
00063   int ievt = event.id().event();
00064   std::cout << "================ "
00065             << irun << " " << ievt << std::endl;
00066 
00067 //  edm::Service<cond::service::PoolDBOutputService> dbservice;
00068 
00069   std::map<std::string, popcon::PayloadIOV> mp = getOfflineInfo();
00070   std::map<std::string, popcon::PayloadIOV>::iterator iter = mp.begin();
00071   std::map<std::string, popcon::PayloadIOV>::iterator iend = mp.end();
00072   std::cout << "list of all tags: " << std::endl;
00073   while ( iter != iend ) {
00074     std::cout << "Tag: "                       << iter->first
00075               << " , last object valid since " << iter->second.last_since
00076               << " to "                        << iter->second.last_till
00077               << std::endl;
00078     iter++;
00079   }
00080 
00081   std::cout << "look for tag " << dataTag << std::endl;
00082   std::map<std::string, popcon::PayloadIOV>::iterator itag =
00083     mp.find( dataTag );
00084 */
00085 
00086   DTPerformance* dtPerf = new DTPerformance( dataTag );
00087 
00088   int status = 0;
00089   std::ifstream ifile( fileName.c_str() );
00090   int whe;
00091   int sta;
00092   int sec;
00093   int qua;
00094   float meanT0;
00095   float meanTtrig;
00096   float meanMtime;
00097   float meanNoise;
00098   float meanAfterPulse;
00099   float meanResolution;
00100   float meanEfficiency;
00101   while ( ifile >> whe
00102                 >> sta
00103                 >> sec
00104                 >> qua
00105                 >> meanT0
00106                 >> meanTtrig
00107                 >> meanMtime
00108                 >> meanNoise
00109                 >> meanAfterPulse
00110                 >> meanResolution
00111                 >> meanEfficiency ) {
00112     status = dtPerf->set( whe, sta, sec, qua,
00113                           meanT0, meanTtrig, meanMtime, meanNoise,
00114                           meanAfterPulse, meanResolution, meanEfficiency,
00115                           DTTimeUnits::counts );
00116     std::cout << whe << " "
00117               << sta << " "
00118               << sec << " "
00119               << qua << std::endl << " === "
00120               << meanT0 << " "
00121               << meanTtrig << " "
00122               << meanMtime << " "
00123               << meanNoise << " "
00124               << meanAfterPulse << " "
00125               << meanResolution << " "
00126               << meanEfficiency << std::endl << "  -> ";                
00127     std::cout << "insert status: " << status << std::endl;
00128   }
00129 
00130 /*
00131   unsigned int runf = irun;
00132   unsigned int runl = 0xffffffff;
00133   popcon::IOVPair iop = { runf, runl };
00134   std::cout << "APPEND NEW OBJECT: "
00135             << runf << " " << runl << " " << dtPerf << std::endl;
00136   m_to_transfer->push_back( std::make_pair( dtPerf, iop ) );
00137 */
00138 
00139   //for each payload provide IOV information (say in this case we use since)
00140   cond::Time_t snc = runNumber;
00141   if ( runNumber > last )
00142        m_to_transfer.push_back( std::make_pair( dtPerf, snc ) );
00143   else
00144        std::cout << "More recent data already present - skipped" << std::endl;
00145 
00146   return;
00147 
00148 }
00149 
00150 
00151 std::string DTPerformanceHandler::id() const {
00152   return dataTag;
00153 }
00154 
00155