Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:09:45

0001 #include "DQMOffline/PFTau/interface/CandidateBenchmark.h"
0002 
0003 #include "DataFormats/Candidate/interface/Candidate.h"
0004 
0005 #include <TFile.h>
0006 #include <TH1.h>
0007 #include <TH2.h>
0008 #include <TROOT.h>
0009 
0010 using namespace std;
0011 
0012 CandidateBenchmark::CandidateBenchmark(Mode mode) : Benchmark(mode) {
0013   pt_ = nullptr;
0014   eta_ = nullptr;
0015   phi_ = nullptr;
0016   charge_ = nullptr;
0017   pdgId_ = nullptr;
0018 
0019   histogramBooked_ = false;
0020 }
0021 
0022 CandidateBenchmark::~CandidateBenchmark() {}
0023 
0024 void CandidateBenchmark::setup(DQMStore::IBooker &b) {
0025   if (!histogramBooked_) {
0026     PhaseSpace ptPS(100, 0, 100);
0027     PhaseSpace phiPS(360, -3.1416, 3.1416);
0028     PhaseSpace etaPS(100, -5, 5);
0029     switch (mode_) {
0030       case DQMOFFLINE:
0031       default:
0032         ptPS = PhaseSpace(50, 0, 100);
0033         phiPS.n = 50;
0034         etaPS.n = 20;
0035         break;
0036     }
0037 
0038     pt_ = book1D(b, "pt_", "pt_;p_{T} (GeV)", ptPS.n, ptPS.m, ptPS.M);
0039     eta_ = book1D(b, "eta_", "eta_;#eta", etaPS.n, etaPS.m, etaPS.M);
0040     phi_ = book1D(b, "phi_", "phi_;#phi", phiPS.n, phiPS.m, phiPS.M);
0041     charge_ = book1D(b, "charge_", "charge_;charge", 3, -1.5, 1.5);
0042 
0043     histogramBooked_ = true;
0044   }
0045 }
0046 
0047 void CandidateBenchmark::setup(DQMStore::IBooker &b, const edm::ParameterSet &parameterSet) {
0048   if (!histogramBooked_) {
0049     edm::ParameterSet ptPS = parameterSet.getParameter<edm::ParameterSet>("PtHistoParameter");
0050     edm::ParameterSet etaPS = parameterSet.getParameter<edm::ParameterSet>("EtaHistoParameter");
0051     edm::ParameterSet phiPS = parameterSet.getParameter<edm::ParameterSet>("PhiHistoParameter");
0052     edm::ParameterSet chPS = parameterSet.getParameter<edm::ParameterSet>("ChargeHistoParameter");
0053 
0054     if (ptPS.getParameter<bool>("switchOn")) {
0055       pt_ = book1D(b,
0056                    "pt_",
0057                    "p_{T};p_{T} (GeV)",
0058                    ptPS.getParameter<int32_t>("nBin"),
0059                    ptPS.getParameter<double>("xMin"),
0060                    ptPS.getParameter<double>("xMax"));
0061     }
0062     if (etaPS.getParameter<bool>("switchOn")) {
0063       eta_ = book1D(b,
0064                     "eta_",
0065                     "#eta;#eta",
0066                     etaPS.getParameter<int32_t>("nBin"),
0067                     etaPS.getParameter<double>("xMin"),
0068                     etaPS.getParameter<double>("xMax"));
0069     }
0070     if (phiPS.getParameter<bool>("switchOn")) {
0071       phi_ = book1D(b,
0072                     "phi_",
0073                     "#phi;#phi",
0074                     phiPS.getParameter<int32_t>("nBin"),
0075                     phiPS.getParameter<double>("xMin"),
0076                     phiPS.getParameter<double>("xMax"));
0077     }
0078     if (chPS.getParameter<bool>("switchOn")) {
0079       charge_ = book1D(b,
0080                        "charge_",
0081                        "charge;charge",
0082                        chPS.getParameter<int32_t>("nBin"),
0083                        chPS.getParameter<double>("xMin"),
0084                        chPS.getParameter<double>("xMax"));
0085     }
0086     histogramBooked_ = true;
0087   }
0088 }
0089 
0090 void CandidateBenchmark::fillOne(const reco::Candidate &cand) {
0091   if (!isInRange(cand.pt(), cand.eta(), cand.phi()))
0092     return;
0093 
0094   if (histogramBooked_) {
0095     if (pt_)
0096       pt_->Fill(cand.pt());
0097     if (eta_)
0098       eta_->Fill(cand.eta());
0099     if (phi_)
0100       phi_->Fill(cand.phi());
0101     if (charge_)
0102       charge_->Fill(cand.charge());
0103   }
0104 }