CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/CondTools/DT/src/DTT0Handler.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/DTT0Handler.h"
00014 
00015 //-------------------------------
00016 // Collaborating Class Headers --
00017 //-------------------------------
00018 #include "CondFormats/DTObjects/interface/DTT0.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 DTT0Handler::DTT0Handler( 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 DTT0Handler::~DTT0Handler() {
00044 }
00045 
00046 //--------------
00047 // Operations --
00048 //--------------
00049 void DTT0Handler::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   std::cout << "last: " << last << std::endl;
00055 
00056   //to access the information on last successful log entry for this tag:
00057 //  cond::LogDBEntry const & lde = logDBEntry();     
00058 
00059   //to access the lastest payload (Ref is a smart pointer)
00060 //  Ref payload = lastPayload();
00061 
00062 /*
00063   int irun = event.id().run();
00064   int ievt = event.id().event();
00065   std::cout << "================ "
00066             << irun << " " << ievt << std::endl;
00067 
00068   std::map<std::string, popcon::PayloadIOV> mp = getOfflineInfo();
00069   std::map<std::string, popcon::PayloadIOV>::iterator iter = mp.begin();
00070   std::map<std::string, popcon::PayloadIOV>::iterator iend = mp.end();
00071   std::cout << "list of all tags: " << std::endl;
00072   while ( iter != iend ) {
00073     std::cout << "Tag: "                       << iter->first
00074               << " , last object valid since " << iter->second.last_since
00075               << " to "                        << iter->second.last_till
00076               << std::endl;
00077     iter++;
00078   }
00079 
00080   std::cout << "look for tag " << dataTag << std::endl;
00081   std::map<std::string, popcon::PayloadIOV>::iterator itag =
00082     mp.find( dataTag );
00083 */
00084 
00085   DTT0* t0 = new DTT0( dataTag );
00086 
00087   int status = 0;
00088   std::ifstream ifile( fileName.c_str() );
00089   int whe;
00090   int sta;
00091   int sec;
00092   int qua;
00093   int lay;
00094   int cel;
00095   float t0mean;
00096   float t0rms;
00097   while ( ifile >> whe
00098                 >> sta
00099                 >> sec
00100                 >> qua
00101                 >> lay
00102                 >> cel
00103                 >> t0mean
00104                 >> t0rms ) {
00105     status = t0->set( whe, sta, sec, qua, lay, cel, t0mean, t0rms,
00106                       DTTimeUnits::counts );
00107     std::cout << whe << " "
00108               << sta << " "
00109               << sec << " "
00110               << qua << " "
00111               << lay << " "
00112               << cel << " "
00113               << t0mean << " "
00114               << t0rms  << "  -> ";                
00115     std::cout << "insert status: " << status << std::endl;
00116   }
00117 
00118 /*
00119   unsigned int runf = irun;
00120   unsigned int runl = 0xffffffff;
00121   popcon::IOVPair iop = { runf, runl };
00122   std::cout << "APPEND NEW OBJECT: "
00123             << runf << " " << runl << " " << t0 << std::endl;
00124   m_to_transfer->push_back( std::make_pair( t0, iop ) );
00125 */
00126 
00127   //for each payload provide IOV information (say in this case we use since)
00128   cond::Time_t snc = runNumber;
00129   if ( runNumber > last )
00130        m_to_transfer.push_back( std::make_pair( t0, snc ) );
00131   else
00132        std::cout << "More recent data already present - skipped" << std::endl;
00133 
00134   return;
00135 
00136 }
00137 
00138 
00139 std::string DTT0Handler::id() const {
00140   return dataTag;
00141 }
00142 
00143