CMS 3D CMS Logo

CastorChannelQuality.cc

Go to the documentation of this file.
00001 
00007 #include <iostream>
00008 
00009 #include "FWCore/Utilities/interface/Exception.h"
00010 #include "CondFormats/CastorObjects/interface/CastorChannelQuality.h"
00011 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
00012 
00013 CastorChannelQuality::CastorChannelQuality() 
00014   : mSorted (false) {}
00015 
00016 CastorChannelQuality::~CastorChannelQuality(){}
00017 
00018 CastorChannelQuality::Quality CastorChannelQuality::quality (unsigned long fId, bool fWarning) const {
00019   Item target;
00020   target.mId = fId;
00021   std::vector<Item>::const_iterator cell;
00022   if (sorted ()) {
00023     cell = std::lower_bound (mItems.begin(), mItems.end(), target);
00024   }
00025   else {
00026     if (fWarning) std::cerr << "CastorChannelQuality::quality-> container is not sorted. Sort it to search effectively" << std::endl;
00027     cell = std::find (mItems.begin(), mItems.end(), target);
00028   }
00029   if (cell == mItems.end() || cell->mId != fId)
00030     throw cms::Exception ("Conditions not found") << "Unavailable Quality for cell " << HcalGenericDetId(fId);
00031   return (CastorChannelQuality::Quality) cell->mQuality;
00032 }
00033 
00034 std::vector<unsigned long> CastorChannelQuality::getAllChannels () const {
00035   std::vector<unsigned long> result;
00036   for (std::vector<Item>::const_iterator item = mItems.begin (); item != mItems.end (); item++) {
00037     result.push_back (item->mId);
00038   }
00039   return result;
00040 }
00041 
00042 bool CastorChannelQuality::setChannel (unsigned long fId, Quality fQuality) {
00043   Item item;
00044   item.mId = fId;
00045   item.mQuality = unsigned (fQuality);
00046   mSorted = false;
00047   return true;
00048 }
00049 
00050 void CastorChannelQuality::sort () {
00051   if (!mSorted) {
00052     std::sort (mItems.begin(), mItems.end());
00053     mSorted = true;
00054   }
00055 }
00056 
00057 const char* CastorChannelQuality::str (Quality fQuality) {
00058   switch (fQuality) {
00059   case BAD: return "BAD";
00060   case GOOD: return "GOOD";
00061   case HOT: return "HOT";
00062   case DEAD: return "DEAD";
00063   case END: return "END";
00064   default: return "UNKNOWN";
00065   }
00066 }

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