File indexing completed on 2024-04-06 12:08:31
0001 #include "DQM/SiStripCommissioningClients/interface/DaqScopeModeHistograms.h"
0002 #include "CondFormats/SiStripObjects/interface/DaqScopeModeAnalysis.h"
0003 #include "DQM/SiStripCommissioningAnalysis/interface/DaqScopeModeAlgorithm.h"
0004 #include "DQM/SiStripCommissioningSummary/interface/DaqScopeModeSummaryFactory.h"
0005 #include "DQM/SiStripCommissioningSummary/interface/SummaryGenerator.h"
0006 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
0007 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 #include <iostream>
0010 #include <memory>
0011
0012 #include <sstream>
0013 #include <iomanip>
0014
0015 using namespace std;
0016 using namespace sistrip;
0017
0018
0019
0020 DaqScopeModeHistograms::DaqScopeModeHistograms(const edm::ParameterSet& pset, DQMStore* bei)
0021 : CommissioningHistograms(
0022 pset.getParameter<edm::ParameterSet>("DaqScopeModeParameters"), bei, sistrip::DAQ_SCOPE_MODE) {
0023 factory_ = std::make_unique<DaqScopeModeSummaryFactory>();
0024 LogTrace(mlDqmClient_) << "[DaqScopeModeHistograms::" << __func__ << "]"
0025 << " Constructing object...";
0026 }
0027
0028
0029
0030 DaqScopeModeHistograms::~DaqScopeModeHistograms() {
0031 LogTrace(mlDqmClient_) << "[DaqScopeModeHistograms::" << __func__ << "]"
0032 << " Destructing object...";
0033 }
0034
0035
0036
0037 void DaqScopeModeHistograms::histoAnalysis(bool debug) {
0038 LogTrace(mlDqmClient_) << "[DaqScopeModeHistograms::" << __func__ << "]";
0039
0040
0041 uint16_t valid = 0;
0042 HistosMap::const_iterator iter;
0043 Analyses::iterator ianal;
0044 std::map<std::string, uint16_t> errors;
0045
0046
0047 for (ianal = data().begin(); ianal != data().end(); ianal++) {
0048 if (ianal->second) {
0049 delete ianal->second;
0050 }
0051 }
0052 data().clear();
0053
0054
0055 for (iter = histos().begin(); iter != histos().end(); iter++) {
0056
0057 if (iter->second.empty()) {
0058 edm::LogWarning(mlDqmClient_) << "[DaqScopeModeHistograms::" << __func__ << "]"
0059 << " Zero histograms found!";
0060 continue;
0061 }
0062
0063
0064 std::vector<TH1*> profs;
0065 Histos::const_iterator ihis = iter->second.begin();
0066 for (; ihis != iter->second.end(); ihis++) {
0067 TProfile* prof = ExtractTObject<TProfile>().extract((*ihis)->me_);
0068 if (prof) {
0069 profs.push_back(prof);
0070 }
0071 if (!prof) {
0072 TH1F* prof = ExtractTObject<TH1F>().extract((*ihis)->me_);
0073 profs.push_back(prof);
0074 }
0075 }
0076
0077
0078 DaqScopeModeAnalysis* anal = new DaqScopeModeAnalysis(iter->first);
0079 DaqScopeModeAlgorithm algo(this->pset(), anal);
0080 algo.analysis(profs);
0081 data()[iter->first] = anal;
0082
0083 if (anal->isValid()) {
0084 valid++;
0085 }
0086 if (!anal->getErrorCodes().empty()) {
0087 errors[anal->getErrorCodes()[0]]++;
0088 }
0089 }
0090
0091 if (!histos().empty()) {
0092 edm::LogVerbatim(mlDqmClient_) << "[DaqScopeModeHistograms::" << __func__ << "]"
0093 << " Analyzed histograms for " << histos().size() << " FED channels, of which "
0094 << valid << " (" << 100 * valid / histos().size() << "%) are valid.";
0095 if (!errors.empty()) {
0096 uint16_t count = 0;
0097 std::stringstream ss;
0098 ss << std::endl;
0099 std::map<std::string, uint16_t>::const_iterator ii;
0100 for (ii = errors.begin(); ii != errors.end(); ++ii) {
0101 ss << " " << ii->first << ": " << ii->second << std::endl;
0102 count += ii->second;
0103 }
0104 edm::LogWarning(mlDqmClient_) << "[DaqScopeModeHistograms::" << __func__ << "]"
0105 << " Found " << count << " errors (" << 100 * count / histos().size()
0106 << "%): " << ss.str();
0107 }
0108 } else {
0109 edm::LogWarning(mlDqmClient_) << "[DaqScopeModeHistograms::" << __func__ << "]"
0110 << " No histograms to analyze!";
0111 }
0112 }
0113
0114
0115 void DaqScopeModeHistograms::printAnalyses() {
0116 Analyses::iterator ianal = data().begin();
0117 Analyses::iterator janal = data().end();
0118 for (; ianal != janal; ++ianal) {
0119 if (ianal->second) {
0120 std::stringstream ss;
0121 ianal->second->print(ss, 1);
0122 ianal->second->print(ss, 2);
0123 if (ianal->second->isValid()) {
0124 LogTrace(mlDqmClient_) << ss.str();
0125 } else {
0126 edm::LogWarning(mlDqmClient_) << ss.str();
0127 }
0128 }
0129 }
0130 }