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 <sstream>
3 #include <iostream>
4 
5 using namespace std;
6 using namespace sipixelobjects;
7 
8 typedef std::map<int, SiPixelFedCablingTree::PixelFEDCabling>::const_iterator IMAP;
9 
10 std::vector<sipixelobjects::CablingPathToDetUnit> SiPixelFedCablingTree::pathToDetUnit(
11  uint32_t rawDetId) const
12 {
13  std::vector<sipixelobjects::CablingPathToDetUnit> result;
14  typedef std::map<int, PixelFEDCabling>::const_iterator IM;
15  for (IM im = theFedCablings.begin(); im != theFedCablings.end(); ++im) {
16  const PixelFEDCabling & aFed = im->second;
17  for (int idxLink = 1; idxLink <= aFed.numberOfLinks(); idxLink++) {
18  const PixelFEDLink * link = aFed.link(idxLink);
19  if (!link) continue;
20  int numberOfRocs = link->numberOfROCs();
21  for(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  IMAP 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  return result;
65 
66 }
67 
68 void SiPixelFedCablingTree::addItem(unsigned int fedId, unsigned int linkId, const PixelROC& roc)
69 {
70  PixelFEDCabling & cabling = theFedCablings[fedId];
71  if (cabling.id() != fedId) cabling=PixelFEDCabling(fedId);
72  cabling.addItem(linkId,roc);
73 }
74 
76  const CablingPathToDetUnit & path) const
77 {
78  const PixelROC* roc = 0;
79  const PixelFEDCabling * aFed = fed(path.fed);
80  if (aFed) {
81  const PixelFEDLink * aLink = aFed->link(path.link);
82  if (aLink) roc = aLink->roc(path.roc);
83  }
84  return roc;
85 }
86 
88 {
89  int status = 0;
90  for (std::map<int, PixelFEDCabling>::const_iterator im = theFedCablings.begin();
91  im != theFedCablings.end(); ++im) {
92  if (im->first != static_cast<int>( im->second.id())) {
93  status = 1;
94  std::cout << "PROBLEM WITH FED ID!!" << im->first <<" vs: "<< im->second.id() << std::endl;
95  }
96  im->second.checkLinkNumbering();
97  }
98  return status;
99 }
unsigned int idInLink() const
id of this ROC in parent Link.
Definition: PixelROC.h:46
void addItem(unsigned int linkId, const PixelROC &roc)
std::string link(std::string &nm, std::string &ns)
Definition: hierarchy.cc:47
list path
Definition: scaleCards.py:51
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:40
double f[11][100]
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &path) const
std::map< int, SiPixelFedCablingTree::PixelFEDCabling >::const_iterator IMAP
tuple out
Definition: dbtoconf.py:99
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]
void addFed(const PixelFEDCabling &f)
add cabling for one fed
tuple cout
Definition: gather_cfg.py:121
tuple status
Definition: ntuplemaker.py:245
int numberOfLinks() const
number of links in FED
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