CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
VpspScanHistograms.cc
Go to the documentation of this file.
8 #include "TProfile.h"
9 #include <iostream>
10 #include <memory>
11 
12 #include <sstream>
13 #include <iomanip>
14 
15 using namespace std;
16 using namespace sistrip;
17 
18 // -----------------------------------------------------------------------------
21  : CommissioningHistograms(pset.getParameter<edm::ParameterSet>("VpspScanParameters"), bei, sistrip::VPSP_SCAN) {
22  factory_ = std::make_unique<VpspScanSummaryFactory>();
23  LogTrace(mlDqmClient_) << "[VpspScanHistograms::" << __func__ << "]"
24  << " Constructing object...";
25 }
26 
27 // -----------------------------------------------------------------------------
30  LogTrace(mlDqmClient_) << "[VpspScanHistograms::" << __func__ << "]"
31  << " Denstructing object...";
32 }
33 
34 // -----------------------------------------------------------------------------
37  LogTrace(mlDqmClient_) << "[VpspScanHistograms::" << __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_) << "[VpspScanHistograms::" << __func__ << "]"
58  << " Zero histograms found!" << endl;
59  continue;
60  }
61 
62  // Retrieve pointers to profile histos for this FED channel
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  }
71 
72  // Perform histo analysis
73  VpspScanAnalysis* anal = new VpspScanAnalysis(iter->first);
74  VpspScanAlgorithm algo(this->pset(), anal);
75  algo.analysis(profs);
76  data()[iter->first] = anal;
77  if (anal->isValid()) {
78  valid++;
79  }
80  if (!anal->getErrorCodes().empty()) {
81  errors[anal->getErrorCodes()[0]]++;
82  }
83  }
84 
85  if (!histos().empty()) {
86  edm::LogVerbatim(mlDqmClient_) << "[VpspScanHistograms::" << __func__ << "]"
87  << " Analyzed histograms for " << histos().size() << " FED channels, of which "
88  << valid << " (" << 100 * valid / histos().size() << "%) are valid.";
89  if (!errors.empty()) {
90  uint16_t count = 0;
91  std::stringstream ss;
92  ss << std::endl;
93  std::map<std::string, uint16_t>::const_iterator ii;
94  for (ii = errors.begin(); ii != errors.end(); ++ii) {
95  ss << " " << ii->first << ": " << ii->second << std::endl;
96  count += ii->second;
97  }
98  edm::LogWarning(mlDqmClient_) << "[VpspScanHistograms::" << __func__ << "]"
99  << " Found " << count << " errors (" << 100 * count / histos().size()
100  << "%): " << ss.str();
101  }
102  } else {
103  edm::LogWarning(mlDqmClient_) << "[VpspScanHistograms::" << __func__ << "]"
104  << " No histograms to analyze!";
105  }
106 }
107 
108 // -----------------------------------------------------------------------------
111  Analyses::iterator ianal = data().begin();
112  Analyses::iterator janal = data().end();
113  for (; ianal != janal; ++ianal) {
114  if (ianal->second) {
115  std::stringstream ss;
116  ianal->second->print(ss, 1);
117  ianal->second->print(ss, 2);
118  if (ianal->second->isValid()) {
119  LogTrace(mlDqmClient_) << ss.str();
120  } else {
121  edm::LogWarning(mlDqmClient_) << ss.str();
122  }
123  }
124  }
125 }
void analysis(const std::vector< TH1 * > &)
Log< level::Info, true > LogVerbatim
bool isValid() const override
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 VPSP scan.
int extract(std::vector< int > *output, const std::string &dati)
~VpspScanHistograms() override
#define debug
Definition: HDRShower.cc:19
std::unique_ptr< Factory > factory_
Histogram-based analysis for VPSP scan.
void printAnalyses() override
Log< level::Warning, false > LogWarning
VpspScanHistograms(const edm::ParameterSet &pset, DQMStore *)
const VString & getErrorCodes() const
const HistosMap & histos() const