CMS 3D CMS Logo

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 
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 }
FEDNumbering.h
SiPixelFedCablingMap::theVersion
std::string theVersion
Definition: SiPixelFedCablingMap.h:53
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
hcaldqm::constants::fedList
const std::vector< unsigned int > fedList
Definition: Constants.h:62
tree
Definition: tree.py:1
gather_cfg.cout
cout
Definition: gather_cfg.py:144
SiPixelFedCablingMap.h
SiPixelFedCablingTree.h
findQualityFiles.v
v
Definition: findQualityFiles.py:179
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
dqmdumpme.first
first
Definition: dqmdumpme.py:55
end
#define end
Definition: vmac.h:39
SiPixelFedCablingMap::Key::operator<
bool operator<(const Key &other) const
Definition: SiPixelFedCablingMap.cc:56
sipixelobjects
Definition: CablingPathToDetUnit.h:4
sipixelobjects::CablingPathToDetUnit
Definition: CablingPathToDetUnit.h:5
SiPixelFedCablingMap::pathToDetUnitHasDetUnit
bool pathToDetUnitHasDetUnit(uint32_t rawDetId, unsigned int fedId) const final
Definition: SiPixelFedCablingMap.cc:161
SiPixelFedCablingMap::pathToDetUnit
std::vector< sipixelobjects::CablingPathToDetUnit > pathToDetUnit(uint32_t rawDetId) const final
Definition: SiPixelFedCablingMap.cc:150
trackingPlots.other
other
Definition: trackingPlots.py:1465
SiPixelFedCablingMap::det2PathMap
std::map< uint32_t, std::vector< sipixelobjects::CablingPathToDetUnit > > det2PathMap() const final
Definition: SiPixelFedCablingMap.cc:141
SiPixelFedCablingMap::theMap
Map theMap
Definition: SiPixelFedCablingMap.h:55
SiPixelFedCablingMap::cablingTree
std::unique_ptr< SiPixelFedCablingTree > cablingTree() const
Definition: SiPixelFedCablingMap.cc:103
SiPixelFedCablingMap::det2fedMap
std::unordered_map< uint32_t, unsigned int > det2fedMap() const final
Definition: SiPixelFedCablingMap.cc:133
MainPageGenerator.tree
tree
Definition: MainPageGenerator.py:264
l1tstage2_dqm_sourceclient-live_cfg.fedId
fedId
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:88
SiPixelFedCablingMap::initializeRocs
void initializeRocs()
Definition: SiPixelFedCablingMap.cc:12
FEDNumbering::MINSiPixeluTCAFEDID
Definition: FEDNumbering.h:105
sipixelobjects::PixelROC
Definition: PixelROC.h:23
SiPixelFedCablingMap::SiPixelFedCablingMap
SiPixelFedCablingMap(const SiPixelFedCablingTree *cab)
Definition: SiPixelFedCablingMap.cc:75
SiPixelFedCablingMap::Key
Definition: SiPixelFedCablingMap.h:46
PixelMapPlotter.roc
roc
Definition: PixelMapPlotter.py:498
mps_fire.result
result
Definition: mps_fire.py:303
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
SiPixelFedCablingTree::fedList
std::vector< const PixelFEDCabling * > fedList() const
Definition: SiPixelFedCablingTree.cc:112
crabWrapper.key
key
Definition: crabWrapper.py:19
BeamSplash_cfg.version
version
Definition: BeamSplash_cfg.py:45
SiPixelFedCablingTree
Definition: SiPixelFedCablingTree.h:13
SiPixelFedCablingMap::findItem
const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &path) const final
Definition: SiPixelFedCablingMap.cc:124
SiPixelFedCablingMap::fedIds
std::vector< unsigned int > fedIds() const
Definition: SiPixelFedCablingMap.cc:114