20 : fullcabling_(), connected_(), detected_(), undetected_(), fedCabling_(&fedcabling), tTopo(topology) {
26 for (
auto ifed =
feds.begin(); ifed !=
feds.end(); ifed++) {
29 for (
auto iconn = conns.begin(); iconn != conns.end(); iconn++) {
33 bool have_fed_id = iconn->fedId();
34 std::vector<int> vector_of_connected_apvs;
37 int which_apv_pair = iconn->apvPairNumber();
46 if (iconn->i2cAddr(0))
47 vector_of_connected_apvs.push_back(2 * which_apv_pair + 0);
48 if (iconn->i2cAddr(1))
49 vector_of_connected_apvs.push_back(2 * which_apv_pair + 1);
51 if (!vector_of_connected_apvs.empty()) {
52 std::map<uint32_t, std::vector<int>> map_of_connected_apvs;
53 map_of_connected_apvs.insert(std::make_pair(iconn->detId(), vector_of_connected_apvs));
60 for (std::vector<FedChannelConnection>::const_iterator idtct = detected_fed_connections.begin();
61 idtct != detected_fed_connections.end();
64 bool have_fed_id = idtct->fedId();
65 std::vector<int> vector_of_detected_apvs;
67 int which_apv_pair = idtct->apvPairNumber();
69 if (idtct->i2cAddr(0))
70 vector_of_detected_apvs.push_back(2 * which_apv_pair + 0);
71 if (idtct->i2cAddr(1))
72 vector_of_detected_apvs.push_back(2 * which_apv_pair + 1);
74 if (!vector_of_detected_apvs.empty()) {
75 std::map<uint32_t, std::vector<int>> map_of_detected_apvs;
76 map_of_detected_apvs.insert(std::make_pair(idtct->detId(), vector_of_detected_apvs));
82 for (std::vector<FedChannelConnection>::const_iterator iudtct = undetected_fed_connections.begin();
83 iudtct != undetected_fed_connections.end();
86 bool have_fed_id = iudtct->fedId();
87 std::vector<int> vector_of_undetected_apvs;
89 int which_apv_pair = iudtct->apvPairNumber();
91 if (iudtct->i2cAddr(0))
92 vector_of_undetected_apvs.push_back(2 * which_apv_pair + 0);
93 if (iudtct->i2cAddr(1))
94 vector_of_undetected_apvs.push_back(2 * which_apv_pair + 1);
96 if (!vector_of_undetected_apvs.empty()) {
97 std::map<uint32_t, std::vector<int>> map_of_undetected_apvs;
98 map_of_undetected_apvs.insert(std::make_pair(iudtct->detId(), vector_of_undetected_apvs));
106 std::map<uint32_t, std::vector<const FedChannelConnection *>> &conns) {
110 edm::LogInfo(
"") <<
" SiStripDetCabling::addDevices for connection " 111 "associated to detid " 112 <<
conn.detId() <<
" apvPairNumber " <<
conn.apvPairNumber() <<
"the fedId is " <<
conn.fedId();
117 if (
conn.apvPairNumber() >= conns[
conn.detId()].size()) {
118 conns[
conn.detId()].resize(
conn.apvPairNumber() + 1);
137 vector_to_fill_with_detids.push_back(conn_it->first);
146 vector_to_fill_with_detids.push_back(conn_it->first);
150 vector_to_fill_with_detids.push_back(conn_it->first);
154 vector_to_fill_with_detids.push_back(conn_it->first);
162 uint32_t det_id)
const {
163 std::map<uint32_t, std::vector<const FedChannelConnection *>>::const_iterator detcabl_it =
167 return (detcabl_it->second);
170 const static std::vector<const FedChannelConnection *> default_empty_fedchannelconnection;
171 return default_empty_fedchannelconnection;
177 const std::vector<const FedChannelConnection *> &fcconns =
getConnections(det_id);
178 for (std::vector<const FedChannelConnection *>::const_iterator iconn = fcconns.begin(); iconn != fcconns.end();
180 if (((*iconn) !=
nullptr) && (((*iconn)->apvPairNumber()) == apv_pair)) {
188 return default_empty_fedchannelconnection;
193 const std::vector<const FedChannelConnection *> &fcconns =
getConnections(det_id);
194 if (!fcconns.empty()) {
197 for (
size_t i = 0;
i < fcconns.size(); ++
i)
199 return (fcconns.at(
i))->dcuId();
203 unsigned int default_zero_value = 0;
204 return default_zero_value;
210 const std::vector<const FedChannelConnection *> &fcconns =
getConnections(det_id);
211 if (!fcconns.empty()) {
214 for (
size_t i = 0;
i < fcconns.size(); ++
i) {
216 return fcconns.at(
i)->nApvPairs();
250 const std::map<uint32_t, std::vector<int>> &specific_connection,
251 std::map<int16_t, uint32_t> *connectionsToFill)
const {
252 for (
std::map<uint32_t, std::vector<int>>::const_iterator conn_it = specific_connection.begin();
253 conn_it != specific_connection.end();
255 uint32_t new_detid = conn_it->first;
256 std::vector<int> new_apv_vector = conn_it->second;
257 std::map<uint32_t, std::vector<int>>::iterator it = map_to_add_to.find(new_detid);
258 if (it == map_to_add_to.end()) {
260 new_apv_vector.end());
261 map_to_add_to.insert(std::make_pair(new_detid, new_apv_vector));
271 if (connectionsToFill) {
277 std::vector<int> existing_apv_vector = it->second;
278 for (std::vector<int>::iterator inew = new_apv_vector.begin(); inew != new_apv_vector.end(); ++inew) {
279 bool there_already =
false;
280 for (std::vector<int>::iterator iold = existing_apv_vector.begin(); iold != existing_apv_vector.end(); ++iold) {
281 if (*iold == *inew) {
282 there_already =
true;
286 if (!there_already) {
287 existing_apv_vector.push_back(*inew);
289 existing_apv_vector.end());
301 const int subdet = detectorId.
subdetId();
319 uint16_t subDetLayer =
layer;
321 if (subDet ==
"TID-")
323 else if (subDet ==
"TID+")
324 subDetLayer += 10 + 3;
325 else if (subDet ==
"TOB")
327 else if (subDet ==
"TEC-")
329 else if (subDet ==
"TEC+")
330 subDetLayer += 1000 + 9;
331 else if (subDet !=
"TIB") {
332 LogDebug(
"SiStripDetCabling") <<
"Error: Wrong subDet. Please use one of TIB, TID, TOB, TEC." << std::endl;
337 return found->second;
345 allToContiguous.clear();
346 std::vector<uint32_t>
all;
349 unsigned int contiguousIndex = 0;
350 for (std::vector<uint32_t>::const_iterator idet =
all.begin(); idet !=
all.end(); ++idet) {
352 allToContiguous.insert(std::make_pair(*idet, contiguousIndex));
358 connectedToContiguous.clear();
364 std::map<uint32_t, unsigned int> allToContiguous;
366 for (std::vector<uint32_t>::const_iterator idet =
connected.begin(); idet !=
connected.end();
368 std::map<uint32_t, unsigned int>::iterator deco = allToContiguous.find(*idet);
369 if (deco != allToContiguous.end()) {
370 connectedToContiguous.insert(*deco);
380 std::map<uint32_t, std::vector<int>>::const_iterator it =
map.find(det_id);
381 return (it !=
map.end());
389 typedef std::vector<const FedChannelConnection *> Conns;
390 typedef std::map<uint32_t, Conns> ConnsMap;
393 ss <<
"[SiStripDetCabling::" << __func__ <<
"]" 394 <<
" Printing DET cabling for " <<
fullcabling_.size() <<
" modules " << std::endl;
396 ss <<
"Printing " <<
ii->second.size() <<
" connections for DetId: " <<
ii->first << std::endl;
397 Conns::const_iterator iii =
ii->second.begin();
398 Conns::const_iterator jjj =
ii->second.end();
399 for (; iii != jjj; ++iii) {
400 if ((*iii)->isConnected()) {
404 ss << **iii << std::endl;
407 ss <<
"Number of connected: " <<
valid << std::endl <<
"Number of connections: " <<
total << std::endl;
411 for (
int connectionType = 0; connectionType < 3; ++connectionType) {
412 if (connectionType == 0)
413 ss <<
"Connected modules:" << std::endl;
414 else if (connectionType == 1)
415 ss <<
"Detected modules:" << std::endl;
417 ss <<
"Undetected modules:" << std::endl;
418 ss <<
"SubDet and layer\t modules" << std::endl;
419 std::map<int16_t, uint32_t>::const_iterator iter =
connectionCount[connectionType].begin();
421 uint32_t subDetLayer = iter->first;
422 uint32_t
modules = iter->second;
423 if (
int(subDetLayer / 10) == 0) {
424 ss <<
"TIB \t layer " << subDetLayer <<
" \t" <<
modules << std::endl;
425 }
else if (
int(subDetLayer / 100) == 0) {
426 int layer = subDetLayer % 10;
430 ss <<
"TID+ \t disk " <<
layer - 3 <<
"\t" <<
modules << std::endl;
431 }
else if (
int(subDetLayer / 1000) == 0) {
432 int layer = subDetLayer % 100;
435 int layer = subDetLayer % 100;
439 ss <<
"TEC+ \t disk " <<
layer - 9 <<
" \t" <<
modules << std::endl;
void addDetected(std::map< uint32_t, std::vector< int >> &) const
static constexpr auto TEC
void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const
const unsigned int getDcuId(uint32_t det_id) const
void addConnected(std::map< uint32_t, std::vector< int >> &) const
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
std::map< uint32_t, std::vector< const FedChannelConnection * > > fullcabling_
static const uint32_t invalid32_
std::map< uint32_t, std::vector< int > > const & connected() const
bool IsUndetected(const uint32_t &det_id) const
void addNotConnectedAPVs(std::map< uint32_t, std::vector< int >> &) const
unsigned int side(const DetId &id) const
bool IsConnected(const uint32_t &det_id) const
int16_t layerSearch(const uint32_t detId) const
unsigned int layer(const DetId &id) const
constexpr std::array< uint8_t, layerIndexSize > layer
const FedChannelConnection & getConnection(uint32_t det_id, unsigned short apv_pair) const
boost::iterator_range< ConnsConstIter > ConnsConstIterRange
bool IsInMap(const uint32_t &det_id, const std::map< uint32_t, std::vector< int >> &) const
Class containning control, module, detector and connection information, at the level of a FED channel...
void print(std::stringstream &) const
void getAllDetectorsContiguousIds(std::map< uint32_t, unsigned int > &) const
void addDevices(const FedChannelConnection &, std::map< uint32_t, std::vector< const FedChannelConnection *>> &)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
static constexpr auto TOB
std::map< uint32_t, std::vector< int > > connected_
Log< level::Info, false > LogInfo
virtual ~SiStripDetCabling()
bool IsDetected(const uint32_t &det_id) const
static constexpr auto TIB
void getActiveDetectorsContiguousIds(std::map< uint32_t, unsigned int > &) const
ConnsConstIterRange undetectedDevices() const
static const uint16_t invalid_
std::map< uint32_t, std::vector< int > > detected_
void addUnDetected(std::map< uint32_t, std::vector< int >> &) const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
std::map< uint32_t, std::vector< int > > undetected_
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
void addAllDetectorsRawIds(std::vector< uint32_t > &vector_to_fill_with_detids) const
const TrackerTopology *const tTopo
std::map< int16_t, uint32_t > connectionCount[3]
FedsConstIterRange fedIds() const
static constexpr auto TID
SiStripDetCabling(const TrackerTopology *const topology)
const uint16_t nApvPairs(uint32_t det_id) const
ConnsConstIterRange detectedDevices() const
ConnsConstIterRange fedConnections(uint16_t fed_id) const
uint32_t detNumber(const std::string &subDet, const uint16_t layer, const int connectionType) const
void addActiveDetectorsRawIds(std::vector< uint32_t > &) const