CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TEfficiency_Harvesting.cc
Go to the documentation of this file.
1 
10 // L1TMonitor includes
14 #include "DataFormats/Common/interface/ConditionsInEdm.h" // Parameters associated to Run, LS and Event
15 #include "DataFormats/Luminosity/interface/LumiDetails.h" // Luminosity Information
16 #include "DataFormats/Luminosity/interface/LumiSummary.h" // Luminosity Information
25 #include "TList.h"
26 #include "TEfficiency.h"
27 #include "TGraph.h"
28 #include "TGraphAsymmErrors.h"
29 
30 using namespace edm;
31 using namespace std;
32 
33 //__________Efficiency_Plot_Handler_Helper_Class_______________________
35  m_dir = handler.m_dir;
36  m_plotName = handler.m_plotName;
37  m_effHisto = handler.m_effHisto;
38 }
39 
41 
42  cout << "[L1TEfficiencyMuons_Harvesting:] Booking efficiency histo for " << m_dir << " and " << m_plotName << endl;
43 
44  MonitorElement *num = igetter.get(m_dir+"/"+m_plotName+"Num");
45  MonitorElement *den = igetter.get(m_dir+"/"+m_plotName+"Den");
46 
47  if (!num || !den) {
48  cout << "[L1TEfficiencyMuons_Harvesting:] " << (!num && !den ? "Num && Den" : !num ? "Num" : "Den") << " not gettable. Quitting booking" << endl;
49  return;
50  }
51  TH1F *numH = num->getTH1F();
52  TH1F *denH = den->getTH1F();
53 
54  if (!numH || !denH) {
55  cout << "[L1TEfficiencyMuons_Harvesting:] " << (!numH && !denH ? "Num && Den" : !numH ? "Num" : "Den") << " is not TH1F. Quitting booking" << endl;
56  return;
57  }
58 
59  int nBinsNum = numH->GetNbinsX();
60  int nBinsDen = denH->GetNbinsX();
61 
62  if (nBinsNum != nBinsDen) {
63  cout << "[L1TEfficiencyMuons_Harvesting:] # bins in num and den is different. Quitting booking" << endl;
64  return;
65  }
66 
67  double min = numH->GetXaxis()->GetXmin();
68  double max = numH->GetXaxis()->GetXmax();
69 
70  ibooker.setCurrentFolder(m_dir);
71 
72  string pt_sketo = "EffvsPt";
73 
74  string ptS20 = "EffvsPt_SINGLE_20";
75  string etaS20 = "EffvsEta_SINGLE_20";
76  string phiS20 = "EffvsPhi_SINGLE_20";
77 
78  string ptS16 = "EffvsPt_SINGLE_16";
79  string etaS16 = "EffvsEta_SINGLE_16";
80  string phiS16 = "EffvsPhi_SINGLE_16";
81 
82  string ptS25 = "EffvsPt_SINGLE_25";
83  string etaS25 = "EffvsEta_SINGLE_25";
84  string phiS25 = "EffvsPhi_SINGLE_25";
85 
86  if (m_plotName == pt_sketo.c_str()) {
87  string title = "L1T Efficiency vs pt [-]";
88  float xbins[33] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 55, 60, 65, 70, 80, 90, 100};
89  m_effHisto = ibooker.book1D(m_plotName,title.c_str(),32, xbins);
90  }
91  if (m_plotName == ptS20.c_str()) {
92  string title = "";
93  float xbins[33] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 55, 60, 65, 70, 80, 90, 100};
94  m_effHisto = ibooker.book1D(m_plotName,title.c_str(),32, xbins);
95  }
96  else if (m_plotName == etaS20.c_str()) {
97  string title = "";
98  m_effHisto = ibooker.book1D(m_plotName,title.c_str(),nBinsNum,min,max);
99  }
100  else if (m_plotName == phiS20.c_str()) {
101  string title = "";
102  m_effHisto = ibooker.book1D(m_plotName,title.c_str(),nBinsNum,min,max);
103  }
104  else if (m_plotName == ptS16.c_str()) {
105  string title = "";
106  float xbins[33] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 55, 60, 65, 70, 80, 90, 100};
107  m_effHisto = ibooker.book1D(m_plotName,title.c_str(),32, xbins);
108  }
109  else if (m_plotName == etaS16.c_str()) {
110  string title = "";
111  m_effHisto = ibooker.book1D(m_plotName,title.c_str(),nBinsNum,min,max);
112  }
113  else if (m_plotName == phiS16.c_str()) {
114  string title = "";
115  m_effHisto = ibooker.book1D(m_plotName,title.c_str(),nBinsNum,min,max);
116  }
117  else if (m_plotName == ptS25.c_str()) {
118  string title = "";
119  float xbins[33] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 55, 60, 65, 70, 80, 90, 100};
120  m_effHisto = ibooker.book1D(m_plotName,title.c_str(),32, xbins);
121  }
122  else if (m_plotName == etaS25.c_str()) {
123  string title = "";
124  m_effHisto = ibooker.book1D(m_plotName,title.c_str(),nBinsNum,min,max);
125  }
126  else if (m_plotName == phiS25.c_str()) {
127  string title = "";
128  m_effHisto = ibooker.book1D(m_plotName,title.c_str(),nBinsNum,min,max);
129  }
130  else {
131  m_effHisto = ibooker.book1D(m_plotName,m_plotName,nBinsNum,min,max);
132  }
133 }
134 
136 
137  if (!m_effHisto) return;
138 
139  cout << "[L1TEfficiencyMuons_Harvesting:] Computing efficiency for " << m_plotName << endl;
140 
141  MonitorElement *num = igetter.get(m_dir+"/"+m_plotName+"Num");
142  MonitorElement *den = igetter.get(m_dir+"/"+m_plotName+"Den");
143 
144  TH1F *numH = num->getTH1F();
145  TH1F *denH = den->getTH1F();
146 
147  numH->Sumw2();
148  denH->Sumw2();
149 
150  TH1F *effH = m_effHisto->getTH1F();
151 
152 //************************************************************************
153 
154  string pt_sketo = "EffvsPt";
155 
156  string ptS20 = "EffvsPt_SINGLE_20";
157  string etaS20 = "EffvsEta_SINGLE_20";
158  string phiS20 = "EffvsPhi_SINGLE_20";
159 
160  string ptS16 = "EffvsPt_SINGLE_16";
161  string etaS16 = "EffvsEta_SINGLE_16";
162  string phiS16 = "EffvsPhi_SINGLE_16";
163 
164  string ptS25 = "EffvsPt_SINGLE_25";
165  string etaS25 = "EffvsEta_SINGLE_25";
166  string phiS25 = "EffvsPhi_SINGLE_25";
167 
168  if (m_plotName == ptS20.c_str()) {
169  effH->GetXaxis()->SetTitle("p_{T}\\,(\\text{Reco} \\, \\mu) ~\\text{[GeV]}");
170  effH->SetTitle("\\text{Single} \\, \\, \\text{Muon} \\, \\, \\text{Quality} ~[\\geq 12] ~/~ p_{T}(\\text{L1} \\, \\mu) \\geq 20 \\, \\text{GeV}");
171  }
172  else if (m_plotName == etaS20.c_str()) {
173  effH->GetXaxis()->SetTitle("\\eta \\,(\\text{Reco} \\, \\mu) ");
174  effH->SetTitle("\\text{Single} \\, \\, \\text{Muon} \\, \\, \\text{Quality} ~[\\geq 12] ~/~ p_{T}(\\text{L1} \\, \\mu) \\geq 20 \\, \\text{GeV}");
175  }
176  else if (m_plotName == phiS20.c_str()) {
177  effH->GetXaxis()->SetTitle("\\phi \\,(\\text{Reco} \\, \\mu) ~\\text{[rad]}");
178  effH->SetTitle("\\text{Single} \\, \\, \\text{Muon} \\, \\, \\text{Quality} ~[\\geq 12] ~/~ p_{T}(\\text{L1} \\, \\mu) \\geq 20 \\, \\text{GeV}");
179  }
180  else if (m_plotName == ptS16.c_str()) {
181  effH->GetXaxis()->SetTitle("p_{T}\\,(\\text{Reco} \\, \\mu) ~\\text{[GeV]}");
182  effH->SetTitle("\\text{Single} \\, \\, \\text{Muon} \\, \\, \\text{Quality} ~[\\geq 12] ~/~ p_{T}(\\text{L1} \\, \\mu) \\geq 16 \\, \\text{GeV}");
183  }
184  else if (m_plotName == etaS16.c_str()) {
185  effH->GetXaxis()->SetTitle("\\eta \\,(\\text{Reco} \\, \\mu) ");
186  effH->SetTitle("\\text{Single} \\, \\, \\text{Muon} \\, \\, \\text{Quality} ~[\\geq 12] ~/~ p_{T}(\\text{L1} \\, \\mu) \\geq 16 \\, \\text{GeV}");
187  }
188  else if (m_plotName == phiS16.c_str()) {
189  effH->GetXaxis()->SetTitle("\\phi \\,(\\text{Reco} \\, \\mu) ~\\text{[rad]}");
190  effH->SetTitle("\\text{Single} \\, \\, \\text{Muon} \\, \\, \\text{Quality} ~[\\geq 12] ~/~ p_{T}(\\text{L1} \\, \\mu) \\geq 16 \\, \\text{GeV}");
191  }
192  else if (m_plotName == ptS25.c_str()) {
193  effH->GetXaxis()->SetTitle("p_{T}\\,(\\text{Reco} \\, \\mu) ~\\text{[GeV]}");
194  effH->SetTitle("\\text{Single} \\, \\, \\text{Muon} \\, \\, \\text{Quality} ~[\\geq 12] ~/~ p_{T}(\\text{L1} \\, \\mu) \\geq 25 \\, \\text{GeV}");
195  }
196  else if (m_plotName == etaS25.c_str()) {
197  effH->GetXaxis()->SetTitle("\\eta \\,(\\text{Reco} \\, \\mu) ");
198  effH->SetTitle("\\text{Single} \\, \\, \\text{Muon} \\, \\, \\text{Quality} ~[\\geq 12] ~/~ p_{T}(\\text{L1} \\, \\mu) \\geq 25 \\, \\text{GeV}");
199  }
200  else if (m_plotName == phiS25.c_str()) {
201  effH->GetXaxis()->SetTitle("\\phi \\,(\\text{Reco} \\, \\mu) ~\\text{[rad]}");
202  effH->SetTitle("\\text{Single} \\, \\, \\text{Muon} \\, \\, \\text{Quality} ~[\\geq 12] ~/~ p_{T}(\\text{L1} \\, \\mu) \\geq 25 \\, \\text{GeV}");
203  }
204  else {
205  effH->GetXaxis()->SetTitle("not");
206  effH->SetTitle("not");
207  }
208 
209  effH->GetYaxis()->SetTitle("L1T Efficiency");
210  effH->GetXaxis()->SetTitleSize(0.028);
211  effH->GetYaxis()->SetTitleSize(0.028);
212  effH->SetTitleSize(0.028);
213  effH->SetTitleOffset(1.29,"X");
214  effH->GetXaxis()->SetLabelSize(0.028);
215  effH->GetYaxis()->SetLabelSize(0.028);
216  effH->SetLineStyle(1);
217  effH->SetLineWidth(2);
218  effH->SetLineColor(2);
219 
220 //************************************************************************
221  effH->Divide(numH,denH, 1.0, 1.0, "B");
222 
223  effH->SetMinimum(0.);
224  effH->SetMaximum(1.1);
225 }
226 
227 //___________DQM_analyzer_class________________________________________
229  // Initializing Variables
230  if (m_verbose) {
231  cout << "[L1TEfficiency_Harvesting:] ____________ Storage inicialization ____________ " << endl;
232  cout << "[L1TEfficiency_Harvesting:] Setting up dbe folder: L1T/Efficiency" << endl;
233  }
234  vector<ParameterSet> plotCfgs = ps.getUntrackedParameter<vector<ParameterSet>>("plotCfgs");
235  vector<ParameterSet>::const_iterator plotCfgIt = plotCfgs.begin();
236  vector<ParameterSet>::const_iterator plotCfgEnd = plotCfgs.end();
237 
238  for (; plotCfgIt!=plotCfgEnd; ++plotCfgIt) {
239  string dir = plotCfgIt->getUntrackedParameter<string>("dqmBaseDir");
240  vector<string> plots = plotCfgIt->getUntrackedParameter<vector<string>>("plots");
241  vector<string>::const_iterator plotIt = plots.begin();
242  vector<string>::const_iterator plotEnd = plots.end();
243 
244  for (; plotIt!=plotEnd; ++plotIt) m_plotHandlers.push_back(L1TEfficiencyPlotHandler(dir,(*plotIt)));
245  }
246 }
247 
248 //_____________________________________________________________________
250 
251 //_____________________________________________________________________
253  if (m_verbose) {cout << "[L1TEfficiency_Harvesting:] Called endRun." << endl;}
254 
255  vector<L1TEfficiencyPlotHandler>::iterator plotHandlerIt = m_plotHandlers.begin();
256  vector<L1TEfficiencyPlotHandler>::iterator plotHandlerEnd = m_plotHandlers.end();
257 
258  for(; plotHandlerIt!=plotHandlerEnd; ++plotHandlerIt) {
259  plotHandlerIt->book(ibooker, igetter);
260  plotHandlerIt->computeEfficiency(ibooker, igetter);
261  }
262 }
263 
264 //_____________________________________________________________________
266  if(m_verbose) cout << "[L1TEfficiency_Harvesting:] Called endLuminosityBlock at LS=" << lumiBlock.id().luminosityBlock() << endl;
267 }
268 
269 //define this as a plug-in
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
const double xbins[]
L1TEfficiencyPlotHandler(std::string dir, std::string plotName)
L1TEfficiency_Harvesting(const edm::ParameterSet &ps)
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void dqmEndLuminosityBlock(DQMStore::IGetter &igetter, edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
virtual void dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) override
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
EventID const & min(EventID const &lh, EventID const &rh)
Definition: EventID.h:137
void book(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
TH1F * getTH1F(void) const
LuminosityBlockNumber_t luminosityBlock() const
tuple cout
Definition: gather_cfg.py:145
dbl *** dir
Definition: mlp_gen.cc:35
void computeEfficiency(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:142