CMS 3D CMS Logo

L1TEfficiencyHarvesting.cc
Go to the documentation of this file.
1 
8 // L1TMonitor includes
11 
12 using namespace edm;
13 using namespace std;
14 
15 namespace dqmoffline {
16  namespace l1t {
17  L1TEfficiencyPlotHandler::L1TEfficiencyPlotHandler(const ParameterSet &ps, std::string plotName)
18  : numeratorDir_(ps.getUntrackedParameter<std::string>("numeratorDir")),
19  denominatorDir_(ps.getUntrackedParameter<std::string>("denominatorDir", numeratorDir_)),
20  outputDir_(ps.getUntrackedParameter<std::string>("outputDir", numeratorDir_)),
21  plotName_(plotName),
22  numeratorSuffix_(ps.getUntrackedParameter<std::string>("numeratorSuffix", "Num")),
23  denominatorSuffix_(ps.getUntrackedParameter<std::string>("denominatorSuffix", "Den")),
24  h_efficiency_() {}
25 
27  : numeratorDir_(handler.numeratorDir_),
28  denominatorDir_(handler.denominatorDir_),
29  outputDir_(handler.outputDir_),
30  plotName_(handler.plotName_),
31  numeratorSuffix_(handler.numeratorSuffix_),
32  denominatorSuffix_(handler.denominatorSuffix_),
33  h_efficiency_(handler.h_efficiency_) {}
34 
36  edm::LogInfo("L1TEfficiencyPlotHandler")
37  << "Booking efficiency histogram for " << outputDir_ << " and " << plotName_ << endl;
38 
39  std::string numeratorName = numeratorDir_ + "/" + plotName_ + numeratorSuffix_;
40  std::string denominatorName = denominatorDir_ + "/" + plotName_ + denominatorSuffix_;
41  MonitorElement *num = igetter.get(numeratorName);
42  MonitorElement *den = igetter.get(denominatorName);
43 
44  if (!num || !den) {
45  edm::LogWarning("L1TEfficiencyPlotHandler") << (!num && !den ? numeratorName + " && " + denominatorName
46  : !num ? numeratorName
47  : denominatorName)
48  << " not gettable. Quitting booking" << endl;
49  return;
50  }
51 
52  TH1 *numH = num->getTH1();
53  TH1 *denH = den->getTH1();
54 
55  if (!numH || !denH) {
56  edm::LogWarning("L1TEfficiencyPlotHandler") << (!numH && !denH ? numeratorName + " && " + denominatorName
57  : !num ? numeratorName
58  : denominatorName)
59  << " is not TH1F. Quitting booking" << endl;
60 
61  return;
62  }
63 
64  if (numH->GetNbinsX() != denH->GetNbinsX()) {
65  edm::LogWarning("L1TEfficiencyPlotHandler") << " # X bins in " << numeratorName << " and " << denominatorName
66  << " are different. Quitting booking" << endl;
67  return;
68  }
69 
70  MonitorElement::Kind kind = num->kind();
73 
74  if (is2D) {
75  if (numH->GetNbinsY() != denH->GetNbinsY()) {
76  edm::LogWarning("L1TEfficiencyPlotHandler") << " # Y bins in " << numeratorName << " and " << denominatorName
77  << " are different. Quitting booking" << endl;
78  return;
79  }
80  }
81 
83  if (is1D) {
84  h_efficiency_ = ibooker.book1D(plotName_, den->getTH1F());
85  } else if (is2D) {
86  h_efficiency_ = ibooker.book2D(plotName_, den->getTH2F());
87  }
89  }
90 
92  if (!h_efficiency_)
93  return;
94 
95  edm::LogInfo("L1TEfficiencyPlotHandler") << " Computing efficiency for " << plotName_ << endl;
96 
99 
100  TH1 *numH = num->getTH1();
101  TH1 *denH = den->getTH1();
102  TH1 *effH = h_efficiency_->getTH1();
103 
104  effH->Divide(numH, denH, 1.0, 1.0, "B");
105  }
106 
107  //___________DQM_analyzer_class________________________________________
109  : verbose_(ps.getUntrackedParameter<bool>("verbose")), plotHandlers_() {
110  if (verbose_) {
111  edm::LogInfo("L1TEfficiencyHarvesting") << "____________ Storage initialization ____________ " << endl;
112  }
113 
114  for (const auto &plotConfig : ps.getUntrackedParameter<std::vector<edm::ParameterSet>>("plotCfgs")) {
115  vector<string> plots = plotConfig.getUntrackedParameter<vector<string>>("plots");
116  for (const auto &plot : plots) {
117  plotHandlers_.push_back(L1TEfficiencyPlotHandler(plotConfig, plot));
118  }
119  }
120  }
121 
122  //_____________________________________________________________________
124 
125  //_____________________________________________________________________
127  if (verbose_) {
128  edm::LogInfo("L1TEfficiencyHarvesting") << "Called endRun." << endl;
129  }
130 
131  for (auto plotHandler : plotHandlers_) {
132  plotHandler.book(ibooker, igetter);
133  plotHandler.computeEfficiency(ibooker, igetter);
134  }
135  }
136 
137  //define this as a plug-in
139  } // namespace l1t
140 } // namespace dqmoffline
L1TEfficiencyHarvesting.h
dqmoffline::l1t::L1TEfficiencyPlotHandler::L1TEfficiencyPlotHandler
L1TEfficiencyPlotHandler(const edm::ParameterSet &ps, std::string plotName)
Definition: L1TEfficiencyHarvesting.cc:17
electrons_cff.bool
bool
Definition: electrons_cff.py:366
dqmoffline::l1t::L1TEfficiencyPlotHandler::book
void book(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
Definition: L1TEfficiencyHarvesting.cc:35
MonitorElementData::Kind::TH1F
edm
HLT enums.
Definition: AlignableModifier.h:19
dqm::impl::MonitorElement::setEfficiencyFlag
void setEfficiencyFlag()
Definition: MonitorElement.h:267
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
dqmoffline::l1t::L1TEfficiencyPlotHandler::outputDir_
std::string outputDir_
Definition: L1TEfficiencyHarvesting.h:55
plotFactory.plot
plot
Definition: plotFactory.py:109
dqm::legacy::MonitorElement::getTH1F
virtual TH1F * getTH1F() const
Definition: MonitorElement.h:479
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
MonitorElementData::Kind::TH2D
MonitorElementData::Kind::TH2F
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
L1TEGammaDiff_cfi.plotName
plotName
Definition: L1TEGammaDiff_cfi.py:20
dqmoffline::l1t::L1TEfficiencyHarvesting
Definition: L1TEfficiencyHarvesting.h:69
dqm::legacy::MonitorElement::getTH1
virtual TH1 * getTH1() const
Definition: MonitorElement.h:475
dqmoffline::l1t::L1TEfficiencyPlotHandler::computeEfficiency
void computeEfficiency(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
Definition: L1TEfficiencyHarvesting.cc:91
dqmoffline::l1t::L1TEfficiencyHarvesting::verbose_
bool verbose_
Definition: L1TEfficiencyHarvesting.h:78
dqmoffline::l1t::L1TEfficiencyPlotHandler
Definition: L1TEfficiencyHarvesting.h:35
edm::ParameterSet
Definition: ParameterSet.h:47
HLTObjectsMonitor_cfi.plots
plots
Definition: HLTObjectsMonitor_cfi.py:17
dqmoffline::l1t::L1TEfficiencyPlotHandler::plotName_
std::string plotName_
Definition: L1TEfficiencyHarvesting.h:56
l1t
delete x;
Definition: CaloConfig.h:22
dqmoffline
Definition: HistDefinition.h:48
MonitorElementData::Kind
Kind
Definition: MonitorElementCollection.h:129
dqmoffline::l1t::L1TEfficiencyHarvesting::L1TEfficiencyHarvesting
L1TEfficiencyHarvesting(const edm::ParameterSet &ps)
Definition: L1TEfficiencyHarvesting.cc:108
dqmoffline::l1t::L1TEfficiencyHarvesting::~L1TEfficiencyHarvesting
~L1TEfficiencyHarvesting() override
Definition: L1TEfficiencyHarvesting.cc:123
MonitorElementData::Kind::TH1D
CalibrationSummaryClient_cfi.kind
kind
Definition: CalibrationSummaryClient_cfi.py:37
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:33
dqmoffline::l1t::L1TEfficiencyHarvesting::plotHandlers_
L1TEfficiencyPlotHandlerCollection plotHandlers_
Definition: L1TEfficiencyHarvesting.h:80
std
Definition: JetResolutionObject.h:76
dqm::implementation::IGetter
Definition: DQMStore.h:484
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
dqmoffline::l1t::L1TEfficiencyPlotHandler::numeratorSuffix_
std::string numeratorSuffix_
Definition: L1TEfficiencyHarvesting.h:57
fastTrackerRecHitType::is2D
bool is2D(HitType hitType)
Definition: FastTrackerRecHit.h:36
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
dqmoffline::l1t::L1TEfficiencyPlotHandler::denominatorSuffix_
std::string denominatorSuffix_
Definition: L1TEfficiencyHarvesting.h:58
dqm::implementation::IBooker
Definition: DQMStore.h:43
dqmoffline::l1t::L1TEfficiencyPlotHandler::numeratorDir_
std::string numeratorDir_
Definition: L1TEfficiencyHarvesting.h:53
dqmoffline::l1t::L1TEfficiencyPlotHandler::h_efficiency_
MonitorElement * h_efficiency_
Definition: L1TEfficiencyHarvesting.h:60
dqmoffline::l1t::L1TEfficiencyPlotHandler::denominatorDir_
std::string denominatorDir_
Definition: L1TEfficiencyHarvesting.h:54
dqmoffline::l1t::L1TEfficiencyHarvesting::dqmEndJob
void dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) override
Definition: L1TEfficiencyHarvesting.cc:126
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
dqm::legacy::MonitorElement::getTH2F
virtual TH2F * getTH2F() const
Definition: MonitorElement.h:491