Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:20

0001 #include "CalibFormats/HcalObjects/interface/HcalCalibrationsSet.h"
0002 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
0003 #include "FWCore/Utilities/interface/Exception.h"
0004 #include <algorithm>
0005 #include <iostream>
0006 #include <utility>
0007 
0008 HcalCalibrationsSet::HcalCalibrationsSet() {}
0009 
0010 const HcalCalibrations& HcalCalibrationsSet::getCalibrations(const DetId fId) const {
0011   DetId fId2(hcalTransformedId(fId));
0012   auto cell = mItems.find(fId2);
0013   if ((cell == mItems.end()) || (!hcalEqualDetId(cell->first, fId2)))
0014     throw cms::Exception("Conditions not found") << "Unavailable HcalCalibrations for cell " << HcalGenericDetId(fId);
0015   return cell->second.calib;
0016 }
0017 
0018 void HcalCalibrationsSet::setCalibrations(DetId fId, const HcalCalibrations& ca) {
0019   DetId fId2(hcalTransformedId(fId));
0020   auto cell = mItems.find(fId2);
0021   if (cell == mItems.end()) {
0022     auto result = mItems.emplace(fId2, fId2);
0023     result.first->second.calib = ca;
0024     return;
0025   }
0026   cell->second.calib = ca;
0027 }
0028 
0029 void HcalCalibrationsSet::clear() { mItems.clear(); }
0030 
0031 std::vector<DetId> HcalCalibrationsSet::getAllChannels() const {
0032   std::vector<DetId> channels;
0033   channels.reserve(mItems.size());
0034   for (const auto& tmp : mItems) {
0035     channels.push_back(tmp.second.id);
0036   }
0037   return channels;
0038 }