CMS 3D CMS Logo

TriggerMatchEfficiencyPlotter.cc
Go to the documentation of this file.
9 // Framework
19 
20 #include <iostream>
21 #include <cstdio>
22 #include <string>
23 #include <cmath>
24 #include "TF1.h"
25 #include "TH1F.h"
26 
27 using namespace edm;
28 using namespace std;
29 
30 //#define DEBUG
31 
33 #ifdef DEBUG
34  cout << "TriggerMatchEfficiencyPlotter(): Constructor " << endl;
35 #endif
36  parameters = ps;
37 
38  triggerhistName1_ = parameters.getParameter<string>("triggerhistName1");
39  triggerhistName2_ = parameters.getParameter<string>("triggerhistName2");
40  theFolder = parameters.getParameter<string>("folder");
41 }
43 
45  ibooker.setCurrentFolder(theFolder);
46 
47  // efficiency plot
48  h_eff_Path1_eta_tight = ibooker.book1D(
49  "matchingEff_eta_" + triggerhistName1_ + "_tight", triggerhistName1_ + ":matching Eff. vs #eta", 8, -2.5, 2.5);
50  h_eff_Path1_pt_tight = ibooker.book1D(
51  "matchingEff_pt_" + triggerhistName1_ + "_tight", triggerhistName1_ + ":matching Eff. vs pt", 10, 20, 220);
52  h_eff_Path1_phi_tight = ibooker.book1D(
53  "matchingEff_phi_" + triggerhistName1_ + "_tight", triggerhistName1_ + ":matching Eff. vs #phi", 8, -3.0, 3.0);
54  h_eff_Path2_eta_tight = ibooker.book1D(
55  "matchingEff_eta_" + triggerhistName2_ + "_tight", triggerhistName2_ + ":matching Eff. vs #eta", 8, -2.5, 2.5);
56  h_eff_Path2_pt_tight = ibooker.book1D(
57  "matchingEff_pt_" + triggerhistName2_ + "_tight", triggerhistName2_ + ":matching Eff. vs pt", 10, 20, 220);
58  h_eff_Path2_phi_tight = ibooker.book1D(
59  "matchingEff_phi_" + triggerhistName2_ + "_tight", triggerhistName2_ + ":matching Eff. vs #phi", 8, -3.0, 3.0);
60 
61  // This prevents this ME to be normalized when drawn into the GUI
62  h_eff_Path1_eta_tight->setEfficiencyFlag();
63  h_eff_Path1_pt_tight->setEfficiencyFlag();
64  h_eff_Path1_phi_tight->setEfficiencyFlag();
65  h_eff_Path2_eta_tight->setEfficiencyFlag();
66  h_eff_Path2_pt_tight->setEfficiencyFlag();
67  h_eff_Path2_phi_tight->setEfficiencyFlag();
68 
69  // AXIS TITLES....
70  h_eff_Path1_eta_tight->setAxisTitle("#eta", 1);
71  h_eff_Path1_pt_tight->setAxisTitle("pt", 1);
72  h_eff_Path1_phi_tight->setAxisTitle("#phi", 1);
73  h_eff_Path2_eta_tight->setAxisTitle("#eta", 1);
74  h_eff_Path2_pt_tight->setAxisTitle("pt", 1);
75  h_eff_Path2_phi_tight->setAxisTitle("#phi", 1);
76 
78  string inputdir = "Muons_miniAOD/TriggerMatchMonitor/EfficiencyInput";
79  string numpath_eta_path1 = inputdir + "/passHLT" + triggerhistName1_ + "_eta_Tight";
80  string denpath_eta_path1 = inputdir + "/totalHLT" + triggerhistName1_ + "_eta_Tight";
81 
82  string numpath_pt_path1 = inputdir + "/passHLT" + triggerhistName1_ + "_pt_Tight";
83  string denpath_pt_path1 = inputdir + "/totalHLT" + triggerhistName1_ + "_pt_Tight";
84 
85  string numpath_phi_path1 = inputdir + "/passHLT" + triggerhistName1_ + "_phi_Tight";
86  string denpath_phi_path1 = inputdir + "/totalHLT" + triggerhistName1_ + "_phi_Tight";
87 
88  string numpath_eta_path2 = inputdir + "/passHLT" + triggerhistName2_ + "_eta_Tight";
89  string denpath_eta_path2 = inputdir + "/totalHLT" + triggerhistName2_ + "_eta_Tight";
90 
91  string numpath_pt_path2 = inputdir + "/passHLT" + triggerhistName2_ + "_pt_Tight";
92  string denpath_pt_path2 = inputdir + "/totalHLT" + triggerhistName2_ + "_pt_Tight";
93 
94  string numpath_phi_path2 = inputdir + "/passHLT" + triggerhistName2_ + "_phi_Tight";
95  string denpath_phi_path2 = inputdir + "/totalHLT" + triggerhistName2_ + "_phi_Tight";
96 
97  MonitorElement *Numerator_eta_path1 = igetter.get(numpath_eta_path1);
98  MonitorElement *Denominator_eta_path1 = igetter.get(denpath_eta_path1);
99 
100  MonitorElement *Numerator_pt_path1 = igetter.get(numpath_pt_path1);
101  MonitorElement *Denominator_pt_path1 = igetter.get(denpath_pt_path1);
102 
103  MonitorElement *Numerator_phi_path1 = igetter.get(numpath_phi_path1);
104  MonitorElement *Denominator_phi_path1 = igetter.get(denpath_phi_path1);
105 
106  MonitorElement *Numerator_eta_path2 = igetter.get(numpath_eta_path2);
107  MonitorElement *Denominator_eta_path2 = igetter.get(denpath_eta_path2);
108 
109  MonitorElement *Numerator_pt_path2 = igetter.get(numpath_pt_path2);
110  MonitorElement *Denominator_pt_path2 = igetter.get(denpath_pt_path2);
111 
112  MonitorElement *Numerator_phi_path2 = igetter.get(numpath_phi_path2);
113  MonitorElement *Denominator_phi_path2 = igetter.get(denpath_phi_path2);
114 
115  if (Numerator_eta_path1 && Denominator_eta_path1) {
116  TH1F *h_numerator_eta_path1 = Numerator_eta_path1->getTH1F();
117  TH1F *h_denominator_eta_path1 = Denominator_eta_path1->getTH1F();
118  TH1F *h_eff_eta_path1 = h_eff_Path1_eta_tight->getTH1F();
119 
120  if (h_eff_eta_path1->GetSumw2N() == 0)
121  h_eff_eta_path1->Sumw2();
122  h_eff_eta_path1->Divide(h_numerator_eta_path1, h_denominator_eta_path1, 1., 1., "B");
123  }
124 
125  if (Numerator_pt_path1 && Denominator_pt_path1) {
126  TH1F *h_numerator_pt_path1 = Numerator_pt_path1->getTH1F();
127  TH1F *h_denominator_pt_path1 = Denominator_pt_path1->getTH1F();
128  TH1F *h_eff_pt_path1 = h_eff_Path1_pt_tight->getTH1F();
129 
130  if (h_eff_pt_path1->GetSumw2N() == 0)
131  h_eff_pt_path1->Sumw2();
132  h_eff_pt_path1->Divide(h_numerator_pt_path1, h_denominator_pt_path1, 1., 1., "B");
133  }
134 
135  if (Numerator_phi_path1 && Denominator_phi_path1) {
136  TH1F *h_numerator_phi_path1 = Numerator_phi_path1->getTH1F();
137  TH1F *h_denominator_phi_path1 = Denominator_phi_path1->getTH1F();
138  TH1F *h_eff_phi_path1 = h_eff_Path1_phi_tight->getTH1F();
139 
140  if (h_eff_phi_path1->GetSumw2N() == 0)
141  h_eff_phi_path1->Sumw2();
142  h_eff_phi_path1->Divide(h_numerator_phi_path1, h_denominator_phi_path1, 1., 1., "B");
143  }
144 
145  //trigger path2
146  if (Numerator_eta_path2 && Denominator_eta_path2) {
147  TH1F *h_numerator_eta_path2 = Numerator_eta_path2->getTH1F();
148  TH1F *h_denominator_eta_path2 = Denominator_eta_path2->getTH1F();
149  TH1F *h_eff_eta_path2 = h_eff_Path2_eta_tight->getTH1F();
150 
151  if (h_eff_eta_path2->GetSumw2N() == 0)
152  h_eff_eta_path2->Sumw2();
153  h_eff_eta_path2->Divide(h_numerator_eta_path2, h_denominator_eta_path2, 1., 1., "B");
154  }
155 
156  if (Numerator_pt_path2 && Denominator_pt_path2) {
157  TH1F *h_numerator_pt_path2 = Numerator_pt_path2->getTH1F();
158  TH1F *h_denominator_pt_path2 = Denominator_pt_path2->getTH1F();
159  TH1F *h_eff_pt_path2 = h_eff_Path2_pt_tight->getTH1F();
160 
161  if (h_eff_pt_path2->GetSumw2N() == 0)
162  h_eff_pt_path2->Sumw2();
163  h_eff_pt_path2->Divide(h_numerator_pt_path2, h_denominator_pt_path2, 1., 1., "B");
164  }
165 
166  if (Numerator_phi_path2 && Denominator_phi_path2) {
167  TH1F *h_numerator_phi_path2 = Numerator_phi_path2->getTH1F();
168  TH1F *h_denominator_phi_path2 = Denominator_phi_path2->getTH1F();
169  TH1F *h_eff_phi_path2 = h_eff_Path2_phi_tight->getTH1F();
170 
171  if (h_eff_phi_path2->GetSumw2N() == 0)
172  h_eff_phi_path2->Sumw2();
173  h_eff_phi_path2->Divide(h_numerator_phi_path2, h_denominator_phi_path2, 1., 1., "B");
174  }
175 }
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
Definition: DQMStore.cc:239
T getParameter(std::string const &) const
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:418
virtual TH1F * getTH1F() const
~TriggerMatchEfficiencyPlotter() override
Destructor.
TriggerMatchEfficiencyPlotter(const edm::ParameterSet &ps)
Constructor.
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
DQM Client Diagnostic.
HLT enums.
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:437