1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
// Migrated to use DQMEDHarvester by: Jyothsna Rani Komaragiri, Oct 2014
#include "HLTriggerOffline/JetMET/interface/JetMETDQMPostProcessor.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include <cmath>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
JetMETDQMPostProcessor::JetMETDQMPostProcessor(const edm::ParameterSet &pset) {
subDir_ = pset.getUntrackedParameter<std::string>("subDir");
patternJetTrg_ = pset.getUntrackedParameter<std::string>("PatternJetTrg", "");
patternMetTrg_ = pset.getUntrackedParameter<std::string>("PatternMetTrg", "");
}
void JetMETDQMPostProcessor::dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) {
//////////////////////////////////
// setup DQM stor //
//////////////////////////////////
bool isJetDir = false;
bool isMetDir = false;
TPRegexp patternJet(patternJetTrg_);
TPRegexp patternMet(patternMetTrg_);
// go to the directory to be processed
if (igetter.dirExists(subDir_))
ibooker.cd(subDir_);
else {
edm::LogWarning("JetMETDQMPostProcessor") << "cannot find directory: " << subDir_ << " , skipping";
return;
}
std::vector<std::string> subdirectories = igetter.getSubdirs();
for (std::vector<std::string>::iterator dir = subdirectories.begin(); dir != subdirectories.end(); dir++) {
ibooker.cd(*dir);
isJetDir = false;
isMetDir = false;
if (TString(*dir).Contains(patternJet))
isJetDir = true;
if (TString(*dir).Contains(patternMet))
isMetDir = true;
if (isMetDir) {
// std::cout << "JetMETDQMPostProcessor - Met paths: " << ibooker.pwd() <<
// " " << *dir << std::endl;
// GenMET
dividehistos(ibooker,
igetter,
"_meGenMETTrgMC",
"_meGenMET",
"_meTurnOngMET",
"Gen Missing ET",
"Gen Missing ET Turn-On RelVal");
dividehistos(ibooker,
igetter,
"_meGenMETTrg",
"_meGenMETTrgLow",
"_meTurnOngMETLow",
"Gen Missing ETLow",
"Gen Missing ET Turn-On Data");
// HLTMET
dividehistos(ibooker,
igetter,
"_meHLTMETTrgMC",
"_meHLTMET",
"_meTurnOnhMET",
"HLT Missing ET",
"HLT Missing ET Turn-On RelVal");
dividehistos(ibooker,
igetter,
"_meHLTMETTrg",
"_meHLTMETTrgLow",
"_meTurnOnhMETLow",
"HLT Missing ETLow",
"HLT Missing ET Turn-On Data");
}
if (isJetDir) {
// std::cout << "JetMETDQMPostProcessor - Jet paths: " << ibooker.pwd() <<
// " " << *dir << std::endl;
// GenJets
dividehistos(ibooker,
igetter,
"_meGenJetPtTrgMC",
"_meGenJetPt",
"_meTurnOngJetPt",
"Gen Jet Pt",
"Gen Jet Pt Turn-On RelVal");
dividehistos(ibooker,
igetter,
"_meGenJetPtTrg",
"_meGenJetPtTrgLow",
"_meTurnOngJetPtLow",
"Gen Jet PtLow",
"Gen Jet Pt Turn-On Data");
dividehistos(ibooker,
igetter,
"_meGenJetEtaTrgMC",
"_meGenJetEta",
"_meTurnOngJetEta",
"Gen Jet Eta",
"Gen Jet Eta Turn-On RelVal");
dividehistos(ibooker,
igetter,
"_meGenJetEtaTrg",
"_meGenJetEtaTrgLow",
"_meTurnOngJetEtaLow",
"Gen Jet EtaLow",
"Gen Jet Eta Turn-On Data");
dividehistos(ibooker,
igetter,
"_meGenJetPhiTrgMC",
"_meGenJetPhi",
"_meTurnOngJetPhi",
"Gen Jet Phi",
"Gen Jet Phi Turn-On RelVal");
dividehistos(ibooker,
igetter,
"_meGenJetPhiTrg",
"_meGenJetPhiTrgLow",
"_meTurnOngJetPhiLow",
"Gen Jet PhiLow",
"Gen Jet Phi Turn-On Data");
// HLTJets
dividehistos(ibooker,
igetter,
"_meHLTJetPtTrgMC",
"_meHLTJetPt",
"_meTurnOnhJetPt",
"HLT Jet Pt",
"HLT Jet Pt Turn-On RelVal");
dividehistos(ibooker,
igetter,
"_meHLTJetPtTrg",
"_meHLTJetPtTrgLow",
"_meTurnOnhJetPtLow",
"HLT Jet PtLow",
"HLT Jet Pt Turn-On Data");
dividehistos(ibooker,
igetter,
"_meHLTJetEtaTrgMC",
"_meHLTJetEta",
"_meTurnOnhJetEta",
"HLT Jet Eta",
"HLT Jet Eta Turn-On RelVal");
dividehistos(ibooker,
igetter,
"_meHLTJetEtaTrg",
"_meHLTJetEtaTrgLow",
"_meTurnOnhJetEtaLow",
"HLT Jet EtaLow",
"HLT Jet Eta Turn-On Data");
dividehistos(ibooker,
igetter,
"_meHLTJetPhiTrgMC",
"_meHLTJetPhi",
"_meTurnOnhJetPhi",
"HLT Jet Phi",
"HLT Jet Phi Turn-On RelVal");
dividehistos(ibooker,
igetter,
"_meHLTJetPhiTrg",
"_meHLTJetPhiTrgLow",
"_meTurnOnhJetPhiLow",
"HLT Jet PhiLow",
"HLT Jet Phi Turn-On Data");
}
ibooker.goUp();
}
}
//----------------------------------------------------------------------
TProfile *JetMETDQMPostProcessor::dividehistos(DQMStore::IBooker &ibooker,
DQMStore::IGetter &igetter,
const std::string &numName,
const std::string &denomName,
const std::string &outName,
const std::string &label,
const std::string &titel) {
// ibooker.pwd();
// std::cout << "In dividehistos: " << ibooker.pwd() << std::endl;
// std::cout << numName <<std::endl;
TH1F *num = getHistogram(ibooker, igetter, ibooker.pwd() + "/" + numName);
// std::cout << denomName << std::endl;
TH1F *denom = getHistogram(ibooker, igetter, ibooker.pwd() + "/" + denomName);
if (num == nullptr)
edm::LogWarning("JetMETDQMPostProcessor")
<< "numerator histogram " << ibooker.pwd() + "/" + numName << " does not exist";
if (denom == nullptr)
edm::LogWarning("JetMETDQMPostProcessor")
<< "denominator histogram " << ibooker.pwd() + "/" + denomName << " does not exist";
// Check if histograms actually exist
if (!num || !denom)
return nullptr;
MonitorElement *meOut = ibooker.bookProfile(
outName, titel, num->GetXaxis()->GetNbins(), num->GetXaxis()->GetXmin(), num->GetXaxis()->GetXmax(), 0., 1.2);
meOut->setEfficiencyFlag();
TProfile *out = meOut->getTProfile();
out->GetXaxis()->SetTitle(label.c_str());
out->SetYTitle("Efficiency");
out->SetOption("PE");
out->SetLineColor(2);
out->SetLineWidth(2);
out->SetMarkerStyle(20);
out->SetMarkerSize(0.8);
out->SetStats(kFALSE);
for (int i = 1; i <= num->GetNbinsX(); i++) {
double e, low, high;
Efficiency((int)num->GetBinContent(i), (int)denom->GetBinContent(i), 0.683, e, low, high);
double err = e - low > high - e ? e - low : high - e;
// here is the trick to store info in TProfile:
out->SetBinContent(i, e);
out->SetBinEntries(i, 1);
out->SetBinError(i, sqrt(e * e + err * err));
}
return out;
}
//----------------------------------------------------------------------
TH1F *JetMETDQMPostProcessor::getHistogram(DQMStore::IBooker &ibooker,
DQMStore::IGetter &igetter,
const std::string &histoPath) {
ibooker.pwd();
MonitorElement *monElement = igetter.get(histoPath);
if (monElement != nullptr)
return monElement->getTH1F();
else
return nullptr;
}
//----------------------------------------------------------------------
void JetMETDQMPostProcessor::Efficiency(
int passing, int total, double level, double &mode, double &lowerBound, double &upperBound) {
// protection
if (total == 0) {
mode = 0.5;
lowerBound = 0;
upperBound = 1;
return;
}
mode = passing / ((double)total);
// see http://root.cern.ch/root/html/TEfficiency.html#compare
lowerBound = TEfficiency::Wilson(total, passing, level, false);
upperBound = TEfficiency::Wilson(total, passing, level, true);
}
//----------------------------------------------------------------------
DEFINE_FWK_MODULE(JetMETDQMPostProcessor);
|