CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PedestalsHistograms.cc
Go to the documentation of this file.
8 #include <iostream>
9 #include <memory>
10 
11 #include <sstream>
12 #include <iomanip>
13 #include "TProfile.h"
14 
15 using namespace std;
16 using namespace sistrip;
17 
18 // -----------------------------------------------------------------------------
21  : CommissioningHistograms(pset.getParameter<edm::ParameterSet>("PedestalsParameters"), bei, sistrip::PEDESTALS) {
22  factory_ = std::make_unique<PedestalsSummaryFactory>();
23  LogTrace(mlDqmClient_) << "[PedestalsHistograms::" << __func__ << "]"
24  << " Constructing object...";
25 }
26 
27 // -----------------------------------------------------------------------------
30  LogTrace(mlDqmClient_) << "[PedestalsHistograms::" << __func__ << "]"
31  << " Destructing object...";
32 }
33 
34 // -----------------------------------------------------------------------------
37  LogTrace(mlDqmClient_) << "[PedestalsHistograms::" << __func__ << "]";
38 
39  // Some initialisation
40  uint16_t valid = 0;
41  HistosMap::const_iterator iter;
42  Analyses::iterator ianal;
43  std::map<std::string, uint16_t> errors;
44 
45  // Clear map holding analysis objects
46  for (ianal = data().begin(); ianal != data().end(); ianal++) {
47  if (ianal->second) {
48  delete ianal->second;
49  }
50  }
51  data().clear();
52 
53  // Iterate through map containing histograms
54  for (iter = histos().begin(); iter != histos().end(); iter++) {
55  // Check vector of histos is not empty
56  if (iter->second.empty()) {
57  edm::LogWarning(mlDqmClient_) << "[PedestalsHistograms::" << __func__ << "]"
58  << " Zero histograms found!";
59  continue;
60  }
61 
62  // Retrieve pointers to profile histos
63  std::vector<TH1*> profs;
64  Histos::const_iterator ihis = iter->second.begin();
65  for (; ihis != iter->second.end(); ihis++) {
66  TProfile* prof = ExtractTObject<TProfile>().extract((*ihis)->me_);
67  if (prof) {
68  profs.push_back(prof);
69  }
70  //@@ Common mode histos?...
71  //TH1F* his = ExtractTObject<TH1F>().extract( (*ihis)->me_ );
72  //if ( his ) { profs.push_back(his); }
73  }
74 
75  // Perform histo analysis
76  PedestalsAnalysis* anal = new PedestalsAnalysis(iter->first);
77  PedestalsAlgorithm algo(this->pset(), anal);
78  algo.analysis(profs);
79  data()[iter->first] = anal;
80  if (anal->isValid()) {
81  valid++;
82  }
83  if (!anal->getErrorCodes().empty()) {
84  errors[anal->getErrorCodes()[0]]++;
85  }
86  }
87 
88  if (!histos().empty()) {
89  edm::LogVerbatim(mlDqmClient_) << "[PedestalsHistograms::" << __func__ << "]"
90  << " Analyzed histograms for " << histos().size() << " FED channels, of which "
91  << valid << " (" << 100 * valid / histos().size() << "%) are valid.";
92  if (!errors.empty()) {
93  uint16_t count = 0;
94  std::stringstream ss;
95  ss << std::endl;
96  std::map<std::string, uint16_t>::const_iterator ii;
97  for (ii = errors.begin(); ii != errors.end(); ++ii) {
98  ss << " " << ii->first << ": " << ii->second << std::endl;
99  count += ii->second;
100  }
101  edm::LogWarning(mlDqmClient_) << "[PedestalsHistograms::" << __func__ << "]"
102  << " Found " << count << " errors (" << 100 * count / histos().size()
103  << "%): " << ss.str();
104  }
105  } else {
106  edm::LogWarning(mlDqmClient_) << "[PedestalsHistograms::" << __func__ << "]"
107  << " No histograms to analyze!";
108  }
109 }
110 
111 // -----------------------------------------------------------------------------
114  Analyses::iterator ianal = data().begin();
115  Analyses::iterator janal = data().end();
116  for (; ianal != janal; ++ianal) {
117  if (ianal->second) {
118  std::stringstream ss;
119  ianal->second->print(ss, 1);
120  ianal->second->print(ss, 2);
121  if (ianal->second->isValid()) {
122  LogTrace(mlDqmClient_) << ss.str();
123  } else {
124  edm::LogWarning(mlDqmClient_) << ss.str();
125  }
126  }
127  }
128 }
void analysis(const std::vector< TH1 * > &)
void printAnalyses() override
Log< level::Info, true > LogVerbatim
PedestalsHistograms(const edm::ParameterSet &pset, DQMStore *)
Analyses & data(bool getMaskedData=false)
const edm::ParameterSet & pset() const
void histoAnalysis(bool debug) override
static const char mlDqmClient_[]
int ii
Definition: cuy.py:589
#define LogTrace(id)
Histogram-based analysis for pedestal run.
bool isValid() const override
int extract(std::vector< int > *output, const std::string &dati)
#define debug
Definition: HDRShower.cc:19
std::unique_ptr< Factory > factory_
Histogram-based analysis for pedestal run.
Log< level::Warning, false > LogWarning
const VString & getErrorCodes() const
const HistosMap & histos() const