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")
46  << (!num && !den ? numeratorName + " && " + denominatorName : !num ? numeratorName : denominatorName)
47  << " not gettable. Quitting booking" << endl;
48  return;
49  }
50 
51  TH1 *numH = num->getTH1();
52  TH1 *denH = den->getTH1();
53 
54  if (!numH || !denH) {
55  edm::LogWarning("L1TEfficiencyPlotHandler")
56  << (!numH && !denH ? numeratorName + " && " + denominatorName : !num ? numeratorName : denominatorName)
57  << " is not TH1F. Quitting booking" << endl;
58 
59  return;
60  }
61 
62  if (numH->GetNbinsX() != denH->GetNbinsX()) {
63  edm::LogWarning("L1TEfficiencyPlotHandler") << " # X bins in " << numeratorName << " and " << denominatorName
64  << " are different. Quitting booking" << endl;
65  return;
66  }
67 
68  MonitorElement::Kind kind = num->kind();
71 
72  if (is2D) {
73  if (numH->GetNbinsY() != denH->GetNbinsY()) {
74  edm::LogWarning("L1TEfficiencyPlotHandler") << " # Y bins in " << numeratorName << " and " << denominatorName
75  << " are different. Quitting booking" << endl;
76  return;
77  }
78  }
79 
81  if (is1D) {
82  h_efficiency_ = ibooker.book1D(plotName_, den->getTH1F());
83  } else if (is2D) {
84  h_efficiency_ = ibooker.book2D(plotName_, den->getTH2F());
85  }
87  }
88 
90  if (!h_efficiency_)
91  return;
92 
93  edm::LogInfo("L1TEfficiencyPlotHandler") << " Computing efficiency for " << plotName_ << endl;
94 
97 
98  TH1 *numH = num->getTH1();
99  TH1 *denH = den->getTH1();
100  TH1 *effH = h_efficiency_->getTH1();
101 
102  effH->Divide(numH, denH, 1.0, 1.0, "B");
103  }
104 
105  //___________DQM_analyzer_class________________________________________
107  : verbose_(ps.getUntrackedParameter<bool>("verbose")), plotHandlers_() {
108  if (verbose_) {
109  edm::LogInfo("L1TEfficiencyHarvesting") << "____________ Storage initialization ____________ " << endl;
110  }
111 
112  for (const auto &plotConfig : ps.getUntrackedParameter<std::vector<edm::ParameterSet>>("plotCfgs")) {
113  vector<string> plots = plotConfig.getUntrackedParameter<vector<string>>("plots");
114  for (const auto &plot : plots) {
115  plotHandlers_.push_back(L1TEfficiencyPlotHandler(plotConfig, plot));
116  }
117  }
118  }
119 
120  //_____________________________________________________________________
122 
123  //_____________________________________________________________________
125  if (verbose_) {
126  edm::LogInfo("L1TEfficiencyHarvesting") << "Called endRun." << endl;
127  }
128 
129  for (auto plotHandler : plotHandlers_) {
130  plotHandler.book(ibooker, igetter);
131  plotHandler.computeEfficiency(ibooker, igetter);
132  }
133  }
134 
135  //define this as a plug-in
137  } // namespace l1t
138 } // 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:393
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:461
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:478
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:21
dqmoffline::l1t::L1TEfficiencyHarvesting
Definition: L1TEfficiencyHarvesting.h:69
dqm::legacy::MonitorElement::getTH1
virtual TH1 * getTH1() const
Definition: MonitorElement.h:474
dqmoffline::l1t::L1TEfficiencyPlotHandler::computeEfficiency
void computeEfficiency(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
Definition: L1TEfficiencyHarvesting.cc:89
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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:106
dqmoffline::l1t::L1TEfficiencyHarvesting::~L1TEfficiencyHarvesting
~L1TEfficiencyHarvesting() override
Definition: L1TEfficiencyHarvesting.cc:121
MonitorElementData::Kind::TH1D
CalibrationSummaryClient_cfi.kind
kind
Definition: CalibrationSummaryClient_cfi.py:37
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
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:651
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:124
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:490