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 #include <iostream>
9 
10 using namespace sipixelobjects;
11 
12 
14  // std::cout << "initialize PixelRocs" << std::endl;
15  for (auto & v : theMap) v.second.initFrameConversion();
16 
17 }
18 
19 
20 bool SiPixelFedCablingMap::Key::operator < (const Key & other) const
21 {
22  if (fed < other.fed) return true;
23  if (fed > other.fed) return false;
24 
25  if (link < other.link) return true;
26  if (link > other.link) return false;
27 
28  if (roc < other.roc) return true;
29  if (roc > other.roc) return false;
30 
31  return false;
32 }
33 
35  : theVersion(cab->version())
36 {
37 // std::cout << "HERE --- SiPixelFedCablingMap CTOR" << std::endl;
38 
39  std::vector<const PixelFEDCabling *> fedList = cab->fedList();
40  for (std::vector<const PixelFEDCabling *>::const_iterator ifed=fedList.begin();
41  ifed != fedList.end(); ifed++) {
42  unsigned int fed = (**ifed).id();
43  unsigned int numLink = (**ifed).numberOfLinks();
44  for (unsigned int link=1; link <= numLink; link++) {
45  const PixelFEDLink * pLink = (**ifed).link(link);
46  if (pLink==0) continue;
47  unsigned int linkId = pLink->id();
48  if (linkId != 0 && linkId!= link)
49  std::cout << "PROBLEM WITH LINK NUMBER!!!!" << std::endl;
50  unsigned int numberROC = pLink->numberOfROCs();
51  for (unsigned int roc=1; roc <= numberROC; roc++) {
52  const PixelROC * pROC = pLink->roc(roc);
53  if (pROC==0) continue;
54  if (pROC->idInLink() != roc)
55  std::cout << "PROBLEM WITH ROC NUMBER!!!!" << std::endl;
56  Key key = {fed, link, roc};
57  theMap[key] = (*pROC);
58  }
59  }
60  }
61 }
62 
63 std::unique_ptr<SiPixelFedCablingTree> SiPixelFedCablingMap::cablingTree() const
64 {
65  std::unique_ptr<SiPixelFedCablingTree> tree(new SiPixelFedCablingTree(theVersion));
66  for (Map::const_iterator im = theMap.begin(); im != theMap.end(); im++) {
67  const sipixelobjects::PixelROC & roc = im->second;
68  unsigned int fedId = im->first.fed;
69  unsigned int linkId = im->first.link;
70  tree->addItem(fedId, linkId, roc);
71  }
72  return tree;
73 }
74 
75 std::vector<unsigned int> SiPixelFedCablingMap::fedIds() const
76 {
77  std::vector<unsigned int> result;
78  for (Map::const_iterator im = theMap.begin(); im != theMap.end(); im++) {
79  unsigned int fedId = im->first.fed;
80  if (find(result.begin(),result.end(),fedId) == result.end()) result.push_back(fedId);
81  }
82  return result;
83 }
84 
87 {
88  const PixelROC* roc = 0;
89  Key key = {path.fed, path.link, path.roc};
90  Map::const_iterator inMap = theMap.find(key);
91  if (inMap!= theMap.end()) roc = &(inMap->second);
92  return roc;
93 }
94 
95 std::vector<sipixelobjects::CablingPathToDetUnit> SiPixelFedCablingMap::pathToDetUnit(
96  uint32_t rawDetId) const
97 {
98  std::vector<sipixelobjects::CablingPathToDetUnit> result;
99  for (Map::const_iterator im = theMap.begin(); im != theMap.end(); ++im) {
100  if(im->second.rawId()==rawDetId ) {
101  CablingPathToDetUnit path = {im->first.fed, im->first.link, im->first.roc};
102  result.push_back(path);
103  }
104  }
105  return result;
106 }
107 
unsigned int idInLink() const
id of this ROC in parent Link.
Definition: PixelROC.h:42
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
tuple path
else: Piece not in the list, fine.
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
std::unique_ptr< SiPixelFedCablingTree > cablingTree() const
std::vector< unsigned int > fedIds() const
tuple cout
Definition: gather_cfg.py:121
std::vector< const PixelFEDCabling * > fedList() const