File indexing completed on 2024-04-06 12:02:34
0001 #include "CondFormats/SiPixelObjects/interface/PixelFEDCabling.h"
0002
0003 #include "CondFormats/SiPixelObjects/interface/PixelROC.h"
0004
0005 #include <sstream>
0006 using namespace std;
0007 using namespace sipixelobjects;
0008
0009 void PixelFEDCabling::setLinks(Links& links) { theLinks = links; }
0010
0011 void PixelFEDCabling::addLink(const PixelFEDLink& link) {
0012 if (link.id() < 1)
0013 return;
0014 if (theLinks.size() < link.id())
0015 theLinks.resize(link.id());
0016 theLinks[link.id() - 1] = link;
0017 }
0018
0019 void PixelFEDCabling::addItem(unsigned int linkId, const PixelROC& roc) {
0020 if (linkId < 1)
0021 return;
0022 if (theLinks.size() < linkId)
0023 theLinks.resize(linkId);
0024 if (theLinks[linkId - 1].id() != linkId)
0025 theLinks[linkId - 1] = PixelFEDLink(linkId);
0026 theLinks[linkId - 1].addItem(roc);
0027 }
0028
0029 bool PixelFEDCabling::checkLinkNumbering() const {
0030 bool result = true;
0031 typedef Links::const_iterator IL;
0032 unsigned int idx_expected = 0;
0033 for (IL il = theLinks.begin(); il != theLinks.end(); il++) {
0034 idx_expected++;
0035 if ((*il).id() != 0 && idx_expected != (*il).id()) {
0036 result = false;
0037 cout << " ** PixelFEDCabling ** link numbering inconsistency, expected id: " << idx_expected
0038 << " has: " << (*il).id() << endl;
0039 }
0040 if (!(*il).checkRocNumbering()) {
0041 result = false;
0042 cout << "** PixelFEDCabling ** inconsistent ROC numbering in link id: " << (*il).id() << endl;
0043 }
0044 }
0045 return result;
0046 }
0047
0048 string PixelFEDCabling::print(int depth) const {
0049 ostringstream out;
0050 typedef vector<PixelFEDLink>::const_iterator IT;
0051 if (depth-- >= 0) {
0052 out << "FED: " << id() << endl;
0053 for (IT it = theLinks.begin(); it != theLinks.end(); it++)
0054 out << (*it).print(depth);
0055 out << "# total number of Links: " << numberOfLinks() << endl;
0056 }
0057 out << endl;
0058 return out.str();
0059 }