CMS 3D CMS Logo

SiPixelQualityProbabilities.cc
Go to the documentation of this file.
4 #include <iostream>
5 #include <iomanip> // std::setw
6 
7 //****************************************************************************//
8 void SiPixelQualityProbabilities::setProbabilities(const unsigned int puBin, const probabilityVec &theProbabilities) {
9  if (m_probabilities.find(puBin) != m_probabilities.end()) {
10  edm::LogWarning("SiPixelQualityProbabilities") << "PU bin: " << puBin << " is already in the map!" << std::endl;
11  return;
12  } else {
13  m_probabilities.emplace(puBin, theProbabilities);
14  }
15 }
16 
17 //****************************************************************************//
19  const unsigned int puBin) const {
20  probabilityMap::const_iterator it = m_probabilities.find(puBin);
21 
22  if (it != m_probabilities.end()) {
23  return it->second;
24  } else {
25  throw cms::Exception("SiPixelQualityProbabilities") << "No Probabilities are defined for PU bin " << puBin << "\n";
26  }
27 }
28 
29 //****************************************************************************//
31  const unsigned int puBin) {
32  probabilityMap::const_iterator it = m_probabilities.find(puBin);
33 
34  if (it != m_probabilities.end()) {
35  return it->second;
36  } else {
37  throw cms::Exception("SiPixelQualityProbabilities") << "No Probabilities are defined for PU bin " << puBin << "\n";
38  }
39 }
40 
41 //****************************************************************************//
43  edm::LogVerbatim("SiPixelQualityProbabilities") << "SiPixelQualityProbabilities::printAll()";
44  edm::LogVerbatim("SiPixelQualityProbabilities") << " ================================================================"
45  "===================================================";
46  for (auto it = m_probabilities.begin(); it != m_probabilities.end(); ++it) {
47  edm::LogVerbatim("SiPixelQualityProbabilities") << "PU :" << it->first << " \n ";
48  for (const auto &entry : it->second) {
49  edm::LogVerbatim("SiPixelQualityProbabilities")
50  << "SiPixelQuality snapshot: " << entry.first << " |probability: " << entry.second << std::endl;
51  }
52  }
53 }
54 
55 //****************************************************************************//
56 void SiPixelQualityProbabilities::print(std::ostream &os) const {
57  for (auto it = m_probabilities.begin(); it != m_probabilities.end(); ++it) {
58  os << "PU :" << it->first << " \n ";
59  for (const auto &entry : it->second) {
60  os << "SiPixelQuality snapshot: " << entry.first << " |probability: " << entry.second << std::endl;
61  }
62  }
63 }
64 
65 //****************************************************************************//
66 std::vector<unsigned int> SiPixelQualityProbabilities::getPileUpBins() const {
67  std::vector<unsigned int> bins;
68  bins.reserve(m_probabilities.size());
69 
70  for (auto it = m_probabilities.begin(); it != m_probabilities.end(); ++it) {
71  bins.push_back(it->first);
72  }
73  return bins;
74 }
75 
76 //****************************************************************************//
77 std::ostream &operator<<(std::ostream &os, SiPixelQualityProbabilities theProbabilities) {
78  std::stringstream ss;
79  theProbabilities.print(ss);
80  os << ss.str();
81  return os;
82 }
void print(std::ostream &os) const
probabilityVec getProbabilities(const unsigned int puBin) const
void setProbabilities(const unsigned int puBin, const probabilityVec &theProbabilities)
std::vector< std::pair< std::string, float > > probabilityVec
std::vector< unsigned int > getPileUpBins() const
std::ostream & operator<<(std::ostream &os, SiPixelQualityProbabilities theProbabilities)