CMS 3D CMS Logo

SiPixelVCal.cc
Go to the documentation of this file.
3 
4 #include <algorithm>
5 
6 bool SiPixelVCal::putSlopeAndOffset(const uint32_t& pixid, float& slopeValue, float& offsetValue) {
7  std::map<unsigned int, VCal>::const_iterator id = m_vcal.find(pixid);
8  if (id != m_vcal.end()) {
9  edm::LogError("SiPixelVCal") << "SiPixelVCal for pixid " << pixid << " is already stored. Skipping this put"
10  << std::endl;
11  return false;
12  } else {
13  m_vcal[pixid] = {slopeValue, offsetValue};
14  }
15  return true;
16 }
17 
18 SiPixelVCal::VCal SiPixelVCal::getSlopeAndOffset(const uint32_t& pixid) const {
19  std::map<unsigned int, VCal>::const_iterator id = m_vcal.find(pixid);
20  if (id != m_vcal.end())
21  return id->second;
22  else
23  edm::LogError("SiPixelVCal") << "SiPixelVCal for pixid " << pixid << " is not stored" << std::endl;
24  VCal vcal_default;
25  return vcal_default;
26 }
27 
28 float SiPixelVCal::getSlope(const uint32_t& pixid) const {
29  std::map<unsigned int, VCal>::const_iterator id = m_vcal.find(pixid);
30  if (id != m_vcal.end())
31  return id->second.slope;
32  else
33  edm::LogError("SiPixelVCal") << "SiPixelVCal slope for pixid " << pixid << " is not stored" << std::endl;
34  return 47.;
35 }
36 
37 float SiPixelVCal::getOffset(const uint32_t& pixid) const {
38  std::map<unsigned int, VCal>::const_iterator id = m_vcal.find(pixid);
39  if (id != m_vcal.end())
40  return id->second.offset;
41  else
42  edm::LogError("SiPixelVCal") << "SiPixelVCal offset for pixid " << pixid << " is not stored" << std::endl;
43  return -60.;
44 }
45 
47  std::map<uint32_t, float> slopes;
48  std::transform(m_vcal.begin(),
49  m_vcal.end(),
50  std::inserter(slopes, slopes.end()),
51  [](std::pair<uint32_t, SiPixelVCal::VCal> vcalentry) -> std::pair<uint32_t, float> {
52  return std::make_pair(vcalentry.first, vcalentry.second.slope);
53  });
54  return slopes;
55 }
56 
58  std::map<uint32_t, float> offsets;
59  std::transform(m_vcal.begin(),
60  m_vcal.end(),
61  std::inserter(offsets, offsets.end()),
62  [](std::pair<uint32_t, SiPixelVCal::VCal> vcalentry) -> std::pair<uint32_t, float> {
63  return std::make_pair(vcalentry.first, vcalentry.second.offset);
64  });
65  return offsets;
66 }
float getSlope(const uint32_t &) const
Definition: SiPixelVCal.cc:28
Log< level::Error, false > LogError
mapToDetId getAllOffsets() const
Definition: SiPixelVCal.cc:57
mapToDetId getAllSlopes() const
Definition: SiPixelVCal.cc:46
std::map< uint32_t, float > mapToDetId
Definition: SiPixelVCal.h:14
float getOffset(const uint32_t &) const
Definition: SiPixelVCal.cc:37
std::map< unsigned int, VCal > m_vcal
Definition: SiPixelVCal.h:39
const std::map< unsigned int, VCal > & getSlopeAndOffset() const
Definition: SiPixelVCal.h:23
void putSlopeAndOffset(std::map< unsigned int, VCal > &vcal)
Definition: SiPixelVCal.h:22
unsigned transform(const HcalDetId &id, unsigned transformCode)