CMS 3D CMS Logo

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