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
#include "DQMOffline/PFTau/interface/CandidateBenchmark.h"

#include "DataFormats/Candidate/interface/Candidate.h"

#include <TFile.h>
#include <TH1.h>
#include <TH2.h>
#include <TROOT.h>

using namespace std;

CandidateBenchmark::CandidateBenchmark(Mode mode) : Benchmark(mode) {
  pt_ = nullptr;
  eta_ = nullptr;
  phi_ = nullptr;
  charge_ = nullptr;
  pdgId_ = nullptr;

  histogramBooked_ = false;
}

CandidateBenchmark::~CandidateBenchmark() {}

void CandidateBenchmark::setup(DQMStore::IBooker &b) {
  if (!histogramBooked_) {
    PhaseSpace ptPS(100, 0, 100);
    PhaseSpace phiPS(360, -3.1416, 3.1416);
    PhaseSpace etaPS(100, -5, 5);
    switch (mode_) {
      case DQMOFFLINE:
      default:
        ptPS = PhaseSpace(50, 0, 100);
        phiPS.n = 50;
        etaPS.n = 20;
        break;
    }

    pt_ = book1D(b, "pt_", "pt_;p_{T} (GeV)", ptPS.n, ptPS.m, ptPS.M);
    eta_ = book1D(b, "eta_", "eta_;#eta", etaPS.n, etaPS.m, etaPS.M);
    phi_ = book1D(b, "phi_", "phi_;#phi", phiPS.n, phiPS.m, phiPS.M);
    charge_ = book1D(b, "charge_", "charge_;charge", 3, -1.5, 1.5);

    histogramBooked_ = true;
  }
}

void CandidateBenchmark::setup(DQMStore::IBooker &b, const edm::ParameterSet &parameterSet) {
  if (!histogramBooked_) {
    edm::ParameterSet ptPS = parameterSet.getParameter<edm::ParameterSet>("PtHistoParameter");
    edm::ParameterSet etaPS = parameterSet.getParameter<edm::ParameterSet>("EtaHistoParameter");
    edm::ParameterSet phiPS = parameterSet.getParameter<edm::ParameterSet>("PhiHistoParameter");
    edm::ParameterSet chPS = parameterSet.getParameter<edm::ParameterSet>("ChargeHistoParameter");

    if (ptPS.getParameter<bool>("switchOn")) {
      pt_ = book1D(b,
                   "pt_",
                   "p_{T};p_{T} (GeV)",
                   ptPS.getParameter<int32_t>("nBin"),
                   ptPS.getParameter<double>("xMin"),
                   ptPS.getParameter<double>("xMax"));
    }
    if (etaPS.getParameter<bool>("switchOn")) {
      eta_ = book1D(b,
                    "eta_",
                    "#eta;#eta",
                    etaPS.getParameter<int32_t>("nBin"),
                    etaPS.getParameter<double>("xMin"),
                    etaPS.getParameter<double>("xMax"));
    }
    if (phiPS.getParameter<bool>("switchOn")) {
      phi_ = book1D(b,
                    "phi_",
                    "#phi;#phi",
                    phiPS.getParameter<int32_t>("nBin"),
                    phiPS.getParameter<double>("xMin"),
                    phiPS.getParameter<double>("xMax"));
    }
    if (chPS.getParameter<bool>("switchOn")) {
      charge_ = book1D(b,
                       "charge_",
                       "charge;charge",
                       chPS.getParameter<int32_t>("nBin"),
                       chPS.getParameter<double>("xMin"),
                       chPS.getParameter<double>("xMax"));
    }
    histogramBooked_ = true;
  }
}

void CandidateBenchmark::fillOne(const reco::Candidate &cand) {
  if (!isInRange(cand.pt(), cand.eta(), cand.phi()))
    return;

  if (histogramBooked_) {
    if (pt_)
      pt_->Fill(cand.pt());
    if (eta_)
      eta_->Fill(cand.eta());
    if (phi_)
      phi_->Fill(cand.phi());
    if (charge_)
      charge_->Fill(cand.charge());
  }
}