CMS 3D CMS Logo

Phase2TrackerCabling.cc
Go to the documentation of this file.
5 #include <sstream>
6 
7 // These functions are used to sort and search the cabling objects
8 
9 // by FED id/ch
11  if (a->getCh().first == b->getCh().first)
12  return a->getCh().second < b->getCh().second;
13  else
14  return a->getCh().first < b->getCh().first;
15 }
16 bool Phase2TrackerCabling::chComp(Phase2TrackerCabling::key a, std::pair<unsigned int, unsigned int> b) {
17  if (a->getCh().first == b.first)
18  return a->getCh().second < b.second;
19  else
20  return a->getCh().first < b.first;
21 }
22 bool Phase2TrackerCabling::fedeq(key a, key b) { return (a->getCh().first == b->getCh().first); }
23 
24 // by detid
26  return a->getDetid() < b->getDetid();
27 }
28 bool Phase2TrackerCabling::detidComp(Phase2TrackerCabling::key a, uint32_t b) { return a->getDetid() < b; }
29 
30 // by gbtid
32  return a->getGbtid() < b->getGbtid();
33 }
34 bool Phase2TrackerCabling::gbtidComp(Phase2TrackerCabling::key a, uint32_t b) { return a->getGbtid() < b; }
35 
36 // by cooling loop
38  return a.getCoolingLoop() < b.getCoolingLoop();
39 }
40 bool Phase2TrackerCabling::coolingComp(const Phase2TrackerModule& a, uint32_t b) { return a.getCoolingLoop() < b; }
42  return (a.getCoolingLoop() == b.getCoolingLoop());
43 }
44 
45 // by power group
47  return a.getPowerGroup() < b.getPowerGroup();
48 }
49 bool Phase2TrackerCabling::powerComp(const Phase2TrackerModule& a, uint32_t b) { return a.getPowerGroup() < b; }
51  return (a.getPowerGroup() == b.getPowerGroup());
52 }
53 
54 // Phase2TrackerCabling methods
55 
56 Phase2TrackerCabling::Phase2TrackerCabling(const std::vector<Phase2TrackerModule>& cons) : connections_(cons) {
57  // initialize the cabling (fill the transient objects and sort.
59 }
60 
62  connections_ = src.connections_;
63  fedCabling_ = src.fedCabling_;
64  detCabling_ = src.detCabling_;
65  gbtCabling_ = src.gbtCabling_;
66 }
67 
69  // fill the cabling objects
70  fedCabling_.reserve(connections_.size());
71  detCabling_.reserve(connections_.size());
72  gbtCabling_.reserve(connections_.size());
73  for (key module = connections_.begin(); module < connections_.end(); ++module) {
74  fedCabling_.push_back(module);
75  detCabling_.push_back(module);
76  gbtCabling_.push_back(module);
77  }
78  // sort the cabling objects
82 }
83 
84 const Phase2TrackerModule& Phase2TrackerCabling::findFedCh(std::pair<unsigned int, unsigned int> fedch) const {
85  // look for ch
86  cabling::const_iterator itid = std::lower_bound(fedCabling_.begin(), fedCabling_.end(), fedch, chComp);
87  if (itid != fedCabling_.end() && (*itid)->getCh() == fedch)
88  return **itid;
89  else
90  throw cms::Exception("IndexNotFound")
91  << "No connection corresponding to FED id/ch = " << fedch.first << "/" << fedch.second;
92 }
93 
95  // look for id
96  cabling::const_iterator itch = std::lower_bound(detCabling_.begin(), detCabling_.end(), detid, detidComp);
97  if (itch != detCabling_.end() && (*itch)->getDetid() == detid)
98  return **itch;
99  else
100  throw cms::Exception("IndexNotFound")
101  << "No connection corresponding to detid = 0x" << std::hex << detid << std::dec;
102 }
103 
105  // look for id
106  cabling::const_iterator itch = std::lower_bound(gbtCabling_.begin(), gbtCabling_.end(), gbtid, gbtidComp);
107  if (itch != gbtCabling_.end() && (*itch)->getGbtid() == gbtid)
108  return **itch;
109  else
110  throw cms::Exception("IndexNotFound")
111  << "No connection corresponding to gbtid = 0x" << std::hex << gbtid << std::dec;
112 }
113 
115  // NB: this approach involves two copies of the connections. Can we do better?
116  // since this is a relatively rare operation, I don't want to pre-sort the connections.
117 
118  // make a copy of the store
119  store resultStore = connections_;
120  // sort according to cooling
121  std::sort(resultStore.begin(), resultStore.end(), coolingOrdering);
122  // search for the proper range
123  std::pair<key, key> range = std::equal_range(resultStore.begin(),
124  resultStore.end(),
125  Phase2TrackerModule(Phase2TrackerModule::SS, 0, 0, 0, 0, 0, coolingLine),
127  // create a new cabling object
128  Phase2TrackerCabling result(store(range.first, range.second));
129  // return the new cabling object
130  return result;
131 }
132 
134  // NB: this approach involves two copies of the connections. Can we do better?
135  // since this is a relatively rare operation, I don't want to pre-sort the connections.
136 
137  // make a copy of the store
138  store resultStore = connections_;
139  // sort according to power groups
140  std::sort(resultStore.begin(), resultStore.end(), powerOrdering);
141  // search for the proper range
142  std::pair<key, key> range = std::equal_range(resultStore.begin(),
143  resultStore.end(),
144  Phase2TrackerModule(Phase2TrackerModule::SS, 0, 0, 0, 0, powerGroup, 0),
145  powerOrdering);
146  // create a new cabling object
147  Phase2TrackerCabling result(store(range.first, range.second));
148  // return the new cabling object
149  return result;
150 }
151 
153  std::string mystring("Summary of the cabling\n======================\n");
154  std::stringstream ss;
155  // number of modules, feds, cooling loop and power groups
156  ss << "Number of modules: " << connections_.size() << std::endl;
157  store orig(connections_);
158  ss << "Number of FEDs: ";
159  cabling tmpc(fedCabling_);
160  ss << std::distance(tmpc.begin(), std::unique(tmpc.begin(), tmpc.end(), fedeq)) << std::endl;
161  ss << "Number of cooling loops: ";
162  std::sort(orig.begin(), orig.end(), coolingOrdering);
163  store tmp(orig);
164  ss << std::distance(tmp.begin(), std::unique(tmp.begin(), tmp.end(), cooleq)) << std::endl;
165  ss << "Number of power groups: ";
166  std::sort(orig.begin(), orig.end(), powerOrdering);
167  tmp = orig;
168  ss << std::distance(tmp.begin(), std::unique(tmp.begin(), tmp.end(), poweq)) << std::endl;
169  mystring += ss.str();
170  return mystring;
171 }
172 
174  std::string mystring("Cabling:\n========\n");
175  for (std::vector<Phase2TrackerModule>::const_iterator it = connections_.begin(); it < connections_.end(); ++it) {
176  mystring += it->description(compact);
177  }
178  return mystring;
179 }
Phase2TrackerCabling::poweq
static bool poweq(const Phase2TrackerModule &a, const Phase2TrackerModule &b)
Definition: Phase2TrackerCabling.cc:50
Phase2TrackerCabling::Phase2TrackerCabling
Phase2TrackerCabling()
Definition: Phase2TrackerCabling.h:22
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
Phase2TrackerCabling::powerComp
static bool powerComp(const Phase2TrackerModule &a, uint32_t b)
Definition: Phase2TrackerCabling.cc:49
Phase2TrackerCabling::gbtCabling_
cabling gbtCabling_
Definition: Phase2TrackerCabling.h:60
MessageLogger.h
Phase2TrackerCabling::detCabling_
cabling detCabling_
Definition: Phase2TrackerCabling.h:61
Phase2TrackerCabling::gbtidOrdering
static bool gbtidOrdering(key a, key b)
Definition: Phase2TrackerCabling.cc:31
Phase2TrackerCabling
Definition: Phase2TrackerCabling.h:9
Phase2TrackerCabling::findGbtid
const Phase2TrackerModule & findGbtid(uint32_t gbtid) const
Definition: Phase2TrackerCabling.cc:104
Phase2TrackerCabling::coolingComp
static bool coolingComp(const Phase2TrackerModule &a, uint32_t b)
Definition: Phase2TrackerCabling.cc:40
Phase2TrackerCabling::filterByCoolingLine
Phase2TrackerCabling filterByCoolingLine(uint32_t coolingLine) const
Definition: Phase2TrackerCabling.cc:114
Phase2TrackerCabling::cabling
std::vector< key > cabling
Definition: Phase2TrackerCabling.h:12
Phase2TrackerCabling::coolingOrdering
static bool coolingOrdering(const Phase2TrackerModule &a, const Phase2TrackerModule &b)
Definition: Phase2TrackerCabling.cc:37
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
Phase2TrackerCabling::cooleq
static bool cooleq(const Phase2TrackerModule &a, const Phase2TrackerModule &b)
Definition: Phase2TrackerCabling.cc:41
Phase2TrackerCabling::filterByPowerGroup
Phase2TrackerCabling filterByPowerGroup(uint32_t powerGroup) const
Definition: Phase2TrackerCabling.cc:133
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
Phase2TrackerCabling::chOrdering
static bool chOrdering(key a, key b)
Definition: Phase2TrackerCabling.cc:10
Phase2TrackerCabling::initializeCabling
void initializeCabling()
Definition: Phase2TrackerCabling.cc:68
Phase2TrackerCabling::findFedCh
const Phase2TrackerModule & findFedCh(std::pair< unsigned int, unsigned int > fedch) const
Definition: Phase2TrackerCabling.cc:84
Phase2TrackerCabling::key
std::vector< Phase2TrackerModule >::const_iterator key
Definition: Phase2TrackerCabling.h:11
b
double b
Definition: hdecay.h:118
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
a
double a
Definition: hdecay.h:119
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
Phase2TrackerModule
Definition: Phase2TrackerModule.h:9
Phase2TrackerCabling::store
std::vector< Phase2TrackerModule > store
Definition: Phase2TrackerCabling.h:10
Phase2TrackerCabling.h
Phase2TrackerCabling::findDetid
const Phase2TrackerModule & findDetid(uint32_t detid) const
Definition: Phase2TrackerCabling.cc:94
tier0.unique
def unique(seq, keepstr=True)
Definition: tier0.py:24
Phase2TrackerModule::SS
Definition: Phase2TrackerModule.h:11
Phase2TrackerCabling::detidOrdering
static bool detidOrdering(key a, key b)
Definition: Phase2TrackerCabling.cc:25
Phase2TrackerCabling::connections_
store connections_
Definition: Phase2TrackerCabling.h:56
Phase2TrackerCabling::fedeq
static bool fedeq(key a, key b)
Definition: Phase2TrackerCabling.cc:22
Exception
Definition: hltDiff.cc:245
Phase2TrackerCabling::detidComp
static bool detidComp(key a, uint32_t b)
Definition: Phase2TrackerCabling.cc:28
Phase2TrackerModule.h
Exception.h
Phase2TrackerCabling::chComp
static bool chComp(key a, std::pair< unsigned int, unsigned int > b)
Definition: Phase2TrackerCabling.cc:16
Phase2TrackerCabling::fedCabling_
cabling fedCabling_
Definition: Phase2TrackerCabling.h:59
mps_fire.result
result
Definition: mps_fire.py:311
Phase2TrackerCabling::summaryDescription
std::string summaryDescription() const
Definition: Phase2TrackerCabling.cc:152
Phase2TrackerCabling::description
std::string description(bool compact=false) const
Definition: Phase2TrackerCabling.cc:173
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7733
Phase2TrackerCabling::powerOrdering
static bool powerOrdering(const Phase2TrackerModule &a, const Phase2TrackerModule &b)
Definition: Phase2TrackerCabling.cc:46
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
Phase2TrackerCabling::gbtidComp
static bool gbtidComp(key a, uint32_t b)
Definition: Phase2TrackerCabling.cc:34