test
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.
4 
5 #include <vector>
6 #include <iostream>
7 #include <algorithm>
8 #include <iostream>
9 
10 using namespace sipixelobjects;
11 
13 
14  // OLD Method
15  //for (auto & v : theMap) v.second.initFrameConversion();
16  // below is the new code, works for phase0 and phase1
17 
18  // Decide if it is phase0 or phase1 based on the first fed, 0-phase0, 1200-phase1
19  unsigned int fedId = (theMap.begin())->first.fed; // get the first fed
20 
21  if(fedId>=FEDNumbering::MINSiPixeluTCAFEDID) { // phase1 >= 1200
22  for (auto & v : theMap) v.second.initFrameConversionPhase1(); // works
23  } else { // phase0
24  for (auto & v : theMap) v.second.initFrameConversion(); // works
25  }
26 
27  // if(0) { // for testing
28  // for (Map::iterator im = theMap.begin(); im != theMap.end(); im++) {
29  // unsigned int fedId = im->first.fed;
30  // unsigned int linkId = im->first.link;
31  // unsigned int rocId = im->first.roc;
32  // auto rawDetID = im->second.rawId();
33  // auto idInDetUnit = im->second.idInDetUnit();
34  // auto idInLink = im->second.idInLink();
35  // //auto v = *im;
36  // if(fedId>=1200) {
37  // //v.second.initFrameConversionPhase1(); //
38  // im->second.initFrameConversionPhase1(); //
39  // } else {
40  // im->second.initFrameConversion();
41  // }
42  // } //
43  // } // end if(0)
44 
45 }
46 
47 
48 bool SiPixelFedCablingMap::Key::operator < (const Key & other) const
49 {
50  if (fed < other.fed) return true;
51  if (fed > other.fed) return false;
52 
53  if (link < other.link) return true;
54  if (link > other.link) return false;
55 
56  if (roc < other.roc) return true;
57  if (roc > other.roc) return false;
58 
59  return false;
60 }
61 
63  : theVersion(cab->version())
64 {
65 
66  // Never called
67  std::vector<const PixelFEDCabling *> fedList = cab->fedList();
68  for (std::vector<const PixelFEDCabling *>::const_iterator ifed=fedList.begin();
69  ifed != fedList.end(); ifed++) {
70  unsigned int fed = (**ifed).id();
71  unsigned int numLink = (**ifed).numberOfLinks();
72  for (unsigned int link=1; link <= numLink; link++) {
73  const PixelFEDLink * pLink = (**ifed).link(link);
74  if (pLink==0) continue;
75  //unsigned int linkId = pLink->id();
76  //if (linkId != 0 && linkId!= link)
77  // std::cout << "PROBLEM WITH LINK NUMBER!!!!" << std::endl;
78  unsigned int numberROC = pLink->numberOfROCs();
79 
80  for (unsigned int roc=1; roc <= numberROC; roc++) {
81  const PixelROC * pROC = pLink->roc(roc);
82  if (pROC==0) continue;
83  //if (pROC->idInLink() != roc)
84  // std::cout << "PROBLEM WITH ROC NUMBER!!!!" << std::endl;
85  Key key = {fed, link, roc};
86  theMap[key] = (*pROC);
87  }
88  }
89  } // fed loop
90 
91 }
92 
93 std::unique_ptr<SiPixelFedCablingTree> SiPixelFedCablingMap::cablingTree() const {
94 
95  std::unique_ptr<SiPixelFedCablingTree> tree(new SiPixelFedCablingTree(theVersion));
96  for (Map::const_iterator im = theMap.begin(); im != theMap.end(); im++) {
97  const sipixelobjects::PixelROC & roc = im->second;
98  unsigned int fedId = im->first.fed;
99  unsigned int linkId = im->first.link;
100  tree->addItem(fedId, linkId, roc);
101  }
102  return tree;
103 }
104 
105 std::vector<unsigned int> SiPixelFedCablingMap::fedIds() const {
106  std::vector<unsigned int> result;
107  for (Map::const_iterator im = theMap.begin(); im != theMap.end(); im++) {
108  unsigned int fedId = im->first.fed;
109  if (find(result.begin(),result.end(),fedId) == result.end()) result.push_back(fedId);
110  }
111  return result;
112 }
113 
116  const PixelROC* roc = 0;
117  Key key = {path.fed, path.link, path.roc};
118  Map::const_iterator inMap = theMap.find(key);
119  if (inMap!= theMap.end()) roc = &(inMap->second);
120  return roc;
121 }
122 
123 std::vector<sipixelobjects::CablingPathToDetUnit> SiPixelFedCablingMap::pathToDetUnit(
124  uint32_t rawDetId) const {
125 
126  std::vector<sipixelobjects::CablingPathToDetUnit> result;
127  for (Map::const_iterator im = theMap.begin(); im != theMap.end(); ++im) {
128  if(im->second.rawId()==rawDetId ) {
129  CablingPathToDetUnit path = {im->first.fed, im->first.link, im->first.roc};
130  result.push_back(path);
131  }
132  }
133  return result;
134 }
135 
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 result
Definition: mps_fire.py:84
virtual std::vector< sipixelobjects::CablingPathToDetUnit > pathToDetUnit(uint32_t rawDetId) const
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &path) const
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
std::unique_ptr< SiPixelFedCablingTree > cablingTree() const
std::vector< unsigned int > fedIds() const
std::vector< const PixelFEDCabling * > fedList() const