Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-05-21 22:39:38

0001 /*
0002  *  See header file for a description of this class.
0003  *
0004  *  \author M. Pelliccioni - INFN Torino
0005  *
0006  *  threadsafe version (//-) oct/nov 2014 - WATWanAbdullah -ncpp-um-my
0007  *
0008  */
0009 
0010 #include "DQM/DTMonitorClient/src/DTOfflineSummaryClients.h"
0011 
0012 // Framework
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 #include "FWCore/ServiceRegistry/interface/Service.h"
0017 
0018 #include "DQMServices/Core/interface/DQMStore.h"
0019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0020 
0021 #include <string>
0022 #include <cmath>
0023 
0024 using namespace edm;
0025 using namespace std;
0026 
0027 DTOfflineSummaryClients::DTOfflineSummaryClients(const ParameterSet& ps) : nevents(0) {
0028   LogVerbatim("DTDQM|DTMonitorClient|DTOfflineSummaryClients") << "[DTOfflineSummaryClients]: Constructor";
0029 
0030   bookingdone = false;
0031 }
0032 
0033 DTOfflineSummaryClients::~DTOfflineSummaryClients() {
0034   LogVerbatim("DTDQM|DTMonitorClient|DTOfflineSummaryClients")
0035       << "DTOfflineSummaryClients: analyzed " << nevents << " events";
0036 }
0037 
0038 void DTOfflineSummaryClients::beginRun(const edm::Run& r, const edm::EventSetup& c){};
0039 
0040 void DTOfflineSummaryClients::dqmEndLuminosityBlock(DQMStore::IBooker& ibooker,
0041                                                     DQMStore::IGetter& igetter,
0042                                                     edm::LuminosityBlock const& lumiSeg,
0043                                                     edm::EventSetup const& context) {
0044   LogVerbatim("DTDQM|DTMonitorClient|DTOfflineSummaryClients")
0045       << "[DTOfflineSummaryClients]: End of LS transition" << endl;
0046 }
0047 
0048 void DTOfflineSummaryClients::dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0049   LogVerbatim("DTDQM|DTMonitorClient|DTOfflineSummaryClients")
0050       << "[DTOfflineSummaryClients]: end job. Performin client operation";
0051 
0052   // book the summary histos
0053 
0054   ibooker.setCurrentFolder("DT/EventInfo");
0055   summaryReport = ibooker.bookFloat("reportSummary");
0056   // Initialize to 1 so that no alarms are thrown at the beginning of the run
0057   summaryReport->Fill(1.);
0058 
0059   summaryReportMap = ibooker.book2D("reportSummaryMap", "DT Report Summary Map", 12, 1, 13, 5, -2, 3);
0060   summaryReportMap->setAxisTitle("sector", 1);
0061   summaryReportMap->setAxisTitle("wheel", 2);
0062 
0063   ibooker.setCurrentFolder("DT/EventInfo/reportSummaryContents");
0064 
0065   for (int wheel = -2; wheel != 3; ++wheel) {
0066     stringstream streams;
0067     streams << "DT_Wheel" << wheel;
0068     string meName = streams.str();
0069 
0070     theSummaryContents.push_back(ibooker.bookFloat(meName));
0071     // Initialize to 1 so that no alarms are thrown at the beginning of the run
0072     theSummaryContents[wheel + 2]->Fill(1.);
0073   }
0074 
0075   // reset the monitor elements
0076   summaryReportMap->Reset();
0077   summaryReport->Fill(0.);
0078   for (int ii = 0; ii != 5; ++ii) {
0079     theSummaryContents[ii]->Fill(0.);
0080   }
0081 
0082   // Fill the map using, at the moment, only the information from DT chamber efficiency
0083   // problems at a granularity smaller than the chamber are ignored
0084   for (int wheel = -2; wheel <= 2; wheel++) {  // loop over wheels
0085     // retrieve the chamber efficiency summary
0086     stringstream str;
0087     str << "DT/05-ChamberEff/EfficiencyMap_All_W" << wheel;
0088     MonitorElement* segmentWheelSummary = igetter.get(str.str());
0089     if (segmentWheelSummary != nullptr) {
0090       float nFailingChambers = 0.;
0091 
0092       for (int sector = 1; sector <= 12; sector++) {  // loop over sectors
0093 
0094         double meaneff = 0.;
0095         double errorsum = 0.;
0096 
0097         for (int station = 1; station != 5; ++station) {  // loop over stations
0098 
0099           const double tmpefficiency = segmentWheelSummary->getBinContent(sector, station);
0100           const double tmpvariance = pow(segmentWheelSummary->getBinError(sector, station), 2);
0101 
0102           if (tmpefficiency == 0 || tmpvariance == 0) {
0103             nFailingChambers++;
0104             continue;
0105           }
0106 
0107           meaneff += tmpefficiency / tmpvariance;
0108           errorsum += 1. / tmpvariance;
0109 
0110           if (tmpefficiency < 0.2)
0111             nFailingChambers++;
0112 
0113           LogTrace("DTDQM|DTMonitorClient|DTOfflineSummaryClients")
0114               << "Wheel: " << wheel << " Stat: " << station << " Sect: " << sector << " status: " << meaneff / errorsum
0115               << endl;
0116         }
0117 
0118         const double eff_result = meaneff / errorsum;
0119 
0120         if (eff_result > 0.7)
0121           summaryReportMap->Fill(sector, wheel, 1.);
0122         else if (eff_result < 0.7 && eff_result > 0.5)
0123           summaryReportMap->Fill(sector, wheel, 0.6);
0124         else if (eff_result < 0.5 && eff_result > 0.3)
0125           summaryReportMap->Fill(sector, wheel, 0.4);
0126         else if (eff_result < 0.3 && eff_result > 0.)
0127           summaryReportMap->Fill(sector, wheel, 0.15);
0128       }
0129       theSummaryContents[wheel + 2]->Fill((48. - nFailingChambers) / 48.);
0130       summaryReport->Fill(summaryReport->getFloatValue() + theSummaryContents[wheel + 2]->getFloatValue() / 5.);
0131     } else {
0132       LogWarning("DTDQM|DTMonitorClient|DTOfflineSummaryClients")
0133           << " [DTOfflineSummaryClients] Segment Summary not found with name: " << str.str() << endl;
0134     }
0135   }
0136 }