CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1EmulatorErrorFlagClient.cc
Go to the documentation of this file.
2 
10 #include "TRandom.h"
11 #include <TF1.h>
12 #include <stdio.h>
13 #include <sstream>
14 #include <math.h>
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 
35  //empty
36 
37 }
38 
40 
41 
42  // get back-end interface
44 
45  //
46 
47  m_nrL1Systems = m_l1Systems.size();
48 
51  m_systemMask.reserve(m_nrL1Systems);
54 
55  int indexSys = 0;
56 
57  for (std::vector<edm::ParameterSet>::const_iterator itSystem =
58  m_l1Systems.begin(); itSystem != m_l1Systems.end(); ++itSystem) {
59 
60  m_systemLabel.push_back(itSystem->getParameter<std::string>(
61  "SystemLabel"));
62 
63  m_systemLabelExt.push_back(itSystem->getParameter<std::string>(
64  "HwValLabel"));
65 
66  m_systemMask.push_back(itSystem->getParameter<unsigned int>(
67  "SystemMask"));
68 
69  m_systemFolder.push_back(itSystem->getParameter<std::string>(
70  "SystemFolder"));
71 
72  indexSys++;
73 
74  }
75 
76  // [SYS]ErrorFlag histogram
77  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
78  if (m_systemFolder[iSys] == "") {
79  m_systemErrorFlag.push_back("L1TEMU/" + m_systemLabel[iSys] + "/"
80  + m_systemLabelExt[iSys] + "ErrorFlag");
81  } else {
82  m_systemErrorFlag.push_back(m_systemFolder[iSys] + "/"
83  + m_systemLabelExt[iSys] + "ErrorFlag");
84  }
85  }
86 
87 
88  m_summaryContent.reserve(m_nrL1Systems);
89 
90 }
91 
92 
94 
95 
96  // get backend interface
98 
99  m_dbe->setCurrentFolder("L1TEMU/EventInfo");
100 
101  if ((m_meSummaryErrorFlagMap = m_dbe->get("L1TEMU/EventInfo/summaryErrorFlagMap"))) {
103  }
104 
105  // define a histogram
106  m_meSummaryErrorFlagMap = m_dbe->book1D("L1SummaryErrorFlagMap",
107  "L1SummaryErrorFlagMap", m_nrL1Systems, 1, m_nrL1Systems + 1);
108 
109  m_meSummaryErrorFlagMap->setAxisTitle("Agreement fraction", 2);
110 
111  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
112 
114  }
115 
116 }
117 
118 
120  const edm::EventSetup& evSetup) {
121 
122  // empty
123 }
124 
125 
127  const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& evSetup) {
128  // optionally reset histograms here
129 }
130 
132  const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& evSetup) {
133 
134  // reset the summary content values
135  for (unsigned int iMon = 0; iMon < m_nrL1Systems; ++iMon) {
136 
137  m_summaryContent[iMon] = 0.;
138  }
139 
140  // for masked systems and objects, set the summary content to -1
141 
142  for (unsigned int iMon = 0; iMon < m_nrL1Systems; ++iMon) {
143 
144  if (m_systemMask[iMon] != 0) {
145  m_summaryContent[iMon] = -1;
146  }
147  }
148 
149  // then fill content for unmasked systems
150 
151  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
152 
153  float percAgree = -1.;
154 
155  if (m_systemMask[iSys] == 0) {
156  percAgree = setSummary(iSys);
157 
158  if ((percAgree == -1) && m_verbose) {
159  std::cout << "\nWarning: ErrorFlag histogram for system "
160  << m_systemLabel[iSys] << " empty!" << std::endl;
161  }
162  }
163 
164  m_summaryContent[iSys] = percAgree;
165 
166  }
167 
168  int numUnMaskedSystems = 0;
169  for (unsigned int iMon = 0; iMon < m_nrL1Systems; iMon++) {
170  if (m_summaryContent[iMon] != -1) {
171  numUnMaskedSystems++;
172 
173  }
174  }
175 
176 
177 
178  // fill the SummaryErrorFlagMap histogram for L1 systems
179  // (bin 0 - underflow, bin iSys + 1 overflow)
180  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
182  }
183 
184  if (m_verbose) {
185  std::cout << "\nSummary report L1EmulatorErrorFlagClient" << std::endl;
186 
187  std::cout << "\nL1 systems: " << m_nrL1Systems << " systems included\n"
188  << std::endl;
189 
190  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
191 
192  std::cout << std::setw(10) << m_systemLabel[iSys] << std::setw(10)
193  << m_systemLabelExt[iSys] << " \t" << m_systemMask[iSys]
194  << " \t" << std::setw(25) << " m_summaryContent["
195  << std::setw(2) << iSys << "] = " << m_summaryContent[iSys]
196  << std::endl;
197  }
198 
199  }
200 
201 }
202 
203 
205  const edm::EventSetup& evSetup) {
206 
207  // there is no loop on events in the offline harvesting step
208  // do not put any code here, it will not be executed
209 
210 }
211 
212 
214  const edm::EventSetup& evSetup) {
215  //empty
216 }
217 
219  //empty
220 }
221 
222 // set subsystem agreement value in summary map
223 Float_t L1EmulatorErrorFlagClient::setSummary(const unsigned int& iMon) const {
224 
225  MonitorElement* QHist = m_dbe->get(m_systemErrorFlag[iMon].data());
226 
227  int ntot = 0;
228  for (int i = 0; i < QHist->getNbinsX(); i++) {
229  ntot += QHist->getBinContent(i + 1);
230  }
231 
232  bool isEmpty = (ntot == 0);
233 
234  //errflag bins: agree, loc agree, loc disagree, data only, emul only
235 
236  return isEmpty ? -1. : ((QHist->getBinContent(1)) / (ntot));
237 }
238 
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
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 * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:942
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)
virtual ~L1EmulatorErrorFlagClient()
Destructor.
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
void beginRun(const edm::Run &, const edm::EventSetup &)
begin run
int iEvent
Definition: GenABIO.cc:230
L1EmulatorErrorFlagClient(const edm::ParameterSet &)
Constructor.
void removeElement(const std::string &name)
Definition: DQMStore.cc:3093
std::vector< edm::ParameterSet > m_l1Systems
std::vector< std::string > m_systemLabel
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1696
void endRun(const edm::Run &, const edm::EventSetup &)
end run
void analyze(const edm::Event &, const edm::EventSetup &)
analyze
Float_t setSummary(const unsigned int &) const
void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
end luminosity block
std::vector< std::string > m_systemLabelExt
double getBinContent(int binx) const
get content of bin (1-D)
std::vector< std::string > m_systemErrorFlag
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::vector< std::string > m_systemFolder
int getNbinsX(void) const
get # of bins in X-axis
tuple cout
Definition: gather_cfg.py:121
volatile std::atomic< bool > shutdown_flag false
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
Definition: Run.h:41