File indexing completed on 2024-04-06 12:02:28
0001 #include "CondFormats/PPSObjects/interface/CTPPSPixelGainCalibrations.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004
0005 void CTPPSPixelGainCalibrations::setGainCalibration(const uint32_t& detid, const CTPPSPixelGainCalibration& PixGains) {
0006 if (detid != PixGains.getDetId()) {
0007 CTPPSPixelGainCalibration newPixGains = PixGains;
0008 newPixGains.setIndexes(detid);
0009 edm::LogInfo("CTPPSPixelGainCalibrations")
0010 << "newPixGains detId = " << newPixGains.getDetId() << " ; iBegin = " << newPixGains.getIBegin()
0011 << " ; iEnd = " << newPixGains.getIEnd() << " ; nCols = " << newPixGains.getNCols()
0012 << " ; nRows =" << newPixGains.getNRows();
0013
0014 int npix = newPixGains.getIEnd();
0015
0016 if (npix != 0)
0017 edm::LogInfo("CTPPSPixelGainCalibrations")
0018 << "newPixGains Ped[0] = " << newPixGains.getPed(0) << " ; Gain[0] = " << newPixGains.getGain(0)
0019 << " ; dead = " << newPixGains.isDead(0) << " ; noisy = " << newPixGains.isNoisy(0);
0020 else
0021 edm::LogError("CTPPSPixelGainCalibrations")
0022 << "looks like setting gain calibrations did not work, npix is " << npix;
0023
0024 m_calibrations[detid] = newPixGains;
0025 }
0026
0027 else
0028 m_calibrations[detid] = PixGains;
0029 }
0030
0031 void CTPPSPixelGainCalibrations::setGainCalibration(const uint32_t& detid,
0032 const std::vector<float>& peds,
0033 const std::vector<float>& gains) {
0034 m_calibrations[detid] = CTPPSPixelGainCalibration(detid, peds, gains);
0035 }
0036
0037 void CTPPSPixelGainCalibrations::setGainCalibrations(const CalibMap& PixGainsCalibs) {
0038 m_calibrations = PixGainsCalibs;
0039 }
0040
0041 void CTPPSPixelGainCalibrations::setGainCalibrations(const std::vector<uint32_t>& detidlist,
0042 const std::vector<std::vector<float>>& peds,
0043 const std::vector<std::vector<float>>& gains) {
0044 int nids = detidlist.size();
0045 for (int detid = 0; detid < nids; ++detid) {
0046 const std::vector<float>& pedsvec = peds[detid];
0047 const std::vector<float>& gainsvec = gains[detid];
0048 m_calibrations[detid] = CTPPSPixelGainCalibration(detid, pedsvec, gainsvec);
0049 }
0050 }
0051
0052 const CTPPSPixelGainCalibration& CTPPSPixelGainCalibrations::getGainCalibration(
0053 const uint32_t& detid) const {
0054 CalibMap::const_iterator it = m_calibrations.find(detid);
0055 if (it == m_calibrations.end())
0056 throw cms::Exception("CTPPSPixelGainCalibrations: ") << " No gain calibrations defined for detid ";
0057
0058 return it->second;
0059 }