Go to the documentation of this file.00001 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingTree.h"
00002 #include <sstream>
00003 #include <iostream>
00004
00005 using namespace std;
00006 using namespace sipixelobjects;
00007
00008 typedef std::map<int, SiPixelFedCablingTree::PixelFEDCabling>::const_iterator IMAP;
00009
00010 std::vector<sipixelobjects::CablingPathToDetUnit> SiPixelFedCablingTree::pathToDetUnit(
00011 uint32_t rawDetId) const
00012 {
00013 std::vector<sipixelobjects::CablingPathToDetUnit> result;
00014 typedef std::map<int, PixelFEDCabling>::const_iterator IM;
00015 for (IM im = theFedCablings.begin(); im != theFedCablings.end(); ++im) {
00016 const PixelFEDCabling & aFed = im->second;
00017 for (unsigned int idxLink = 1; idxLink <= aFed.numberOfLinks(); idxLink++) {
00018 const PixelFEDLink * link = aFed.link(idxLink);
00019 if (!link) continue;
00020 unsigned int numberOfRocs = link->numberOfROCs();
00021 for(unsigned int idxRoc = 1; idxRoc <= numberOfRocs; idxRoc++) {
00022 const PixelROC * roc = link->roc(idxRoc);
00023 if (rawDetId == roc->rawId() ) {
00024 CablingPathToDetUnit path = {aFed.id(), link->id(), roc->idInLink()};
00025 result.push_back(path);
00026 }
00027 }
00028 }
00029 }
00030 return result;
00031 }
00032
00033 void SiPixelFedCablingTree::addFed(const PixelFEDCabling & f)
00034 {
00035 int id = f.id();
00036 theFedCablings[id] = f;
00037 }
00038
00039 const PixelFEDCabling * SiPixelFedCablingTree::fed(unsigned int id) const
00040 {
00041 IMAP it = theFedCablings.find(id);
00042 return ( it == theFedCablings.end() ) ? 0 : & (*it).second;
00043 }
00044
00045 string SiPixelFedCablingTree::print(int depth) const
00046 {
00047 ostringstream out;
00048 if ( depth-- >=0 ) {
00049 out << theVersion << endl;
00050 for(IMAP it=theFedCablings.begin(); it != theFedCablings.end(); it++) {
00051 out << (*it).second.print(depth);
00052 }
00053 }
00054 out << endl;
00055 return out.str();
00056 }
00057
00058 std::vector<const PixelFEDCabling *> SiPixelFedCablingTree::fedList() const
00059 {
00060 std::vector<const PixelFEDCabling *> result;
00061 for (IMAP im = theFedCablings.begin(); im != theFedCablings.end(); im++) {
00062 result.push_back( &(im->second) );
00063 }
00064 return result;
00065
00066 }
00067
00068 void SiPixelFedCablingTree::addItem(unsigned int fedId, unsigned int linkId, const PixelROC& roc)
00069 {
00070 PixelFEDCabling & cabling = theFedCablings[fedId];
00071 if (cabling.id() != fedId) cabling=PixelFEDCabling(fedId);
00072 cabling.addItem(linkId,roc);
00073 }
00074
00075 const sipixelobjects::PixelROC* SiPixelFedCablingTree::findItem(
00076 const CablingPathToDetUnit & path) const
00077 {
00078 const PixelROC* roc = 0;
00079 const PixelFEDCabling * aFed = fed(path.fed);
00080 if (aFed) {
00081 const PixelFEDLink * aLink = aFed->link(path.link);
00082 if (aLink) roc = aLink->roc(path.roc);
00083 }
00084 return roc;
00085 }
00086
00087 int SiPixelFedCablingTree::checkNumbering() const
00088 {
00089 int status = 0;
00090 for (std::map<int, PixelFEDCabling>::const_iterator im = theFedCablings.begin();
00091 im != theFedCablings.end(); ++im) {
00092 if (im->first != static_cast<int>( im->second.id())) {
00093 status = 1;
00094 std::cout << "PROBLEM WITH FED ID!!" << im->first <<" vs: "<< im->second.id() << std::endl;
00095 }
00096 im->second.checkLinkNumbering();
00097 }
00098 return status;
00099 }