CMS 3D CMS Logo

CandidateBenchmark.cc
Go to the documentation of this file.
2 
4 
5 
6 #include <TROOT.h>
7 #include <TFile.h>
8 #include <TH1.h>
9 #include <TH2.h>
10 
11 
12 using namespace std;
13 
14 
16  pt_ = 0;
17  eta_ = 0;
18  phi_ = 0;
19  charge_ = 0;
20  pdgId_ = 0;
21 
22  histogramBooked_ = false;
23 
24 }
25 
27 
28 
30 
31  if (!histogramBooked_) {
32  PhaseSpace ptPS(100,0,100);
33  PhaseSpace phiPS(360, -3.1416, 3.1416);
34  PhaseSpace etaPS(100, -5,5);
35  switch(mode_) {
36  case DQMOFFLINE:
37  default:
38  ptPS = PhaseSpace(50, 0, 100);
39  phiPS.n = 50;
40  etaPS.n = 20;
41  break;
42  }
43 
44  pt_ = book1D(b, "pt_", "pt_;p_{T} (GeV)", ptPS.n, ptPS.m, ptPS.M);
45  eta_ = book1D(b, "eta_", "eta_;#eta", etaPS.n, etaPS.m, etaPS.M);
46  phi_ = book1D(b, "phi_", "phi_;#phi", phiPS.n, phiPS.m, phiPS.M);
47  charge_ = book1D(b, "charge_", "charge_;charge", 3,-1.5,1.5);
48 
49  histogramBooked_ = true;
50  }
51 }
52 
54  if (!histogramBooked_) {
55  edm::ParameterSet ptPS = parameterSet.getParameter<edm::ParameterSet>("PtHistoParameter");
56  edm::ParameterSet etaPS = parameterSet.getParameter<edm::ParameterSet>("EtaHistoParameter");
57  edm::ParameterSet phiPS = parameterSet.getParameter<edm::ParameterSet>("PhiHistoParameter");
58  edm::ParameterSet chPS = parameterSet.getParameter<edm::ParameterSet>("ChargeHistoParameter");
59 
60  if (ptPS.getParameter<bool>("switchOn")) {
61  pt_ = book1D(b, "pt_", "p_{T};p_{T} (GeV)", ptPS.getParameter<int32_t>("nBin"),
62  ptPS.getParameter<double>("xMin"),
63  ptPS.getParameter<double>("xMax"));
64  }
65  if (etaPS.getParameter<bool>("switchOn")) {
66  eta_ = book1D(b, "eta_", "#eta;#eta", 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, "phi_", "#phi;#phi", phiPS.getParameter<int32_t>("nBin"),
72  phiPS.getParameter<double>("xMin"),
73  phiPS.getParameter<double>("xMax"));
74  }
75  if (chPS.getParameter<bool>("switchOn")) {
76  charge_ = book1D(b, "charge_","charge;charge",chPS.getParameter<int32_t>("nBin"),
77  chPS.getParameter<double>("xMin"),
78  chPS.getParameter<double>("xMax"));
79  }
80  histogramBooked_ = true;
81  }
82 }
83 
85 
86  if( !isInRange(cand.pt(), cand.eta(), cand.phi() ) ) return;
87 
88  if (histogramBooked_) {
89  if (pt_) pt_->Fill( cand.pt() );
90  if (eta_) eta_->Fill( cand.eta() );
91  if (phi_) phi_->Fill( cand.phi() );
92  if (charge_) charge_->Fill( cand.charge() );
93  }
94 }
95 
T getParameter(std::string const &) const
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:23
void fillOne(const reco::Candidate &candidate)
fill histograms with a given particle
abstract base class
Definition: Benchmark.h:22
TH1F * pdgId_
COLIN add this histo.
virtual double eta() const =0
momentum pseudorapidity
virtual double pt() const =0
transverse momentum
double b
Definition: hdecay.h:120
virtual int charge() const =0
electric charge
Mode mode_
Definition: Benchmark.h:105
void setup(DQMStore::IBooker &b)
book histograms
bool isInRange(float pt, float eta, float phi) const
Definition: Benchmark.h:58
virtual double phi() const =0
momentum azimuthal angle
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11