File indexing completed on 2024-04-06 11:58:19
0001 #include "CalibFormats/SiStripObjects/interface/SiStripRegionCabling.h"
0002 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0003 #include "FWCore/Utilities/interface/typelookup.h"
0004
0005 using namespace sistrip;
0006
0007 SiStripRegionCabling::SiStripRegionCabling(const uint32_t etadivisions,
0008 const uint32_t phidivisions,
0009 const double etamax)
0010 :
0011
0012 etadivisions_(static_cast<int>(etadivisions)),
0013 phidivisions_(static_cast<int>(phidivisions)),
0014 etamax_(etamax),
0015 regioncabling_()
0016
0017 {}
0018
0019 const SiStripRegionCabling::PositionIndex SiStripRegionCabling::positionIndex(const Position position) const {
0020 int eta = static_cast<int>((position.first + etamax_) * etadivisions_ / (2. * etamax_));
0021 int phi = static_cast<int>((position.second + M_PI) * phidivisions_ / (2. * M_PI));
0022 return PositionIndex(static_cast<uint32_t>(eta), static_cast<uint32_t>(phi));
0023 }
0024
0025 const uint32_t SiStripRegionCabling::region(const Position position) const {
0026 PositionIndex index = positionIndex(position);
0027 return region(index);
0028 }
0029
0030 SiStripRegionCabling::PositionIndex SiStripRegionCabling::increment(const PositionIndex index,
0031 int deta,
0032 int dphi) const {
0033 int eta = static_cast<int>(index.first) + deta;
0034 if (eta > etadivisions_ - 1)
0035 eta = etadivisions_ - 1;
0036 else if (eta < 0)
0037 eta = 0;
0038
0039 int phi = static_cast<int>(index.second) + dphi;
0040 while (phi < 0)
0041 phi += phidivisions_;
0042 while (phi > phidivisions_ - 1)
0043 phi -= phidivisions_;
0044
0045 return PositionIndex(static_cast<uint32_t>(eta), static_cast<uint32_t>(phi));
0046 }
0047
0048 const SiStripRegionCabling::SubDet SiStripRegionCabling::subdetFromDetId(const uint32_t detid) {
0049 DetId detectorId = DetId(detid);
0050 if (detectorId.subdetId() == StripSubdetector::TIB)
0051 return TIB;
0052 else if (detectorId.subdetId() == StripSubdetector::TID)
0053 return TID;
0054 else if (detectorId.subdetId() == StripSubdetector::TOB)
0055 return TOB;
0056 else if (detectorId.subdetId() == StripSubdetector::TEC)
0057 return TEC;
0058 else
0059 return ALLSUBDETS;
0060 }
0061
0062
0063
0064 void SiStripRegionCabling::print(std::stringstream &ss) const {
0065 uint32_t valid = 0;
0066 uint32_t total = 0;
0067 ss << "[SiStripRegionCabling::" << __func__ << "] Printing REGION cabling:" << std::endl;
0068 ss << "Printing cabling for " << regioncabling_.size() << " regions" << std::endl;
0069 Cabling::const_iterator id = regioncabling_.begin();
0070 Cabling::const_iterator jd = regioncabling_.end();
0071 for (; id != jd; ++id) {
0072 ss << "Printing cabling for " << id->size() << " regions for partition "
0073 << static_cast<int32_t>(id - regioncabling_.begin()) << std::endl;
0074 RegionCabling::const_iterator ir = id->begin();
0075 RegionCabling::const_iterator jr = id->end();
0076 for (; ir != jr; ++ir) {
0077 ss << "Printing cabling for " << ir->size() << " wedges for region " << static_cast<int32_t>(ir - id->begin())
0078 << std::endl;
0079 WedgeCabling::const_iterator iw = ir->begin();
0080 WedgeCabling::const_iterator jw = ir->end();
0081 for (; iw != jw; ++iw) {
0082 ss << "Printing cabling for " << iw->size() << " elements for wedge " << static_cast<int32_t>(iw - ir->begin())
0083 << std::endl;
0084 ElementCabling::const_iterator ie = iw->begin();
0085 ElementCabling::const_iterator je = iw->end();
0086 for (; ie != je; ++ie) {
0087 ss << "Printing cabling for " << ie->second.size() << " connections for element (DetId) " << ie->first
0088 << std::endl;
0089 std::vector<FedChannelConnection>::const_iterator ic = ie->second.begin();
0090 std::vector<FedChannelConnection>::const_iterator jc = ie->second.end();
0091 for (; ic != jc; ++ic) {
0092 if (ic->isConnected()) {
0093 valid++;
0094 }
0095 total++;
0096 ic->print(ss);
0097 ss << std::endl;
0098 }
0099 }
0100 }
0101 }
0102 }
0103 ss << "Number of connected: " << valid << std::endl << "Number of connections: " << total << std::endl;
0104 }