Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-17 23:36:00

0001 #include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "CondFormats/SiStripObjects/interface/SiStripDetSummary.h"
0004 
0005 #include <algorithm>
0006 
0007 bool SiStripBadStrip::put(const uint32_t& DetId, Range input) {
0008   // put in SiStripBadStrip::v_badstrips of DetId
0009   Registry::iterator p = std::lower_bound(indexes.begin(), indexes.end(), DetId, SiStripBadStrip::StrictWeakOrdering());
0010   if (p != indexes.end() && p->detid == DetId) {
0011     edm::LogError("SiStripBadStrip") << "[" << __PRETTY_FUNCTION__ << "] SiStripBadStrip for DetID " << DetId
0012                                      << " is already stored. Skipping this put" << std::endl;
0013     return false;
0014   }
0015 
0016   size_t sd = input.second - input.first;
0017   DetRegistry detregistry;
0018   detregistry.detid = DetId;
0019   detregistry.ibegin = v_badstrips.size();
0020   detregistry.iend = v_badstrips.size() + sd;
0021   indexes.insert(p, detregistry);
0022 
0023   v_badstrips.insert(v_badstrips.end(), input.first, input.second);
0024   return true;
0025 }
0026 
0027 const SiStripBadStrip::Range SiStripBadStrip::getRange(const uint32_t DetId) const {
0028   // get SiStripBadStrip Range of DetId
0029 
0030   RegistryIterator p = std::lower_bound(indexes.begin(), indexes.end(), DetId, SiStripBadStrip::StrictWeakOrdering());
0031   if (p == indexes.end() || p->detid != DetId)
0032     return SiStripBadStrip::Range(v_badstrips.end(), v_badstrips.end());
0033   else {
0034     __builtin_prefetch((&v_badstrips.front()) + p->ibegin);
0035     __builtin_prefetch((&v_badstrips.front()) + p->ibegin + 24);
0036     __builtin_prefetch((&v_badstrips.front()) + p->iend - 24);
0037     return SiStripBadStrip::Range(v_badstrips.begin() + p->ibegin, v_badstrips.begin() + p->iend);
0038   }
0039 }
0040 
0041 SiStripBadStrip::Range SiStripBadStrip::getRangeByPos(unsigned short pos) const {
0042   if (pos > indexes.size())
0043     return Range(v_badstrips.end(), v_badstrips.end());
0044   auto p = indexes.begin() + pos;
0045   __builtin_prefetch((&v_badstrips.front()) + p->ibegin);
0046   __builtin_prefetch((&v_badstrips.front()) + p->ibegin + 24);
0047   __builtin_prefetch((&v_badstrips.front()) + p->iend - 24);
0048   return Range(v_badstrips.begin() + p->ibegin, v_badstrips.begin() + p->iend);
0049 }
0050 
0051 void SiStripBadStrip::getDetIds(std::vector<uint32_t>& DetIds_) const {
0052   // returns vector of DetIds in map
0053   SiStripBadStrip::RegistryIterator begin = indexes.begin();
0054   SiStripBadStrip::RegistryIterator end = indexes.end();
0055   for (SiStripBadStrip::RegistryIterator p = begin; p != end; ++p) {
0056     DetIds_.push_back(p->detid);
0057   }
0058 }
0059 
0060 void SiStripBadStrip::printSummary(std::stringstream& ss, const TrackerTopology* trackerTopo) const {
0061   SiStripDetSummary summaryBadModules{trackerTopo};
0062   SiStripDetSummary summaryBadStrips{trackerTopo};
0063 
0064   // Loop on the vector<DetRegistry> and take the bad modules and bad strips
0065   Registry::const_iterator it = indexes.begin();
0066   for (; it != indexes.end(); ++it) {
0067     summaryBadModules.add(it->detid);
0068     summaryBadStrips.add(it->iend - it->ibegin);
0069   }
0070   ss << "Summary of bad modules in detector:" << std::endl;
0071   summaryBadModules.print(ss, false);
0072   ss << "Summary of bad strip in detectors:" << std::endl;
0073   summaryBadStrips.print(ss, false);
0074 }
0075 
0076 void SiStripBadStrip::printDebug(std::stringstream& ss, const TrackerTopology* /*trackerTopo*/) const {
0077   ss << "Printing all bad strips for all DetIds" << std::endl;
0078   // Loop on the vector<DetRegistry> and take the bad modules and bad strips
0079   Registry::const_iterator it = indexes.begin();
0080   for (; it != indexes.end(); ++it) {
0081     //    ss << "For DetId = " << it->detid << std::endl;
0082     SiStripBadStrip::Range range(getRange(it->detid));
0083     for (std::vector<unsigned int>::const_iterator badStrip = range.first; badStrip != range.second; ++badStrip) {
0084       ss << "DetId=" << it->detid << " Strip=" << decode(*badStrip).firstStrip << ":" << decode(*badStrip).range
0085          << " flag=" << decode(*badStrip).flag << std::endl;
0086     }
0087   }
0088 }