CMS 3D CMS Logo

L1EmulatorErrorFlagClient.cc
Go to the documentation of this file.
2 
10 #include "TRandom.h"
11 #include <TF1.h>
12 #include <cstdio>
13 #include <sstream>
14 #include <cmath>
15 #include <TProfile.h>
16 #include <TProfile2D.h>
17 #include <memory>
18 #include <iostream>
19 #include <vector>
20 #include <iomanip>
21 #include <string>
22 #include <fstream>
23 #include "TROOT.h"
24 
26  m_verbose(parSet.getUntrackedParameter<bool>("verbose", false)),
27  m_l1Systems(parSet.getParameter<std::vector<edm::ParameterSet> >("L1Systems")),
28  m_nrL1Systems(0) {
29 
30  initialize();
31 }
32 
34  //empty
35 }
36 
38 
39  m_nrL1Systems = m_l1Systems.size();
40 
43  m_systemMask.reserve(m_nrL1Systems);
46 
47  int indexSys = 0;
48 
49  for (std::vector<edm::ParameterSet>::const_iterator itSystem =
50  m_l1Systems.begin(); itSystem != m_l1Systems.end(); ++itSystem) {
51 
52  m_systemLabel.push_back(itSystem->getParameter<std::string>(
53  "SystemLabel"));
54 
55  m_systemLabelExt.push_back(itSystem->getParameter<std::string>(
56  "HwValLabel"));
57 
58  m_systemMask.push_back(itSystem->getParameter<unsigned int>(
59  "SystemMask"));
60 
61  m_systemFolder.push_back(itSystem->getParameter<std::string>(
62  "SystemFolder"));
63 
64  indexSys++;
65 
66  }
67 
68  // [SYS]ErrorFlag histogram
69  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
70  if (m_systemFolder[iSys] == "") {
71  m_systemErrorFlag.push_back("L1TEMU/" + m_systemLabel[iSys] + "/"
72  + m_systemLabelExt[iSys] + "ErrorFlag");
73  } else {
74  m_systemErrorFlag.push_back(m_systemFolder[iSys] + "/"
75  + m_systemLabelExt[iSys] + "ErrorFlag");
76  }
77  }
78 
79 
80  m_summaryContent.reserve(m_nrL1Systems);
81 
82 }
83 
84 
86 
87  ibooker.setCurrentFolder("L1TEMU/EventInfo");
88 
89  if ((m_meSummaryErrorFlagMap = igetter.get("L1TEMU/EventInfo/summaryErrorFlagMap"))) {
91  }
92 
93  // define a histogram
94  m_meSummaryErrorFlagMap = ibooker.book1D("L1SummaryErrorFlagMap",
95  "L1SummaryErrorFlagMap", m_nrL1Systems, 1, m_nrL1Systems + 1);
96 
97  m_meSummaryErrorFlagMap->setAxisTitle("Agreement fraction", 2);
98 
99  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
100 
102  }
103 }
104 
106  const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& evSetup) {
107 
108  // reset the summary content values
109  for (unsigned int iMon = 0; iMon < m_nrL1Systems; ++iMon) {
110 
111  m_summaryContent[iMon] = 0.;
112  }
113 
114  // for masked systems and objects, set the summary content to -1
115 
116  for (unsigned int iMon = 0; iMon < m_nrL1Systems; ++iMon) {
117 
118  if (m_systemMask[iMon] != 0) {
119  m_summaryContent[iMon] = -1;
120  }
121  }
122 
123  // then fill content for unmasked systems
124 
125  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
126 
127  float percAgree = -1.;
128 
129  if (m_systemMask[iSys] == 0) {
130  percAgree = setSummary(igetter, iSys);
131 
132  if ((percAgree == -1) && m_verbose) {
133  std::cout << "\nWarning: ErrorFlag histogram for system "
134  << m_systemLabel[iSys] << " empty!" << std::endl;
135  }
136  }
137 
138  m_summaryContent[iSys] = percAgree;
139 
140  }
141 
142  int numUnMaskedSystems = 0;
143  for (unsigned int iMon = 0; iMon < m_nrL1Systems; iMon++) {
144  if (m_summaryContent[iMon] != -1) {
145  numUnMaskedSystems++;
146 
147  }
148  }
149 
150 
151 
152  // fill the SummaryErrorFlagMap histogram for L1 systems
153  // (bin 0 - underflow, bin iSys + 1 overflow)
154  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
156  }
157 
158  if (m_verbose) {
159  std::cout << "\nSummary report L1EmulatorErrorFlagClient" << std::endl;
160 
161  std::cout << "\nL1 systems: " << m_nrL1Systems << " systems included\n"
162  << std::endl;
163 
164  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
165 
166  std::cout << std::setw(10) << m_systemLabel[iSys] << std::setw(10)
167  << m_systemLabelExt[iSys] << " \t" << m_systemMask[iSys]
168  << " \t" << std::setw(25) << " m_summaryContent["
169  << std::setw(2) << iSys << "] = " << m_summaryContent[iSys]
170  << std::endl;
171  }
172 
173  }
174 
175 }
176 
177 // set subsystem agreement value in summary map
178 Float_t L1EmulatorErrorFlagClient::setSummary(DQMStore::IGetter &igetter, const unsigned int& iMon) const {
179 
180  MonitorElement* QHist = igetter.get(m_systemErrorFlag[iMon]);
181 
182  int ntot = 0;
183  for (int i = 0; i < QHist->getNbinsX(); i++) {
184  ntot += QHist->getBinContent(i + 1);
185  }
186 
187  bool isEmpty = (ntot == 0);
188 
189  //errflag bins: agree, loc agree, loc disagree, data only, emul only
190 
191  return isEmpty ? -1. : ((QHist->getBinContent(1)) / (ntot));
192 }
193 
~L1EmulatorErrorFlagClient() override
Destructor.
void setBinContent(int binx, double content)
set content of bin (1-D)
size_t m_nrL1Systems
number of L1 trigger systems
std::vector< Float_t > m_summaryContent
summary report
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:302
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
const std::string & getName() const
get name of ME
Float_t setSummary(DQMStore::IGetter &igetter, const unsigned int &) const
L1EmulatorErrorFlagClient(const edm::ParameterSet &)
Constructor.
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
std::vector< edm::ParameterSet > m_l1Systems
std::vector< std::string > m_systemLabel
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
std::vector< std::string > m_systemLabelExt
double getBinContent(int binx) const
get content of bin (1-D)
std::vector< std::string > m_systemErrorFlag
HLT enums.
std::vector< std::string > m_systemFolder
int getNbinsX() const
get # of bins in X-axis
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void removeElement(Args &&...args)
Definition: DQMStore.h:310