CMS 3D CMS Logo

CandidateBenchmark.cc
Go to the documentation of this file.
2 
4 
5 #include <TFile.h>
6 #include <TH1.h>
7 #include <TH2.h>
8 #include <TROOT.h>
9 
10 using namespace std;
11 
13  pt_ = nullptr;
14  eta_ = nullptr;
15  phi_ = nullptr;
16  charge_ = nullptr;
17  pdgId_ = nullptr;
18 
19  histogramBooked_ = false;
20 }
21 
23 
25  if (!histogramBooked_) {
26  PhaseSpace ptPS(100, 0, 100);
27  PhaseSpace phiPS(360, -3.1416, 3.1416);
28  PhaseSpace etaPS(100, -5, 5);
29  switch (mode_) {
30  case DQMOFFLINE:
31  default:
32  ptPS = PhaseSpace(50, 0, 100);
33  phiPS.n = 50;
34  etaPS.n = 20;
35  break;
36  }
37 
38  pt_ = book1D(b, "pt_", "pt_;p_{T} (GeV)", ptPS.n, ptPS.m, ptPS.M);
39  eta_ = book1D(b, "eta_", "eta_;#eta", etaPS.n, etaPS.m, etaPS.M);
40  phi_ = book1D(b, "phi_", "phi_;#phi", phiPS.n, phiPS.m, phiPS.M);
41  charge_ = book1D(b, "charge_", "charge_;charge", 3, -1.5, 1.5);
42 
43  histogramBooked_ = true;
44  }
45 }
46 
48  if (!histogramBooked_) {
50  edm::ParameterSet etaPS = parameterSet.getParameter<edm::ParameterSet>("EtaHistoParameter");
51  edm::ParameterSet phiPS = parameterSet.getParameter<edm::ParameterSet>("PhiHistoParameter");
52  edm::ParameterSet chPS = parameterSet.getParameter<edm::ParameterSet>("ChargeHistoParameter");
53 
54  if (ptPS.getParameter<bool>("switchOn")) {
55  pt_ = book1D(b,
56  "pt_",
57  "p_{T};p_{T} (GeV)",
58  ptPS.getParameter<int32_t>("nBin"),
59  ptPS.getParameter<double>("xMin"),
60  ptPS.getParameter<double>("xMax"));
61  }
62  if (etaPS.getParameter<bool>("switchOn")) {
63  eta_ = book1D(b,
64  "eta_",
65  "#eta;#eta",
66  etaPS.getParameter<int32_t>("nBin"),
67  etaPS.getParameter<double>("xMin"),
68  etaPS.getParameter<double>("xMax"));
69  }
70  if (phiPS.getParameter<bool>("switchOn")) {
71  phi_ = book1D(b,
72  "phi_",
73  "#phi;#phi",
74  phiPS.getParameter<int32_t>("nBin"),
75  phiPS.getParameter<double>("xMin"),
76  phiPS.getParameter<double>("xMax"));
77  }
78  if (chPS.getParameter<bool>("switchOn")) {
79  charge_ = book1D(b,
80  "charge_",
81  "charge;charge",
82  chPS.getParameter<int32_t>("nBin"),
83  chPS.getParameter<double>("xMin"),
84  chPS.getParameter<double>("xMax"));
85  }
86  histogramBooked_ = true;
87  }
88 }
89 
91  if (!isInRange(cand.pt(), cand.eta(), cand.phi()))
92  return;
93 
94  if (histogramBooked_) {
95  if (pt_)
96  pt_->Fill(cand.pt());
97  if (eta_)
98  eta_->Fill(cand.eta());
99  if (phi_)
100  phi_->Fill(cand.phi());
101  if (charge_)
102  charge_->Fill(cand.charge());
103  }
104 }
TH1F * book1D(DQMStore::IBooker &b, const char *histname, const char *title, int nbins, float xmin, float xmax)
book a 1D histogram, either with DQM or plain root depending if DQM_ has been initialized in a child ...
Definition: Benchmark.cc:15
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void fillOne(const reco::Candidate &candidate)
fill histograms with a given particle
abstract base class
Definition: Benchmark.h:19
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
TH1F * pdgId_
COLIN add this histo.
bool isInRange(float pt, float eta, float phi) const
Definition: Benchmark.h:50
double b
Definition: hdecay.h:118
Mode mode_
Definition: Benchmark.h:118
void setup(DQMStore::IBooker &b)
book histograms
~CandidateBenchmark() override