CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFCandidateMonitor.cc
Go to the documentation of this file.
5 
7 
8 #include <TROOT.h>
9 #include <TFile.h>
10 #include <TH1.h>
11 #include <TH2.h>
12 //
13 // -- Constructor
14 //
15 PFCandidateMonitor::PFCandidateMonitor( float dRMax, bool matchCharge, Benchmark::Mode mode) :
16  Benchmark(mode),
17  candBench_(mode),
18  matchCandBench_(mode),
19  dRMax_(dRMax),
20  matchCharge_(matchCharge) {
21 
22  setRange( 0.0, 10e10, -10.0, 10.0, -3.14, 3.14);
23 
24  pt_ref_ = 0;
25  eta_ref_ = 0;
26  phi_ref_ = 0;
27 
28  createReferenceHistos_ = false;
29  histogramBooked_ = false;
30 }
31 //
32 // -- Destructor
33 //
35 
36 //
37 // -- Set Parameters accessing them from ParameterSet
38 //
40 
41  dRMax_ = parameterSet.getParameter<double>( "deltaRMax" );
42  matchCharge_ = parameterSet.getParameter<bool>( "matchCharge" );
43  mode_ = (Benchmark::Mode) parameterSet.getParameter<int>( "mode" );
44  createReferenceHistos_ = parameterSet.getParameter<bool>( "CreateReferenceHistos" );
45 
46 
47  setRange( parameterSet.getParameter<double>("ptMin"),
48  parameterSet.getParameter<double>("ptMax"),
49  parameterSet.getParameter<double>("etaMin"),
50  parameterSet.getParameter<double>("etaMax"),
51  parameterSet.getParameter<double>("phiMin"),
52  parameterSet.getParameter<double>("phiMax") );
53 
56 }
57 //
58 // -- Set Parameters
59 //
60 void PFCandidateMonitor::setParameters(float dRMax, bool matchCharge, Benchmark::Mode mode,
61  float ptmin, float ptmax, float etamin, float etamax,
62  float phimin, float phimax, bool refHistoFlag) {
63  dRMax_ = dRMax;
64  matchCharge_ = matchCharge;
65  mode_ = mode;
66  createReferenceHistos_ = refHistoFlag;
67 
68  setRange( ptmin, ptmax, etamin, etamax, phimin, phimax );
69 
72 }
73 //
74 // -- Create histograms accessing parameters from ParameterSet
75 //
76 void PFCandidateMonitor::setup(const edm::ParameterSet & parameterSet) {
77  candBench_.setup(parameterSet);
78  matchCandBench_.setup(parameterSet);
79 
81  edm::ParameterSet ptPS = parameterSet.getParameter<edm::ParameterSet>("PtHistoParameter");
82  edm::ParameterSet etaPS = parameterSet.getParameter<edm::ParameterSet>("EtaHistoParameter");
83  edm::ParameterSet phiPS = parameterSet.getParameter<edm::ParameterSet>("PhiHistoParameter");
84  if (ptPS.getParameter<bool>("switchOn")) {
85  pt_ref_ = book1D("pt_ref_", "pt_ref_;p_{T} (GeV)", ptPS.getParameter<int32_t>("nBin"),
86  ptPS.getParameter<double>("xMin"),
87  ptPS.getParameter<double>("xMax"));
88  }
89 
90  if (etaPS.getParameter<bool>("switchOn")) {
91  eta_ref_ = book1D("eta_ref_", "eta_ref_;#eta_ref_", etaPS.getParameter<int32_t>("nBin"),
92  etaPS.getParameter<double>("xMin"),
93  etaPS.getParameter<double>("xMax"));
94  }
95  if (phiPS.getParameter<bool>("switchOn")) {
96  phi_ref_ = book1D("phi_ref_", "phi_ref_;#phref_i", phiPS.getParameter<int32_t>("nBin"),
97  phiPS.getParameter<double>("xMin"),
98  phiPS.getParameter<double>("xMax"));
99  }
100  histogramBooked_ = true;
101  }
102 }
103 //
104 // -- Create histograms using local parameters
105 //
107  candBench_.setup();
109 
111  PhaseSpace ptPS(100,0,100);
112  PhaseSpace phiPS(360, -3.1416, 3.1416);
113  PhaseSpace etaPS(100, -5,5);
114 
115  pt_ref_ = book1D("pt_ref_", "pt_ref_;p_{T} (GeV)", ptPS.n, ptPS.m, ptPS.M);
116 
117  eta_ref_ = book1D("eta_ref_", "eta_ref_;#eta", etaPS.n, etaPS.m, etaPS.M);
118 
119  phi_ref_ = book1D("phi_ref_", "phi_ref_;#phi", phiPS.n, phiPS.m, phiPS.M);
120 
121  histogramBooked_ = true;
122  }
123 }
124 //
125 // -- Set directory to book histograms using ROOT
126 //
129 
132 }
133 //
134 // -- fill histograms for a given Jet pair
135 //
137 
139 
140  if (pt_ref_) pt_ref_->Fill(cand.pt());
141  if (eta_ref_) eta_ref_->Fill(cand.eta() );
142  if (phi_ref_) phi_ref_->Fill(cand.phi() );
143  }
144 }
145 
T getParameter(std::string const &) const
void setup()
book histograms
virtual double pt() const =0
transverse momentum
void setup()
book histograms
void setup()
book histograms
abstract base class
Definition: Benchmark.h:20
virtual void setDirectory(TDirectory *dir)
Definition: Benchmark.cc:19
void setParameters(float dRMax, bool matchCharge, Benchmark::Mode mode, float ptmin, float ptmax, float etamin, float etamax, float phimin, float phimax, bool refHistoFlag)
set the parameters locally
void setDirectory(TDirectory *dir)
set directory (to use in ROOT)
void setParameters(Mode mode)
Definition: Benchmark.h:49
CandidateBenchmark candBench_
void setRange(float ptMin, float ptMax, float etaMin, float etaMax, float phiMin, float phiMax)
Definition: Benchmark.h:51
void fillOne(const reco::Candidate &cand)
double ptmin
Definition: HydjetWrapper.h:86
MatchCandidateBenchmark matchCandBench_
Mode mode_
Definition: Benchmark.h:86
dbl *** dir
Definition: mlp_gen.cc:35
TH1F * book1D(const char *histname, const char *title, int nbins, float xmin, float xmax)
book a 1D histogram, either with DQM or plain root.
Definition: Benchmark.cc:25
virtual double phi() const =0
momentum azimuthal angle
virtual double eta() const =0
momentum pseudorapidity
PFCandidateMonitor(float dRMax=0.3, bool matchCharge=true, Benchmark::Mode mode=Benchmark::DEFAULT)