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  for (std::vector<edm::ParameterSet>::const_iterator itSystem = m_l1Systems.begin(); itSystem != m_l1Systems.end();
45  ++itSystem) {
46  m_systemLabel.push_back(itSystem->getParameter<std::string>("SystemLabel"));
47 
48  m_systemLabelExt.push_back(itSystem->getParameter<std::string>("HwValLabel"));
49 
50  m_systemMask.push_back(itSystem->getParameter<unsigned int>("SystemMask"));
51 
52  m_systemFolder.push_back(itSystem->getParameter<std::string>("SystemFolder"));
53  }
54 
55  // [SYS]ErrorFlag histogram
56  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
57  if (m_systemFolder[iSys].empty()) {
58  m_systemErrorFlag.push_back("L1TEMU/" + m_systemLabel[iSys] + "/" + m_systemLabelExt[iSys] + "ErrorFlag");
59  } else {
60  m_systemErrorFlag.push_back(m_systemFolder[iSys] + "/" + m_systemLabelExt[iSys] + "ErrorFlag");
61  }
62  }
63 
65 }
66 
68  ibooker.setCurrentFolder("L1TEMU/EventInfo");
69 
70  // define a histogram
72  ibooker.book1D("L1SummaryErrorFlagMap", "L1SummaryErrorFlagMap", m_nrL1Systems, 1, m_nrL1Systems + 1);
73 
74  m_meSummaryErrorFlagMap->setAxisTitle("Agreement fraction", 2);
75 
76  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
78  }
79 }
80 
82  DQMStore::IGetter& igetter,
83  const edm::LuminosityBlock& lumiSeg,
84  const edm::EventSetup& evSetup) {
85  // reset the summary content values
86  for (unsigned int iMon = 0; iMon < m_nrL1Systems; ++iMon) {
87  m_summaryContent[iMon] = 0.;
88  }
89 
90  // for masked systems and objects, set the summary content to -1
91 
92  for (unsigned int iMon = 0; iMon < m_nrL1Systems; ++iMon) {
93  if (m_systemMask[iMon] != 0) {
94  m_summaryContent[iMon] = -1;
95  }
96  }
97 
98  // then fill content for unmasked systems
99 
100  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
101  float percAgree = -1.;
102 
103  if (m_systemMask[iSys] == 0) {
104  percAgree = setSummary(igetter, iSys);
105 
106  if ((percAgree == -1) && m_verbose) {
107  std::cout << "\nWarning: ErrorFlag histogram for system " << m_systemLabel[iSys] << " empty!" << std::endl;
108  }
109  }
110 
111  m_summaryContent[iSys] = percAgree;
112  }
113 
114  // fill the SummaryErrorFlagMap histogram for L1 systems
115  // (bin 0 - underflow, bin iSys + 1 overflow)
116  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
118  }
119 
120  if (m_verbose) {
121  std::cout << "\nSummary report L1EmulatorErrorFlagClient" << std::endl;
122 
123  std::cout << "\nL1 systems: " << m_nrL1Systems << " systems included\n" << std::endl;
124 
125  for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
126  std::cout << std::setw(10) << m_systemLabel[iSys] << std::setw(10) << m_systemLabelExt[iSys] << " \t"
127  << m_systemMask[iSys] << " \t" << std::setw(25) << " m_summaryContent[" << std::setw(2) << iSys
128  << "] = " << m_summaryContent[iSys] << std::endl;
129  }
130  }
131 }
132 
133 // set subsystem agreement value in summary map
134 Float_t L1EmulatorErrorFlagClient::setSummary(DQMStore::IGetter& igetter, const unsigned int& iMon) const {
135  MonitorElement* QHist = igetter.get(m_systemErrorFlag[iMon]);
136 
137  int ntot = 0;
138  for (int i = 0; i < QHist->getNbinsX(); i++) {
139  ntot += QHist->getBinContent(i + 1);
140  }
141 
142  bool isEmpty = (ntot == 0);
143 
144  //errflag bins: agree, loc agree, loc disagree, data only, emul only
145 
146  return isEmpty ? -1. : ((QHist->getBinContent(1)) / (ntot));
147 }
~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:712
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
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)