Go to the documentation of this file.00001 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h"
00002 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingTree.h"
00003
00004 #include <vector>
00005 #include <iostream>
00006 #include <algorithm>
00007
00008 using namespace sipixelobjects;
00009
00010 bool SiPixelFedCablingMap::Key::operator < (const Key & other) const
00011 {
00012 if (fed < other.fed) return true;
00013 if (fed > other.fed) return false;
00014
00015 if (link < other.link) return true;
00016 if (link > other.link) return false;
00017
00018 if (roc < other.roc) return true;
00019 if (roc > other.roc) return false;
00020
00021 return false;
00022 }
00023
00024 SiPixelFedCablingMap::SiPixelFedCablingMap(const SiPixelFedCablingTree *cab)
00025 : theVersion(cab->version())
00026 {
00027
00028
00029 std::vector<const PixelFEDCabling *> fedList = cab->fedList();
00030 for (std::vector<const PixelFEDCabling *>::const_iterator ifed=fedList.begin();
00031 ifed != fedList.end(); ifed++) {
00032 unsigned int fed = (**ifed).id();
00033 unsigned int numLink = (**ifed).numberOfLinks();
00034 for (unsigned int link=1; link <= numLink; link++) {
00035 const PixelFEDLink * pLink = (**ifed).link(link);
00036 if (pLink==0) continue;
00037 unsigned int linkId = pLink->id();
00038 if (linkId != 0 && linkId!= link)
00039 std::cout << "PROBLEM WITH LINK NUMBER!!!!" << std::endl;
00040 unsigned int numberROC = pLink->numberOfROCs();
00041 for (unsigned int roc=1; roc <= numberROC; roc++) {
00042 const PixelROC * pROC = pLink->roc(roc);
00043 if (pROC==0) continue;
00044 if (pROC->idInLink() != roc)
00045 std::cout << "PROBLEM WITH ROC NUMBER!!!!" << std::endl;
00046 Key key = {fed, link, roc};
00047 theMap[key] = (*pROC);
00048 }
00049 }
00050 }
00051 }
00052
00053 SiPixelFedCablingTree * SiPixelFedCablingMap::cablingTree() const
00054 {
00055 SiPixelFedCablingTree * tree = new SiPixelFedCablingTree(theVersion);
00056 for (Map::const_iterator im = theMap.begin(); im != theMap.end(); im++) {
00057 const sipixelobjects::PixelROC & roc = im->second;
00058 unsigned int fedId = im->first.fed;
00059 unsigned int linkId = im->first.link;
00060 tree->addItem(fedId, linkId, roc);
00061 }
00062 return tree;
00063 }
00064
00065 std::vector<unsigned int> SiPixelFedCablingMap::fedIds() const
00066 {
00067 std::vector<unsigned int> result;
00068 for (Map::const_iterator im = theMap.begin(); im != theMap.end(); im++) {
00069 unsigned int fedId = im->first.fed;
00070 if (find(result.begin(),result.end(),fedId) == result.end()) result.push_back(fedId);
00071 }
00072 return result;
00073 }
00074
00075 const sipixelobjects::PixelROC* SiPixelFedCablingMap::findItem(
00076 const sipixelobjects::CablingPathToDetUnit & path) const
00077 {
00078 const PixelROC* roc = 0;
00079 Key key = {path.fed, path.link, path.roc};
00080 Map::const_iterator inMap = theMap.find(key);
00081 if (inMap!= theMap.end()) roc = &(inMap->second);
00082 return roc;
00083 }
00084
00085 std::vector<sipixelobjects::CablingPathToDetUnit> SiPixelFedCablingMap::pathToDetUnit(
00086 uint32_t rawDetId) const
00087 {
00088 std::vector<sipixelobjects::CablingPathToDetUnit> result;
00089 for (Map::const_iterator im = theMap.begin(); im != theMap.end(); ++im) {
00090 if(im->second.rawId()==rawDetId ) {
00091 CablingPathToDetUnit path = {im->first.fed, im->first.link, im->first.roc};
00092 result.push_back(path);
00093 }
00094 }
00095 return result;
00096 }
00097