![]() |
![]() |
00001 #include "CondFormats/SiPixelObjects/interface/PixelFEDCabling.h" 00002 00003 #include "CondFormats/SiPixelObjects/interface/PixelROC.h" 00004 00005 #include <sstream> 00006 using namespace std; 00007 using namespace sipixelobjects; 00008 00009 void PixelFEDCabling::setLinks(Links & links) 00010 { 00011 theLinks = links; 00012 } 00013 00014 void PixelFEDCabling::addLink(const PixelFEDLink & link) 00015 { 00016 if ( link.id() < 1) return; 00017 if ( theLinks.size() < link.id() ) theLinks.resize(link.id()); 00018 theLinks[link.id()-1] = link; 00019 } 00020 00021 void PixelFEDCabling::addItem(unsigned int linkId, const PixelROC & roc) 00022 { 00023 if ( linkId < 1) return; 00024 if ( theLinks.size() < linkId ) theLinks.resize(linkId); 00025 if ( theLinks[linkId-1].id() != linkId) theLinks[linkId-1] = PixelFEDLink(linkId); 00026 theLinks[linkId-1].addItem(roc); 00027 } 00028 00029 bool PixelFEDCabling::checkLinkNumbering() const 00030 { 00031 bool result = true; 00032 typedef Links::const_iterator IL; 00033 unsigned int idx_expected = 0; 00034 for (IL il = theLinks.begin(); il != theLinks.end(); il++) { 00035 idx_expected++; 00036 if (idx_expected != (*il).id() ) { 00037 result = false; 00038 cout << " ** PixelFEDCabling ** link numbering inconsistency, expected id: " 00039 << idx_expected <<" has: " << (*il).id() << endl; 00040 } 00041 if (! (*il).checkRocNumbering() ) { 00042 result = false; 00043 cout << "** PixelFEDCabling ** inconsistent ROC numbering in link id: " 00044 << (*il).id() << endl; 00045 } 00046 } 00047 return result; 00048 } 00049 00050 string PixelFEDCabling::print(int depth) const 00051 { 00052 ostringstream out; 00053 typedef vector<PixelFEDLink>::const_iterator IT; 00054 if (depth-- >=0 ) { 00055 out <<"FED: "<<id()<< endl; 00056 for (IT it=theLinks.begin(); it != theLinks.end(); it++) 00057 out << (*it).print(depth); 00058 out <<"# total number of Links: "<< numberOfLinks() << endl; 00059 } 00060 out << endl; 00061 return out.str(); 00062 } 00063