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 
8 // L1TMonitor includes
10 
12 
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
17 
25 
27 
28 #include "TList.h"
29 
30 using namespace edm;
31 using namespace std;
32 
33 //__________Efficiency_Plot_Handler_Helper_Class_______________________
35 
36  m_dir = handler.m_dir;
37  m_plotName = handler.m_plotName;
38  m_effHisto = handler.m_effHisto;
39 
40 }
41 
42 
44 
45  cout << "[L1TEfficiencyMuons_Harvesting:] Booking efficiency histo for "
46  << m_dir << " and " << m_plotName << endl;
47 
48  MonitorElement *num = igetter.get(m_dir+"/"+m_plotName+"Num");
49  MonitorElement *den = igetter.get(m_dir+"/"+m_plotName+"Den");
50 
51  if (!num || !den) {
52 
53  cout << "[L1TEfficiencyMuons_Harvesting:] "
54  << (!num && !den ? "Num && Den" : !num ? "Num" : "Den")
55  << " not gettable. Quitting booking" << endl;
56 
57  return;
58 
59  }
60 
61  TH1F *numH = num->getTH1F();
62  TH1F *denH = den->getTH1F();
63 
64  if (!numH || !denH) {
65 
66  cout << "[L1TEfficiencyMuons_Harvesting:] "
67  << (!numH && !denH ? "Num && Den" : !numH ? "Num" : "Den")
68  << " is not TH1F. Quitting booking" << endl;
69 
70  return;
71 
72  }
73 
74  int nBinsNum = numH->GetNbinsX();
75  int nBinsDen = denH->GetNbinsX();
76 
77  if (nBinsNum != nBinsDen) {
78 
79  cout << "[L1TEfficiencyMuons_Harvesting:] # bins in num and den is different. Quitting booking" << endl;
80 
81  return;
82 
83  }
84 
85  double min = numH->GetXaxis()->GetXmin();
86  double max = numH->GetXaxis()->GetXmax();
87 
88  ibooker.setCurrentFolder(m_dir);
89  m_effHisto = ibooker.book1D(m_plotName,m_plotName,nBinsNum,min,max);
90 
91 }
92 
93 
95 
96  if (!m_effHisto)
97  return;
98 
99  cout << "[L1TEfficiencyMuons_Harvesting:] Computing efficiency for "
100  << m_plotName << endl;
101 
102  MonitorElement *num = igetter.get(m_dir+"/"+m_plotName+"Num");
103  MonitorElement *den = igetter.get(m_dir+"/"+m_plotName+"Den");
104 
105  TH1F *numH = num->getTH1F();
106  TH1F *denH = den->getTH1F();
107 
108  numH->Sumw2();
109  denH->Sumw2();
110 
111  TH1F *effH = m_effHisto->getTH1F();
112 
113  effH->Divide(numH,denH);
114 
115 }
116 
117 
118 //___________DQM_analyzer_class________________________________________
120 
121  // Initializing Variables
122  if (m_verbose) {
123  cout << "[L1TEfficiency_Harvesting:] ____________ Storage inicialization ____________ " << endl;
124  cout << "[L1TEfficiency_Harvesting:] Setting up dbe folder: L1T/Efficiency" << endl;
125  }
126 
127  vector<ParameterSet> plotCfgs = ps.getUntrackedParameter<vector<ParameterSet>>("plotCfgs");
128 
129  vector<ParameterSet>::const_iterator plotCfgIt = plotCfgs.begin();
130  vector<ParameterSet>::const_iterator plotCfgEnd = plotCfgs.end();
131 
132  for (; plotCfgIt!=plotCfgEnd; ++plotCfgIt) {
133 
134  string dir = plotCfgIt->getUntrackedParameter<string>("dqmBaseDir");
135  vector<string> plots = plotCfgIt->getUntrackedParameter<vector<string>>("plots");
136 
137  vector<string>::const_iterator plotIt = plots.begin();
138  vector<string>::const_iterator plotEnd = plots.end();
139 
140  for (; plotIt!=plotEnd; ++plotIt)
141  m_plotHandlers.push_back(L1TEfficiencyPlotHandler(dir,(*plotIt)));
142 
143  }
144 
145 }
146 
147 
148 //_____________________________________________________________________
150 
151 
152 //_____________________________________________________________________
154 
155  if (m_verbose) {cout << "[L1TEfficiency_Harvesting:] Called endRun." << endl;}
156 
157  vector<L1TEfficiencyPlotHandler>::iterator plotHandlerIt = m_plotHandlers.begin();
158  vector<L1TEfficiencyPlotHandler>::iterator plotHandlerEnd = m_plotHandlers.end();
159 
160  for(; plotHandlerIt!=plotHandlerEnd; ++plotHandlerIt) {
161  plotHandlerIt->book(ibooker, igetter);
162  plotHandlerIt->computeEfficiency(ibooker, igetter);
163  }
164 
165 }
166 
167 
168 //_____________________________________________________________________
170 
171  if(m_verbose){
172  cout << "[L1TEfficiency_Harvesting:] Called endLuminosityBlock at LS="
173  << lumiBlock.id().luminosityBlock() << endl;
174  }
175 }
176 
177 
178 //define this as a plug-in
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
L1TEfficiencyPlotHandler(std::string dir, std::string plotName)
L1TEfficiency_Harvesting(const edm::ParameterSet &ps)
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:301
#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:273
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