CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/CondTools/DT/src/DTStatusFlagHandler.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2009/09/25 12:03:21 $
00005  *  $Revision: 1.4 $
00006  *  \author Paolo Ronchese INFN Padova
00007  *
00008  */
00009 
00010 //-----------------------
00011 // This Class' Header --
00012 //-----------------------
00013 #include "CondTools/DT/interface/DTStatusFlagHandler.h"
00014 
00015 //-------------------------------
00016 // Collaborating Class Headers --
00017 //-------------------------------
00018 #include "CondFormats/DTObjects/interface/DTStatusFlag.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 DTStatusFlagHandler::DTStatusFlagHandler( 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 DTStatusFlagHandler::~DTStatusFlagHandler() {
00044 }
00045 
00046 //--------------
00047 // Operations --
00048 //--------------
00049 void DTStatusFlagHandler::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   std::map<std::string, popcon::PayloadIOV> mp = getOfflineInfo();
00068   std::map<std::string, popcon::PayloadIOV>::iterator iter = mp.begin();
00069   std::map<std::string, popcon::PayloadIOV>::iterator iend = mp.end();
00070   std::cout << "list of all tags: " << std::endl;
00071   while ( iter != iend ) {
00072     std::cout << "Tag: "                       << iter->first
00073               << " , last object valid since " << iter->second.last_since
00074               << " to "                        << iter->second.last_till
00075               << std::endl;
00076     iter++;
00077   }
00078 
00079   std::cout << "look for tag " << dataTag << std::endl;
00080   std::map<std::string, popcon::PayloadIOV>::iterator itag =
00081     mp.find( dataTag );
00082 */
00083 
00084   DTStatusFlag* stFlag = new DTStatusFlag( dataTag );
00085 
00086   int status = 0;
00087   std::ifstream ifile( fileName.c_str() );
00088   int whe;
00089   int sta;
00090   int sec;
00091   int qua;
00092   int lay;
00093   int cel;
00094   int noiseFlag;
00095   int    feMask;
00096   int   tdcMask;
00097   int  trigMask;
00098   int  deadFlag;
00099   int  nohvFlag;
00100   while ( ifile >> whe
00101                 >> sta
00102                 >> sec
00103                 >> qua
00104                 >> lay
00105                 >> cel
00106                 >> noiseFlag
00107                 >> feMask
00108                 >> tdcMask
00109                 >> trigMask
00110                 >> deadFlag
00111                 >> nohvFlag ) {
00112     status = stFlag->set( whe, sta, sec, qua, lay, cel,
00113                           noiseFlag != 0,
00114                              feMask != 0,
00115                             tdcMask != 0,
00116                            trigMask != 0,
00117                            deadFlag != 0,
00118                            nohvFlag != 0 );
00119     std::cout << whe << " "
00120               << sta << " "
00121               << sec << " "
00122               << qua << " "
00123               << lay << " "
00124               << cel << " "
00125               << noiseFlag << " "
00126               <<    feMask << " "
00127               <<   tdcMask << " "
00128               <<  trigMask << " "
00129               <<  deadFlag << " "
00130               <<  nohvFlag << "  -> ";                
00131     std::cout << "insert status: " << status << std::endl;
00132   }
00133 
00134 /*
00135   unsigned int runf = irun;
00136   unsigned int runl = 0xffffffff;
00137   popcon::IOVPair iop = { runf, runl };
00138   std::cout << "APPEND NEW OBJECT: "
00139             << runf << " " << runl << " " << stFlag << std::endl;
00140   m_to_transfer->push_back( std::make_pair( stFlag, iop ) );
00141 */
00142 
00143   //for each payload provide IOV information (say in this case we use since)
00144   cond::Time_t snc = runNumber;
00145   if ( runNumber > last )
00146        m_to_transfer.push_back( std::make_pair( stFlag, snc ) );
00147   else
00148        std::cout << "More recent data already present - skipped" << std::endl;
00149 
00150   return;
00151 
00152 }
00153 
00154 
00155 std::string DTStatusFlagHandler::id() const {
00156   return dataTag;
00157 }
00158 
00159