CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelFedCablingTree.cc
Go to the documentation of this file.
2 #include <algorithm>
3 #include <sstream>
4 #include <iostream>
5 
6 using namespace std;
7 using namespace sipixelobjects;
8 
9 typedef std::unordered_map<int, SiPixelFedCablingTree::PixelFEDCabling>::const_iterator IMAP;
10 
11 std::vector<sipixelobjects::CablingPathToDetUnit> SiPixelFedCablingTree::pathToDetUnit(
12  uint32_t rawDetId) const
13 {
14  std::vector<sipixelobjects::CablingPathToDetUnit> result;
15  for (auto im = theFedCablings.begin(); im != theFedCablings.end(); ++im) {
16  const PixelFEDCabling & aFed = im->second;
17  for (unsigned int idxLink = 1; idxLink <= aFed.numberOfLinks(); idxLink++) {
18  const PixelFEDLink * link = aFed.link(idxLink);
19  if (!link) continue;
20  unsigned int numberOfRocs = link->numberOfROCs();
21  for(unsigned int idxRoc = 1; idxRoc <= numberOfRocs; idxRoc++) {
22  const PixelROC * roc = link->roc(idxRoc);
23  if (rawDetId == roc->rawId() ) {
24  CablingPathToDetUnit path = {aFed.id(), link->id(), roc->idInLink()};
25  result.push_back(path);
26  }
27  }
28  }
29  }
30  return result;
31 }
32 
34 {
35  int id = f.id();
36  theFedCablings[id] = f;
37 }
38 
39 const PixelFEDCabling * SiPixelFedCablingTree::fed(unsigned int id) const
40 {
41  auto it = theFedCablings.find(id);
42  return ( it == theFedCablings.end() ) ? 0 : & (*it).second;
43 }
44 
45 string SiPixelFedCablingTree::print(int depth) const
46 {
47  ostringstream out;
48  if ( depth-- >=0 ) {
49  out << theVersion << endl;
50  for(IMAP it=theFedCablings.begin(); it != theFedCablings.end(); it++) {
51  out << (*it).second.print(depth);
52  }
53  }
54  out << endl;
55  return out.str();
56 }
57 
58 std::vector<const PixelFEDCabling *> SiPixelFedCablingTree::fedList() const
59 {
60  std::vector<const PixelFEDCabling *> result;
61  for (IMAP im = theFedCablings.begin(); im != theFedCablings.end(); im++) {
62  result.push_back( &(im->second) );
63  }
64  std::sort(result.begin(),result.end(),[](const PixelFEDCabling * a,const PixelFEDCabling * b){return a->id()<b->id();});
65  return result;
66 
67 }
68 
69 void SiPixelFedCablingTree::addItem(unsigned int fedId, unsigned int linkId, const PixelROC& roc)
70 {
71  PixelFEDCabling & cabling = theFedCablings[fedId];
72  if (cabling.id() != fedId) cabling=PixelFEDCabling(fedId);
73  cabling.addItem(linkId,roc);
74 }
75 
77  const CablingPathToDetUnit & path) const
78 {
79  const PixelROC* roc = 0;
80  const PixelFEDCabling * aFed = fed(path.fed);
81  if (aFed) {
82  const PixelFEDLink * aLink = aFed->link(path.link);
83  if (aLink) roc = aLink->roc(path.roc);
84  }
85  return roc;
86 }
87 
88 
90  const CablingPathToDetUnit & path,
91  const PixelFEDCabling * aFed) const
92 {
93  const PixelROC* roc = 0;
94  const PixelFEDLink * aLink = aFed->link(path.link);
95  if (aLink) roc = aLink->roc(path.roc);
96  return roc;
97 }
98 
99 
101 {
102  int status = 0;
103  for (auto im = theFedCablings.begin(); im != theFedCablings.end(); ++im) {
104  if (im->first != static_cast<int>( im->second.id())) {
105  status = 1;
106  std::cout << "PROBLEM WITH FED ID!!" << im->first <<" vs: "<< im->second.id() << std::endl;
107  }
108  im->second.checkLinkNumbering();
109  }
110  return status;
111 }
unsigned int numberOfLinks() const
number of links in FED
unsigned int idInLink() const
id of this ROC in parent Link.
Definition: PixelROC.h:42
void addItem(unsigned int linkId, const PixelROC &roc)
tuple path
else: Piece not in the list, fine.
virtual std::vector< sipixelobjects::CablingPathToDetUnit > pathToDetUnit(uint32_t rawDetId) const
tuple result
Definition: query.py:137
uint32_t rawId() const
return the DetUnit to which this ROC belongs to.
Definition: PixelROC.h:36
double f[11][100]
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &path) const
tuple out
Definition: dbtoconf.py:99
std::unordered_map< int, SiPixelFedCablingTree::PixelFEDCabling >::const_iterator IMAP
double b
Definition: hdecay.h:120
const PixelFEDCabling * fed(unsigned int idFed) const
get fed identified by its id
const PixelFEDLink * link(unsigned int id) const
return link identified by id. Link id&#39;s are ranged [1, numberOfLinks]
double a
Definition: hdecay.h:121
void addFed(const PixelFEDCabling &f)
add cabling for one fed
const sipixelobjects::PixelROC * findItemInFed(const sipixelobjects::CablingPathToDetUnit &path, const PixelFEDCabling *aFed) const
tuple cout
Definition: gather_cfg.py:121
tuple status
Definition: ntuplemaker.py:245
void addItem(unsigned int fedId, unsigned int linkId, const sipixelobjects::PixelROC &roc)
std::vector< const PixelFEDCabling * > fedList() const
std::string print(int depth=0) const