CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/CondFormats/SiStripObjects/src/SiStripBadStrip.cc

Go to the documentation of this file.
00001 #include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 #include "CondFormats/SiStripObjects/interface/SiStripDetSummary.h"
00004 
00005 #include <algorithm>
00006 
00007 bool SiStripBadStrip::put(const uint32_t& DetId, Range input) {
00008   // put in SiStripBadStrip::v_badstrips of DetId
00009   Registry::iterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiStripBadStrip::StrictWeakOrdering());
00010   if (p!=indexes.end() && p->detid==DetId){
00011     edm::LogError("SiStripBadStrip") << "[" << __PRETTY_FUNCTION__ << "] SiStripBadStrip for DetID " << DetId << " is already stored. Skippig this put" << std::endl;
00012     return false;
00013   }
00014   
00015   size_t sd= input.second-input.first;
00016   DetRegistry detregistry;
00017   detregistry.detid=DetId;
00018   detregistry.ibegin=v_badstrips.size();
00019   detregistry.iend=v_badstrips.size()+sd;
00020   indexes.insert(p,detregistry);
00021 
00022   v_badstrips.insert(v_badstrips.end(),input.first,input.second);
00023   return true;
00024 }
00025 
00026 const SiStripBadStrip::Range SiStripBadStrip::getRange(const uint32_t& DetId) const {
00027   // get SiStripBadStrip Range of DetId
00028   
00029   RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiStripBadStrip::StrictWeakOrdering());
00030   if (p==indexes.end()|| p->detid!=DetId) 
00031     return SiStripBadStrip::Range(v_badstrips.end(),v_badstrips.end()); 
00032   else 
00033     return SiStripBadStrip::Range(v_badstrips.begin()+p->ibegin,v_badstrips.begin()+p->iend);
00034 }
00035 
00036 
00037 void SiStripBadStrip::getDetIds(std::vector<uint32_t>& DetIds_) const {
00038   // returns vector of DetIds in map
00039   SiStripBadStrip::RegistryIterator begin = indexes.begin();
00040   SiStripBadStrip::RegistryIterator end   = indexes.end();
00041   for (SiStripBadStrip::RegistryIterator p=begin; p != end; ++p) {
00042     DetIds_.push_back(p->detid);
00043   }
00044 }
00045 
00046 void SiStripBadStrip::printSummary(std::stringstream & ss) const {
00047   SiStripDetSummary summaryBadModules;
00048   SiStripDetSummary summaryBadStrips;
00049 
00050   // Loop on the vector<DetRegistry> and take the bad modules and bad strips
00051   Registry::const_iterator it = indexes.begin();
00052   for( ; it!=indexes.end(); ++it ) {
00053     summaryBadModules.add(it->detid);
00054     summaryBadStrips.add(it->iend - it->ibegin);
00055   }
00056   ss << "Summary of bad modules in detector:" << std::endl;
00057   summaryBadModules.print(ss, false);
00058   ss << "Summary of bad strip in detectors:" << std::endl;
00059   summaryBadStrips.print(ss, false);
00060 }
00061 
00062 void SiStripBadStrip::printDebug(std::stringstream & ss) const {
00063   ss << "Printing all bad strips for all DetIds" << std::endl;
00064   // Loop on the vector<DetRegistry> and take the bad modules and bad strips
00065   Registry::const_iterator it = indexes.begin();
00066   for( ; it!=indexes.end(); ++it ) {
00067     ss << "For DetId = " << it->detid << std::endl;
00068     SiStripBadStrip::Range range(getRange(it->detid));
00069     for( std::vector<unsigned int>::const_iterator badStrip = range.first;
00070          badStrip != range.second; ++badStrip ) {
00071       ss << "strip: " << *badStrip << std::endl;
00072     }
00073   }
00074 }