CMS 3D CMS Logo

SiPixelPerformanceSummary.cc

Go to the documentation of this file.
00001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00002 
00003 #include "CondFormats/SiPixelObjects/interface/SiPixelPerformanceSummary.h"
00004 
00005 
00006 SiPixelPerformanceSummary::SiPixelPerformanceSummary() : runNumber_(0), timeValue_(0) {}
00007 
00008 
00009 SiPixelPerformanceSummary::SiPixelPerformanceSummary(const SiPixelPerformanceSummary& spps) {
00010   runNumber_ = spps.getRunNumber();
00011   timeValue_ = spps.getTimeValue();
00012   allDetSummaries_ = spps.getAllDetSummaries();
00013 }
00014 
00015 
00016 SiPixelPerformanceSummary::~SiPixelPerformanceSummary() {}
00017 
00018 
00019 std::pair<bool, std::vector<SiPixelPerformanceSummary::DetSummary>::iterator> 
00020                 SiPixelPerformanceSummary::initDet(const uint32_t detId) { 
00021   std::vector<float> performanceValues; 
00022   for (int i=0; i<kDetSummarySize; ++i) performanceValues.push_back(kDefaultValue);
00023   return setDet(detId, performanceValues);
00024 }
00025 
00026 
00027 std::pair<bool, std::vector<SiPixelPerformanceSummary::DetSummary>::iterator> 
00028                 SiPixelPerformanceSummary::setDet(const uint32_t detId, 
00029                                                   const std::vector<float>& performanceValues) {
00030   std::vector<DetSummary>::iterator iDetSum = allDetSummaries_.end();
00031   
00032   if (performanceValues.size()!=kDetSummarySize) { // for inappropriate input
00033     edm::LogError("Error") << "wrong input size = "<< performanceValues.size() 
00034                            <<" can only add "<< kDetSummarySize 
00035                            <<" values; NOT adding to SiPixelPerformanceSummary";
00036     return std::make_pair(false, iDetSum);
00037   }
00038   iDetSum = std::lower_bound(allDetSummaries_.begin(), allDetSummaries_.end(), 
00039                              detId, SiPixelPerformanceSummary::StrictWeakOrdering());
00040 
00041   if (iDetSum!=allDetSummaries_.end() && // for an existong entry 
00042       iDetSum->detId_==detId) return std::make_pair(false, iDetSum); 
00043 
00044   
00045   DetSummary detSummary; // for a new entry, put at (position-1) returned by StrictWeakOrdering(?) 
00046              detSummary.detId_ = detId;
00047              detSummary.performanceValues_ = performanceValues;
00048   return std::make_pair(true, allDetSummaries_.insert(iDetSum, detSummary));
00049 }
00050 
00051 
00052 bool SiPixelPerformanceSummary::setValue(uint32_t detId, int index, float performanceValue) {
00053   if (index>kDetSummarySize) {
00054     edm::LogError("SetError") << "could not set the performance value for index = "<< index <<" > "<< kDetSummarySize;
00055     return false;
00056   }
00057   std::pair<bool, std::vector<DetSummary>::iterator> initResult = initDet(detId);
00058   if (initResult.first==true || initResult.second!=allDetSummaries_.end()) { 
00059     initResult.second->performanceValues_[index] = performanceValue;
00060     return true;
00061   }
00062   else {
00063     edm::LogError("SetError") << "could not set the performance value; " 
00064                               << "new entry could not be created for detId = "<< detId;
00065     return false; 
00066   }
00067   return true;
00068 }
00069 
00070 
00071 float SiPixelPerformanceSummary::getValue(uint32_t detId, int index) {
00072   if (index>kDetSummarySize) {
00073     edm::LogError("GetError") << "could not get values for index = "<< index <<" > "<< kDetSummarySize;
00074     return kDefaultValue;
00075   }
00076   std::vector<float> performanceValues; 
00077   performanceValues.clear();
00078   getDetSummary(detId, performanceValues);
00079   if (performanceValues.size()==kDetSummarySize) return performanceValues[index]; 
00080   else return kDefaultValue; 
00081 }
00082 
00083 
00084 bool SiPixelPerformanceSummary::setNumberOfDigis(uint32_t detId, float mean, float RMS) {
00085   bool mSet = setValue(detId, 0, mean);
00086   bool rSet = setValue(detId, 1, RMS);
00087   return (mSet && rSet); 
00088 }
00089 
00090 
00091 bool SiPixelPerformanceSummary::setNoisePercentage(uint32_t detId, float percentage) {
00092   return setValue(detId, 2, percentage);
00093 }
00094 
00095 
00096 void SiPixelPerformanceSummary::getAllDetIds(std::vector<uint32_t>& allDetIds) const {
00097   std::vector<DetSummary>::const_iterator begin = allDetSummaries_.begin();
00098   std::vector<DetSummary>::const_iterator end = allDetSummaries_.end();
00099   for (std::vector<DetSummary>::const_iterator iDetSum=begin; 
00100        iDetSum!=end; ++iDetSum) allDetIds.push_back(iDetSum->detId_);
00101 }
00102 
00103 
00104 void SiPixelPerformanceSummary::getDetSummary(const uint32_t detId, std::vector<float>& performanceValues) const {
00105   std::vector<DetSummary>::const_iterator iDetSum = std::find_if(allDetSummaries_.begin(), 
00106                                                                  allDetSummaries_.end(), 
00107                                                                  MatchDetSummaryDetId(detId));
00108   if (iDetSum==allDetSummaries_.end()) edm::LogError("get") << "cannot find any detSummary for detId = "<< detId;
00109   else performanceValues = iDetSum->performanceValues_; 
00110 }
00111 
00112 
00113 void SiPixelPerformanceSummary::print() const {
00114   edm::LogInfo("print") << "SiPixelPerformanceSummary size = "<< allDetSummaries_.size() 
00115                         << "; run number = "<< runNumber_ << "; time value = "<< timeValue_ << std::endl;
00116 }
00117 
00118 
00119 void SiPixelPerformanceSummary::print(const uint32_t detId) const {
00120   std::vector<DetSummary>::const_iterator iDetSum = std::find_if(allDetSummaries_.begin(), 
00121                                                                  allDetSummaries_.end(), 
00122                                                                  MatchDetSummaryDetId(detId));
00123   if (iDetSum==allDetSummaries_.end()) edm::LogError("print") << "cannot find any DetSummary for detId = "<< detId; 
00124   else {
00125     edm::LogInfo("print") << "detId = "<< detId <<" detSummary for detId = "<< iDetSum->detId_;
00126     print(iDetSum->performanceValues_);
00127   }
00128 }
00129 
00130 
00131 void SiPixelPerformanceSummary::print(const std::vector<float>& performanceValues) const {
00132  for (std::vector<float>::const_iterator iPV=performanceValues.begin(); 
00133                                          iPV!=performanceValues.end(); ++iPV) std::cout <<" "<< *iPV;
00134  std::cout << std::endl;
00135 }
00136 
00137 
00138 void SiPixelPerformanceSummary::printall() const {
00139   print();
00140   std::vector<DetSummary>::const_iterator begin = allDetSummaries_.begin();
00141   std::vector<DetSummary>::const_iterator end = allDetSummaries_.end();
00142   for (std::vector<DetSummary>::const_iterator iDetSum=begin; iDetSum!=end; ++iDetSum) {
00143     std::cout <<" detId = "<< iDetSum->detId_;
00144     print(iDetSum->performanceValues_);
00145   }
00146 }

Generated on Tue Jun 9 17:26:47 2009 for CMSSW by  doxygen 1.5.4