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::LogError("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::LogError("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  }
104 }
105 
107 {
108  if (!h_efficiency_)
109  return;
110 
111  edm::LogInfo("L1TEfficiencyPlotHandler") << " Computing efficiency for " << plotName_ << endl;
112 
115 
116  TH1 *numH = num->getTH1();
117  TH1 *denH = den->getTH1();
118  TH1 *effH = h_efficiency_->getTH1();
119 
120  effH->Divide(numH, denH, 1.0, 1.0, "B");
121 }
122 
123 //___________DQM_analyzer_class________________________________________
125  verbose_(ps.getUntrackedParameter<bool>("verbose")),
126  plotHandlers_()
127 {
128  if (verbose_) {
129  edm::LogInfo("L1TEfficiencyHarvesting") << "____________ Storage initialization ____________ " << endl;
130  }
131 
132  for (auto plotConfig : ps.getUntrackedParameter < std::vector<edm::ParameterSet> > ("plotCfgs")) {
133  vector < string > plots = plotConfig.getUntrackedParameter < vector < string >> ("plots");
134  for (auto plot : plots) {
135  plotHandlers_.push_back(L1TEfficiencyPlotHandler(plotConfig, plot));
136  }
137  }
138 }
139 
140 //_____________________________________________________________________
142 {
143 }
144 
145 //_____________________________________________________________________
147 {
148  if (verbose_) {
149  edm::LogInfo("L1TEfficiencyHarvesting") << "Called endRun." << endl;
150  }
151 
152  for (auto plotHandler : plotHandlers_) {
153  plotHandler.book(ibooker, igetter);
154  plotHandler.computeEfficiency(ibooker, igetter);
155  }
156 }
157 
158 //_____________________________________________________________________
160  EventSetup const& c)
161 {
162  if (verbose_) {
163  edm::LogInfo("L1TEfficiencyHarvesting") << "Called endLuminosityBlock at LS=" << lumiBlock.id().luminosityBlock()
164  << endl;
165  }
166 }
167 
168 //define this as a plug-in
170 } //l1t
171 } // dqmoffline
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
L1TEfficiencyHarvesting(const edm::ParameterSet &ps)
virtual void dqmEndLuminosityBlock(DQMStore::IGetter &igetter, edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
L1TEfficiencyPlotHandler(const edm::ParameterSet &ps, std::string plotName)
delete x;
Definition: CaloConfig.h:22
bool is2D(HitType hitType)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
TH1 * getTH1(void) const
void dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) override
Kind kind(void) const
Get the type of the monitor element.
L1TEfficiencyPlotHandlerCollection plotHandlers_
void book(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
TH1F * getTH1F(void) const
LuminosityBlockNumber_t luminosityBlock() const
HLT enums.
void computeEfficiency(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
TH2F * getTH2F(void) const