CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelFedCablingMap.cc
Go to the documentation of this file.
3 
4 #include <vector>
5 #include <iostream>
6 #include <algorithm>
7 
8 using namespace sipixelobjects;
9 
10 bool SiPixelFedCablingMap::Key::operator < (const Key & other) const
11 {
12  if (fed < other.fed) return true;
13  if (fed > other.fed) return false;
14 
15  if (link < other.link) return true;
16  if (link > other.link) return false;
17 
18  if (roc < other.roc) return true;
19  if (roc > other.roc) return false;
20 
21  return false;
22 }
23 
25  : theVersion(cab->version())
26 {
27 // std::cout << "HERE --- SiPixelFedCablingMap CTOR" << std::endl;
28 
29  std::vector<const PixelFEDCabling *> fedList = cab->fedList();
30  for (std::vector<const PixelFEDCabling *>::const_iterator ifed=fedList.begin();
31  ifed != fedList.end(); ifed++) {
32  unsigned int fed = (**ifed).id();
33  unsigned int numLink = (**ifed).numberOfLinks();
34  for (unsigned int link=1; link <= numLink; link++) {
35  const PixelFEDLink * pLink = (**ifed).link(link);
36  if (pLink==0) continue;
37  unsigned int linkId = pLink->id();
38  if (linkId != 0 && linkId!= link)
39  std::cout << "PROBLEM WITH LINK NUMBER!!!!" << std::endl;
40  unsigned int numberROC = pLink->numberOfROCs();
41  for (unsigned int roc=1; roc <= numberROC; roc++) {
42  const PixelROC * pROC = pLink->roc(roc);
43  if (pROC==0) continue;
44  if (pROC->idInLink() != roc)
45  std::cout << "PROBLEM WITH ROC NUMBER!!!!" << std::endl;
46  Key key = {fed, link, roc};
47  theMap[key] = (*pROC);
48  }
49  }
50  }
51 }
52 
54 {
56  for (Map::const_iterator im = theMap.begin(); im != theMap.end(); im++) {
57  const sipixelobjects::PixelROC & roc = im->second;
58  unsigned int fedId = im->first.fed;
59  unsigned int linkId = im->first.link;
60  tree->addItem(fedId, linkId, roc);
61  }
62  return tree;
63 }
64 
65 std::vector<unsigned int> SiPixelFedCablingMap::fedIds() const
66 {
67  std::vector<unsigned int> result;
68  for (Map::const_iterator im = theMap.begin(); im != theMap.end(); im++) {
69  unsigned int fedId = im->first.fed;
70  if (find(result.begin(),result.end(),fedId) == result.end()) result.push_back(fedId);
71  }
72  return result;
73 }
74 
77 {
78  const PixelROC* roc = 0;
79  Key key = {path.fed, path.link, path.roc};
80  Map::const_iterator inMap = theMap.find(key);
81  if (inMap!= theMap.end()) roc = &(inMap->second);
82  return roc;
83 }
84 
85 std::vector<sipixelobjects::CablingPathToDetUnit> SiPixelFedCablingMap::pathToDetUnit(
86  uint32_t rawDetId) const
87 {
88  std::vector<sipixelobjects::CablingPathToDetUnit> result;
89  for (Map::const_iterator im = theMap.begin(); im != theMap.end(); ++im) {
90  if(im->second.rawId()==rawDetId ) {
91  CablingPathToDetUnit path = {im->first.fed, im->first.link, im->first.roc};
92  result.push_back(path);
93  }
94  }
95  return result;
96 }
97 
unsigned int idInLink() const
id of this ROC in parent Link.
Definition: PixelROC.h:46
SiPixelFedCablingMap(const SiPixelFedCablingTree *cab)
bool operator<(const Key &other) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::string link(std::string &nm, std::string &ns)
Definition: hierarchy.cc:24
tuple result
Definition: query.py:137
virtual std::vector< sipixelobjects::CablingPathToDetUnit > pathToDetUnit(uint32_t rawDetId) const
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &path) const
SiPixelFedCablingTree * cablingTree() const
list key
Definition: combine.py:13
std::vector< unsigned int > fedIds() const
tuple cout
Definition: gather_cfg.py:121
void addItem(unsigned int fedId, unsigned int linkId, const sipixelobjects::PixelROC &roc)
std::vector< const PixelFEDCabling * > fedList() const