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 {
26 
27 }
28 
32  outputDir_(handler.outputDir_),
33  plotName_(handler.plotName_),
37 {
38 
39 }
40 
42 {
43 
44  edm::LogInfo("L1TEfficiencyPlotHandler") << "Booking efficiency histogram for " << outputDir_ << " and " << plotName_
45  << endl;
46 
47  std::string numeratorName = numeratorDir_ + "/" + plotName_ + numeratorSuffix_;
48  std::string denominatorName = denominatorDir_ + "/" + plotName_ + denominatorSuffix_;
49  MonitorElement *num = igetter.get(numeratorName);
50  MonitorElement *den = igetter.get(denominatorName);
51 
52  if (!num || !den) {
53 
54  edm::LogWarning("L1TEfficiencyPlotHandler")
55  << (!num && !den ? numeratorName + " && " + denominatorName : !num ? numeratorName : denominatorName)
56  << " not gettable. Quitting booking" << endl;
57  return;
58  }
59 
60  TH1 *numH = num->getTH1();
61  TH1 *denH = den->getTH1();
62 
63  if (!numH || !denH) {
64 
65  edm::LogWarning("L1TEfficiencyPlotHandler")
66  << (!numH && !denH ? numeratorName + " && " + denominatorName : !num ? numeratorName : denominatorName)
67  << " is not TH1F. Quitting booking" << endl;
68 
69  return;
70 
71  }
72 
73  if (numH->GetNbinsX() != denH->GetNbinsX()) {
75  "L1TEfficiencyPlotHandler") << " # X bins in " <<
76  numeratorName << " and " << denominatorName <<
77  " are different. Quitting booking" << endl;
78  return;
79  }
80 
82  bool is1D = kind == MonitorElement::DQM_KIND_TH1F ||
84  bool is2D = kind == MonitorElement::DQM_KIND_TH2F ||
86 
87  if (is2D) {
88  if (numH->GetNbinsY() != denH->GetNbinsY()) {
90  "L1TEfficiencyPlotHandler") << " # Y bins in " << numeratorName <<
91  " and " << denominatorName << " are different. Quitting booking" <<
92  endl;
93  return;
94  }
95  }
96 
98  if (is1D) {
99  h_efficiency_ = ibooker.book1D(plotName_, den->getTH1F());
100  }
101  else if (is2D) {
102  h_efficiency_ = ibooker.book2D(plotName_, den->getTH2F());
103  }
105 }
106 
108 {
109  if (!h_efficiency_)
110  return;
111 
112  edm::LogInfo("L1TEfficiencyPlotHandler") << " Computing efficiency for " << plotName_ << endl;
113 
116 
117  TH1 *numH = num->getTH1();
118  TH1 *denH = den->getTH1();
119  TH1 *effH = h_efficiency_->getTH1();
120 
121  effH->Divide(numH, denH, 1.0, 1.0, "B");
122 }
123 
124 //___________DQM_analyzer_class________________________________________
126  verbose_(ps.getUntrackedParameter<bool>("verbose")),
127  plotHandlers_()
128 {
129  if (verbose_) {
130  edm::LogInfo("L1TEfficiencyHarvesting") << "____________ Storage initialization ____________ " << endl;
131  }
132 
133  for (auto plotConfig : ps.getUntrackedParameter < std::vector<edm::ParameterSet> > ("plotCfgs")) {
134  vector < string > plots = plotConfig.getUntrackedParameter < vector < string >> ("plots");
135  for (auto plot : plots) {
136  plotHandlers_.push_back(L1TEfficiencyPlotHandler(plotConfig, plot));
137  }
138  }
139 }
140 
141 //_____________________________________________________________________
143 {
144 }
145 
146 //_____________________________________________________________________
148 {
149  if (verbose_) {
150  edm::LogInfo("L1TEfficiencyHarvesting") << "Called endRun." << endl;
151  }
152 
153  for (auto plotHandler : plotHandlers_) {
154  plotHandler.book(ibooker, igetter);
155  plotHandler.computeEfficiency(ibooker, igetter);
156  }
157 }
158 
159 
160 //define this as a plug-in
162 } //l1t
163 } // dqmoffline
T getUntrackedParameter(std::string const &, T const &) const
L1TEfficiencyHarvesting(const edm::ParameterSet &ps)
TH1F * getTH1F() const
L1TEfficiencyPlotHandler(const edm::ParameterSet &ps, std::string plotName)
TH1 * getTH1() const
delete x;
Definition: CaloConfig.h:22
void setEfficiencyFlag()
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
bool is2D(HitType hitType)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
void dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) override
TH2F * getTH2F() const
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:303
L1TEfficiencyPlotHandlerCollection plotHandlers_
void book(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
HLT enums.
void computeEfficiency(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
Kind kind() const
Get the type of the monitor element.