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 
10  if( m_probabilities.find(puBin) != m_probabilities.end()){
11  edm::LogWarning("SiPixelQualityProbabilities") << "PU bin: " << puBin <<" is already in the map!"<<std::endl;
12  return;
13  } else {
14  m_probabilities.emplace(puBin,theProbabilities);
15  }
16 }
17 
18 //****************************************************************************//
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  probabilityMap::const_iterator it = m_probabilities.find(puBin);
32 
33  if (it != m_probabilities.end()){
34  return it->second;
35  } else {
36  throw cms::Exception("SiPixelQualityProbabilities")<< "No Probabilities are defined for PU bin " << puBin << "\n";
37  }
38 
39 }
40 
41 
42 //****************************************************************************//
44 
45  edm::LogVerbatim("SiPixelQualityProbabilities")<<"SiPixelQualityProbabilities::printAll()";
46  edm::LogVerbatim("SiPixelQualityProbabilities")<<" ===================================================================================================================";
47  for(auto it = m_probabilities.begin(); it != m_probabilities.end() ; ++it){
48  edm::LogVerbatim("SiPixelQualityProbabilities")<< "PU :"<< it->first << " \n ";
49  for (const auto &entry : it->second){
50  edm::LogVerbatim("SiPixelQualityProbabilities")<<"SiPixelQuality snapshot: " << entry.first << " |probability: " << entry.second << std::endl;
51  }
52  }
53 
54 }
55 
56 //****************************************************************************//
57 void SiPixelQualityProbabilities::print(std::ostream & os) const {
58 
59  for(auto it = m_probabilities.begin(); it != m_probabilities.end() ; ++it){
60  os<< "PU :"<< it->first << " \n ";
61  for (const auto &entry : it->second){
62  os<<"SiPixelQuality snapshot: " << entry.first << " |probability: " << entry.second << std::endl;
63  }
64  }
65 
66 }
67 
68 
69 //****************************************************************************//
70 std::vector<unsigned int> SiPixelQualityProbabilities::getPileUpBins() const {
71  std::vector<unsigned int> bins;
72  bins.reserve(m_probabilities.size());
73 
74  for(auto it = m_probabilities.begin(); it != m_probabilities.end() ; ++it){
75  bins.push_back(it->first);
76  }
77  return bins;
78 }
79 
80 //****************************************************************************//
81 std::ostream & operator<<( std::ostream & os, SiPixelQualityProbabilities theProbabilities) {
82  std::stringstream ss;
83  theProbabilities.print( ss );
84  os << ss.str();
85  return os;
86 }
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)