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 /*
2  * \file L1TEfficiency_Harvesting.cc
3  *
4  * $Date: 2013/03/18 17:17:53 $
5  * $Revision: 1.2 $
6  * \author J. Pela, C. Battilana
7  *
8  */
9 
10 // L1TMonitor includes
12 
14 
16 #include "DataFormats/Common/interface/ConditionsInEdm.h" // Parameters associated to Run, LS and Event
17 #include "DataFormats/Luminosity/interface/LumiDetails.h" // Luminosity Information
18 #include "DataFormats/Luminosity/interface/LumiSummary.h" // Luminosity Information
19 
27 
29 
30 #include "TList.h"
31 
32 using namespace edm;
33 using namespace std;
34 
35 //__________Efficiency_Plot_Handler_Helper_Class_______________________
37 
38  m_dir = handler.m_dir;
39  m_plotName = handler.m_plotName;
40  m_dbe = handler.m_dbe;
41 
42  m_effHisto = handler.m_effHisto;
43 
44 }
45 
46 
48 
49  if(verbose){
50  cout << "[L1TEfficiencyMuons_Harvesting:] Booking efficiency histo for "
51  << m_dir << " and " << m_plotName << endl;
52  }
53 
54  MonitorElement *num = m_dbe->get(m_dir+"/"+m_plotName+"Num");
55  MonitorElement *den = m_dbe->get(m_dir+"/"+m_plotName+"Den");
56 
57  if (!num || !den) {
58 
59  if(verbose){
60  cout << "[L1TEfficiencyMuons_Harvesting:] "
61  << (!num && !den ? "Num && Den" : !num ? "Num" : "Den")
62  << " not gettable. Quitting booking" << endl;
63  }
64  return;
65 
66  }
67 
68  TH1F *numH = num->getTH1F();
69  TH1F *denH = den->getTH1F();
70 
71  if (!numH || !denH) {
72 
73  if(verbose){
74  cout << "[L1TEfficiencyMuons_Harvesting:] "
75  << (!numH && !denH ? "Num && Den" : !numH ? "Num" : "Den")
76  << " is not TH1F. Quitting booking" << endl;
77  }
78  return;
79 
80  }
81 
82  int nBinsNum = numH->GetNbinsX();
83  int nBinsDen = denH->GetNbinsX();
84 
85  if (nBinsNum != nBinsDen) {
86 
87  if(verbose){
88  cout << "[L1TEfficiencyMuons_Harvesting:] # bins in num and den is different. Quitting booking" << endl;
89  }
90  return;
91 
92  }
93 
94  double min = numH->GetXaxis()->GetXmin();
95  double max = numH->GetXaxis()->GetXmax();
96 
97  m_dbe->setCurrentFolder(m_dir);
98  m_effHisto = m_dbe->book1D(m_plotName,m_plotName,nBinsNum,min,max);
99 
100 }
101 
102 
104 
105  if (!m_effHisto)
106  return;
107 
108  if(verbose){
109  cout << "[L1TEfficiencyMuons_Harvesting:] Computing efficiency for "
110  << m_plotName << endl;
111  }
112 
113  MonitorElement *num = m_dbe->get(m_dir+"/"+m_plotName+"Num");
114  MonitorElement *den = m_dbe->get(m_dir+"/"+m_plotName+"Den");
115 
116  TH1F *numH = num->getTH1F();
117  TH1F *denH = den->getTH1F();
118 
119  numH->Sumw2();
120  denH->Sumw2();
121 
122  TH1F *effH = m_effHisto->getTH1F();
123 
124  effH->Divide(numH,denH);
125 
126 }
127 
128 
129 //___________DQM_analyzer_class________________________________________
131 
132  // Initializing Variables
133  if (m_verbose) {
134  cout << "[L1TEfficiency_Harvesting:] ____________ Storage inicialization ____________ " << endl;
135  cout << "[L1TEfficiency_Harvesting:] Setting up dbe folder: L1T/Efficiency" << endl;
136  }
137 
138  DQMStore* dbe = Service <DQMStore>().operator->();
139  dbe->setVerbose(0);
140 
141  // Initializing Variables
142  if (m_verbose) {cout << "[L1TEfficiency_Harvesting:] Pointer for DQM Store: " << dbe << endl;}
143 
144  vector<ParameterSet> plotCfgs = ps.getUntrackedParameter<vector<ParameterSet>>("plotCfgs");
145 
146  vector<ParameterSet>::const_iterator plotCfgIt = plotCfgs.begin();
147  vector<ParameterSet>::const_iterator plotCfgEnd = plotCfgs.end();
148 
149  for (; plotCfgIt!=plotCfgEnd; ++plotCfgIt) {
150 
151  string dir = plotCfgIt->getUntrackedParameter<string>("dqmBaseDir");
152  vector<string> plots = plotCfgIt->getUntrackedParameter<vector<string>>("plots");
153 
154  vector<string>::const_iterator plotIt = plots.begin();
155  vector<string>::const_iterator plotEnd = plots.end();
156 
157  for (; plotIt!=plotEnd; ++plotIt)
158  m_plotHandlers.push_back(L1TEfficiencyPlotHandler(dir,(*plotIt),dbe));
159 
160  }
161 
162 }
163 
164 
165 //_____________________________________________________________________
167 
168 
169 //_____________________________________________________________________
171 
172  if (m_verbose) {cout << "[L1TEfficiency_Harvesting:] Called beginJob." << endl;}
173 
174 }
175 
176 
177 //_____________________________________________________________________
179 
180  if (m_verbose) {cout << "[L1TEfficiency_Harvesting:] Called endJob." << endl;}
181 
182 }
183 
184 //_____________________________________________________________________
186 
187  if (m_verbose) {cout << "[L1TEfficiency_Harvesting:] Called beginRun." << endl;}
188 
189 }
190 
191 
192 //_____________________________________________________________________
194 
195  if (m_verbose) {cout << "[L1TEfficiency_Harvesting:] Called endRun." << endl;}
196 
197  vector<L1TEfficiencyPlotHandler>::iterator plotHandlerIt = m_plotHandlers.begin();
198  vector<L1TEfficiencyPlotHandler>::iterator plotHandlerEnd = m_plotHandlers.end();
199 
200  for(; plotHandlerIt!=plotHandlerEnd; ++plotHandlerIt) {
201  plotHandlerIt->book(m_verbose);
202  plotHandlerIt->computeEfficiency(m_verbose);
203  }
204 
205 }
206 
207 
208 //_____________________________________________________________________
210 
211  if(m_verbose){
212  cout << "[L1TEfficiency_Harvesting:] Called beginLuminosityBlock at LS="
213  << lumiBlock.id().luminosityBlock() << endl;
214  }
215 }
216 
217 
218 //_____________________________________________________________________
220 
221  if(m_verbose){
222  cout << "[L1TEfficiency_Harvesting:] Called endLuminosityBlock at LS="
223  << lumiBlock.id().luminosityBlock() << endl;
224  }
225 }
226 
227 
228 //_____________________________________________________________________
229 void L1TEfficiency_Harvesting::analyze(const Event & iEvent, const EventSetup & eventSetup){
230 
231 
232 }
233 
234 //define this as a plug-in
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
L1TEfficiency_Harvesting(const edm::ParameterSet &ps)
virtual void endLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
DEFINE_FWK_MODULE(HiMixingModule)
void endRun(const edm::Run &run, const edm::EventSetup &iSetup)
int iEvent
Definition: GenABIO.cc:243
virtual void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
L1TEfficiencyPlotHandler(std::string dir, std::string plotName, DQMStore *dbe)
EventID const & min(EventID const &lh, EventID const &rh)
Definition: EventID.h:132
void setVerbose(unsigned level)
Definition: DQMStore.cc:398
void analyze(const edm::Event &e, const edm::EventSetup &c)
TH1F * getTH1F(void) const
long long int num
Definition: procUtils.cc:71
LuminosityBlockNumber_t luminosityBlock() const
tuple cout
Definition: gather_cfg.py:121
dbl *** dir
Definition: mlp_gen.cc:35
void beginRun(const edm::Run &run, const edm::EventSetup &iSetup)
Definition: Run.h:36
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:137