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

/*
 *  See header file for a description of this class.
 *
 *  \author G. Cerminara - INFN Torino
 */

#include "DQM/DTMonitorClient/src/DTCertificationSummary.h"
#include "DataFormats/FEDRawData/interface/FEDNumbering.h"

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

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

using namespace std;
using namespace edm;

DTCertificationSummary::DTCertificationSummary(const ParameterSet& pset) {}

DTCertificationSummary::~DTCertificationSummary() {}

void DTCertificationSummary::dqmEndLuminosityBlock(DQMStore::IBooker& ibooker,
                                                   DQMStore::IGetter& igetter,
                                                   edm::LuminosityBlock const& lumiSeg,
                                                   edm::EventSetup const& context) {
  //FR moved here from beginJob

  // book the ME
  ibooker.setCurrentFolder("DT/EventInfo");
  // global fraction
  if (!igetter.get("CertificationSummary")) {
    totalCertFraction = ibooker.bookFloat("CertificationSummary");
    totalCertFraction->Fill(-1);

    // certification map
    certMap = ibooker.book2D("CertificationSummaryMap", "DT Certification Summary Map", 12, 1, 13, 5, -2, 3);
    certMap->setAxisTitle("sector", 1);
    certMap->setAxisTitle("wheel", 2);

    ibooker.setCurrentFolder("DT/EventInfo/CertificationContents");
    // Wheel "fractions" -> will be 0 or 1
    for (int wheel = -2; wheel != 3; ++wheel) {
      stringstream streams;
      streams << "DT_Wheel" << wheel;
      certFractions[wheel] = ibooker.bookFloat(streams.str());
      certFractions[wheel]->Fill(-1);
    }
  }
}

void DTCertificationSummary::beginRun(const Run& run, const EventSetup& setup) {}

void DTCertificationSummary::endRun(const Run& run, const EventSetup& setup) {}

void DTCertificationSummary::dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
  // get the relevant summary histos
  MonitorElement* effSummary = igetter.get("DT/05-ChamberEff/EfficiencyGlbSummary");
  MonitorElement* resSummary = igetter.get("DT/02-Segments/ResidualsGlbSummary");
  MonitorElement* segQualSummary = igetter.get("DT/02-Segments/segmentSummary");

  // check that all needed histos are there
  if (effSummary == nullptr || resSummary == nullptr || segQualSummary == nullptr) {
    LogWarning("DQM|DTMonitorClient|DTCertificationSummary")
        << "*** Warning: not all needed summaries are present!" << endl;
    return;
  }

  // reset the MEs
  totalCertFraction->Fill(0.);
  certFractions[-2]->Fill(0.);
  certFractions[-1]->Fill(0.);
  certFractions[-0]->Fill(0.);
  certFractions[1]->Fill(0.);
  certFractions[2]->Fill(0.);
  certMap->Reset();

  // loop over all sectors and wheels
  for (int wheel = -2; wheel != 3; ++wheel) {
    for (int sector = 1; sector != 13; ++sector) {
      double eff = effSummary->getBinContent(sector, wheel + 3);
      double res = resSummary->getBinContent(sector, wheel + 3);
      double segQual = segQualSummary->getBinContent(sector, wheel + 3);

      double total = 0;
      if (segQual != 0) {
        total = min(res, eff);
      } else {
        total = eff;
      }

      certMap->Fill(sector, wheel, total);
      // can use variable weight depending on the sector
      double weight = 1. / 12.;
      certFractions[wheel]->Fill(certFractions[wheel]->getFloatValue() + weight * total);
      double totalWeight = 1. / 60.;
      totalCertFraction->Fill(totalCertFraction->getFloatValue() + totalWeight * total);
    }
  }
}