CMS 3D CMS Logo

OptoScanHistograms.cc
Go to the documentation of this file.
8 #include "TProfile.h"
9 #include <iostream>
10 #include <sstream>
11 #include <iomanip>
12 
13 using namespace std;
14 using namespace sistrip;
15 
16 // -----------------------------------------------------------------------------
19  : CommissioningHistograms(pset.getParameter<edm::ParameterSet>("OptoScanParameters"), bei, sistrip::OPTO_SCAN) {
20  factory_ = unique_ptr<OptoScanSummaryFactory>(new OptoScanSummaryFactory);
21  LogTrace(mlDqmClient_) << "[OptoScanHistograms::" << __func__ << "]"
22  << " Constructing object...";
23 }
24 
25 // -----------------------------------------------------------------------------
28  LogTrace(mlDqmClient_) << "[OptoScanHistograms::" << __func__ << "]"
29  << " Denstructing object...";
30 }
31 
32 // -----------------------------------------------------------------------------
35  LogTrace(mlDqmClient_) << "[OptoScanHistograms::" << __func__ << "]";
36 
37  // Some initialisation
38  uint16_t valid = 0;
39  HistosMap::const_iterator iter;
40  Analyses::iterator ianal;
41  std::map<std::string, uint16_t> errors;
42 
43  // Clear map holding analysis objects
44  for (ianal = data().begin(); ianal != data().end(); ianal++) {
45  if (ianal->second) {
46  delete ianal->second;
47  }
48  }
49  data().clear();
50 
51  // Iterate through map containing histograms
52  for (iter = histos().begin(); iter != histos().end(); iter++) {
53  // Check vector of histos is not empty
54  if (iter->second.empty()) {
55  edm::LogWarning(mlDqmClient_) << "[OptoScanHistograms::" << __func__ << "]"
56  << " Zero histograms found!";
57  continue;
58  }
59 
60  // Retrieve pointers to histos
61  std::vector<TH1*> profs;
62  Histos::const_iterator ihis = iter->second.begin();
63  for (; ihis != iter->second.end(); ihis++) {
64  TProfile* prof = ExtractTObject<TProfile>().extract((*ihis)->me_);
65  if (prof) {
66  profs.push_back(prof);
67  }
68  }
69 
70  // Perform histo analysis
71  OptoScanAnalysis* anal = new OptoScanAnalysis(iter->first);
72  OptoScanAlgorithm algo(this->pset(), anal);
73  algo.analysis(profs);
74  data()[iter->first] = anal;
75  if (anal->isValid()) {
76  valid++;
77  }
78  if (!anal->getErrorCodes().empty()) {
79  errors[anal->getErrorCodes()[0]]++;
80  }
81  }
82 
83  if (!histos().empty()) {
84  edm::LogVerbatim(mlDqmClient_) << "[OptoScanHistograms::" << __func__ << "]"
85  << " Analyzed histograms for " << histos().size() << " FED channels, of which "
86  << valid << " (" << 100 * valid / histos().size() << "%) are valid.";
87  } else {
88  edm::LogWarning(mlDqmClient_) << "[OptoScanHistograms::" << __func__ << "]"
89  << " No histograms to analyze!";
90  }
91 
92  if (!histos().empty()) {
93  edm::LogVerbatim(mlDqmClient_) << "[OptoScanHistograms::" << __func__ << "]"
94  << " Analyzed histograms for " << histos().size() << " FED channels, of which "
95  << valid << " (" << 100 * valid / histos().size() << "%) are valid.";
96  if (!errors.empty()) {
97  uint16_t count = 0;
98  std::stringstream ss;
99  ss << std::endl;
100  std::map<std::string, uint16_t>::const_iterator ii;
101  for (ii = errors.begin(); ii != errors.end(); ++ii) {
102  ss << " " << ii->first << ": " << ii->second << std::endl;
103  count += ii->second;
104  }
105  edm::LogWarning(mlDqmClient_) << "[OptoScanHistograms::" << __func__ << "]"
106  << " Found " << count << " errors (" << 100 * count / histos().size()
107  << "%): " << ss.str();
108  }
109  } else {
110  edm::LogWarning(mlDqmClient_) << "[OptoScanHistograms::" << __func__ << "]"
111  << " No histograms to analyze!";
112  }
113 }
114 
115 // -----------------------------------------------------------------------------
118  Analyses::iterator ianal = data().begin();
119  Analyses::iterator janal = data().end();
120  for (; ianal != janal; ++ianal) {
121  if (ianal->second) {
122  std::stringstream ss;
123  if (ianal->second->isValid()) {
124  ianal->second->print(ss);
125  LogTrace(mlDqmClient_) << ss.str();
126  } else {
127  ianal->second->print(ss, 0);
128  ianal->second->print(ss, 1);
129  ianal->second->print(ss, 2);
130  ianal->second->print(ss, 3);
131  edm::LogWarning(mlDqmClient_) << ss.str();
132  }
133  }
134  }
135 }
Histogram-based analysis for opto bias/gain scan.
void analysis(const std::vector< TH1 * > &)
Analyses & data(bool getMaskedData=false)
void histoAnalysis(bool debug) override
~OptoScanHistograms() override
const edm::ParameterSet & pset() const
OptoScanHistograms(const edm::ParameterSet &pset, DQMStore *)
static const char mlDqmClient_[]
void printAnalyses() override
sistrip classes
#define LogTrace(id)
ii
Definition: cuy.py:590
int extract(std::vector< int > *output, const std::string &dati)
#define debug
Definition: HDRShower.cc:19
std::unique_ptr< Factory > factory_
#define begin
Definition: vmac.h:32
HLT enums.
const VString & getErrorCodes() const
bool isValid() const override
const HistosMap & histos() const