CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/CondFormats/RPCObjects/src/LinkBoardSpec.cc

Go to the documentation of this file.
00001 
00002 #include "CondFormats/RPCObjects/interface/LinkBoardSpec.h"
00003 #include <sstream>
00004 
00005 LinkBoardSpec::LinkBoardSpec(bool m, int l, int n)
00006     : theMaster(m), theLinkBoardNumInLink(l), theCode(n) { }
00007 
00008 void LinkBoardSpec::add(const FebConnectorSpec & feb)
00009 {
00010   theFebs.push_back(feb);
00011 }
00012 
00013 const FebConnectorSpec * LinkBoardSpec::feb(int febInputNum) const
00014 {
00015   //FIXME - temporary implementaion, to be replace by LUT (in preparation)
00016   typedef std::vector<FebConnectorSpec>::const_iterator IT;
00017   for (IT it=theFebs.begin(); it != theFebs.end(); it++) {
00018     if(febInputNum==it->linkBoardInputNum()) return &(*it);
00019   }
00020   return 0;
00021 }
00022 
00023 std::string LinkBoardSpec::linkBoardName() const
00024 {
00025   std::ostringstream lbName;
00026   std::string char1Val[2]={"B","E"};                              // 1,2
00027   std::string char2Val[3]={"N","M","P"};                          // 0,1,2
00028   std::string char4Val[9]={"0","1","2","3","A","B","C","D","E"};  // 0,...,8
00029   int n3=theCode%10;
00030   int num3=(theCode%100)/10;
00031   int n2=(theCode%1000)/100;
00032   int n1=(theCode%10000)/1000;
00033   int wheel=(theCode%100000)/10000;
00034   if(n2==0)wheel=-wheel;
00035   int sector=theCode/100000;
00036   std::string sign="";
00037   if(wheel>0) sign="+";
00038   lbName <<"LB_R"<<char1Val[n1-1]<<sign<<wheel<<"_S"<<sector<<"_"<<char1Val[n1-1]<<char2Val[n2]<<num3<<char4Val[n3]<<"_CH"<<theLinkBoardNumInLink;
00039   return lbName.str();
00040 }
00041 
00042 std::string LinkBoardSpec::print(int depth ) const 
00043 {
00044   std::ostringstream str;
00045   std::string type = (theMaster) ? "master" : "slave";
00046   str <<" LinkBoardSpec: " << std::endl
00047             <<" --->" <<type<<" linkBoardNumInLink: " << theLinkBoardNumInLink 
00048             << std::endl;
00049   depth--;
00050   if (depth >=0) {
00051     typedef std::vector<FebConnectorSpec>::const_iterator IT;
00052     for (IT it=theFebs.begin(); it != theFebs.end(); it++) str << (*it).print(depth);
00053   }
00054   return str.str();
00055 }
00056