CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTEventInfoClient.cc
Go to the documentation of this file.
2 
6 
15 #include "TRandom.h"
16 #include <TF1.h>
17 #include <stdio.h>
18 #include <sstream>
19 #include <math.h>
20 #include <TProfile.h>
21 #include <TProfile2D.h>
22 #include <memory>
23 #include <iostream>
24 #include <iomanip>
25 #include <map>
26 #include <vector>
27 #include <string>
28 #include <fstream>
29 #include "TROOT.h"
30 
31 using namespace edm;
32 using namespace std;
33 
35 {
36  parameters_=ps;
37  initialize();
38 }
39 
41  if(verbose_) std::cout <<"[TriggerDQM]: ending... " << std::endl;
42 }
43 
44 //--------------------------------------------------------
46 
47  counterLS_=0;
48  counterEvt_=0;
49 
50  // get back-end interface
52 
53  // base folder for the contents of this job
54  verbose_ = parameters_.getUntrackedParameter<bool>("verbose", false);
55 
56  monitorDir_ = parameters_.getUntrackedParameter<std::string>("monitorDir","");
57  if(verbose_) std::cout << "Monitor dir = " << monitorDir_ << std::endl;
58 
59  prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
60  if(verbose_) std::cout << "DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< std::endl;
61 
62  prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
63  if(verbose_) std::cout << "DQM event prescale = " << prescaleEvt_ << " events(s)"<< std::endl;
64 
65 
66 
67 }
68 
69 //--------------------------------------------------------
71 
72  if(verbose_) std::cout <<"[TriggerDQM]: Begin Job" << std::endl;
73  // get backendinterface
75 
76  dbe_->setCurrentFolder("HLT/EventInfo");
77 
78 // sprintf(histo, "reportSummary");
79  reportSummary_ = dbe_->get("HLT/EventInfo/reportSumamry");
80  if ( reportSummary_ ) {
81  dbe_->removeElement(reportSummary_->getName());
82  }
83 
84  reportSummary_ = dbe_->bookFloat("reportSummary");
85 
86  int nPDs = 20;
87 
88  //initialize reportSummary to 1
89  if (reportSummary_) reportSummary_->Fill(1);
90 
91  dbe_->setCurrentFolder("HLT/EventInfo/reportSummaryContents");
92 
93 
94  char histo[100];
95 
96  for (int n = 0; n < nPDs; n++) {
97 
98  switch(n){
99  case 0 : sprintf(histo,"hlt_dqm_EGamma"); break;
100  case 1 : sprintf(histo,"hlt_dqm_Muon"); break;
101  case 2 : sprintf(histo,"hlt_dqm_JetMet"); break;
102  case 3 : sprintf(histo,"hlt_dqm_BJets"); break;
103  case 4 : sprintf(histo,"hlt_dqm_Tau"); break;
104  case 5 : sprintf(histo,"hlt_dqm_Test1"); break;
105  case 6 : sprintf(histo,"hlt_dqm_Test2"); break;
106  case 7 : sprintf(histo,"hlt_dqm_Test3"); break;
107  case 8 : sprintf(histo,"hlt_dqm_Test4"); break;
108  case 9 : sprintf(histo,"hlt_dqm_Test5"); break;
109  case 10 : sprintf(histo,"hlt_dqm_Test6"); break;
110  case 11 : sprintf(histo,"hlt_dqm_Test7"); break;
111  case 12 : sprintf(histo,"hlt_dqm_Test8"); break;
112  case 13 : sprintf(histo,"hlt_dqm_Test9"); break;
113  case 14 : sprintf(histo,"hlt_dqm_Test10"); break;
114  case 15 : sprintf(histo,"hlt_dqm_Test11"); break;
115  case 16 : sprintf(histo,"hlt_dqm_Test12"); break;
116  case 17 : sprintf(histo,"hlt_dqm_Test13"); break;
117  case 18 : sprintf(histo,"hlt_dqm_Test14"); break;
118  case 19 : sprintf(histo,"hlt_dqm_Test15"); break;
119  }
120 
121 
122 
123 // if( reportSummaryContent_[i] = dbe_->get("HLT/EventInfo/reportSummaryContents/" + histo) )
124 // {
125 // dbe_->removeElement(reportSummaryContent_[i]->getName());
126 // }
127 
128  reportSummaryContent_[n] = dbe_->bookFloat(histo);
129  }
130 
131  //initialize reportSummaryContents to 1
132  for (int k = 0; k < nPDs; k++) {
133  summaryContent[k] = 1;
134  reportSummaryContent_[k]->Fill(1.);
135  }
136 
137 
138  dbe_->setCurrentFolder("HLT/EventInfo");
139 
140  reportSummaryMap_ = dbe_->get("HLT/EventInfo/reportSummaryMap");
141  if ( reportSummaryMap_ ) {
142  dbe_->removeElement(reportSummaryMap_->getName());
143  }
144 
145 
146  reportSummaryMap_ = dbe_->book2D("reportSummaryMap", "reportSummaryMap", 1, 1, 2, 10, 1, 11);
147  reportSummaryMap_->setAxisTitle("", 1);
148  reportSummaryMap_->setAxisTitle("", 2);
149  reportSummaryMap_->setBinLabel(1,"SingleElectron",2);
150  reportSummaryMap_->setBinLabel(2,"DoubleElectron",2);
151  reportSummaryMap_->setBinLabel(3,"SingleMu",2);
152  reportSummaryMap_->setBinLabel(4,"DoubleMu",2);
153  reportSummaryMap_->setBinLabel(5,"Photon",2);
154  reportSummaryMap_->setBinLabel(6,"Tau",2);
155  reportSummaryMap_->setBinLabel(7,"BTag",2);
156  reportSummaryMap_->setBinLabel(8,"HT",2);
157  reportSummaryMap_->setBinLabel(9,"Jet",2);
158  reportSummaryMap_->setBinLabel(10,"MET",2);
159  reportSummaryMap_->setBinLabel(1," ",1);
160 
161 }
162 
163 //--------------------------------------------------------
164 void HLTEventInfoClient::beginRun(const Run& r, const EventSetup& context) {
165 }
166 
167 //--------------------------------------------------------
169  // optionally reset histograms here
170 }
171 
173 
174 
175  int ilumi = int(lumiSeg.id().luminosityBlock());
176 
177  const int nPDs = 10;
178  MonitorElement* Pass_Hists[nPDs];
179  int nPathsPD[nPDs];
180  double PDResult[nPDs];
181  int nTotPD[nPDs];
182  for( int i = 0; i < nPDs; i++ ) {
183  PDResult[i] = 1.0;
184  nTotPD[i] = 0.0;
185  }
186  bool isCollision = true;
187 
188  for( int i = 0; i < nPDs; i++ ) {
189  if( i == 0 ) Pass_Hists[i] = dbe_->get("HLT/FourVector/PathsSummary/HLT_SingleElectron_Pass_Any"); // SingleElectron
190  if( i == 1 ) Pass_Hists[i] = dbe_->get("HLT/FourVector/PathsSummary/HLT_DoubleElectron_Pass_Any"); // DoubleElectron
191  if( i == 2 ) Pass_Hists[i] = dbe_->get("HLT/FourVector/PathsSummary/HLT_SingleMu_Pass_Any"); // SingleMu
192  if( i == 3 ) Pass_Hists[i] = dbe_->get("HLT/FourVector/PathsSummary/HLT_DoubleMu_Pass_Any"); // DoubleMu
193  if( i == 4 ) Pass_Hists[i] = dbe_->get("HLT/FourVector/PathsSummary/HLT_Photon_Pass_Any"); // Photon
194  if( i == 5 ) Pass_Hists[i] = dbe_->get("HLT/FourVector/PathsSummary/HLT_Tau_Pass_Any"); // Tau
195  if( i == 6 ) Pass_Hists[i] = dbe_->get("HLT/FourVector/PathsSummary/HLT_BTag_Pass_Any"); // BTag
196  if( i == 7 ) Pass_Hists[i] = dbe_->get("HLT/FourVector/PathsSummary/HLT_HT_Pass_Any"); // HT
197  if( i == 8 ) Pass_Hists[i] = dbe_->get("HLT/FourVector/PathsSummary/HLT_Jet_Pass_Any"); // Jet
198  if( i == 9 ) Pass_Hists[i] = dbe_->get("HLT/FourVector/PathsSummary/HLT_MET_Pass_Any"); // MET
199 
200  if( Pass_Hists[i] ) {
201  if( i == 5 && !isCollision ) continue;
202  nPathsPD[i] = Pass_Hists[i]->getNbinsX();
203  int noBins = 2;
204  if( i == 1 ) noBins = 3; // the last trigger is low rate
205  if( i == 8 ) noBins = 4; // two last triggers are low rate
206 
207  for( int j = 0; j < nPathsPD[i]-noBins; j++ ) {
208  // if triggers in each PD are too much prescaled (or low rate), skip in the summary
209 
210  if( i == 1 && (j == 0) ) continue; // DoubleElectron
211  if( i == 3 && (j == 1 || j == 4) ) continue; // DoubleMu
212  if( i == 4 && (j > 1) ) continue; // Photon
213  if( i == 5 && (j > 4) ) continue; // Tau
214  if( i == 7 && (j == 7) ) continue; // HT
215  if( i == 8 && (j == 8) ) continue; // Jet
216  if( i == 9 && (j == 8 || j == 13 || j == 15) ) continue; // MET
217 
218  double val = Pass_Hists[i]->getBinContent(j+1);
219  if( val == 0 ) {
220  if( ilumi > 5 ) PDResult[i] = 0.5;
221  }
222  nTotPD[i] += val;
223  }
224  if( nTotPD[i] == 0 ) {
225  if( ilumi > 5 ) PDResult[i] = 0.0;
226  }
227  }
228  else {
229  isCollision = false;
230  }
231  }
232 
233  for (int k = 0; k < nPDs; k++) {
234  if( k < 10 ) {
235  summaryContent[k] = PDResult[k];
236  reportSummaryContent_[k]->Fill(PDResult[k]);
237  }
238  else {
239  summaryContent[k] = 1;
240  reportSummaryContent_[k]->Fill(1.);
241  }
242  }
243  summarySum = 0;
244 
245  for (int m = 0; m < nPDs; m++) {
246  summarySum += summaryContent[m];
247  }
248 
249 
250  reportSummary = summarySum / nPDs;;
251  if (reportSummary_) reportSummary_->Fill(reportSummary);
252 
253 
254  reportSummaryMap_->setBinContent(1,1,summaryContent[0]);//SingleElectron
255  reportSummaryMap_->setBinContent(1,2,summaryContent[1]);//DoubleElectron
256  reportSummaryMap_->setBinContent(1,3,summaryContent[2]);//SingleMu
257  reportSummaryMap_->setBinContent(1,4,summaryContent[3]);//DoubleMu
258  reportSummaryMap_->setBinContent(1,5,summaryContent[4]);//Photon
259  reportSummaryMap_->setBinContent(1,6,summaryContent[5]);//Tau
260  reportSummaryMap_->setBinContent(1,7,summaryContent[6]);//BTag
261  reportSummaryMap_->setBinContent(1,8,summaryContent[7]);//HT
262  reportSummaryMap_->setBinContent(1,9,summaryContent[8]);//Jet
263  reportSummaryMap_->setBinContent(1,10,summaryContent[9]);//MET
264 
265 }
266 
267 //--------------------------------------------------------
268 void HLTEventInfoClient::analyze(const Event& e, const EventSetup& context){
269 
270  counterEvt_++;
271  if (prescaleEvt_<1) return;
272  if (prescaleEvt_>0 && counterEvt_%prescaleEvt_ != 0) return;
273 
274  if(verbose_) std::cout << "HLTEventInfoClient::analyze" << std::endl;
275 
276 
277 }
278 
279 //--------------------------------------------------------
280 void HLTEventInfoClient::endRun(const Run& r, const EventSetup& context){
281 }
282 
283 //--------------------------------------------------------
285 }
286 
287 
288 
290 {
291 
292  MonitorElement * me_ = dbi->get(meName);
293 
294  if (!me_) {
295  if(verbose_) std::cout << "ME NOT FOUND." << std::endl;
296  return NULL;
297  }
298 
299  return me_->getTH1F();
300 }
301 
303 {
304 
305 
306  MonitorElement * me_ = dbi->get(meName);
307 
308  if (!me_) {
309  if(verbose_) std::cout << "ME NOT FOUND." << std::endl;
310  return NULL;
311  }
312 
313  return me_->getTH2F();
314 }
315 
316 
317 
319 {
320 
321 
322  MonitorElement * me_ = dbi->get(meName);
323 
324  if (!me_) {
325  if(verbose_) std::cout << "ME NOT FOUND." << std::endl;
326  return NULL;
327  }
328 
329  return me_->getTProfile2D();
330 }
331 
332 
334 {
335 
336 
337  MonitorElement * me_ = dbi->get(meName);
338 
339  if (!me_) {
340  if(verbose_) std::cout << "ME NOT FOUND." << std::endl;
341  return NULL;
342  }
343 
344  return me_->getTProfile();
345 }
346 
347 
348 
349 
350 
351 
352 
353 
LuminosityBlockID id() const
int i
Definition: DBlmapReader.cc:9
TProfile2D * getTProfile2D(void) const
TProfile * get1DProfile(std::string meName, DQMStore *dbi)
TH2F * get2DHisto(std::string meName, DQMStore *dbi)
TH1F * get1DHisto(std::string meName, DQMStore *dbi)
#define NULL
Definition: scimark2.h:8
void beginJob()
BeginJob.
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:809
void Fill(long long x)
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
DQM Client Diagnostic.
void removeElement(const std::string &name)
Definition: DQMStore.cc:2772
int j
Definition: DBlmapReader.cc:9
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1623
DQMStore * dbe_
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
virtual ~HLTEventInfoClient()
Destructor.
int k[5][pyjets_maxn]
TH1F * getTH1F(void) const
LuminosityBlockNumber_t luminosityBlock() const
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
double getBinContent(int binx) const
get content of bin (1-D)
TProfile * getTProfile(void) const
TProfile2D * get2DProfile(std::string meName, DQMStore *dbi)
int getNbinsX(void) const
get # of bins in X-axis
tuple cout
Definition: gather_cfg.py:121
void analyze(const edm::Event &e, const edm::EventSetup &c)
Fake Analyze.
TH2F * getTH2F(void) const
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1000
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
Definition: Run.h:41
HLTEventInfoClient(const edm::ParameterSet &ps)
Constructor.