CMS 3D CMS Logo

CastorCalibrationsSet.cc

Go to the documentation of this file.
00001 #include "CalibFormats/CastorObjects/interface/CastorCalibrationsSet.h"
00002 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
00003 #include "FWCore/Utilities/interface/Exception.h"
00004 #include <algorithm>
00005 
00006 
00007 CastorCalibrationsSet::CastorCalibrationsSet() 
00008   : sorted_ (false) {}
00009 
00010 const CastorCalibrations& CastorCalibrationsSet::getCalibrations(const DetId fId) const {
00011   Item target(fId);
00012   std::vector<Item>::const_iterator cell;
00013   if (sorted_) {
00014     cell = std::lower_bound (mItems.begin(), mItems.end(), target);
00015   }
00016   else {
00017     cell = std::find(mItems.begin(),mItems.end(), target);
00018   }
00019   if (cell == mItems.end() || cell->id != fId) 
00020     throw cms::Exception ("Conditions not found") << "Unavailable CastorCalibrations for cell " << HcalGenericDetId(fId);
00021   return cell->calib;
00022 }
00023 
00024 void CastorCalibrationsSet::setCalibrations(DetId fId, const CastorCalibrations& ca) {
00025   sorted_=false;
00026   std::vector<Item>::iterator cell=std::find(mItems.begin(),mItems.end(),Item(fId)); //slow, but guaranteed
00027   if (cell==mItems.end()) mItems.push_back(Item(fId));
00028   cell->calib=ca;
00029 }
00030 void CastorCalibrationsSet::sort () {
00031   if (!sorted_) {
00032     std::sort (mItems.begin(), mItems.end());
00033     sorted_ = true;
00034   }
00035 }
00036 void CastorCalibrationsSet::clear() {
00037   mItems.clear();
00038 }

Generated on Tue Jun 9 17:25:22 2009 for CMSSW by  doxygen 1.5.4