CMS 3D CMS Logo

OptoScanHistograms.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>("OptoScanParameters"), bei, sistrip::OPTO_SCAN) {
22  factory_ = std::make_unique<OptoScanSummaryFactory>();
23  LogTrace(mlDqmClient_) << "[OptoScanHistograms::" << __func__ << "]"
24  << " Constructing object...";
25 }
26 
27 // -----------------------------------------------------------------------------
30  LogTrace(mlDqmClient_) << "[OptoScanHistograms::" << __func__ << "]"
31  << " Denstructing object...";
32 }
33 
34 // -----------------------------------------------------------------------------
37  LogTrace(mlDqmClient_) << "[OptoScanHistograms::" << __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_) << "[OptoScanHistograms::" << __func__ << "]"
58  << " Zero histograms found!";
59  continue;
60  }
61 
62  // Retrieve pointers to 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  }
71 
72  // Perform histo analysis
73  OptoScanAnalysis* anal = new OptoScanAnalysis(iter->first);
74  OptoScanAlgorithm 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_) << "[OptoScanHistograms::" << __func__ << "]"
87  << " Analyzed histograms for " << histos().size() << " FED channels, of which "
88  << valid << " (" << 100 * valid / histos().size() << "%) are valid.";
89  } else {
90  edm::LogWarning(mlDqmClient_) << "[OptoScanHistograms::" << __func__ << "]"
91  << " No histograms to analyze!";
92  }
93 
94  if (!histos().empty()) {
95  edm::LogVerbatim(mlDqmClient_) << "[OptoScanHistograms::" << __func__ << "]"
96  << " Analyzed histograms for " << histos().size() << " FED channels, of which "
97  << valid << " (" << 100 * valid / histos().size() << "%) are valid.";
98  if (!errors.empty()) {
99  uint16_t count = 0;
100  std::stringstream ss;
101  ss << std::endl;
102  std::map<std::string, uint16_t>::const_iterator ii;
103  for (ii = errors.begin(); ii != errors.end(); ++ii) {
104  ss << " " << ii->first << ": " << ii->second << std::endl;
105  count += ii->second;
106  }
107  edm::LogWarning(mlDqmClient_) << "[OptoScanHistograms::" << __func__ << "]"
108  << " Found " << count << " errors (" << 100 * count / histos().size()
109  << "%): " << ss.str();
110  }
111  } else {
112  edm::LogWarning(mlDqmClient_) << "[OptoScanHistograms::" << __func__ << "]"
113  << " No histograms to analyze!";
114  }
115 }
116 
117 // -----------------------------------------------------------------------------
120  Analyses::iterator ianal = data().begin();
121  Analyses::iterator janal = data().end();
122  for (; ianal != janal; ++ianal) {
123  if (ianal->second) {
124  std::stringstream ss;
125  if (ianal->second->isValid()) {
126  ianal->second->print(ss);
127  LogTrace(mlDqmClient_) << ss.str();
128  } else {
129  ianal->second->print(ss, 0);
130  ianal->second->print(ss, 1);
131  ianal->second->print(ss, 2);
132  ianal->second->print(ss, 3);
133  edm::LogWarning(mlDqmClient_) << ss.str();
134  }
135  }
136  }
137 }
MessageLogger.h
CommissioningHistograms::pset
const edm::ParameterSet & pset() const
Definition: CommissioningHistograms.h:163
edm
HLT enums.
Definition: AlignableModifier.h:19
OptoScanHistograms::OptoScanHistograms
OptoScanHistograms(const edm::ParameterSet &pset, DQMStore *)
Definition: OptoScanHistograms.cc:20
sistrip::OPTO_SCAN
Definition: ConstantsForRunType.h:74
ExtractTObject.h
OptoScanSummaryFactory.h
CommissioningHistograms::data
Analyses & data(bool getMaskedData=false)
Definition: CommissioningHistograms.cc:718
ExtractTObject
Definition: ExtractTObject.h:9
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
sistrip::mlDqmClient_
static const char mlDqmClient_[]
Definition: ConstantsForLogger.h:19
OptoScanHistograms.h
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
cmsdt::algo
algo
Definition: constants.h:165
debug
#define debug
Definition: HDRShower.cc:19
dqm::legacy::DQMStore
Definition: DQMStore.h:727
errors
Definition: errors.py:1
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
CommissioningHistograms::factory_
std::unique_ptr< Factory > factory_
Definition: CommissioningHistograms.h:129
OptoScanHistograms::~OptoScanHistograms
~OptoScanHistograms() override
Definition: OptoScanHistograms.cc:29
OptoScanAnalysis.h
SiStripConstants.h
edm::ParameterSet
Definition: ParameterSet.h:47
ParameterSet
Definition: Functions.h:16
OptoScanAlgorithm.h
OptoScanHistograms::printAnalyses
void printAnalyses() override
Definition: OptoScanHistograms.cc:119
ExtractTObject::extract
static T * extract(MonitorElement *me)
Definition: ExtractTObject.cc:21
OptoScanHistograms::histoAnalysis
void histoAnalysis(bool debug) override
Definition: OptoScanHistograms.cc:36
CommissioningHistograms
Definition: CommissioningHistograms.h:23
std
Definition: JetResolutionObject.h:76
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
CommissioningHistograms::histos
const HistosMap & histos() const
Definition: CommissioningHistograms.h:161
OptoScanAnalysis
Histogram-based analysis for opto bias/gain scan.
Definition: OptoScanAnalysis.h:15
OptoScanAlgorithm
Definition: OptoScanAlgorithm.h:18
RunInfoPI::valid
Definition: RunInfoPayloadInspectoHelper.h:16
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
sistrip
sistrip classes
Definition: SiStripQualityHelpers.h:14
conversion_template_cfg.anal
anal
Definition: conversion_template_cfg.py:16
cuy.ii
ii
Definition: cuy.py:590
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
debug_messages_cfi.errors
errors
Definition: debug_messages_cfi.py:54