CMS 3D CMS Logo

L1RPCConfigSourceHandler.cc

Go to the documentation of this file.
00001 #include "CondTools/RPC/interface/L1RPCConfigSourceHandler.h"
00002 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
00003 #include "FWCore/ServiceRegistry/interface/Service.h"
00004 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
00005 
00006 popcon::L1RPCConfigSourceHandler::L1RPCConfigSourceHandler(const edm::ParameterSet& ps):
00007   m_name(ps.getUntrackedParameter<std::string>("name","L1RPCConfigSourceHandler")),
00008   m_validate(ps.getUntrackedParameter<int>("Validate",0)),
00009   m_ppt(ps.getUntrackedParameter<int>("PACsPerTower")),
00010   m_dataDir(ps.getUntrackedParameter<std::string>("filedir","L1Trigger/RPCTrigger/data/Eff90PPT12/"))
00011 {
00012         //      std::cout << "L1RPCConfigSourceHandler: L1RPCConfigSourceHandler constructor" << std::endl;
00013   edm::FileInPath fp(m_dataDir+"pacPat_t0sc0sg0.xml");
00014   std::string patternsDirNameUnstriped = fp.fullPath();
00015   m_patternsDir = patternsDirNameUnstriped.substr(0,patternsDirNameUnstriped.find_last_of("/")+1);
00016 }
00017 
00018 popcon::L1RPCConfigSourceHandler::~L1RPCConfigSourceHandler()
00019 {
00020 }
00021 
00022 void popcon::L1RPCConfigSourceHandler::getNewObjects()
00023 {
00024 
00025   edm::Service<cond::service::PoolDBOutputService> mydbservice;
00026 
00027 //  std::cout << "L1RPCConfigSourceHandler: L1RPCConfigSourceHandler::getNewObjects begins\n";
00028 //  std::cerr << "------- " << m_name 
00029 //           << " - > getNewObjects" << std::endl;
00030 //  std::cerr<<"Got offlineInfo, tag: "<<std::endl;
00031 //  std::cerr << tagInfo().name << " , last object valid from " 
00032 //          << tagInfo().lastInterval.first << " to "
00033 //            << tagInfo().lastInterval.second << " , token is "
00034 //            << tagInfo().token << " and this is the payload "
00035 //            << tagInfo().lastPayloadToken << std::endl;
00036 
00037 // first check what is already there in offline DB
00038         const L1RPCConfig* patterns_prev;
00039 
00040         if(m_validate==1) {
00041           std::cout<<" Validation was requested, so will check present contents"<<std::endl;
00042         }
00043 
00044         readConfig();
00045 
00046         cond::Time_t snc=mydbservice->currentTime();
00047 
00048 // look for recent changes
00049         int difference=1;
00050         if (m_validate==1) difference=Compare2Configs(patterns_prev,patterns);
00051         if (!difference) cout<<"No changes - will not write anything!!!"<<endl;
00052         if (difference==1) {
00053           cout<<"Will write new object to offline DB!!!"<<endl;
00054           m_to_transfer.push_back(std::make_pair((L1RPCConfig*)patterns,snc));
00055         }
00056 
00057         std::cout << "L1RPCConfigSourceHandler: L1RPCConfigSourceHandler::getNewObjects ends\n";
00058 }
00059 
00060 void popcon::L1RPCConfigSourceHandler::readConfig()
00061 {
00062   patterns =  new L1RPCConfig();
00063   patterns->setPPT(m_ppt);
00064 // parse and insert patterns
00065   int scCnt = 0, sgCnt = 0;
00066   if(m_ppt == 1) {
00067     scCnt = 1;
00068     sgCnt = 1;
00069   }
00070   else if(m_ppt == 12) {
00071     scCnt = 1;
00072     sgCnt = 12;
00073   }
00074   else if(m_ppt == 144) {
00075     scCnt = 12;
00076     sgCnt = 12;
00077   }
00078   else {
00079     throw cms::Exception("BadConfig") << "Bad number of ppt requested: " << m_ppt << "\n";
00080   }
00081 
00082   for (int tower = 0; tower < RPCConst::m_TOWER_COUNT; ++tower) {
00083     for (int logSector = 0; logSector < scCnt; ++logSector) {
00084       for (int logSegment = 0; logSegment < sgCnt; ++logSegment) {
00085 
00086         std::stringstream fname;
00087         fname << m_patternsDir
00088               << "pacPat_t" << tower 
00089               << "sc" << logSector 
00090               << "sg" <<logSegment 
00091               << ".xml";
00092 
00093         cout<<"Parsing "<<fname.str()<<flush;
00094         RPCPatternsParser parser;
00095         parser.parse(fname.str());
00096         cout<<" - done "<<endl;
00097 
00098         RPCPattern::RPCPatVec npats = parser.getPatternsVec(tower, logSector, logSegment);
00099            
00100         for (unsigned int ip=0; ip<npats.size(); ip++) {
00101           npats[ip].setCoords(tower,logSector,logSegment);
00102           patterns->m_pats.push_back(npats[ip]);
00103         }
00104 
00105         RPCPattern::TQualityVec nquals = parser.getQualityVec(); 
00106         for (unsigned int iq=0; iq<nquals.size(); iq++) {
00107           nquals[iq].m_tower=tower;
00108           nquals[iq].m_logsector=logSector;
00109           nquals[iq].m_logsegment=logSegment;
00110           patterns->m_quals.push_back(nquals[iq]);
00111         }
00112             
00113       } // segments
00114     } // sectors
00115   } // towers
00116 }
00117 
00118 int popcon::L1RPCConfigSourceHandler::Compare2Configs(const L1RPCConfig* pat1, L1RPCConfig* pat2) {
00119   std::cout<<" L1RPCConfigSourceHandler::Compare2Configs: sorry, option not available - different configs assumed"<<std::endl;
00120   return 1;
00121 }

Generated on Tue Jun 9 17:26:56 2009 for CMSSW by  doxygen 1.5.4