CMS 3D CMS Logo

L1EmulatorErrorFlagClient.cc
Go to the documentation of this file.
2 
9 #include "TRandom.h"
10 #include <TF1.h>
11 #include <cstdio>
12 #include <sstream>
13 #include <cmath>
14 #include <TProfile.h>
15 #include <TProfile2D.h>
16 #include <memory>
17 #include <iostream>
18 #include <vector>
19 #include <iomanip>
20 #include <string>
21 #include <fstream>
22 #include "TROOT.h"
23 
25  : m_verbose(parSet.getUntrackedParameter<bool>("verbose", false)),
26  m_l1Systems(parSet.getParameter<std::vector<edm::ParameterSet> >("L1Systems")),
27  m_nrL1Systems(0) {
28  initialize();
29 }
30 
32  //empty
33 }
34 
36  m_nrL1Systems = m_l1Systems.size();
37 
40  m_systemMask.reserve(m_nrL1Systems);
43 
44  int indexSys = 0;
45 
46  for (std::vector<edm::ParameterSet>::const_iterator itSystem = m_l1Systems.begin(); itSystem != m_l1Systems.end();
47  ++itSystem) {
48  m_systemLabel.push_back(itSystem->getParameter<std::string>("SystemLabel"));
49 
50  m_systemLabelExt.push_back(itSystem->getParameter<std::string>("HwValLabel"));
51 
52  m_systemMask.push_back(itSystem->getParameter<unsigned int>("SystemMask"));
53 
54  m_systemFolder.push_back(itSystem->getParameter<std::string>("SystemFolder"));
55 
56  indexSys++;
57  }
58 
59  // [SYS]ErrorFlag histogram
60  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
61  if (m_systemFolder[iSys].empty()) {
62  m_systemErrorFlag.push_back("L1TEMU/" + m_systemLabel[iSys] + "/" + m_systemLabelExt[iSys] + "ErrorFlag");
63  } else {
64  m_systemErrorFlag.push_back(m_systemFolder[iSys] + "/" + m_systemLabelExt[iSys] + "ErrorFlag");
65  }
66  }
67 
69 }
70 
72  ibooker.setCurrentFolder("L1TEMU/EventInfo");
73 
74  // define a histogram
76  ibooker.book1D("L1SummaryErrorFlagMap", "L1SummaryErrorFlagMap", m_nrL1Systems, 1, m_nrL1Systems + 1);
77 
78  m_meSummaryErrorFlagMap->setAxisTitle("Agreement fraction", 2);
79 
80  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
82  }
83 }
84 
86  DQMStore::IGetter& igetter,
87  const edm::LuminosityBlock& lumiSeg,
88  const edm::EventSetup& evSetup) {
89  // reset the summary content values
90  for (unsigned int iMon = 0; iMon < m_nrL1Systems; ++iMon) {
91  m_summaryContent[iMon] = 0.;
92  }
93 
94  // for masked systems and objects, set the summary content to -1
95 
96  for (unsigned int iMon = 0; iMon < m_nrL1Systems; ++iMon) {
97  if (m_systemMask[iMon] != 0) {
98  m_summaryContent[iMon] = -1;
99  }
100  }
101 
102  // then fill content for unmasked systems
103 
104  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
105  float percAgree = -1.;
106 
107  if (m_systemMask[iSys] == 0) {
108  percAgree = setSummary(igetter, iSys);
109 
110  if ((percAgree == -1) && m_verbose) {
111  std::cout << "\nWarning: ErrorFlag histogram for system " << m_systemLabel[iSys] << " empty!" << std::endl;
112  }
113  }
114 
115  m_summaryContent[iSys] = percAgree;
116  }
117 
118  int numUnMaskedSystems = 0;
119  for (unsigned int iMon = 0; iMon < m_nrL1Systems; iMon++) {
120  if (m_summaryContent[iMon] != -1) {
121  numUnMaskedSystems++;
122  }
123  }
124 
125  // fill the SummaryErrorFlagMap histogram for L1 systems
126  // (bin 0 - underflow, bin iSys + 1 overflow)
127  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
129  }
130 
131  if (m_verbose) {
132  std::cout << "\nSummary report L1EmulatorErrorFlagClient" << std::endl;
133 
134  std::cout << "\nL1 systems: " << m_nrL1Systems << " systems included\n" << std::endl;
135 
136  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
137  std::cout << std::setw(10) << m_systemLabel[iSys] << std::setw(10) << m_systemLabelExt[iSys] << " \t"
138  << m_systemMask[iSys] << " \t" << std::setw(25) << " m_summaryContent[" << std::setw(2) << iSys
139  << "] = " << m_summaryContent[iSys] << std::endl;
140  }
141  }
142 }
143 
144 // set subsystem agreement value in summary map
145 Float_t L1EmulatorErrorFlagClient::setSummary(DQMStore::IGetter& igetter, const unsigned int& iMon) const {
146  MonitorElement* QHist = igetter.get(m_systemErrorFlag[iMon]);
147 
148  int ntot = 0;
149  for (int i = 0; i < QHist->getNbinsX(); i++) {
150  ntot += QHist->getBinContent(i + 1);
151  }
152 
153  bool isEmpty = (ntot == 0);
154 
155  //errflag bins: agree, loc agree, loc disagree, data only, emul only
156 
157  return isEmpty ? -1. : ((QHist->getBinContent(1)) / (ntot));
158 }
~L1EmulatorErrorFlagClient() override
Destructor.
size_t m_nrL1Systems
number of L1 trigger systems
std::vector< Float_t > m_summaryContent
summary report
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
L1EmulatorErrorFlagClient(const edm::ParameterSet &)
Constructor.
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
std::vector< edm::ParameterSet > m_l1Systems
std::vector< std::string > m_systemLabel
virtual 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 void setBinContent(int binx, double content)
set content of bin (1-D)
std::vector< std::string > m_systemLabelExt
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:690
std::vector< std::string > m_systemErrorFlag
HLT enums.
std::vector< std::string > m_systemFolder
virtual int getNbinsX() const
get # of bins in X-axis
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
Float_t setSummary(DQMStore::IGetter &igetter, const unsigned int &) const
__shared__ uint32_t ntot
virtual double getBinContent(int binx) const
get content of bin (1-D)
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)