Go to the documentation of this file.00001 #include <iostream>
00002
00003 #include "FWCore/Utilities/interface/Exception.h"
00004 #include "DQM/HcalMonitorClient/interface/HcalDQMChannelQuality.h"
00005
00006 HcalDQMChannelQuality::HcalDQMChannelQuality()
00007 : mSorted (false) {}
00008
00009 HcalDQMChannelQuality::~HcalDQMChannelQuality(){}
00010
00011 HcalDQMChannelQuality::Quality HcalDQMChannelQuality::quality (unsigned long fId, bool fWarning) const {
00012 Item target;
00013 target.mId = fId;
00014 std::vector<Item>::const_iterator cell;
00015 if (sorted ()) {
00016 cell = std::lower_bound (mItems.begin(), mItems.end(), target);
00017 }
00018 else {
00019 if (fWarning) std::cerr << "HcalDQMChannelQuality::quality-> container is not sorted. Sort it to search effectively" << std::endl;
00020 cell = std::find (mItems.begin(), mItems.end(), target);
00021 }
00022 if (cell == mItems.end() || cell->mId != fId)
00023 throw cms::Exception ("Conditions not found") << "Unavailable Quality for cell " << fId;
00024 return (HcalDQMChannelQuality::Quality) cell->mQuality;
00025 }
00026
00027 bool HcalDQMChannelQuality::isMasked (unsigned long fId, bool fWarning) const{
00028
00029 Item target;
00030 target.mId = fId;
00031 std::vector<Item>::const_iterator cell;
00032 if (sorted ()) {
00033 cell = std::lower_bound (mItems.begin(), mItems.end(), target);
00034 }
00035 else {
00036 if (fWarning) std::cerr << "HcalDQMChannelQuality::quality-> container is not sorted. Sort it to search effectively" << std::endl;
00037 cell = std::find (mItems.begin(), mItems.end(), target);
00038 }
00039 if (cell == mItems.end() || cell->mId != fId)
00040 throw cms::Exception ("Conditions not found") << "Unavailable Quality for cell " << fId;
00041 return cell->mMasked;
00042
00043 }
00044
00045 unsigned short HcalDQMChannelQuality::flagAlgo (unsigned long fId, bool fWarning) const{
00046
00047 Item target;
00048 target.mId = fId;
00049 std::vector<Item>::const_iterator cell;
00050 if (sorted ()) {
00051 cell = std::lower_bound (mItems.begin(), mItems.end(), target);
00052 }
00053 else {
00054 if (fWarning) std::cerr << "HcalDQMChannelQuality::quality-> container is not sorted. Sort it to search effectively" << std::endl;
00055 cell = std::find (mItems.begin(), mItems.end(), target);
00056 }
00057 if (cell == mItems.end() || cell->mId != fId)
00058 throw cms::Exception ("Conditions not found") << "Unavailable Quality for cell " << fId;
00059 return cell->mAlgo;
00060
00061 }
00062
00063 std::vector<unsigned long> HcalDQMChannelQuality::getAllChannels () const {
00064 std::vector<unsigned long> result;
00065 for (std::vector<Item>::const_iterator item = mItems.begin (); item != mItems.end (); item++) {
00066 result.push_back (item->mId);
00067 }
00068 return result;
00069 }
00070
00071 bool HcalDQMChannelQuality::setChannel (unsigned long fId, unsigned short fAlgo, Quality fQuality) {
00072 Item item;
00073 item.mId = fId;
00074 item.mAlgo = fAlgo;
00075 item.mMasked = maskCell(fQuality);
00076 item.mQuality = unsigned (fQuality);
00077 mSorted = false;
00078 return true;
00079 }
00080
00081 bool HcalDQMChannelQuality::maskCell(Quality fQuality) const {
00082 switch (fQuality) {
00083 case BAD: return true;
00084 case HOT: return true;
00085 case GOOD: return false;
00086 case COOL: return false;
00087 case DEAD: return false;
00088 case END: return false;
00089 default: return false;
00090 }
00091 }
00092
00093 void HcalDQMChannelQuality::sort () {
00094 if (!mSorted) {
00095 std::sort (mItems.begin(), mItems.end());
00096 mSorted = true;
00097 }
00098 }
00099
00100 const char* HcalDQMChannelQuality::str (Quality fQuality) {
00101 switch (fQuality) {
00102 case BAD: return "BAD";
00103 case GOOD: return "GOOD";
00104 case COOL: return "COOL";
00105 case HOT: return "HOT";
00106 case DEAD: return "DEAD";
00107 case END: return "END";
00108 default: return "UNKNOWN";
00109 }
00110 }