Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:22

0001 #include <fstream>
0002 #include <iomanip>
0003 #include <iostream>
0004 #include <memory>
0005 
0006 #include "DQM/EcalPreshowerMonitorClient/interface/ESSummaryClient.h"
0007 
0008 using namespace std;
0009 
0010 ESSummaryClient::ESSummaryClient(const edm::ParameterSet &ps)
0011     : ESClient(ps), meReportSummary_(nullptr), meReportSummaryMap_(nullptr) {
0012   for (unsigned iZ(0); iZ != 2; ++iZ)
0013     for (unsigned iD(0); iD != 2; ++iD)
0014       meReportSummaryContents_[iZ][iD] = nullptr;
0015 }
0016 
0017 ESSummaryClient::~ESSummaryClient() {}
0018 
0019 void ESSummaryClient::book(DQMStore::IBooker &_ibooker) {
0020   if (debug_)
0021     cout << "ESSummaryClient: setup" << endl;
0022 
0023   _ibooker.setCurrentFolder(prefixME_ + "/EventInfo");
0024 
0025   meReportSummary_ = _ibooker.bookFloat("reportSummary");
0026 
0027   _ibooker.setCurrentFolder(prefixME_ + "/EventInfo/reportSummaryContents");
0028 
0029   char histo[200];
0030 
0031   for (int i = 0; i < 2; ++i) {
0032     for (int j = 0; j < 2; ++j) {
0033       int iz = (i == 0) ? 1 : -1;
0034       sprintf(histo, "EcalPreshower Z %d P %d", iz, j + 1);
0035       meReportSummaryContents_[i][j] = _ibooker.bookFloat(histo);
0036     }
0037   }
0038 
0039   _ibooker.setCurrentFolder(prefixME_ + "/EventInfo");
0040 
0041   meReportSummaryMap_ = _ibooker.book2D("reportSummaryMap", "reportSummaryMap", 80, 0.5, 80.5, 80, 0.5, 80.5);
0042   meReportSummaryMap_->setAxisTitle("Si X", 1);
0043   meReportSummaryMap_->setAxisTitle("Si Y", 2);
0044 }
0045 
0046 void ESSummaryClient::fillReportSummary(DQMStore::IGetter &_igetter) {
0047   for (int i = 0; i < 80; i++) {
0048     for (int j = 0; j < 80; j++) {
0049       meReportSummaryMap_->setBinContent(i + 1, j + 1, -1.);
0050     }
0051   }
0052 
0053   char histo[200];
0054 
0055   float nDI_FedErr[80][80];
0056   float DCC[80][80];
0057   float eCount;
0058 
0059   MonitorElement *me;
0060 
0061   for (int i = 0; i < 80; ++i)
0062     for (int j = 0; j < 80; ++j) {
0063       nDI_FedErr[i][j] = -1;
0064       DCC[i][j] = 0;
0065     }
0066 
0067   for (int i = 0; i < 2; ++i) {
0068     for (int j = 0; j < 2; ++j) {
0069       int iz = (i == 0) ? 1 : -1;
0070 
0071       sprintf(histo, "ES Integrity Errors Z %d P %d", iz, j + 1);
0072       me = _igetter.get(prefixME_ + "/ESIntegrityTask/" + histo);
0073       if (me)
0074         for (int x = 0; x < 40; ++x)
0075           for (int y = 0; y < 40; ++y)
0076             nDI_FedErr[i * 40 + x][(1 - j) * 40 + y] = me->getBinContent(x + 1, y + 1);
0077 
0078       sprintf(histo, "ES Integrity Summary 1 Z %d P %d", iz, j + 1);
0079       me = _igetter.get(prefixME_ + "/ESIntegrityClient/" + histo);
0080       if (me)
0081         for (int x = 0; x < 40; ++x)
0082           for (int y = 0; y < 40; ++y)
0083             DCC[i * 40 + x][(1 - j) * 40 + y] = me->getBinContent(x + 1, y + 1);
0084 
0085       sprintf(histo, "ES RecHit 2D Occupancy Z %d P %d", iz, j + 1);
0086       me = _igetter.get(prefixME_ + "/ESOccupancyTask/" + histo);
0087       if (me)
0088         eCount = me->getBinContent(40, 40);
0089       else
0090         eCount = 1.;
0091     }
0092   }
0093 
0094   // The global-summary
0095   // ReportSummary Map
0096   //  ES+F  ES-F
0097   //  ES+R  ES-R
0098   float nValidChannels = 0;
0099   float nGlobalErrors = 0;
0100   float nValidChannelsES[2][2] = {};
0101   float nGlobalErrorsES[2][2] = {};
0102 
0103   for (int x = 0; x < 80; ++x) {
0104     if (eCount < 1)
0105       break;  // Fill reportSummaryMap after have 1 event
0106     for (int y = 0; y < 80; ++y) {
0107       int z = (x < 40) ? 0 : 1;
0108       int p = (y >= 40) ? 0 : 1;
0109 
0110       if (DCC[x][y] == 0.) {
0111         meReportSummaryMap_->setBinContent(x + 1, y + 1, -1.);
0112       } else {
0113         if (nDI_FedErr[x][y] >= 0) {
0114           meReportSummaryMap_->setBinContent(x + 1, y + 1, 1 - (nDI_FedErr[x][y] / eCount));
0115 
0116           nValidChannels++;
0117           nGlobalErrors += nDI_FedErr[x][y] / eCount;
0118 
0119           nValidChannelsES[z][p]++;
0120           nGlobalErrorsES[z][p] += nDI_FedErr[x][y] / eCount;
0121         } else {
0122           meReportSummaryMap_->setBinContent(x + 1, y + 1, -1.);
0123         }
0124       }
0125     }
0126   }
0127 
0128   for (unsigned iZ(0); iZ != 2; ++iZ) {
0129     for (unsigned iD(0); iD != 2; ++iD) {
0130       float reportSummaryES(-1.);
0131       if (nValidChannelsES[iZ][iD] != 0)
0132         reportSummaryES = 1. - nGlobalErrorsES[iZ][iD] / nValidChannelsES[iZ][iD];
0133 
0134       meReportSummaryContents_[iZ][iD]->Fill(reportSummaryES);
0135     }
0136   }
0137 
0138   float reportSummary(-1.);
0139   if (nValidChannels != 0)
0140     reportSummary = 1. - nGlobalErrors / nValidChannels;
0141 
0142   meReportSummary_->Fill(reportSummary);
0143 }
0144 
0145 void ESSummaryClient::endLumiAnalyze(DQMStore::IGetter &_igetter) {
0146   fillReportSummary(_igetter);
0147 
0148   // The following overwrites the report summary if LS-based Good Channel
0149   // Fraction histogram is available The source is turned off by default in
0150   // ESIntegrityTask
0151 
0152   MonitorElement *source(_igetter.get(prefixME_ + "/ESIntegrityTask/ES Good Channel Fraction"));
0153   if (!source)
0154     return;
0155 
0156   meReportSummary_->Fill(-1.0);
0157   for (unsigned iZ(0); iZ != 2; ++iZ)
0158     for (unsigned iD(0); iD != 2; ++iD)
0159       meReportSummaryContents_[iZ][iD]->Fill(-1.);
0160 
0161   for (int i = 0; i < 2; ++i)
0162     for (int j = 0; j < 2; ++j)
0163       meReportSummaryContents_[i][j]->Fill(source->getBinContent(i + 1, j + 1));
0164 
0165   meReportSummary_->Fill(source->getBinContent(3, 3));
0166 }
0167 
0168 void ESSummaryClient::endJobAnalyze(DQMStore::IGetter &_igetter) { fillReportSummary(_igetter); }