CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CondFormats/SiPixelObjects/src/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 #include <algorithm>
00006 
00007 using namespace edm; 
00008 using namespace std; 
00009 
00010 
00011 SiPixelPerformanceSummary::SiPixelPerformanceSummary() 
00012                          : timeStamp_(0), runNumber_(0), luminosityBlock_(0), numberOfEvents_(0) {}
00013 
00014 
00015 SiPixelPerformanceSummary::SiPixelPerformanceSummary(const SiPixelPerformanceSummary& performanceSummary) {
00016         timeStamp_ = performanceSummary.getTimeStamp();
00017         runNumber_ = performanceSummary.getRunNumber();
00018   luminosityBlock_ = performanceSummary.getLuminosityBlock();
00019    numberOfEvents_ = performanceSummary.getNumberOfEvents(); 
00020   allDetSummaries_ = performanceSummary.getAllDetSummaries();
00021 }
00022 
00023 
00024 SiPixelPerformanceSummary::~SiPixelPerformanceSummary() {}
00025 
00026 
00027 void SiPixelPerformanceSummary::clear() {
00028   timeStamp_=0; runNumber_=0; luminosityBlock_=0; numberOfEvents_=0; allDetSummaries_.clear(); 
00029 }
00030 
00031 
00032 pair<bool, vector<SiPixelPerformanceSummary::DetSummary>::iterator> 
00033                   SiPixelPerformanceSummary::initDet(const uint32_t detId) { 
00034   vector<float> performanceValues; 
00035   for (int i=0; i<kDetSummarySize; ++i) performanceValues.push_back(kDefaultValue);
00036   return setDet(detId, performanceValues);
00037 }
00038 
00039 
00040 pair<bool, vector<SiPixelPerformanceSummary::DetSummary>::iterator> 
00041                   SiPixelPerformanceSummary::setDet(const uint32_t detId, 
00042                                                     const vector<float>& performanceValues) {
00043   vector<DetSummary>::iterator iDetSumm = allDetSummaries_.end();
00044   
00045   if (performanceValues.size()!=kDetSummarySize) { // for inappropriate input
00046     cout << "not adding these "<< performanceValues.size() << " values; " 
00047          << "SiPixelPerformanceSummary can only add "<< kDetSummarySize <<" values per DetSummary";
00048     return make_pair(false, iDetSumm);
00049   }
00050   iDetSumm = lower_bound(allDetSummaries_.begin(), allDetSummaries_.end(), 
00051                          detId, SiPixelPerformanceSummary::StrictWeakOrdering()); 
00052   
00053   if (iDetSumm!=allDetSummaries_.end() && // for an existong entry 
00054       iDetSumm->detId_==detId) return make_pair(false, iDetSumm); 
00055   
00056   DetSummary newDetSumm; // for a new entry, put at (position-1) returned by StrictWeakOrdering
00057              newDetSumm.detId_ = detId; 
00058              newDetSumm.performanceValues_ = performanceValues;
00059   return make_pair(true, allDetSummaries_.insert(iDetSumm, newDetSumm));
00060 }
00061 
00062 
00063 bool SiPixelPerformanceSummary::setValue(uint32_t detId, int index, float performanceValue) {
00064   if (index>kDetSummarySize) {
00065     cout << "cannot set the performance value for index = "<< index <<" > "<< kDetSummarySize;
00066     return false;
00067   }
00068   pair<bool, vector<DetSummary>::iterator> initResult = initDet(detId);
00069   if (initResult.first || initResult.second!=allDetSummaries_.end()) { 
00070     initResult.second->performanceValues_[index] = performanceValue;
00071     return true;
00072   }
00073   else {
00074     cout << "cannot set the performance value; cannot create new entry for detId = "<< detId;
00075     return false; 
00076   }
00077   return true;
00078 }
00079 
00080 
00081 float SiPixelPerformanceSummary::getValue(uint32_t detId, int index) {
00082   if (index>kDetSummarySize) {
00083     cout << "cannot get value for detId = "<< detId <<" index = "<< index <<" > "<< kDetSummarySize; 
00084     return kDefaultValue;
00085   }
00086   vector<float> performanceValues = getDetSummary(detId);
00087   if (performanceValues.size()==kDetSummarySize) return performanceValues[index]; 
00088   else return kDefaultValue; 
00089 }
00090 
00091 
00092 bool SiPixelPerformanceSummary::setRawDataErrorType(uint32_t detId, int bin, float nErrors) {
00093   return  setValue(detId, bin, nErrors);
00094 }
00095 
00096 
00097 bool SiPixelPerformanceSummary::setNumberOfDigis(uint32_t detId, float mean, float rms, float emPtn) {
00098   return (setValue(detId, 15, mean) && setValue(detId, 16, rms) && setValue(detId, 17, emPtn)); 
00099 }
00100 
00101 bool SiPixelPerformanceSummary::setADC(uint32_t detId, float mean, float rms, float emPtn) {
00102   return (setValue(detId, 18, mean) && setValue(detId, 19, rms) && setValue(detId, 20, emPtn)); 
00103 }
00104 
00105 
00106 bool SiPixelPerformanceSummary::setNumberOfClusters(uint32_t detId, float mean, float rms, float emPtn) {
00107   return (setValue(detId, 21, mean) && setValue(detId, 22, rms) && setValue(detId, 23, emPtn)); 
00108 }
00109 
00110 bool SiPixelPerformanceSummary::setClusterCharge(uint32_t detId, float mean, float rms, float emPtn) {
00111   return (setValue(detId, 24, mean) && setValue(detId, 25, rms) && setValue(detId, 26, emPtn)); 
00112 }
00113 
00114 bool SiPixelPerformanceSummary::setClusterSize(uint32_t detId, float mean, float rms, float emPtn) {
00115   return (setValue(detId, 27, mean) && setValue(detId, 28, rms) && setValue(detId, 29, emPtn)); 
00116 }
00117 
00118 bool SiPixelPerformanceSummary::setClusterSizeX(uint32_t detId, float mean, float rms, float emPtn) {
00119   return (setValue(detId, 30, mean) && setValue(detId, 31, rms) && setValue(detId, 32, emPtn)); 
00120 }
00121 
00122 bool SiPixelPerformanceSummary::setClusterSizeY(uint32_t detId, float mean, float rms, float emPtn) {
00123   return (setValue(detId, 33, mean) && setValue(detId, 34, rms) && setValue(detId, 35, emPtn)); 
00124 }
00125 
00126 
00127 bool SiPixelPerformanceSummary::setNumberOfRecHits(uint32_t detId, float mean, float rms, float emPtn) {
00128   return (setValue(detId, 36, mean) && setValue(detId, 37, rms) && setValue(detId, 38, emPtn)); 
00129 }
00130 
00131 
00132 bool SiPixelPerformanceSummary::setResidualX(uint32_t detId, float mean, float rms, float emPtn) {
00133   return (setValue(detId, 39, mean) && setValue(detId, 40, rms) && setValue(detId, 41, emPtn)); 
00134 }
00135 
00136 bool SiPixelPerformanceSummary::setResidualY(uint32_t detId, float mean, float rms, float emPtn) {
00137   return (setValue(detId, 42, mean) && setValue(detId, 43, rms) && setValue(detId, 44, emPtn)); 
00138 }
00139 
00140 
00141 bool SiPixelPerformanceSummary::setNumberOfNoisCells(uint32_t detId, float nNpixCells) {
00142   return  setValue(detId, 45, nNpixCells); 
00143 }
00144 
00145 bool SiPixelPerformanceSummary::setNumberOfDeadCells(uint32_t detId, float nNpixCells) {
00146   return  setValue(detId, 46, nNpixCells); 
00147 }
00148 
00149 bool SiPixelPerformanceSummary::setNumberOfPixelHitsInTrackFit(uint32_t detId, float nPixelHits) {
00150   return  setValue(detId, 47, nPixelHits); 
00151 }
00152 
00153 bool SiPixelPerformanceSummary::setFractionOfTracks(uint32_t detId, float mean, float rms) {
00154   return (setValue(detId, 48, mean) && setValue(detId, 49, rms)); 
00155 }
00156 
00157 bool SiPixelPerformanceSummary::setNumberOfOnTrackClusters(uint32_t detId, float nClusters) {
00158   return setValue(detId, 50, nClusters); 
00159 }
00160 
00161 bool SiPixelPerformanceSummary::setNumberOfOffTrackClusters(uint32_t detId, float nClusters) {
00162   return setValue(detId, 51, nClusters); 
00163 }
00164 
00165 bool SiPixelPerformanceSummary::setClusterChargeOnTrack(uint32_t detId, float mean, float rms) {
00166   return (setValue(detId, 52, mean) && setValue(detId, 53, rms)); 
00167 }
00168 
00169 bool SiPixelPerformanceSummary::setClusterChargeOffTrack(uint32_t detId, float mean, float rms) {
00170   return (setValue(detId, 54, mean) && setValue(detId, 55, rms)); 
00171 }
00172 
00173 bool SiPixelPerformanceSummary::setClusterSizeOnTrack(uint32_t detId, float mean, float rms) {
00174   return (setValue(detId, 56, mean) && setValue(detId, 57, rms)); 
00175 }
00176 
00177 bool SiPixelPerformanceSummary::setClusterSizeOffTrack(uint32_t detId, float mean, float rms) {
00178   return (setValue(detId, 58, mean) && setValue(detId, 59, rms)); 
00179 }
00180 
00181 vector<uint32_t> SiPixelPerformanceSummary::getAllDetIds() const {
00182   vector<uint32_t> allDetIds; 
00183   for (vector<DetSummary>::const_iterator iDetSumm = allDetSummaries_.begin(); 
00184        iDetSumm!=allDetSummaries_.end(); ++iDetSumm) allDetIds.push_back(iDetSumm->detId_); 
00185   return allDetIds; 
00186 }
00187 
00188 
00189 vector<float> SiPixelPerformanceSummary::getDetSummary(const uint32_t detId) const {
00190   vector<DetSummary>::const_iterator iDetSumm = find_if(allDetSummaries_.begin(), 
00191                                                         allDetSummaries_.end(), 
00192                                                         MatchDetSummaryDetId(detId));
00193   if (iDetSumm==allDetSummaries_.end()) { 
00194     vector<float> performanceValues; 
00195     cout << "cannot get DetSummary for detId = "<< detId; 
00196     return performanceValues; 
00197   }
00198   else return iDetSumm->performanceValues_; 
00199 }
00200 
00201 
00202 void SiPixelPerformanceSummary::print(const uint32_t detId) const {
00203   vector<float> performanceValues = getDetSummary(detId);   
00204   cout << "DetSummary for detId "<< detId <<" : ";
00205   for (vector<float>::const_iterator v = performanceValues.begin(); v!=performanceValues.end(); ++v) cout <<" "<< *v; 
00206   cout << endl;
00207 }
00208 
00209 
00210 void SiPixelPerformanceSummary::print() const {
00211   cout << "SiPixelPerformanceSummary size (allDets) = "<< allDetSummaries_.size() << ", "
00212        << "time stamp = "<< timeStamp_ << ", "
00213        << "run number = "<< runNumber_ << ", "
00214        << "luminosity section = "<< luminosityBlock_ << ", "
00215        << "number of events = "<< numberOfEvents_ << endl;
00216 }
00217 
00218 
00219 void SiPixelPerformanceSummary::printAll() const {
00220   print();
00221   for (vector<DetSummary>::const_iterator iDetSumm = allDetSummaries_.begin(); 
00222        iDetSumm!=allDetSummaries_.end(); ++iDetSumm) print(iDetSumm->detId_); 
00223 }