24 auto feds = fedcabling.
fedIds();
25 for (
auto ifed = feds.begin(); ifed != feds.end(); ifed++) {
28 for (
auto iconn = conns.begin(); iconn != conns.end(); iconn++) {
32 bool have_fed_id = iconn->fedId();
33 std::vector<int> vector_of_connected_apvs;
36 int which_apv_pair = iconn->apvPairNumber();
45 if (iconn->i2cAddr(0))
46 vector_of_connected_apvs.push_back(2 * which_apv_pair + 0);
47 if (iconn->i2cAddr(1))
48 vector_of_connected_apvs.push_back(2 * which_apv_pair + 1);
50 if (!vector_of_connected_apvs.empty()) {
51 std::map<uint32_t, std::vector<int>> map_of_connected_apvs;
52 map_of_connected_apvs.insert(std::make_pair(iconn->detId(), vector_of_connected_apvs));
59 for (std::vector<FedChannelConnection>::const_iterator idtct = detected_fed_connections.begin();
60 idtct != detected_fed_connections.end();
63 bool have_fed_id = idtct->fedId();
64 std::vector<int> vector_of_detected_apvs;
66 int which_apv_pair = idtct->apvPairNumber();
68 if (idtct->i2cAddr(0))
69 vector_of_detected_apvs.push_back(2 * which_apv_pair + 0);
70 if (idtct->i2cAddr(1))
71 vector_of_detected_apvs.push_back(2 * which_apv_pair + 1);
73 if (!vector_of_detected_apvs.empty()) {
74 std::map<uint32_t, std::vector<int>> map_of_detected_apvs;
75 map_of_detected_apvs.insert(std::make_pair(idtct->detId(), vector_of_detected_apvs));
81 for (std::vector<FedChannelConnection>::const_iterator iudtct = undetected_fed_connections.begin();
82 iudtct != undetected_fed_connections.end();
85 bool have_fed_id = iudtct->fedId();
86 std::vector<int> vector_of_undetected_apvs;
88 int which_apv_pair = iudtct->apvPairNumber();
90 if (iudtct->i2cAddr(0))
91 vector_of_undetected_apvs.push_back(2 * which_apv_pair + 0);
92 if (iudtct->i2cAddr(1))
93 vector_of_undetected_apvs.push_back(2 * which_apv_pair + 1);
95 if (!vector_of_undetected_apvs.empty()) {
96 std::map<uint32_t, std::vector<int>> map_of_undetected_apvs;
97 map_of_undetected_apvs.insert(std::make_pair(iudtct->detId(), vector_of_undetected_apvs));
105 std::map<uint32_t, std::vector<const FedChannelConnection *>> &conns) {
109 edm::LogInfo(
"") <<
" SiStripDetCabling::addDevices for connection " 110 "associated to detid " 136 vector_to_fill_with_detids.push_back(conn_it->first);
145 vector_to_fill_with_detids.push_back(conn_it->first);
149 vector_to_fill_with_detids.push_back(conn_it->first);
153 vector_to_fill_with_detids.push_back(conn_it->first);
161 uint32_t det_id)
const {
162 std::map<uint32_t, std::vector<const FedChannelConnection *>>::const_iterator detcabl_it =
166 return (detcabl_it->second);
169 const static std::vector<const FedChannelConnection *> default_empty_fedchannelconnection;
170 return default_empty_fedchannelconnection;
176 const std::vector<const FedChannelConnection *> &fcconns =
getConnections(det_id);
177 for (std::vector<const FedChannelConnection *>::const_iterator iconn = fcconns.begin(); iconn != fcconns.end();
179 if (((*iconn) !=
nullptr) && (((*iconn)->apvPairNumber()) == apv_pair)) {
187 return default_empty_fedchannelconnection;
192 const std::vector<const FedChannelConnection *> &fcconns =
getConnections(det_id);
193 if (!fcconns.empty()) {
196 for (
size_t i = 0;
i < fcconns.size(); ++
i)
198 return (fcconns.at(
i))->dcuId();
202 unsigned int default_zero_value = 0;
203 return default_zero_value;
209 const std::vector<const FedChannelConnection *> &fcconns =
getConnections(det_id);
210 if (!fcconns.empty()) {
213 for (
size_t i = 0;
i < fcconns.size(); ++
i) {
215 return fcconns.at(
i)->nApvPairs();
249 const std::map<uint32_t, std::vector<int>> &specific_connection,
250 std::map<int16_t, uint32_t> *connectionsToFill)
const {
251 for (
std::map<uint32_t, std::vector<int>>::const_iterator conn_it = specific_connection.begin();
252 conn_it != specific_connection.end();
254 uint32_t new_detid = conn_it->first;
255 std::vector<int> new_apv_vector = conn_it->second;
256 std::map<uint32_t, std::vector<int>>::iterator it = map_to_add_to.find(new_detid);
257 if (it == map_to_add_to.end()) {
258 std::sort(new_apv_vector.begin(),
259 new_apv_vector.end());
260 map_to_add_to.insert(std::make_pair(new_detid, new_apv_vector));
270 if (connectionsToFill) {
276 std::vector<int> existing_apv_vector = it->second;
277 for (std::vector<int>::iterator inew = new_apv_vector.begin(); inew != new_apv_vector.end(); ++inew) {
278 bool there_already =
false;
279 for (std::vector<int>::iterator iold = existing_apv_vector.begin(); iold != existing_apv_vector.end(); ++iold) {
280 if (*iold == *inew) {
281 there_already =
true;
285 if (!there_already) {
286 existing_apv_vector.push_back(*inew);
287 std::sort(existing_apv_vector.begin(),
288 existing_apv_vector.end());
300 const int subdet = detectorId.
subdetId();
318 uint16_t subDetLayer = layer;
320 if (subDet ==
"TID-")
322 else if (subDet ==
"TID+")
323 subDetLayer += 10 + 3;
324 else if (subDet ==
"TOB")
326 else if (subDet ==
"TEC-")
328 else if (subDet ==
"TEC+")
329 subDetLayer += 1000 + 9;
330 else if (subDet !=
"TIB") {
331 LogDebug(
"SiStripDetCabling") <<
"Error: Wrong subDet. Please use one of TIB, TID, TOB, TEC." << std::endl;
336 return found->second;
344 allToContiguous.clear();
345 std::vector<uint32_t>
all;
347 std::sort(all.begin(), all.end());
348 unsigned int contiguousIndex = 0;
349 for (std::vector<uint32_t>::const_iterator idet = all.begin(); idet != all.end(); ++idet) {
351 allToContiguous.insert(std::make_pair(*idet, contiguousIndex));
357 connectedToContiguous.clear();
360 std::sort(connected.begin(),
363 std::map<uint32_t, unsigned int> allToContiguous;
365 for (std::vector<uint32_t>::const_iterator idet = connected.begin(); idet != connected.end();
367 std::map<uint32_t, unsigned int>::iterator deco = allToContiguous.find(*idet);
368 if (deco != allToContiguous.end()) {
369 connectedToContiguous.insert(*deco);
379 std::map<uint32_t, std::vector<int>>::const_iterator it =
map.find(det_id);
380 return (it !=
map.end());
388 typedef std::vector<const FedChannelConnection *> Conns;
389 typedef std::map<uint32_t, Conns> ConnsMap;
392 ss <<
"[SiStripDetCabling::" << __func__ <<
"]" 393 <<
" Printing DET cabling for " <<
fullcabling_.size() <<
" modules " << std::endl;
394 for (; ii !=
jj; ++
ii) {
395 ss <<
"Printing " << ii->second.size() <<
" connections for DetId: " << ii->first << std::endl;
396 Conns::const_iterator iii = ii->second.begin();
397 Conns::const_iterator jjj = ii->second.end();
398 for (; iii != jjj; ++iii) {
399 if ((*iii)->isConnected()) {
403 ss << **iii << std::endl;
406 ss <<
"Number of connected: " << valid << std::endl <<
"Number of connections: " << total << std::endl;
410 for (
int connectionType = 0; connectionType < 3; ++connectionType) {
411 if (connectionType == 0)
412 ss <<
"Connected modules:" << std::endl;
413 else if (connectionType == 1)
414 ss <<
"Detected modules:" << std::endl;
416 ss <<
"Undetected modules:" << std::endl;
417 ss <<
"SubDet and layer\t modules" << std::endl;
418 std::map<int16_t, uint32_t>::const_iterator iter =
connectionCount[connectionType].begin();
420 uint32_t subDetLayer = iter->first;
421 uint32_t
modules = iter->second;
422 if (
int(subDetLayer / 10) == 0) {
423 ss <<
"TIB \t layer " << subDetLayer <<
" \t" << modules << std::endl;
424 }
else if (
int(subDetLayer / 100) == 0) {
425 int layer = subDetLayer % 10;
427 ss <<
"TID- \t disk " << layer <<
"\t" << modules << std::endl;
429 ss <<
"TID+ \t disk " << layer - 3 <<
"\t" << modules << std::endl;
430 }
else if (
int(subDetLayer / 1000) == 0) {
431 int layer = subDetLayer % 100;
432 ss <<
"TOB \t layer " << layer <<
" \t" << modules << std::endl;
434 int layer = subDetLayer % 100;
436 ss <<
"TEC- \t disk " << layer <<
" \t" << modules << std::endl;
438 ss <<
"TEC+ \t disk " << layer - 9 <<
" \t" << modules << std::endl;
ConnsConstIterRange detectedDevices() const
const FedChannelConnection & getConnection(uint32_t det_id, unsigned short apv_pair) const
void addActiveDetectorsRawIds(std::vector< uint32_t > &) const
std::map< uint32_t, std::vector< int > > const & connected() const
std::map< uint32_t, std::vector< const FedChannelConnection * > > fullcabling_
CaloTopology const * topology(0)
const unsigned int getDcuId(uint32_t det_id) const
static const uint32_t invalid32_
void addFromSpecificConnection(std::map< uint32_t, std::vector< int >> &, const std::map< uint32_t, std::vector< int >> &, std::map< int16_t, uint32_t > *connectionsToFill=nullptr) const
ConnsConstIterRange undetectedDevices() const
uint16_t apvPairNumber() const
unsigned int side(const DetId &id) const
bool IsConnected(const uint32_t &det_id) const
int16_t layerSearch(const uint32_t detId) const
const uint16_t & fedId() const
const SiStripFedCabling * fedCabling_
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
boost::iterator_range< ConnsConstIter > ConnsConstIterRange
const uint32_t & detId() const
Class containning control, module, detector and connection information, at the level of a FED channel...
FedsConstIterRange fedIds() const
uint32_t detNumber(const std::string &subDet, const uint16_t layer, const int connectionType) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool IsUndetected(const uint32_t &det_id) const
void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const
void getAllDetectorsContiguousIds(std::map< uint32_t, unsigned int > &) const
void addDevices(const FedChannelConnection &, std::map< uint32_t, std::vector< const FedChannelConnection * >> &)
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
std::map< uint32_t, std::vector< int > > connected_
void addNotConnectedAPVs(std::map< uint32_t, std::vector< int >> &) const
virtual ~SiStripDetCabling()
void addUnDetected(std::map< uint32_t, std::vector< int >> &) const
static const uint16_t invalid_
std::map< uint32_t, std::vector< int > > detected_
ConnsConstIterRange fedConnections(uint16_t fed_id) const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
std::map< uint32_t, std::vector< int > > undetected_
unsigned int layer(const DetId &id) const
bool IsInMap(const uint32_t &det_id, const std::map< uint32_t, std::vector< int >> &) const
const uint16_t nApvPairs(uint32_t det_id) const
void getActiveDetectorsContiguousIds(std::map< uint32_t, unsigned int > &) const
const TrackerTopology *const tTopo
std::map< int16_t, uint32_t > connectionCount[3]
void addConnected(std::map< uint32_t, std::vector< int >> &) const
void addAllDetectorsRawIds(std::vector< uint32_t > &vector_to_fill_with_detids) const
bool IsDetected(const uint32_t &det_id) const
void addDetected(std::map< uint32_t, std::vector< int >> &) const
void print(std::stringstream &) const
SiStripDetCabling(const TrackerTopology *const topology)