Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
/*
 *  See header file for a description of this class.
 *
 *  \author M. Pelliccioni - INFN Torino
 *
 *  threadsafe version (//-) oct/nov 2014 - WATWanAbdullah -ncpp-um-my
 *
 */

#include "DQM/DTMonitorClient/src/DTOfflineSummaryClients.h"

// Framework
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"

#include "DQMServices/Core/interface/DQMStore.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include <string>
#include <cmath>

using namespace edm;
using namespace std;

DTOfflineSummaryClients::DTOfflineSummaryClients(const ParameterSet& ps) : nevents(0) {
  LogVerbatim("DTDQM|DTMonitorClient|DTOfflineSummaryClients") << "[DTOfflineSummaryClients]: Constructor";

  bookingdone = false;
}

DTOfflineSummaryClients::~DTOfflineSummaryClients() {
  LogVerbatim("DTDQM|DTMonitorClient|DTOfflineSummaryClients")
      << "DTOfflineSummaryClients: analyzed " << nevents << " events";
}

void DTOfflineSummaryClients::beginRun(const edm::Run& r, const edm::EventSetup& c) {}

void DTOfflineSummaryClients::dqmEndLuminosityBlock(DQMStore::IBooker& ibooker,
                                                    DQMStore::IGetter& igetter,
                                                    edm::LuminosityBlock const& lumiSeg,
                                                    edm::EventSetup const& context) {
  LogVerbatim("DTDQM|DTMonitorClient|DTOfflineSummaryClients")
      << "[DTOfflineSummaryClients]: End of LS transition" << endl;
}

void DTOfflineSummaryClients::dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
  LogVerbatim("DTDQM|DTMonitorClient|DTOfflineSummaryClients")
      << "[DTOfflineSummaryClients]: end job. Performin client operation";

  // book the summary histos

  ibooker.setCurrentFolder("DT/EventInfo");
  summaryReport = ibooker.bookFloat("reportSummary");
  // Initialize to 1 so that no alarms are thrown at the beginning of the run
  summaryReport->Fill(1.);

  summaryReportMap = ibooker.book2D("reportSummaryMap", "DT Report Summary Map", 12, 1, 13, 5, -2, 3);
  summaryReportMap->setAxisTitle("sector", 1);
  summaryReportMap->setAxisTitle("wheel", 2);

  ibooker.setCurrentFolder("DT/EventInfo/reportSummaryContents");

  for (int wheel = -2; wheel != 3; ++wheel) {
    stringstream streams;
    streams << "DT_Wheel" << wheel;
    string meName = streams.str();

    theSummaryContents.push_back(ibooker.bookFloat(meName));
    // Initialize to 1 so that no alarms are thrown at the beginning of the run
    theSummaryContents[wheel + 2]->Fill(1.);
  }

  // reset the monitor elements
  summaryReportMap->Reset();
  summaryReport->Fill(0.);
  for (int ii = 0; ii != 5; ++ii) {
    theSummaryContents[ii]->Fill(0.);
  }

  // Fill the map using, at the moment, only the information from DT chamber efficiency
  // problems at a granularity smaller than the chamber are ignored
  for (int wheel = -2; wheel <= 2; wheel++) {  // loop over wheels
    // retrieve the chamber efficiency summary
    stringstream str;
    str << "DT/05-ChamberEff/EfficiencyMap_All_W" << wheel;
    MonitorElement* segmentWheelSummary = igetter.get(str.str());
    if (segmentWheelSummary != nullptr) {
      float nFailingChambers = 0.;

      for (int sector = 1; sector <= 12; sector++) {  // loop over sectors

        double meaneff = 0.;
        double errorsum = 0.;

        for (int station = 1; station != 5; ++station) {  // loop over stations

          const double tmpefficiency = segmentWheelSummary->getBinContent(sector, station);
          const double tmpvariance = pow(segmentWheelSummary->getBinError(sector, station), 2);

          if (tmpefficiency == 0 || tmpvariance == 0) {
            nFailingChambers++;
            continue;
          }

          meaneff += tmpefficiency / tmpvariance;
          errorsum += 1. / tmpvariance;

          if (tmpefficiency < 0.2)
            nFailingChambers++;

          LogTrace("DTDQM|DTMonitorClient|DTOfflineSummaryClients")
              << "Wheel: " << wheel << " Stat: " << station << " Sect: " << sector << " status: " << meaneff / errorsum
              << endl;
        }

        const double eff_result = meaneff / errorsum;

        if (eff_result > 0.7)
          summaryReportMap->Fill(sector, wheel, 1.);
        else if (eff_result < 0.7 && eff_result > 0.5)
          summaryReportMap->Fill(sector, wheel, 0.6);
        else if (eff_result < 0.5 && eff_result > 0.3)
          summaryReportMap->Fill(sector, wheel, 0.4);
        else if (eff_result < 0.3 && eff_result > 0.)
          summaryReportMap->Fill(sector, wheel, 0.15);
      }
      theSummaryContents[wheel + 2]->Fill((48. - nFailingChambers) / 48.);
      summaryReport->Fill(summaryReport->getFloatValue() + theSummaryContents[wheel + 2]->getFloatValue() / 5.);
    } else {
      LogWarning("DTDQM|DTMonitorClient|DTOfflineSummaryClients")
          << " [DTOfflineSummaryClients] Segment Summary not found with name: " << str.str() << endl;
    }
  }
}