Go to the documentation of this file.00001 #include "DQM/L1TMonitorClient/interface/L1EmulatorErrorFlagClient.h"
00002
00003 #include "FWCore/ServiceRegistry/interface/Service.h"
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 #include "FWCore/Framework/interface/ESHandle.h"
00006 #include "FWCore/Framework/interface/EventSetup.h"
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008 #include "DQMServices/Core/interface/QReport.h"
00009 #include "DQMServices/Core/interface/DQMStore.h"
00010 #include "TRandom.h"
00011 #include <TF1.h>
00012 #include <stdio.h>
00013 #include <sstream>
00014 #include <math.h>
00015 #include <TProfile.h>
00016 #include <TProfile2D.h>
00017 #include <memory>
00018 #include <iostream>
00019 #include <vector>
00020 #include <iomanip>
00021 #include <string>
00022 #include <fstream>
00023 #include "TROOT.h"
00024
00025 L1EmulatorErrorFlagClient::L1EmulatorErrorFlagClient(const edm::ParameterSet& parSet) :
00026 m_verbose(parSet.getUntrackedParameter<bool>("verbose", false)),
00027 m_l1Systems(parSet.getParameter<std::vector<edm::ParameterSet> >("L1Systems")),
00028 m_nrL1Systems(0) {
00029
00030 initialize();
00031 }
00032
00033 L1EmulatorErrorFlagClient::~L1EmulatorErrorFlagClient() {
00034
00035
00036
00037 }
00038
00039 void L1EmulatorErrorFlagClient::initialize() {
00040
00041
00042
00043 m_dbe = edm::Service<DQMStore>().operator->();
00044
00045
00046
00047 m_nrL1Systems = m_l1Systems.size();
00048
00049 m_systemLabel.reserve(m_nrL1Systems);
00050 m_systemLabelExt.reserve(m_nrL1Systems);
00051 m_systemMask.reserve(m_nrL1Systems);
00052 m_systemFolder.reserve(m_nrL1Systems);
00053 m_systemErrorFlag.reserve(m_nrL1Systems);
00054
00055 int indexSys = 0;
00056
00057 for (std::vector<edm::ParameterSet>::const_iterator itSystem =
00058 m_l1Systems.begin(); itSystem != m_l1Systems.end(); ++itSystem) {
00059
00060 m_systemLabel.push_back(itSystem->getParameter<std::string>(
00061 "SystemLabel"));
00062
00063 m_systemLabelExt.push_back(itSystem->getParameter<std::string>(
00064 "HwValLabel"));
00065
00066 m_systemMask.push_back(itSystem->getParameter<unsigned int>(
00067 "SystemMask"));
00068
00069 m_systemFolder.push_back(itSystem->getParameter<std::string>(
00070 "SystemFolder"));
00071
00072 indexSys++;
00073
00074 }
00075
00076
00077 for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
00078 if (m_systemFolder[iSys] == "") {
00079 m_systemErrorFlag.push_back("L1TEMU/" + m_systemLabel[iSys] + "/"
00080 + m_systemLabelExt[iSys] + "ErrorFlag");
00081 } else {
00082 m_systemErrorFlag.push_back(m_systemFolder[iSys] + "/"
00083 + m_systemLabelExt[iSys] + "ErrorFlag");
00084 }
00085 }
00086
00087
00088 m_summaryContent.reserve(m_nrL1Systems);
00089
00090 }
00091
00092
00093 void L1EmulatorErrorFlagClient::beginJob() {
00094
00095
00096
00097 m_dbe = edm::Service<DQMStore>().operator->();
00098
00099 m_dbe->setCurrentFolder("L1TEMU/EventInfo");
00100
00101 if ((m_meSummaryErrorFlagMap = m_dbe->get("L1TEMU/EventInfo/summaryErrorFlagMap"))) {
00102 m_dbe->removeElement(m_meSummaryErrorFlagMap->getName());
00103 }
00104
00105
00106 m_meSummaryErrorFlagMap = m_dbe->book1D("L1SummaryErrorFlagMap",
00107 "L1SummaryErrorFlagMap", m_nrL1Systems, 1, m_nrL1Systems + 1);
00108
00109 m_meSummaryErrorFlagMap->setAxisTitle("Agreement fraction", 2);
00110
00111 for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
00112
00113 m_meSummaryErrorFlagMap->setBinLabel(iSys + 1, m_systemLabel[iSys], 1);
00114 }
00115
00116 }
00117
00118
00119 void L1EmulatorErrorFlagClient::beginRun(const edm::Run& run,
00120 const edm::EventSetup& evSetup) {
00121
00122
00123 }
00124
00125
00126 void L1EmulatorErrorFlagClient::beginLuminosityBlock(
00127 const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& evSetup) {
00128
00129 }
00130
00131 void L1EmulatorErrorFlagClient::endLuminosityBlock(
00132 const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& evSetup) {
00133
00134
00135 for (unsigned int iMon = 0; iMon < m_nrL1Systems; ++iMon) {
00136
00137 m_summaryContent[iMon] = 0.;
00138 }
00139
00140
00141
00142 for (unsigned int iMon = 0; iMon < m_nrL1Systems; ++iMon) {
00143
00144 if (m_systemMask[iMon] != 0) {
00145 m_summaryContent[iMon] = -1;
00146 }
00147 }
00148
00149
00150
00151 for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
00152
00153 float percAgree = -1.;
00154
00155 if (m_systemMask[iSys] == 0) {
00156 percAgree = setSummary(iSys);
00157
00158 if ((percAgree == -1) && m_verbose) {
00159 std::cout << "\nWarning: ErrorFlag histogram for system "
00160 << m_systemLabel[iSys] << " empty!" << std::endl;
00161 }
00162 }
00163
00164 m_summaryContent[iSys] = percAgree;
00165
00166 }
00167
00168 int numUnMaskedSystems = 0;
00169 for (unsigned int iMon = 0; iMon < m_nrL1Systems; iMon++) {
00170 if (m_summaryContent[iMon] != -1) {
00171 numUnMaskedSystems++;
00172
00173 }
00174 }
00175
00176
00177
00178
00179
00180 for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
00181 m_meSummaryErrorFlagMap->setBinContent(iSys + 1, m_summaryContent[iSys]);
00182 }
00183
00184 if (m_verbose) {
00185 std::cout << "\nSummary report L1EmulatorErrorFlagClient" << std::endl;
00186
00187 std::cout << "\nL1 systems: " << m_nrL1Systems << " systems included\n"
00188 << std::endl;
00189
00190 for (unsigned int iSys = 0; iSys < m_nrL1Systems; ++iSys) {
00191
00192 std::cout << std::setw(10) << m_systemLabel[iSys] << std::setw(10)
00193 << m_systemLabelExt[iSys] << " \t" << m_systemMask[iSys]
00194 << " \t" << std::setw(25) << " m_summaryContent["
00195 << std::setw(2) << iSys << "] = " << m_summaryContent[iSys]
00196 << std::endl;
00197 }
00198
00199 }
00200
00201 }
00202
00203
00204 void L1EmulatorErrorFlagClient::analyze(const edm::Event& iEvent,
00205 const edm::EventSetup& evSetup) {
00206
00207
00208
00209
00210 }
00211
00212
00213 void L1EmulatorErrorFlagClient::endRun(const edm::Run& run,
00214 const edm::EventSetup& evSetup) {
00215
00216 }
00217
00218 void L1EmulatorErrorFlagClient::endJob() {
00219
00220 }
00221
00222
00223 Float_t L1EmulatorErrorFlagClient::setSummary(const unsigned int& iMon) const {
00224
00225 MonitorElement* QHist = m_dbe->get(m_systemErrorFlag[iMon].data());
00226
00227 int ntot = 0;
00228 for (int i = 0; i < QHist->getNbinsX(); i++) {
00229 ntot += QHist->getBinContent(i + 1);
00230 }
00231
00232 bool isEmpty = (ntot == 0);
00233
00234
00235
00236 return isEmpty ? -1. : ((QHist->getBinContent(1)) / (ntot));
00237 }
00238