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 {
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  TH1F *numH = num->getTH1F();
61  TH1F *denH = den->getTH1F();
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  int nBinsNum = numH->GetNbinsX();
74  int nBinsDen = denH->GetNbinsX();
75 
76  if (nBinsNum != nBinsDen) {
77  edm::LogError("L1TEfficiencyPlotHandler") << " # bins in " << numeratorName << " and " << denominatorName
78  << " are different. Quitting booking" << endl;
79  return;
80  }
81 
82  double min = numH->GetXaxis()->GetXmin();
83  double max = numH->GetXaxis()->GetXmax();
84 
86  h_efficiency_ = ibooker.book1D(plotName_, plotName_, nBinsNum, min, max);
87 
88 }
89 
91 {
92  if (!h_efficiency_)
93  return;
94 
95  edm::LogInfo("L1TEfficiencyPlotHandler") << " Computing efficiency for " << plotName_ << endl;
96 
99 
100  TH1F *numH = num->getTH1F();
101  TH1F *denH = den->getTH1F();
102 
103  numH->Sumw2();
104  denH->Sumw2();
105 
106  TH1F *effH = h_efficiency_->getTH1F();
107 
108  effH->Divide(numH, denH, 1.0, 1.0, "B");
109 }
110 
111 //___________DQM_analyzer_class________________________________________
113  verbose_(ps.getUntrackedParameter<bool>("verbose")),
114  plotHandlers_()
115 {
116  if (verbose_) {
117  edm::LogInfo("L1TEfficiencyHarvesting") << "____________ Storage initialization ____________ " << endl;
118  }
119 
120  for (auto plotConfig : ps.getUntrackedParameter < std::vector<edm::ParameterSet> > ("plotCfgs")) {
121  vector < string > plots = plotConfig.getUntrackedParameter < vector < string >> ("plots");
122  for (auto plot : plots) {
123  plotHandlers_.push_back(L1TEfficiencyPlotHandler(plotConfig, plot));
124  }
125  }
126 }
127 
128 //_____________________________________________________________________
130 {
131 }
132 
133 //_____________________________________________________________________
135 {
136  if (verbose_) {
137  edm::LogInfo("L1TEfficiencyHarvesting") << "Called endRun." << endl;
138  }
139 
140  for (auto plotHandler : plotHandlers_) {
141  plotHandler.book(ibooker, igetter);
142  plotHandler.computeEfficiency(ibooker, igetter);
143  }
144 }
145 
146 //_____________________________________________________________________
148  EventSetup const& c)
149 {
150  if (verbose_) {
151  edm::LogInfo("L1TEfficiencyHarvesting") << "Called endLuminosityBlock at LS=" << lumiBlock.id().luminosityBlock()
152  << endl;
153  }
154 }
155 
156 //define this as a plug-in
158 } //l1t
159 } // dqmoffline
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
L1TEfficiencyHarvesting(const edm::ParameterSet &ps)
L1TEfficiencyPlotHandler(std::string dir, std::string plotName)
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
delete x;
Definition: CaloConfig.h:22
void computeEfficiency(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
L1TEfficiencyPlotHandler(const edm::ParameterSet &ps, std::string plotName)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
virtual void dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) override
T min(T a, T b)
Definition: MathUtil.h:58
L1TEfficiencyPlotHandlerCollection plotHandlers_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
TH1F * getTH1F(void) const
LuminosityBlockNumber_t luminosityBlock() const
void book(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
HLT enums.