CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TEMUEventInfoClient.cc
Go to the documentation of this file.
2 
10 #include "TRandom.h"
11 #include <TF1.h>
12 #include <stdio.h>
13 #include <sstream>
14 #include <math.h>
15 #include <TProfile.h>
16 #include <TProfile2D.h>
17 #include <memory>
18 #include <iostream>
19 #include <vector>
20 #include <iomanip>
21 #include <string>
22 #include <fstream>
23 #include "TROOT.h"
24 
25 using namespace edm;
26 using namespace std;
27 
29 {
30  parameters_=ps;
31  initialize();
32 }
33 
35  if(verbose_) cout <<"[TriggerDQM]: ending... " << endl;
36 }
37 
38 //--------------------------------------------------------
40 
41  counterLS_=0;
42  counterEvt_=0;
43 
44  // get back-end interface
46 
47  // base folder for the contents of this job
48  verbose_ = parameters_.getUntrackedParameter<bool>("verbose", false);
49 
50  monitorDir_ = parameters_.getUntrackedParameter<string>("monitorDir","");
51  if(verbose_) cout << "Monitor dir = " << monitorDir_ << endl;
52 
53  prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
54  if(verbose_) cout << "DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< endl;
55 
56  prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
57  if(verbose_) cout << "DQM event prescale = " << prescaleEvt_ << " events(s)"<< endl;
58 
59  //tbd should revert to regular order as defined in hardwarevalidation
60  // + use std labels defined in traits therein
61  std::string syslabel [nsysmon_]=
62  {"DTTF","DTTPG","CSCTF","CSCTPG","RPC","GMT", "ECAL","HCAL","RCT","GCT","GT"};
63  std::string syslabelext[nsysmon_]=
64  {"DTF","DTP","CTF","CTP","RPC","GMT", "ETP","HTP","RCT","GCT","GLT"};
65  std::vector<unsigned int> sysmask(0,nsysmon_);
66  sysmask = parameters_.getUntrackedParameter<std::vector<unsigned int> >("maskedSystems", sysmask);
67 
68  for(int i=0; i<nsysmon_; i++) {
69  syslabel_[i] = syslabel[i];
70  syslabelext_[i] = syslabelext[i];
71  sysmask_[i] = sysmask[i];
72  }
73 
74  std::vector<string> emptyMask;
75 
76  dataMask = parameters_.getUntrackedParameter<std::vector<string> >("dataMaskedSystems", emptyMask);
77  emulMask = parameters_.getUntrackedParameter<std::vector<string> >("emulatorMaskedSystems", emptyMask);
78 
79  s_mapDataValues["EMPTY"] = data_empty;
80  s_mapDataValues["ALL"] = data_all;
81  s_mapDataValues["GT"] = data_gt;
82  s_mapDataValues["MUONS"] = data_muons;
83  s_mapDataValues["JETS"] = data_jets;
84  s_mapDataValues["TAUJETS"] = data_taujets;
85  s_mapDataValues["ISOEM"] = data_isoem;
86  s_mapDataValues["NONISOEM"] = data_nonisoem;
87  s_mapDataValues["MET"] = data_met;
88 
89  s_mapEmulValues["EMPTY"] = emul_empty;
90  s_mapEmulValues["ALL"] = emul_all;
91  s_mapEmulValues["DTTF"] = emul_dtf;
92  s_mapEmulValues["DTTPG"] = emul_dtp;
93  s_mapEmulValues["CSCTF"] = emul_ctf;
94  s_mapEmulValues["CSCTPG"] = emul_ctp;
95  s_mapEmulValues["RPC"] = emul_rpc;
96  s_mapEmulValues["GMT"] = emul_gmt;
97  s_mapEmulValues["ECAL"] = emul_etp;
98  s_mapEmulValues["HCAL"] = emul_htp;
99  s_mapEmulValues["RCT"] = emul_rct;
100  s_mapEmulValues["GCT"] = emul_gct;
101  s_mapEmulValues["GLT"] = emul_glt;
102 
103  emulatorMap[0] = 13;
104  emulatorMap[1] = 12;
105  emulatorMap[2] = 11;
106  emulatorMap[3] = 10;
107  emulatorMap[4] = 9;
108  emulatorMap[5] = 8;
109  emulatorMap[6] = 15;
110  emulatorMap[7] = 14;
111  emulatorMap[8] = 17;
112  emulatorMap[9] = 16;
113  emulatorMap[10] = 7;
114 
115 }
116 
117 //--------------------------------------------------------
119 
120  if(verbose_) cout <<"[TriggerDQM]: Begin Job" << endl;
121  // get backendinterface
123 
124  dbe_->setCurrentFolder("L1TEMU/EventInfo");
125 
126 // sprintf(histo, "reportSummary");
127  if( (reportSummary_ = dbe_->get("L1TEMU/EventInfo/reportSumamry")) ){
128  dbe_->removeElement(reportSummary_->getName());
129  }
130 
131  reportSummary_ = dbe_->bookFloat("reportSummary");
132 
133  //initialize reportSummary to 1
134  if (reportSummary_) reportSummary_->Fill(1);
135 
136  dbe_->setCurrentFolder("L1TEMU/EventInfo/reportSummaryContents");
137 
138 
139  char histo[100];
140 
141  for (int n = 0; n < nsys_; n++) {
142 
143  switch(n){
144  case 0 : sprintf(histo,"L1T_MET"); break;
145  case 1 : sprintf(histo,"L1T_NonIsoEM"); break;
146  case 2 : sprintf(histo,"L1T_IsoEM"); break;
147  case 3 : sprintf(histo,"L1T_TauJets"); break;
148  case 4 : sprintf(histo,"L1T_Jets"); break;
149  case 5 : sprintf(histo,"L1T_Muons"); break;
150  case 6 : sprintf(histo,"L1T_GT"); break;
151  case 7 : sprintf(histo,"L1TEMU_GLT"); break;
152  case 8 : sprintf(histo,"L1TEMU_GMT"); break;
153  case 9 : sprintf(histo,"L1TEMU_RPC"); break;
154  case 10: sprintf(histo,"L1TEMU_CTP"); break;
155  case 11: sprintf(histo,"L1TEMU_CTF"); break;
156  case 12: sprintf(histo,"L1TEMU_DTP"); break;
157  case 13: sprintf(histo,"L1TEMU_DTF"); break;
158  case 14: sprintf(histo,"L1TEMU_HTP"); break;
159  case 15: sprintf(histo,"L1TEMU_ETP"); break;
160  case 16: sprintf(histo,"L1TEMU_GCT"); break;
161  case 17: sprintf(histo,"L1TEMU_RCT"); break;
162  }
163 
164  reportSummaryContent_[n] = dbe_->bookFloat(histo);
165  }
166 
167  //initialize reportSummaryContents to 0
168  for (int k = 0; k < nsys_; k++) {
169  summaryContent[k] = 0;
170  reportSummaryContent_[k]->Fill(0.);
171  }
172 
173 
174  dbe_->setCurrentFolder("L1TEMU/EventInfo");
175 
176  if( (reportSummaryMap_ = dbe_->get("L1TEMU/EventInfo/reportSummaryMap")) ){
177  dbe_->removeElement(reportSummaryMap_->getName());
178  }
179 
180  reportSummaryMap_ = dbe_->book2D("reportSummaryMap", "reportSummaryMap", 2, 1, 3, 11, 1, 12);
181  reportSummaryMap_->setAxisTitle("", 1);
182  reportSummaryMap_->setAxisTitle("", 2);
183 
184  reportSummaryMap_->setBinLabel(1," ",1);
185  reportSummaryMap_->setBinLabel(2," ",1);
186 
187  reportSummaryMap_->setBinLabel(1," ",2);
188  reportSummaryMap_->setBinLabel(2," ",2);
189  reportSummaryMap_->setBinLabel(3," ",2);
190  reportSummaryMap_->setBinLabel(4," ",2);
191  reportSummaryMap_->setBinLabel(5," ",2);
192  reportSummaryMap_->setBinLabel(6," ",2);
193  reportSummaryMap_->setBinLabel(7," ",2);
194  reportSummaryMap_->setBinLabel(8," ",2);
195  reportSummaryMap_->setBinLabel(9," ",2);
196  reportSummaryMap_->setBinLabel(10," ",2);
197  reportSummaryMap_->setBinLabel(11," ",2);
198 
199 
200 }
201 
202 //--------------------------------------------------------
203 void L1TEMUEventInfoClient::beginRun(const Run& r, const EventSetup& context) {
204 }
205 
206 //--------------------------------------------------------
208  // optionally reset histograms here
209 }
210 
212  const edm::EventSetup& c){
213 
214 
215  for (int k = 0; k < nsys_; k++) {
216  summaryContent[k] = 0;
217  reportSummaryContent_[k]->Fill(0.);
218  }
219  summarySum = 0;
220 
221 
222  //
223  // Apply masks for data and emulator
224  //
225 
226  // Data Mask
227  unsigned int NumDataMask = dataMask.size();
228  std::vector<string> maskedData;
229  for( unsigned int i=0; i<NumDataMask; i++ ){
230  std::string mask_sys_tmp = dataMask[i];
231  std::string mask_sys = StringToUpper(mask_sys_tmp);
232  switch(s_mapDataValues[mask_sys])
233  {
234  case data_empty:
235  break;
236  case data_all:
237  for( int m=0; m<7; m++ ) summaryContent[m] = -1;
238  maskedData.push_back(mask_sys_tmp);
239  break;
240  case data_gt:
241  summaryContent[6]=-1;
242  maskedData.push_back(mask_sys_tmp);
243  break;
244  case data_muons:
245  summaryContent[5]=-1;
246  maskedData.push_back(mask_sys_tmp);
247  break;
248  case data_jets:
249  summaryContent[4]=-1;
250  maskedData.push_back(mask_sys_tmp);
251  break;
252  case data_taujets:
253  summaryContent[3]=-1;
254  maskedData.push_back(mask_sys_tmp);
255  break;
256  case data_isoem:
257  summaryContent[2]=-1;
258  maskedData.push_back(mask_sys_tmp);
259  break;
260  case data_nonisoem:
261  summaryContent[1]=-1;
262  maskedData.push_back(mask_sys_tmp);
263  break;
264  case data_met:
265  summaryContent[0]=-1;
266  maskedData.push_back(mask_sys_tmp);
267  break;
268  default:
269  if( verbose_ ) cout << " User input mask '" << mask_sys_tmp << "' is not recognized." << endl;
270  break;
271  }
272  }
273 
274  // Emulator Mask
275  unsigned int NumEmulMask = emulMask.size();
276  std::vector<string> maskedEmul;
277  for( unsigned int i=0; i<NumEmulMask; i++ ){
278  std::string mask_sys_tmp = emulMask[i];
279  std::string mask_sys = StringToUpper(mask_sys_tmp);
280  switch(s_mapEmulValues[mask_sys])
281  {
282  case emul_empty:
283  break;
284  case emul_all:
285  for( int m=7; m<18; m++ ) summaryContent[m] = -1;
286  maskedEmul.push_back(mask_sys_tmp);
287  break;
288  case emul_glt:
289  summaryContent[7]=-1;
290  maskedEmul.push_back(mask_sys_tmp);
291  break;
292  case emul_gmt:
293  summaryContent[8]=-1;
294  maskedEmul.push_back(mask_sys_tmp);
295  break;
296  case emul_rpc:
297  summaryContent[9]=-1;
298  maskedEmul.push_back(mask_sys_tmp);
299  break;
300  case emul_ctp:
301  summaryContent[10]=-1;
302  maskedEmul.push_back(mask_sys_tmp);
303  break;
304  case emul_ctf:
305  summaryContent[11]=-1;
306  maskedEmul.push_back(mask_sys_tmp);
307  break;
308  case emul_dtp:
309  summaryContent[12]=-1;
310  maskedEmul.push_back(mask_sys_tmp);
311  break;
312  case emul_dtf:
313  summaryContent[13]=-1;
314  maskedEmul.push_back(mask_sys_tmp);
315  break;
316  case emul_htp:
317  summaryContent[14]=-1;
318  maskedEmul.push_back(mask_sys_tmp);
319  break;
320  case emul_etp:
321  summaryContent[15]=-1;
322  maskedEmul.push_back(mask_sys_tmp);
323  break;
324  case emul_gct:
325  summaryContent[16]=-1;
326  maskedEmul.push_back(mask_sys_tmp);
327  break;
328  case emul_rct:
329  summaryContent[17]=-1;
330  maskedEmul.push_back(mask_sys_tmp);
331  break;
332  default:
333  if( verbose_ ) cout << " User input mask '" << mask_sys_tmp << "' is not recognized." << endl;
334  break;
335  }
336  }
337 
338  for( int i=0; i<nsysmon_; i++ ){
339  if( summaryContent[emulatorMap[i]]==-1 ) sysmask_[i] = 1;
340  }
341 
342 
343  MonitorElement* QHist[nsysmon_];
344  std::string lbl("");
345  for(int i=0; i<nsysmon_; i++) {
346  lbl.clear();
347  lbl+="L1TEMU/"; lbl+=syslabel_[i]; lbl+="/";
348  lbl+=syslabelext_[i]; lbl+="ErrorFlag";
349  QHist[i]=dbe_->get(lbl.data());
350  float pv = -1.;
351  if(!sysmask_[i]){
352  pv = setSummary(QHist[i]);
353  }
354  summaryContent[emulatorMap[i]] = pv;
355  }
356 
357 
358 
359  int numUnMaskedSystems = 0;
360  for( int m=0; m<nsys_; m++ ){
361  if( summaryContent[m]!=-1){
362  if( m>6 ){
363  summarySum += summaryContent[m];
364  numUnMaskedSystems++;
365  }
366 
367  reportSummaryContent_[m]->Fill( summaryContent[m] );
368  }
369  }
370 
371 
372 
373  // For now, only use L1TEMU for reportSummary value
374  reportSummary = summarySum/float(numUnMaskedSystems);
375  if (reportSummary_) reportSummary_->Fill(reportSummary);
376 
377 
378  //L1T summary map
379  reportSummaryMap_->setBinContent(1,11,summaryContent[6]); // GT
380  reportSummaryMap_->setBinContent(1,10,summaryContent[5]); // Muons
381  reportSummaryMap_->setBinContent(1,9, summaryContent[4]); // Jets
382  reportSummaryMap_->setBinContent(1,8, summaryContent[3]); // TauJets
383  reportSummaryMap_->setBinContent(1,7, summaryContent[2]); // IsoEM
384  reportSummaryMap_->setBinContent(1,6, summaryContent[1]); // NonIsoEM
385  reportSummaryMap_->setBinContent(1,5, summaryContent[0]); // MET
386 
387  //L1TEMU summary map
388  reportSummaryMap_->setBinContent(2,11,summaryContent[7]); // GLT
389  reportSummaryMap_->setBinContent(2,10,summaryContent[8]); // GMT
390  reportSummaryMap_->setBinContent(2,9, summaryContent[9]); // RPC
391  reportSummaryMap_->setBinContent(2,8, summaryContent[10]);// CTP
392  reportSummaryMap_->setBinContent(2,7, summaryContent[11]);// CTF
393  reportSummaryMap_->setBinContent(2,6, summaryContent[12]);// DTP
394  reportSummaryMap_->setBinContent(2,5, summaryContent[13]);// DTF
395  reportSummaryMap_->setBinContent(2,4, summaryContent[14]);// HTP
396  reportSummaryMap_->setBinContent(2,3, summaryContent[15]);// ETP
397  reportSummaryMap_->setBinContent(2,2, summaryContent[16]);// GCT
398  reportSummaryMap_->setBinContent(2,1, summaryContent[17]);// RCT
399 
400 
401  if( verbose_ ){
402  if( maskedData.size()>0 ){
403  std::cout << " Masked Data Systems = ";
404  for( unsigned int i=0; i<maskedData.size(); i++ ){
405  if( i!=maskedData.size()-1 ){
406  std::cout << maskedData[i] << ", ";
407  }
408  else {
409  std::cout << maskedData[i] << std::endl;
410  }
411  }
412  }
413  if( maskedEmul.size()>0 ){
414  std::cout << " Masked Emul Systems = ";
415  for( unsigned int i=0; i<maskedEmul.size(); i++ ){
416  if( i!=maskedEmul.size()-1 ){
417  std::cout << maskedEmul[i] << ", ";
418  }
419  else {
420  std::cout << maskedEmul[i] << std::endl;
421  }
422  }
423  }
424 
425  std::cout << " L1T " << std::endl;
426  std::cout << " summaryContent[0] = MET = " << summaryContent[0] << std::endl;
427  std::cout << " summaryContent[1] = NonIsoEM = " << summaryContent[1] << std::endl;
428  std::cout << " summaryContent[2] = IsoEM = " << summaryContent[2] << std::endl;
429  std::cout << " summaryContent[3] = TauJets = " << summaryContent[3] << std::endl;
430  std::cout << " summaryContent[4] = Jets = " << summaryContent[4] << std::endl;
431  std::cout << " summaryContent[5] = Muons = " << summaryContent[5] << std::endl;
432  std::cout << " summaryContent[6] = GT = " << summaryContent[6] << std::endl;
433  std::cout << " L1T EMU" << std::endl;
434  std::cout << " summaryContent[7] = GLT = " << summaryContent[7] << std::endl;
435  std::cout << " summaryContent[8] = GMT = " << summaryContent[8] << std::endl;
436  std::cout << " summaryContent[9] = RPC = " << summaryContent[9] << std::endl;
437  std::cout << " summaryContent[10] = CTP = " << summaryContent[10] << std::endl;
438  std::cout << " summaryContent[11] = CTF = " << summaryContent[11] << std::endl;
439  std::cout << " summaryContent[12] = DTP = " << summaryContent[12] << std::endl;
440  std::cout << " summaryContent[13] = DTF = " << summaryContent[13] << std::endl;
441  std::cout << " summaryContent[14] = HTP = " << summaryContent[14] << std::endl;
442  std::cout << " summaryContent[15] = ETP = " << summaryContent[15] << std::endl;
443  std::cout << " summaryContent[16] = GCT = " << summaryContent[16] << std::endl;
444  std::cout << " summaryContent[17] = RCT = " << summaryContent[17] << std::endl;
445  }
446 
447 
448 }
449 
450 //--------------------------------------------------------
451 void L1TEMUEventInfoClient::analyze(const Event& e, const EventSetup& context){
452 
453  counterEvt_++;
454  if (prescaleEvt_<1) return;
455  if (prescaleEvt_>0 && counterEvt_%prescaleEvt_ != 0) return;
456 
457  if(verbose_) cout << "L1TEMUEventInfoClient::analyze" << endl;
458 }
459 
460 //--------------------------------------------------------
461 void L1TEMUEventInfoClient::endRun(const Run& r, const EventSetup& context){
462 }
463 
464 //--------------------------------------------------------
466 }
467 
468 //set subsystem pv in summary map
470  bool isempty = QHist->getEntries()==0;
471  //errflag bins: agree, loc agree, loc disagree, data only, emul only
472  if(!isempty)
473  for(int i=1; i<5; i++)
474  if(QHist->getBinContent(i)>0)
475  {isempty=false;continue;}
476  return isempty ? -1. :
477  (QHist->getBinContent(1)) / (QHist->getEntries());
478 }
479 
480 TH1F * L1TEMUEventInfoClient::get1DHisto(string meName, DQMStore * dbi)
481 {
482 
483  MonitorElement * me_ = dbi->get(meName);
484 
485  if (!me_) {
486  if(verbose_) cout << "ME NOT FOUND." << endl;
487  return NULL;
488  }
489 
490  return me_->getTH1F();
491 }
492 
493 TH2F * L1TEMUEventInfoClient::get2DHisto(string meName, DQMStore * dbi)
494 {
495 
496 
497  MonitorElement * me_ = dbi->get(meName);
498 
499  if (!me_) {
500  if(verbose_) cout << "ME NOT FOUND." << endl;
501  return NULL;
502  }
503 
504  return me_->getTH2F();
505 }
506 
507 
508 
509 TProfile2D * L1TEMUEventInfoClient::get2DProfile(string meName, DQMStore * dbi)
510 {
511 
512 
513  MonitorElement * me_ = dbi->get(meName);
514 
515  if (!me_) {
516  if(verbose_) cout << "ME NOT FOUND." << endl;
517  return NULL;
518  }
519 
520  return me_->getTProfile2D();
521 }
522 
523 
524 TProfile * L1TEMUEventInfoClient::get1DProfile(string meName, DQMStore * dbi)
525 {
526 
527 
528  MonitorElement * me_ = dbi->get(meName);
529 
530  if (!me_) {
531  if(verbose_) cout << "ME NOT FOUND." << endl;
532  return NULL;
533  }
534 
535  return me_->getTProfile();
536 }
537 
538 string L1TEMUEventInfoClient::StringToUpper(string strToConvert)
539 {//change each element of the string to upper case
540  for(unsigned int i=0;i<strToConvert.length();i++)
541  {
542  strToConvert[i] = toupper(strToConvert[i]);
543  }
544  return strToConvert;//return the converted string
545 }
546 
547 
548 
549 
550 
551 
552 
553 
std::string StringToUpper(std::string strToConvert)
int i
Definition: DBlmapReader.cc:9
TProfile2D * getTProfile2D(void) const
void beginJob(void)
BeginJob.
TH1F * get1DHisto(std::string meName, DQMStore *dbi)
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
#define NULL
Definition: scimark2.h:8
Float_t setSummary(MonitorElement *)
tuple histo
Definition: trackerHits.py:12
double getEntries(void) const
get # of entries
virtual ~L1TEMUEventInfoClient()
Destructor.
TProfile2D * get2DProfile(std::string meName, DQMStore *dbi)
L1TEMUEventInfoClient(const edm::ParameterSet &ps)
Constructor.
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:451
void Fill(long long x)
void removeElement(const std::string &name)
Definition: DQMStore.cc:2353
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
DQM Client Diagnostic.
TProfile * get1DProfile(std::string meName, DQMStore *dbi)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1265
DQMStore * dbe_
int k[5][pyjets_maxn]
TH1F * getTH1F(void) const
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
double getBinContent(int binx) const
get content of bin (1-D)
void analyze(const edm::Event &e, const edm::EventSetup &c)
Fake Analyze.
TProfile * getTProfile(void) const
tuple cout
Definition: gather_cfg.py:41
TH2F * get2DHisto(std::string meName, DQMStore *dbi)
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
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:642
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:232
Definition: Run.h:32