Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:47

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