Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 
0002 #include "CondFormats/RPCObjects/interface/LinkBoardSpec.h"
0003 #include <sstream>
0004 
0005 LinkBoardSpec::LinkBoardSpec(bool m, int l, int n) : theMaster(m), theLinkBoardNumInLink(l), theCode(n) {}
0006 
0007 void LinkBoardSpec::add(const FebConnectorSpec& feb) { theFebs.push_back(feb); }
0008 
0009 const FebConnectorSpec* LinkBoardSpec::feb(int febInputNum) const {
0010   //FIXME - temporary implementaion, to be replace by LUT (in preparation)
0011   typedef std::vector<FebConnectorSpec>::const_iterator IT;
0012   for (IT it = theFebs.begin(); it != theFebs.end(); it++) {
0013     if (febInputNum == it->linkBoardInputNum())
0014       return &(*it);
0015   }
0016   return nullptr;
0017 }
0018 
0019 std::string LinkBoardSpec::linkBoardName() const {
0020   std::ostringstream lbName;
0021   std::string char1Val[2] = {"B", "E"};                                     // 1,2
0022   std::string char2Val[3] = {"N", "M", "P"};                                // 0,1,2
0023   std::string char4Val[9] = {"0", "1", "2", "3", "A", "B", "C", "D", "E"};  // 0,...,8
0024   int n3 = theCode % 10;
0025   int num3 = (theCode % 100) / 10;
0026   int n2 = (theCode % 1000) / 100;
0027   int n1 = (theCode % 10000) / 1000;
0028   int wheel = (theCode % 100000) / 10000;
0029   if (n2 == 0)
0030     wheel = -wheel;
0031   int sector = theCode / 100000;
0032   std::string sign = "";
0033   if (wheel > 0)
0034     sign = "+";
0035   lbName << "LB_R" << char1Val[n1 - 1] << sign << wheel << "_S" << sector << "_" << char1Val[n1 - 1] << char2Val[n2]
0036          << num3 << char4Val[n3] << "_CH" << theLinkBoardNumInLink;
0037   return lbName.str();
0038 }
0039 
0040 std::string LinkBoardSpec::print(int depth) const {
0041   std::ostringstream str;
0042   std::string type = (theMaster) ? "master" : "slave";
0043   str << " LinkBoardSpec: " << std::endl
0044       << " --->" << type << " linkBoardNumInLink: " << theLinkBoardNumInLink << std::endl;
0045   depth--;
0046   if (depth >= 0) {
0047     typedef std::vector<FebConnectorSpec>::const_iterator IT;
0048     for (IT it = theFebs.begin(); it != theFebs.end(); it++)
0049       str << (*it).print(depth);
0050   }
0051   return str.str();
0052 }