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_dbe = handler.m_dbe;
39 
40  m_effHisto = handler.m_effHisto;
41 
42 }
43 
44 
46 
47  if(verbose){
48  cout << "[L1TEfficiencyMuons_Harvesting:] Booking efficiency histo for "
49  << m_dir << " and " << m_plotName << endl;
50  }
51 
52  MonitorElement *num = m_dbe->get(m_dir+"/"+m_plotName+"Num");
53  MonitorElement *den = m_dbe->get(m_dir+"/"+m_plotName+"Den");
54 
55  if (!num || !den) {
56 
57  if(verbose){
58  cout << "[L1TEfficiencyMuons_Harvesting:] "
59  << (!num && !den ? "Num && Den" : !num ? "Num" : "Den")
60  << " not gettable. Quitting booking" << endl;
61  }
62  return;
63 
64  }
65 
66  TH1F *numH = num->getTH1F();
67  TH1F *denH = den->getTH1F();
68 
69  if (!numH || !denH) {
70 
71  if(verbose){
72  cout << "[L1TEfficiencyMuons_Harvesting:] "
73  << (!numH && !denH ? "Num && Den" : !numH ? "Num" : "Den")
74  << " is not TH1F. Quitting booking" << endl;
75  }
76  return;
77 
78  }
79 
80  int nBinsNum = numH->GetNbinsX();
81  int nBinsDen = denH->GetNbinsX();
82 
83  if (nBinsNum != nBinsDen) {
84 
85  if(verbose){
86  cout << "[L1TEfficiencyMuons_Harvesting:] # bins in num and den is different. Quitting booking" << endl;
87  }
88  return;
89 
90  }
91 
92  double min = numH->GetXaxis()->GetXmin();
93  double max = numH->GetXaxis()->GetXmax();
94 
95  m_dbe->setCurrentFolder(m_dir);
96  m_effHisto = m_dbe->book1D(m_plotName,m_plotName,nBinsNum,min,max);
97 
98 }
99 
100 
102 
103  if (!m_effHisto)
104  return;
105 
106  if(verbose){
107  cout << "[L1TEfficiencyMuons_Harvesting:] Computing efficiency for "
108  << m_plotName << endl;
109  }
110 
111  MonitorElement *num = m_dbe->get(m_dir+"/"+m_plotName+"Num");
112  MonitorElement *den = m_dbe->get(m_dir+"/"+m_plotName+"Den");
113 
114  TH1F *numH = num->getTH1F();
115  TH1F *denH = den->getTH1F();
116 
117  numH->Sumw2();
118  denH->Sumw2();
119 
120  TH1F *effH = m_effHisto->getTH1F();
121 
122  effH->Divide(numH,denH);
123 
124 }
125 
126 
127 //___________DQM_analyzer_class________________________________________
129 
130  // Initializing Variables
131  if (m_verbose) {
132  cout << "[L1TEfficiency_Harvesting:] ____________ Storage inicialization ____________ " << endl;
133  cout << "[L1TEfficiency_Harvesting:] Setting up dbe folder: L1T/Efficiency" << endl;
134  }
135 
136  DQMStore* dbe = Service <DQMStore>().operator->();
137  dbe->setVerbose(0);
138 
139  // Initializing Variables
140  if (m_verbose) {cout << "[L1TEfficiency_Harvesting:] Pointer for DQM Store: " << dbe << endl;}
141 
142  vector<ParameterSet> plotCfgs = ps.getUntrackedParameter<vector<ParameterSet>>("plotCfgs");
143 
144  vector<ParameterSet>::const_iterator plotCfgIt = plotCfgs.begin();
145  vector<ParameterSet>::const_iterator plotCfgEnd = plotCfgs.end();
146 
147  for (; plotCfgIt!=plotCfgEnd; ++plotCfgIt) {
148 
149  string dir = plotCfgIt->getUntrackedParameter<string>("dqmBaseDir");
150  vector<string> plots = plotCfgIt->getUntrackedParameter<vector<string>>("plots");
151 
152  vector<string>::const_iterator plotIt = plots.begin();
153  vector<string>::const_iterator plotEnd = plots.end();
154 
155  for (; plotIt!=plotEnd; ++plotIt)
156  m_plotHandlers.push_back(L1TEfficiencyPlotHandler(dir,(*plotIt),dbe));
157 
158  }
159 
160 }
161 
162 
163 //_____________________________________________________________________
165 
166 
167 //_____________________________________________________________________
169 
170  if (m_verbose) {cout << "[L1TEfficiency_Harvesting:] Called beginJob." << endl;}
171 
172 }
173 
174 
175 //_____________________________________________________________________
177 
178  if (m_verbose) {cout << "[L1TEfficiency_Harvesting:] Called endJob." << endl;}
179 
180 }
181 
182 //_____________________________________________________________________
184 
185  if (m_verbose) {cout << "[L1TEfficiency_Harvesting:] Called beginRun." << endl;}
186 
187 }
188 
189 
190 //_____________________________________________________________________
192 
193  if (m_verbose) {cout << "[L1TEfficiency_Harvesting:] Called endRun." << endl;}
194 
195  vector<L1TEfficiencyPlotHandler>::iterator plotHandlerIt = m_plotHandlers.begin();
196  vector<L1TEfficiencyPlotHandler>::iterator plotHandlerEnd = m_plotHandlers.end();
197 
198  for(; plotHandlerIt!=plotHandlerEnd; ++plotHandlerIt) {
199  plotHandlerIt->book(m_verbose);
200  plotHandlerIt->computeEfficiency(m_verbose);
201  }
202 
203 }
204 
205 
206 //_____________________________________________________________________
208 
209  if(m_verbose){
210  cout << "[L1TEfficiency_Harvesting:] Called beginLuminosityBlock at LS="
211  << lumiBlock.id().luminosityBlock() << endl;
212  }
213 }
214 
215 
216 //_____________________________________________________________________
218 
219  if(m_verbose){
220  cout << "[L1TEfficiency_Harvesting:] Called endLuminosityBlock at LS="
221  << lumiBlock.id().luminosityBlock() << endl;
222  }
223 }
224 
225 
226 //_____________________________________________________________________
227 void L1TEfficiency_Harvesting::analyze(const Event & iEvent, const EventSetup & eventSetup){
228 
229 
230 }
231 
232 //define this as a plug-in
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
L1TEfficiency_Harvesting(const edm::ParameterSet &ps)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void endLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
void endRun(const edm::Run &run, const edm::EventSetup &iSetup)
int iEvent
Definition: GenABIO.cc:230
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:137
void analyze(const edm::Event &e, const edm::EventSetup &c)
TH1F * getTH1F(void) const
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:41
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:142