Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-17 23:36:00

0001 #include "CondFormats/SiPixelObjects/interface/SiPixelVCal.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 
0004 #include <algorithm>
0005 
0006 bool SiPixelVCal::putSlopeAndOffset(const uint32_t& pixid, float& slopeValue, float& offsetValue) {
0007   std::map<unsigned int, VCal>::const_iterator id = m_vcal.find(pixid);
0008   if (id != m_vcal.end()) {
0009     edm::LogError("SiPixelVCal") << "SiPixelVCal for pixid " << pixid << " is already stored. Skipping this put"
0010                                  << std::endl;
0011     return false;
0012   } else {
0013     m_vcal[pixid] = {slopeValue, offsetValue};
0014   }
0015   return true;
0016 }
0017 
0018 SiPixelVCal::VCal SiPixelVCal::getSlopeAndOffset(const uint32_t& pixid) const {
0019   std::map<unsigned int, VCal>::const_iterator id = m_vcal.find(pixid);
0020   if (id != m_vcal.end())
0021     return id->second;
0022   else
0023     edm::LogError("SiPixelVCal") << "SiPixelVCal for pixid " << pixid << " is not stored" << std::endl;
0024   VCal vcal_default;
0025   return vcal_default;
0026 }
0027 
0028 float SiPixelVCal::getSlope(const uint32_t& pixid) const {
0029   std::map<unsigned int, VCal>::const_iterator id = m_vcal.find(pixid);
0030   if (id != m_vcal.end())
0031     return id->second.slope;
0032   else
0033     edm::LogError("SiPixelVCal") << "SiPixelVCal slope for pixid " << pixid << " is not stored" << std::endl;
0034   return 47.;
0035 }
0036 
0037 float SiPixelVCal::getOffset(const uint32_t& pixid) const {
0038   std::map<unsigned int, VCal>::const_iterator id = m_vcal.find(pixid);
0039   if (id != m_vcal.end())
0040     return id->second.offset;
0041   else
0042     edm::LogError("SiPixelVCal") << "SiPixelVCal offset for pixid " << pixid << " is not stored" << std::endl;
0043   return -60.;
0044 }
0045 
0046 SiPixelVCal::mapToDetId SiPixelVCal::getAllSlopes() const {
0047   std::map<uint32_t, float> slopes;
0048   std::transform(m_vcal.begin(),
0049                  m_vcal.end(),
0050                  std::inserter(slopes, slopes.end()),
0051                  [](std::pair<uint32_t, SiPixelVCal::VCal> vcalentry) -> std::pair<uint32_t, float> {
0052                    return std::make_pair(vcalentry.first, vcalentry.second.slope);
0053                  });
0054   return slopes;
0055 }
0056 
0057 SiPixelVCal::mapToDetId SiPixelVCal::getAllOffsets() const {
0058   std::map<uint32_t, float> offsets;
0059   std::transform(m_vcal.begin(),
0060                  m_vcal.end(),
0061                  std::inserter(offsets, offsets.end()),
0062                  [](std::pair<uint32_t, SiPixelVCal::VCal> vcalentry) -> std::pair<uint32_t, float> {
0063                    return std::make_pair(vcalentry.first, vcalentry.second.offset);
0064                  });
0065   return offsets;
0066 }