CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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  // OLD Method
14  //for (auto & v : theMap) v.second.initFrameConversion();
15  // below is the new code, works for phase0 and phase1
16 
17  // Decide if it is phase0 or phase1 based on the first fed, 0-phase0, 1200-phase1
18  unsigned int fedId = (theMap.begin())->first.fed; // get the first fed
19 
20  // Specifically for CMSSW_9_0_X, we need to call a different version of the frame
21  // conversion steered by the version name in the cabling map
22  if (theVersion.find("CMSSW_9_0_X") != std::string::npos) {
23  for (auto &v : theMap)
24  v.second.initFrameConversionPhase1_CMSSW_9_0_X(); // works
25  std::cout << "*** Found CMSSW_9_0_X specific cabling map\n";
26  return;
27  }
28 
29  if (fedId >= FEDNumbering::MINSiPixeluTCAFEDID) { // phase1 >= 1200
30  for (auto &v : theMap)
31  v.second.initFrameConversionPhase1(); // works
32  } else { // phase0
33  for (auto &v : theMap)
34  v.second.initFrameConversion(); // works
35  }
36 
37  // if(0) { // for testing
38  // for (Map::iterator im = theMap.begin(); im != theMap.end(); im++) {
39  // unsigned int fedId = im->first.fed;
40  // unsigned int linkId = im->first.link;
41  // unsigned int rocId = im->first.roc;
42  // auto rawDetID = im->second.rawId();
43  // auto idInDetUnit = im->second.idInDetUnit();
44  // auto idInLink = im->second.idInLink();
45  // //auto v = *im;
46  // if(fedId>=1200) {
47  // //v.second.initFrameConversionPhase1(); //
48  // im->second.initFrameConversionPhase1(); //
49  // } else {
50  // im->second.initFrameConversion();
51  // }
52  // } //
53  // } // end if(0)
54 }
55 
56 bool SiPixelFedCablingMap::Key::operator<(const Key &other) const {
57  if (fed < other.fed)
58  return true;
59  if (fed > other.fed)
60  return false;
61 
62  if (link < other.link)
63  return true;
64  if (link > other.link)
65  return false;
66 
67  if (roc < other.roc)
68  return true;
69  if (roc > other.roc)
70  return false;
71 
72  return false;
73 }
74 
76  // Never called
77  std::vector<const PixelFEDCabling *> fedList = cab->fedList();
78  for (std::vector<const PixelFEDCabling *>::const_iterator ifed = fedList.begin(); ifed != fedList.end(); ifed++) {
79  unsigned int fed = (**ifed).id();
80  unsigned int numLink = (**ifed).numberOfLinks();
81  for (unsigned int link = 1; link <= numLink; link++) {
82  const PixelFEDLink *pLink = (**ifed).link(link);
83  if (pLink == nullptr)
84  continue;
85  //unsigned int linkId = pLink->id();
86  //if (linkId != 0 && linkId!= link)
87  // std::cout << "PROBLEM WITH LINK NUMBER!!!!" << std::endl;
88  unsigned int numberROC = pLink->numberOfROCs();
89 
90  for (unsigned int roc = 1; roc <= numberROC; roc++) {
91  const PixelROC *pROC = pLink->roc(roc);
92  if (pROC == nullptr)
93  continue;
94  //if (pROC->idInLink() != roc)
95  // std::cout << "PROBLEM WITH ROC NUMBER!!!!" << std::endl;
96  Key key = {fed, link, roc};
97  theMap[key] = (*pROC);
98  }
99  }
100  } // fed loop
101 }
102 
103 std::unique_ptr<SiPixelFedCablingTree> SiPixelFedCablingMap::cablingTree() const {
104  std::unique_ptr<SiPixelFedCablingTree> tree(new SiPixelFedCablingTree(theVersion));
105  for (Map::const_iterator im = theMap.begin(); im != theMap.end(); im++) {
106  const sipixelobjects::PixelROC &roc = im->second;
107  unsigned int fedId = im->first.fed;
108  unsigned int linkId = im->first.link;
109  tree->addItem(fedId, linkId, roc);
110  }
111  return tree;
112 }
113 
114 std::vector<unsigned int> SiPixelFedCablingMap::fedIds() const {
115  std::vector<unsigned int> result;
116  for (Map::const_iterator im = theMap.begin(); im != theMap.end(); im++) {
117  unsigned int fedId = im->first.fed;
118  if (find(result.begin(), result.end(), fedId) == result.end())
119  result.push_back(fedId);
120  }
121  return result;
122 }
123 
125  const PixelROC *roc = nullptr;
126  Key key = {path.fed, path.link, path.roc};
127  Map::const_iterator inMap = theMap.find(key);
128  if (inMap != theMap.end())
129  roc = &(inMap->second);
130  return roc;
131 }
132 
133 std::unordered_map<uint32_t, unsigned int> SiPixelFedCablingMap::det2fedMap() const {
134  std::unordered_map<uint32_t, unsigned int> result;
135  for (auto im = theMap.begin(); im != theMap.end(); ++im) {
136  result[im->second.rawId()] = im->first.fed; // we know: a det is in only one fed!
137  }
138  return result;
139 }
140 
141 std::map<uint32_t, std::vector<sipixelobjects::CablingPathToDetUnit> > SiPixelFedCablingMap::det2PathMap() const {
142  std::map<uint32_t, std::vector<sipixelobjects::CablingPathToDetUnit> > result;
143  for (auto im = theMap.begin(); im != theMap.end(); ++im) {
144  CablingPathToDetUnit path = {im->first.fed, im->first.link, im->first.roc};
145  result[im->second.rawId()].push_back(path);
146  }
147  return result;
148 }
149 
150 std::vector<sipixelobjects::CablingPathToDetUnit> SiPixelFedCablingMap::pathToDetUnit(uint32_t rawDetId) const {
151  std::vector<sipixelobjects::CablingPathToDetUnit> result;
152  for (auto im = theMap.begin(); im != theMap.end(); ++im) {
153  if (im->second.rawId() == rawDetId) {
154  CablingPathToDetUnit path = {im->first.fed, im->first.link, im->first.roc};
155  result.push_back(path);
156  }
157  }
158  return result;
159 }
160 
161 bool SiPixelFedCablingMap::pathToDetUnitHasDetUnit(uint32_t rawDetId, unsigned int fedId) const {
162  auto end = theMap.end();
163  for (auto im = theMap.lower_bound({fedId, 0, 0}); im != end and im->first.fed == fedId; ++im) {
164  if (im->second.rawId() == rawDetId) {
165  return true;
166  }
167  }
168  return false;
169 }
std::map< uint32_t, std::vector< sipixelobjects::CablingPathToDetUnit > > det2PathMap() const final
SiPixelFedCablingMap(const SiPixelFedCablingTree *cab)
bool operator<(const Key &other) const
std::vector< sipixelobjects::CablingPathToDetUnit > pathToDetUnit(uint32_t rawDetId) const final
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
tuple result
Definition: mps_fire.py:311
if(conf_.getParameter< bool >("UseStripCablingDB"))
tuple key
prepare the HTCondor submission files and eventually submit them
const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &path) const final
bool pathToDetUnitHasDetUnit(uint32_t rawDetId, unsigned int fedId) const final
std::vector< unsigned int > const fedList
Definition: Constants.h:63
std::unique_ptr< SiPixelFedCablingTree > cablingTree() const
string end
Definition: dataset.py:937
std::unordered_map< uint32_t, unsigned int > det2fedMap() const final
std::vector< unsigned int > fedIds() const
tuple cout
Definition: gather_cfg.py:144
std::vector< const PixelFEDCabling * > fedList() const