File indexing completed on 2024-04-06 12:07:58
0001 #include "DQM/L1TMonitorClient/interface/L1TdeCSCTPGClient.h"
0002
0003 #include "FWCore/ServiceRegistry/interface/Service.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/Framework/interface/ESHandle.h"
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "DQMServices/Core/interface/DQMStore.h"
0009 #include "TRandom.h"
0010 using namespace edm;
0011 using namespace std;
0012
0013 L1TdeCSCTPGClient::L1TdeCSCTPGClient(const edm::ParameterSet &ps)
0014 : monitorDir_(ps.getParameter<string>("monitorDir")),
0015 chambers_(ps.getParameter<std::vector<std::string>>("chambers")),
0016
0017 alctVars_(ps.getParameter<std::vector<std::string>>("alctVars")),
0018 clctVars_(ps.getParameter<std::vector<std::string>>("clctVars")),
0019 lctVars_(ps.getParameter<std::vector<std::string>>("lctVars")),
0020
0021 alctNBin_(ps.getParameter<std::vector<unsigned>>("alctNBin")),
0022 clctNBin_(ps.getParameter<std::vector<unsigned>>("clctNBin")),
0023 lctNBin_(ps.getParameter<std::vector<unsigned>>("lctNBin")),
0024 alctMinBin_(ps.getParameter<std::vector<double>>("alctMinBin")),
0025 clctMinBin_(ps.getParameter<std::vector<double>>("clctMinBin")),
0026 lctMinBin_(ps.getParameter<std::vector<double>>("lctMinBin")),
0027 alctMaxBin_(ps.getParameter<std::vector<double>>("alctMaxBin")),
0028 clctMaxBin_(ps.getParameter<std::vector<double>>("clctMaxBin")),
0029 lctMaxBin_(ps.getParameter<std::vector<double>>("lctMaxBin")),
0030 useB904ME11_(ps.getParameter<bool>("useB904ME11")),
0031 useB904ME21_(ps.getParameter<bool>("useB904ME21")),
0032 useB904ME234s2_(ps.getParameter<bool>("useB904ME234s2")),
0033 isRun3_(ps.getParameter<bool>("isRun3")),
0034
0035
0036
0037 make1DPlots_(ps.getParameter<bool>("make1DPlots")) {
0038 useB904_ = useB904ME11_ or useB904ME21_ or useB904ME234s2_;
0039 }
0040
0041 L1TdeCSCTPGClient::~L1TdeCSCTPGClient() {}
0042
0043 void L1TdeCSCTPGClient::dqmEndLuminosityBlock(DQMStore::IBooker &ibooker,
0044 DQMStore::IGetter &igetter,
0045 const edm::LuminosityBlock &lumiSeg,
0046 const edm::EventSetup &c) {
0047 book(ibooker);
0048 processHistograms(igetter);
0049 }
0050
0051
0052 void L1TdeCSCTPGClient::dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) {
0053 book(ibooker);
0054 processHistograms(igetter);
0055 }
0056
0057 void L1TdeCSCTPGClient::book(DQMStore::IBooker &iBooker) {
0058 iBooker.setCurrentFolder(monitorDir_);
0059
0060
0061 if (useB904ME11_) {
0062 chambers_.resize(1);
0063 }
0064
0065 else if (useB904ME21_) {
0066 auto temp = chambers_[3];
0067 chambers_.resize(1);
0068 chambers_[0] = temp;
0069 }
0070
0071 else if (useB904ME234s2_) {
0072 auto temp = chambers_.back();
0073 chambers_.resize(1);
0074 chambers_[0] = temp;
0075 }
0076
0077 else if (isRun3_) {
0078 clctVars_.resize(9);
0079 lctVars_.resize(9);
0080 }
0081
0082 else {
0083 clctVars_.resize(4);
0084 lctVars_.resize(5);
0085 }
0086
0087
0088 if (useB904ME11_ or useB904ME21_ or useB904ME234s2_ or make1DPlots_) {
0089
0090 for (unsigned iType = 0; iType < chambers_.size(); iType++) {
0091
0092 for (unsigned iVar = 0; iVar < alctVars_.size(); iVar++) {
0093 const std::string key("alct_" + alctVars_[iVar] + "_diff");
0094 const std::string histName(key + "_" + chambers_[iType]);
0095 const std::string histTitle(chambers_[iType] + " ALCT " + alctVars_[iVar] + " (Emul - Data)");
0096 if (chamberHistos_[iType][key] == nullptr)
0097 chamberHistos_[iType][key] =
0098 iBooker.book1D(histName, histTitle, alctNBin_[iVar], alctMinBin_[iVar], alctMaxBin_[iVar]);
0099 else
0100 chamberHistos_[iType][key]->Reset();
0101 }
0102
0103
0104 for (unsigned iVar = 0; iVar < clctVars_.size(); iVar++) {
0105 const std::string key("clct_" + clctVars_[iVar] + "_diff");
0106 const std::string histName(key + "_" + chambers_[iType]);
0107 const std::string histTitle(chambers_[iType] + " CLCT " + clctVars_[iVar] + " (Emul - Data)");
0108 if (chamberHistos_[iType][key] == nullptr)
0109 chamberHistos_[iType][key] =
0110 iBooker.book1D(histName, histTitle, clctNBin_[iVar], clctMinBin_[iVar], clctMaxBin_[iVar]);
0111 else
0112 chamberHistos_[iType][key]->Reset();
0113 }
0114
0115
0116 for (unsigned iVar = 0; iVar < lctVars_.size(); iVar++) {
0117 const std::string key("lct_" + lctVars_[iVar] + "_diff");
0118 const std::string histName(key + "_" + chambers_[iType]);
0119 const std::string histTitle(chambers_[iType] + " LCT " + lctVars_[iVar] + " (Emul - Data)");
0120 if (chamberHistos_[iType][key] == nullptr)
0121 chamberHistos_[iType][key] =
0122 iBooker.book1D(histName, histTitle, lctNBin_[iVar], lctMinBin_[iVar], lctMaxBin_[iVar]);
0123 else
0124 chamberHistos_[iType][key]->Reset();
0125 }
0126 }
0127 }
0128
0129
0130 lctDataSummary_eff_ = iBooker.book2D(
0131 "lct_csctp_data_summary_eff", "Efficiency of data LCT being correctly emulated", 36, 1, 37, 18, 0, 18);
0132 alctDataSummary_eff_ = iBooker.book2D(
0133 "alct_csctp_data_summary_eff", "Efficiency of data ALCT being correctly emulated", 36, 1, 37, 18, 0, 18);
0134 clctDataSummary_eff_ = iBooker.book2D(
0135 "clct_csctp_data_summary_eff", "Efficiency of data CLCT being correctly emulated", 36, 1, 37, 18, 0, 18);
0136
0137 lctEmulSummary_eff_ = iBooker.book2D(
0138 "lct_csctp_emul_summary_eff", "Fraction of emulated LCT without matching data LCT", 36, 1, 37, 18, 0, 18);
0139 alctEmulSummary_eff_ = iBooker.book2D(
0140 "alct_csctp_emul_summary_eff", "Fraction of emulated ALCT without matching data ALCT", 36, 1, 37, 18, 0, 18);
0141 clctEmulSummary_eff_ = iBooker.book2D(
0142 "clct_csctp_emul_summary_eff", "Fraction of emulated CLCT without matching data CLCT", 36, 1, 37, 18, 0, 18);
0143
0144
0145 lctDataSummary_eff_->setAxisTitle("Chamber", 1);
0146 alctDataSummary_eff_->setAxisTitle("Chamber", 1);
0147 clctDataSummary_eff_->setAxisTitle("Chamber", 1);
0148
0149 lctEmulSummary_eff_->setAxisTitle("Chamber", 1);
0150 alctEmulSummary_eff_->setAxisTitle("Chamber", 1);
0151 clctEmulSummary_eff_->setAxisTitle("Chamber", 1);
0152
0153
0154 lctDataSummary_eff_->setOption("colz");
0155 alctDataSummary_eff_->setOption("colz");
0156 clctDataSummary_eff_->setOption("colz");
0157
0158 lctEmulSummary_eff_->setOption("colz");
0159 alctEmulSummary_eff_->setOption("colz");
0160 clctEmulSummary_eff_->setOption("colz");
0161
0162
0163 const std::array<std::string, 9> suffix_label{{"4/2", "4/1", "3/2", "3/1", " 2/2", "2/1", "1/3", "1/2", "1/1"}};
0164
0165
0166 for (int ybin = 1; ybin <= 9; ++ybin) {
0167 lctDataSummary_eff_->setBinLabel(ybin, "ME-" + suffix_label[ybin - 1], 2);
0168 alctDataSummary_eff_->setBinLabel(ybin, "ME-" + suffix_label[ybin - 1], 2);
0169 clctDataSummary_eff_->setBinLabel(ybin, "ME-" + suffix_label[ybin - 1], 2);
0170
0171 lctEmulSummary_eff_->setBinLabel(ybin, "ME-" + suffix_label[ybin - 1], 2);
0172 alctEmulSummary_eff_->setBinLabel(ybin, "ME-" + suffix_label[ybin - 1], 2);
0173 clctEmulSummary_eff_->setBinLabel(ybin, "ME-" + suffix_label[ybin - 1], 2);
0174
0175 lctDataSummary_eff_->setBinLabel(19 - ybin, "ME+" + suffix_label[ybin - 1], 2);
0176 alctDataSummary_eff_->setBinLabel(19 - ybin, "ME+" + suffix_label[ybin - 1], 2);
0177 clctDataSummary_eff_->setBinLabel(19 - ybin, "ME+" + suffix_label[ybin - 1], 2);
0178
0179 lctEmulSummary_eff_->setBinLabel(19 - ybin, "ME+" + suffix_label[ybin - 1], 2);
0180 alctEmulSummary_eff_->setBinLabel(19 - ybin, "ME+" + suffix_label[ybin - 1], 2);
0181 clctEmulSummary_eff_->setBinLabel(19 - ybin, "ME+" + suffix_label[ybin - 1], 2);
0182 }
0183 }
0184
0185 void L1TdeCSCTPGClient::processHistograms(DQMStore::IGetter &igetter) {
0186 MonitorElement *dataMon;
0187 MonitorElement *emulMon;
0188
0189
0190 if (useB904ME11_ or useB904ME21_ or useB904ME234s2_ or make1DPlots_) {
0191
0192 for (unsigned iType = 0; iType < chambers_.size(); iType++) {
0193
0194 for (unsigned iVar = 0; iVar < alctVars_.size(); iVar++) {
0195 const std::string key("alct_" + alctVars_[iVar]);
0196 const std::string histData(key + "_data_" + chambers_[iType]);
0197 const std::string histEmul(key + "_emul_" + chambers_[iType]);
0198
0199 dataMon = igetter.get(monitorDir_ + "/" + histData);
0200 emulMon = igetter.get(monitorDir_ + "/" + histEmul);
0201
0202 if (dataMon == nullptr or emulMon == nullptr) {
0203 edm::LogWarning("L1TdeCSCTPGClient")
0204 << __PRETTY_FUNCTION__ << " could not load the necessary histograms for harvesting " << histData << " / "
0205 << histEmul;
0206 continue;
0207 }
0208
0209 TH1F *hDiff = chamberHistos_[iType][key + "_diff"]->getTH1F();
0210
0211 if (dataMon && emulMon) {
0212 TH1F *hData = dataMon->getTH1F();
0213 TH1F *hEmul = emulMon->getTH1F();
0214 hDiff->Add(hEmul, hData, 1, -1);
0215 }
0216 }
0217
0218
0219 for (unsigned iVar = 0; iVar < clctVars_.size(); iVar++) {
0220 const std::string key("clct_" + clctVars_[iVar]);
0221 const std::string histData(key + "_data_" + chambers_[iType]);
0222 const std::string histEmul(key + "_emul_" + chambers_[iType]);
0223
0224 dataMon = igetter.get(monitorDir_ + "/" + histData);
0225 emulMon = igetter.get(monitorDir_ + "/" + histEmul);
0226
0227 if (dataMon == nullptr or emulMon == nullptr) {
0228 edm::LogWarning("L1TdeCSCTPGClient")
0229 << __PRETTY_FUNCTION__ << " could not load the necessary histograms for harvesting " << histData << " / "
0230 << histEmul;
0231 continue;
0232 }
0233
0234 TH1F *hDiff = chamberHistos_[iType][key + "_diff"]->getTH1F();
0235
0236 if (dataMon && emulMon) {
0237 TH1F *hData = dataMon->getTH1F();
0238 TH1F *hEmul = emulMon->getTH1F();
0239 hDiff->Add(hEmul, hData, 1, -1);
0240 }
0241 }
0242
0243
0244 for (unsigned iVar = 0; iVar < lctVars_.size(); iVar++) {
0245 const std::string key("lct_" + lctVars_[iVar]);
0246 const std::string histData(key + "_data_" + chambers_[iType]);
0247 const std::string histEmul(key + "_emul_" + chambers_[iType]);
0248
0249 dataMon = igetter.get(monitorDir_ + "/" + histData);
0250 emulMon = igetter.get(monitorDir_ + "/" + histEmul);
0251
0252 if (dataMon == nullptr or emulMon == nullptr) {
0253 edm::LogWarning("L1TdeCSCTPGClient")
0254 << __PRETTY_FUNCTION__ << " could not load the necessary histograms for harvesting " << histData << " / "
0255 << histEmul;
0256 continue;
0257 }
0258
0259 TH1F *hDiff = chamberHistos_[iType][key + "_diff"]->getTH1F();
0260
0261 if (dataMon && emulMon) {
0262 TH1F *hData = dataMon->getTH1F();
0263 TH1F *hEmul = emulMon->getTH1F();
0264 hDiff->Add(hEmul, hData, 1, -1);
0265 }
0266 }
0267 }
0268 }
0269
0270
0271 MonitorElement *lctDataSummary_denom_ = igetter.get(monitorDir_ + "/lct_csctp_data_summary_denom");
0272 MonitorElement *lctDataSummary_num_ = igetter.get(monitorDir_ + "/lct_csctp_data_summary_num");
0273 MonitorElement *alctDataSummary_denom_ = igetter.get(monitorDir_ + "/alct_csctp_data_summary_denom");
0274 MonitorElement *alctDataSummary_num_ = igetter.get(monitorDir_ + "/alct_csctp_data_summary_num");
0275 MonitorElement *clctDataSummary_denom_ = igetter.get(monitorDir_ + "/clct_csctp_data_summary_denom");
0276 MonitorElement *clctDataSummary_num_ = igetter.get(monitorDir_ + "/clct_csctp_data_summary_num");
0277
0278 if (lctDataSummary_denom_ == nullptr or lctDataSummary_num_ == nullptr or alctDataSummary_denom_ == nullptr or
0279 alctDataSummary_num_ == nullptr or clctDataSummary_denom_ == nullptr or clctDataSummary_num_ == nullptr) {
0280 edm::LogWarning("L1TdeCSCTPGClient") << __PRETTY_FUNCTION__
0281 << " could not load the necessary data histograms for 2D summary plots";
0282 return;
0283 }
0284
0285 MonitorElement *lctEmulSummary_denom_ = igetter.get(monitorDir_ + "/lct_csctp_emul_summary_denom");
0286 MonitorElement *lctEmulSummary_num_ = igetter.get(monitorDir_ + "/lct_csctp_emul_summary_num");
0287 MonitorElement *alctEmulSummary_denom_ = igetter.get(monitorDir_ + "/alct_csctp_emul_summary_denom");
0288 MonitorElement *alctEmulSummary_num_ = igetter.get(monitorDir_ + "/alct_csctp_emul_summary_num");
0289 MonitorElement *clctEmulSummary_denom_ = igetter.get(monitorDir_ + "/clct_csctp_emul_summary_denom");
0290 MonitorElement *clctEmulSummary_num_ = igetter.get(monitorDir_ + "/clct_csctp_emul_summary_num");
0291
0292 if (lctEmulSummary_denom_ == nullptr or lctEmulSummary_num_ == nullptr or alctEmulSummary_denom_ == nullptr or
0293 alctEmulSummary_num_ == nullptr or clctEmulSummary_denom_ == nullptr or clctEmulSummary_num_ == nullptr) {
0294 edm::LogWarning("L1TdeCSCTPGClient")
0295 << __PRETTY_FUNCTION__ << " could not load the necessary emulation histograms for the 2D summary plots";
0296 return;
0297 }
0298
0299 lctDataSummary_eff_->getTH2F()->Divide(lctDataSummary_num_->getTH2F(), lctDataSummary_denom_->getTH2F(), 1, 1, "");
0300 alctDataSummary_eff_->getTH2F()->Divide(alctDataSummary_num_->getTH2F(), alctDataSummary_denom_->getTH2F(), 1, 1, "");
0301 clctDataSummary_eff_->getTH2F()->Divide(clctDataSummary_num_->getTH2F(), clctDataSummary_denom_->getTH2F(), 1, 1, "");
0302
0303 lctEmulSummary_eff_->getTH2F()->Divide(lctEmulSummary_num_->getTH2F(), lctEmulSummary_denom_->getTH2F(), 1, 1, "");
0304 alctEmulSummary_eff_->getTH2F()->Divide(alctEmulSummary_num_->getTH2F(), alctEmulSummary_denom_->getTH2F(), 1, 1, "");
0305 clctEmulSummary_eff_->getTH2F()->Divide(clctEmulSummary_num_->getTH2F(), clctEmulSummary_denom_->getTH2F(), 1, 1, "");
0306
0307
0308 lctDataSummary_eff_->getTH2F()->GetZaxis()->SetRangeUser(0.95, 1);
0309 alctDataSummary_eff_->getTH2F()->GetZaxis()->SetRangeUser(0.95, 1);
0310 clctDataSummary_eff_->getTH2F()->GetZaxis()->SetRangeUser(0.95, 1);
0311 }