CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalSummaryClient.cc
Go to the documentation of this file.
4 
8 
12 
13 #include <iostream>
14 
15 /*
16  * \file HcalSummaryClient.cc
17  *
18  * \author J. Temple
19  * \brief Summary Client class
20  */
21 
23 {
24  name_=myname;
26  minevents_=0;
27  minerrorrate_=0;
29  ProblemCells=0;
31  StatusVsLS_=0;
33  reportMap_=0;
35 
36  // set total number of cells in each subdetector
37  subdetCells_.insert(std::make_pair("HB",2592));
38  subdetCells_.insert(std::make_pair("HE",2592));
39  subdetCells_.insert(std::make_pair("HO",2160));
40  subdetCells_.insert(std::make_pair("HF",1728));
41  subdetCells_.insert(std::make_pair("HO0",576));
42  subdetCells_.insert(std::make_pair("HO12",1584));
43  subdetCells_.insert(std::make_pair("HFlumi",288)); // 8 rings, 36 cells/ring
44  // Assume subdetectors are 'unknown'
45  HBpresent_=-1;
46  HEpresent_=-1;
47  HOpresent_=-1;
48  HFpresent_=-1;
49 
50  EnoughEvents_=0;
51  MinEvents_=0;
52  MinErrorRate_=0;
53 
54  doSetup_ = true;
55 
56 }
57 
59 {
60  name_=myname;
61  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
62  debug_ = ps.getUntrackedParameter<int>("debug",0);
63  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
64  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
65  prefixME_.append("/");
66  subdir_ = ps.getUntrackedParameter<std::string>("SummaryFolder","EventInfo/"); // SummaryMonitor_Hcal
67  if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
68  subdir_.append("/");
69  subdir_=prefixME_+subdir_;
70  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
71 
72  NLumiBlocks_ = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
73  UseBadChannelStatusInSummary_ = ps.getUntrackedParameter<bool>("UseBadChannelStatusInSummary",false);
74 
75  // These aren't used in summary client, are they?
76  badChannelStatusMask_ = ps.getUntrackedParameter<int>("Summary_BadChannelStatusMask",
77  ps.getUntrackedParameter<int>("BadChannelStatusMask",0));
78  minerrorrate_ = ps.getUntrackedParameter<double>("Summary_minerrorrate",
79  ps.getUntrackedParameter<double>("minerrorrate",0));
80  minevents_ = ps.getUntrackedParameter<int>("Summary_minevents",
81  ps.getUntrackedParameter<int>("minevents",0));
82  Online_ = ps.getUntrackedParameter<bool>("online",false);
83 
84  // Specify the directories where the tasks to be check reside
85  TaskList_ = ps.getUntrackedParameter<std::vector<std::string> >("TaskDirectories");
86  // Minimum number of events per lumi section that must be present for checks to be made. *ALL* tasks must contain at least this many events
87  minEvents_ = ps.getUntrackedParameter<int>("minEvents",500);
88 
90  ProblemCells=0;
92  StatusVsLS_=0;
94  reportMap_=0;
96 
97  // set total number of cells in each subdetector
98  subdetCells_.insert(std::make_pair("HB",2592));
99  subdetCells_.insert(std::make_pair("HE",2592));
100  subdetCells_.insert(std::make_pair("HO",2160));
101  subdetCells_.insert(std::make_pair("HF",1728));
102  subdetCells_.insert(std::make_pair("HO0",576));
103  subdetCells_.insert(std::make_pair("HO12",1584));
104  subdetCells_.insert(std::make_pair("HFlumi",288)); // 8 rings, 36 cells/ring
105  // Assume subdetectors are 'unknown'
106  HBpresent_=-1;
107  HEpresent_=-1;
108  HOpresent_=-1;
109  HFpresent_=-1;
110 
111  EnoughEvents_=0;
112  MinEvents_=0;
113  MinErrorRate_=0;
114 
115  doSetup_ = true;
116 
117 }
118 
120 {
121  if (debug_>2) std::cout <<"\tHcalSummaryClient::analyze()"<<std::endl;
122 
123  if ( doSetup_ ) setup(ib,ig);
124 
125  //
126 
127  // Start with counters in 'unknown' status; they'll be set by analyze_everything routines
128  status_global_=-1;
129  status_HB_=-1;
130  status_HE_=-1;
131  status_HO_=-1;
132  status_HF_=-1;
133 
134  status_HO0_=-1;
135  status_HO12_=-1;
136  status_HFlumi_=-1;
137  status_global_=-1;
138 
139  if (EnoughEvents_!=0) EnoughEvents_->Reset();
140  enoughevents_=true; // assume we have enough events for all tests to have run
142  {
143  if (debug_>2) std::cout <<"<HcalSummaryClient::analyze> CLIENT = "<<clients_[i]->name_<<" ENOUGH = "<<clients_[i]->enoughevents_<<std::endl;
144  enoughevents_&=clients_[i]->enoughevents_;
146  {
147  if (clients_[i]->enoughevents_==false && debug_>1)
148  std::cout <<"Failed enoughevents test for monitor "<<clients_[i]->name()<<std::endl;
149  }
150  }
151 
152  // check to find which subdetectors are present -- need to do this prior to checking whether enoughevents_ == false!
153  MonitorElement* temp_present;
154  if (HBpresent_!=1)
155  {
156  temp_present=ig.get(prefixME_+"HcalInfo/HBpresent");
157  if (temp_present!=0)
158  HBpresent_=temp_present->getIntValue();
159  }
160  if (HEpresent_!=1)
161  {
162  temp_present=ig.get(prefixME_+"HcalInfo/HEpresent");
163  if (temp_present!=0)
164  HEpresent_=temp_present->getIntValue();
165  }
166  if (HOpresent_!=1)
167  {
168  temp_present=ig.get(prefixME_+"HcalInfo/HOpresent");
169  if (temp_present!=0)
170  HOpresent_=temp_present->getIntValue();
171  }
172  if (HFpresent_!=1)
173  {
174  temp_present=ig.get(prefixME_+"HcalInfo/HFpresent");
175  if (temp_present!=0)
176  HFpresent_=temp_present->getIntValue();
177  }
178 
179  if (debug_>1)
180  std::cout <<"<HcalSummaryClient::analyze> HB present = "<<HBpresent_<<" "<<"HE present = "<<HEpresent_<<" "<<"HO present = "<<HOpresent_<<" "<<"HF present = "<<HFpresent_<<std::endl;
181 
182  if (enoughevents_==false)
183  {
184  if (debug_>0) std::cout <<"<HcalSummaryClient::analyze> Not enough events processed to evaluate summary status!"<<std::endl;
185 
186  // 'HXpresent_' values are set to -1 by default.
187  // They are set to +1 when a channel is present.
188  // I don't think there are any cases where values =0,
189  // but I'm not positive of this yet -- Jeff, 10 Aug 2010
190 
191  // Check whether any events are found for each subdetector
192  if (HBpresent_>0) status_HB_=1;
193  else status_HB_=-1; // HB not present or unknown
194  if (HEpresent_>0) status_HE_=1;
195  else status_HE_=-1; // HE not present or unknown
196  if (HOpresent_>0) status_HO_=1;
197  else status_HO_=-1; // HO not present or unknown
198  if (HFpresent_>0) status_HF_=1;
199  else status_HF_=-1; // HF not present or unknown
200 
201  // Update this in the future? Use '||' instead of '&&'?
202  if (HBpresent_<=0 && HEpresent_<=0 && HOpresent_<=0 && HFpresent_<=0)
203  status_global_=-1;
204  else
205  status_global_=1;
206 
207  // Set other statuses based on subdetectors
211 
212  if (debug_>1)
213  {
214  std::cout <<"Insufficient events processed. Subdetector status is:"<<std::endl;
215  std::cout<<"\tHB: "<<status_HB_<<std::endl;
216  std::cout<<"\tHE: "<<status_HE_<<std::endl;
217  std::cout<<"\tHO: "<<status_HO_<<std::endl;
218  std::cout<<"\tHF: "<<status_HF_<<std::endl;
219  std::cout<<"\tHO0: "<<status_HO0_<<std::endl;
220  std::cout<<"\tHO12: "<<status_HO12_<<std::endl;
221  std::cout<<"\tHFlumi: "<<status_HFlumi_<<std::endl;
222  }
223 
224  fillReportSummary(ib,ig,LS);
225  return;
226  }
227  if (EnoughEvents_!=0) EnoughEvents_->setBinContent(clients_.size()+1,1); // summary is good to go!
228 
229  // set status to 0 if subdetector is present (or assumed present)
230  if (HBpresent_>0) status_HB_=0;
231  if (HEpresent_>0) status_HE_=0;
233  if (HFpresent_>0) {status_HF_=0; status_HFlumi_=0;}
234 
235  if (HBpresent_>0 || HEpresent_>0 ||
236  HOpresent_>0 || HFpresent_>0 )
237  status_global_=0;
238 
239  // don't want to fool with variable-sized arrays at the moment; revisit later
240  //const unsigned int csize=clients_.size();
241  double localHB[20]={0};
242  double localHE[20]={0};
243  double localHF[20]={0};
244  double localHO[20]={0};
245  double localHFlumi[20]={0};
246  double localHO0[20]={0};
247  double localHO12[20]={0};
248 
249  // reset all depth histograms
250  if (SummaryMapByDepth==0)
251  {
252  if (debug_>0)
253  std::cout <<"<HcalSummaryClient::analyze> ERROR: SummaryMapByDepth can't be found!"<<std::endl;
254  }
255  else
256  {
257  for (unsigned int i=0;i<(SummaryMapByDepth->depth).size();++i)
258  SummaryMapByDepth->depth[i]->Reset();
259 
260  int etabins=-9999;
261  int phibins=-9999;
262 
263  // Get Channel Status histograms here
264  std::vector<MonitorElement*> chStat;
265  chStat.push_back(ig.get(prefixME_+"HcalInfo/ChannelStatus/HB HE HF Depth 1 ChannelStatus"));
266  chStat.push_back(ig.get(prefixME_+"HcalInfo/ChannelStatus/HB HE HF Depth 2 ChannelStatus"));
267  chStat.push_back(ig.get(prefixME_+"HcalInfo/ChannelStatus/HE Depth 3 ChannelStatus"));
268  chStat.push_back(ig.get(prefixME_+"HcalInfo/ChannelStatus/HO Depth 4 ChannelStatus"));
269 
270 
271  for (int d=0;d<4;++d)
272  {
273  etabins=(SummaryMapByDepth->depth[d])->getNbinsX();
274  phibins=(SummaryMapByDepth->depth[d])->getNbinsY();
275  for (int eta=1;eta<=etabins;++eta)
276  {
277  int ieta=CalcIeta(eta-1,d+1);
278  for (int phi=1;phi<=phibins;++phi)
279  {
280  // local phi counter is the same as iphi
281  // for |ieta|>20, iphi%2==0 cells are unphysical; skip 'em
282  // for |ieta|>39, iphi%4!=3 cells are unphysical
283  if (abs(ieta)>20 && phi%2==0) continue;
284  if (abs(ieta)>39 && phi%4!=3) continue;
285 
286  // First loop calculates "local" error rates for each individual client
287  // This must be done separately from the SummaryMap overall loop, because that loop issues a
288  // 'break' the first time an error is found (to avoid double-counting multiple errors in a single channel).
289  for (unsigned int cl=0;cl<clients_.size();++cl)
290  {
291  if (clients_[cl]->ProblemCellsByDepth==0) continue;
292 
293  if ((clients_[cl]->ProblemCellsByDepth)->depth[d]==0) continue;
294  if ((clients_[cl]->ProblemCellsByDepth)->depth[d]->getBinContent(eta,phi)>clients_[cl]->minerrorrate_)
295  {
296  if (isHF(eta-1,d+1))
297  {
298  ++localHF[cl];
299  if ((d==0 && (abs(ieta)==33 || abs(ieta)==34)) || // depth 1, rings 33,34
300  (d==1 && (abs(ieta)==35 || abs(ieta)==36))) // depth 2, rings 35,36
301  ++localHFlumi[cl];
302  }
303  else if (isHO(eta-1,d+1))
304  {
305  ++localHO[cl];
306  if (abs(ieta)<5) ++localHO0[cl];
307  else ++localHO12[cl];
308  }
309  else if (isHB(eta-1,d+1)) ++localHB[cl];
310  else if (isHE(eta-1,d+1)) ++localHE[cl];
311  }
312  } // for (loop on clients_.size() to determine individual client error rates)
313 
314  // Check for certification errors -- do we want to add some extra warnings (filling channel status db plot with new value, etc?) in this case?
315 
316  if (UseBadChannelStatusInSummary_ && chStat[d]!=0)
317  {
318  double chanStat=chStat[d]->getBinContent(eta,phi);
319  // chanStat<0 indicates original status from database was <0; this is counted as an error,
320  // since such values should never appear in the database.
321  if (chanStat<0)
322  {
323  if (isHF(eta-1,d+1))
324  {
325  ++status_HF_;
326  if ((d==0 && (abs(ieta)==33 || abs(ieta)==34)) || // depth 1, rings 33,34
327  (d==1 && (abs(ieta)==35 || abs(ieta)==36))) // depth 2, rings 35,36
328  {
329  ++status_HFlumi_;
330  }
331  continue; // don't bother looking at individual clients for results; channel status is already corrupted
332  }
333  else if (isHO(eta-1,d+1))
334  {
335  ++status_HO_;
336  if (abs(ieta)<5)
337  ++status_HO0_;
338  else ++status_HO12_;
339  continue;
340  }
341  else if (isHB(eta-1,d+1))
342  {
343  ++status_HB_;
344  continue;
345  }
346  else if (isHE(eta-1,d+1))
347  {
348  ++status_HE_;
349  continue;
350  }
351  } // if (chanStat<0)
352  } // if (UseBadChannelStatusInSummary_)
353 
354  // loop over all client tests
355 
356  // SummaryMapByDepth is slightly different from previous version -- it now just shows cells
357  // that contribute as "problems", rather than giving good channels a status of 1, and bad a status of 0
358  for (unsigned int cl=0;cl<clients_.size();++cl)
359  {
360  // Best way to handle this?
361  // We know that first element is HcalMonitorModule info, which has
362  // no problem cells defined. Create some, or start counting from cl=1?
363  if (debug_>4 && eta==1 && phi==1) std::cout <<"Checking summary for client "<<clients_[cl]->name()<<std::endl;
364  if (clients_[cl]->ProblemCellsByDepth==0) continue;
365 
366  if ((clients_[cl]->ProblemCellsByDepth)->depth[d]==0) continue;
367  if ((clients_[cl]->ProblemCellsByDepth)->depth[d]->getBinContent(eta,phi)>clients_[cl]->minerrorrate_)
368  {
369  if ((clients_[cl]->ProblemCellsByDepth)->depth[d]->getBinContent(eta,phi)<999)
370  SummaryMapByDepth->depth[d]->setBinContent(eta,phi,1);
371  else
372  SummaryMapByDepth->depth[d]->setBinContent(eta,phi,999); // known problems filled with a value of 999
373  if (isHF(eta-1,d+1))
374  {
375  ++status_HF_;
376  if ((d==0 && (abs(ieta)==33 || abs(ieta)==34)) || // depth 1, rings 33,34
377  (d==1 && (abs(ieta)==35 || abs(ieta)==36))) // depth 2, rings 35,36
378  {
379  ++status_HFlumi_;
380  }
381  }
382  else if (isHO(eta-1,d+1))
383  {
384  ++status_HO_;
385  if (abs(ieta)<5)
386  ++status_HO0_;
387  else ++status_HO12_;
388  }
389  else if (isHB(eta-1,d+1)) ++status_HB_;
390  else if (isHE(eta-1,d+1)) ++status_HE_;
391  break; // man, this break causes problems for certificationMap!!! -- Jason; WHY? -- Jeff
392  }
393  } // for (main loop on clients_.size() to calculate reportSummary statuses)
394  }
395  }
396  } // for (int d=0;d<4;++d)
397 
399  } // else (SummaryMapByDepth exists)
400 
401  // We've checked all problems; now compute overall status
402  int totalcells=0;
403  std::map<std::string, int>::const_iterator it;
404 
405  if (HBpresent_>0)
406  {
408  it=subdetCells_.find("HB");
409  totalcells+=it->second;
410  status_HB_= 1-(status_HB_/it->second);
411  for (unsigned int i=0;i<clients_.size();++i)
412  {
413  localHB[i]=1-(1.*localHB[i]/it->second);
414  localHB[i]=std::max(0.,localHB[i]);
415  }
416  status_HB_=std::max(0.,status_HB_); // converts fraction of bad channels to good fraction
417  }
418  else status_HB_=-1; // enoughevents_ can be true even if HB not present; need to set status_HB_=-1 in both cases
419 
420  if (HEpresent_>0)
421  {
423  it=subdetCells_.find("HE");
424  totalcells+=it->second;
425  status_HE_= 1-(status_HE_/it->second);
426  for (unsigned int i=0;i<clients_.size();++i)
427  {
428  localHE[i]=1-(1.*localHE[i]/it->second);
429  localHE[i]=std::max(0.,localHE[i]);
430  }
431  status_HE_=std::max(0.,status_HE_); // converts fraction of bad channels to good fraction
432  }
433  else status_HE_=-1;
434 
435  if (HOpresent_>0)
436  {
438  it=subdetCells_.find("HO");
439  totalcells+=it->second;
440  status_HO_= 1-(status_HO_/it->second);
441  status_HO_=std::max(0.,status_HO_); // converts fraction of bad channels to good fraction
442  for (unsigned int i=0;i<clients_.size();++i)
443  {
444  localHO[i]=1-(1.*localHO[i]/it->second);
445  localHO[i]=std::max(0.,localHO[i]);
446  }
447  it=subdetCells_.find("HO0");
448  status_HO0_= 1-(status_HO0_/it->second);
449  for (unsigned int i=0;i<clients_.size();++i)
450  {
451  localHO0[i]=1-(1.*localHO0[i]/it->second);
452  localHO0[i]=std::max(0.,localHO0[i]);
453  }
454  status_HO0_=std::max(0.,status_HO0_); // converts fraction of bad channels to good fraction
455  it=subdetCells_.find("HO12");
456  status_HO12_= 1-(status_HO12_/it->second);
457  status_HO12_=std::max(0.,status_HO12_); // converts fraction of bad channels to good fraction
458  for (unsigned int i=0;i<clients_.size();++i)
459  {
460  localHO12[i]=1-(1.*localHO12[i]/it->second);
461  localHO12[i]=std::max(0.,localHO12[i]);
462  }
463  }
464  else
465  {
466  status_HO_=-1;
467  status_HO0_=-1;
468  status_HO12_=-1;
469  }
470  if (HFpresent_>0)
471  {
473  it=subdetCells_.find("HF");
474  totalcells+=it->second;
475  status_HF_= 1-(status_HF_/it->second);
476  status_HF_=std::max(0.,status_HF_); // converts fraction of bad channels to good fraction
477  for (unsigned int i=0;i<clients_.size();++i)
478  {
479  localHF[i]=1-(1.*localHF[i]/it->second);
480  localHF[i]=std::max(0.,localHF[i]);
481  }
482  it=subdetCells_.find("HFlumi");
483  status_HFlumi_= 1-(status_HFlumi_/it->second);
484  status_HFlumi_=std::max(0.,status_HFlumi_); // converts fraction of bad channels to good fraction
485  for (unsigned int i=0;i<clients_.size();++i)
486  {
487  localHFlumi[i]=1-(1.*localHFlumi[i]/it->second);
488  localHFlumi[i]=std::max(0.,localHFlumi[i]);
489  }
490  }
491  else
492  {
493  status_HF_=-1;
494  status_HFlumi_=-1;
495  }
496 
497  if (totalcells==0)
498  status_global_=-1;
499  else
500  {
501  status_global_=1-status_global_/totalcells;
502  status_global_=std::max(0.,status_global_); // convert to good fraction
503  }
504 
505 
506  // Fill certification map here
507 
508  ig.setCurrentFolder(prefixME_+"HcalInfo");
509  certificationMap_=ig.get(prefixME_+"HcalInfo/CertificationMap");
511  certificationMap_=ib.book2D("CertificationMap","Certification Map",7,0,7,
512  clients_.size()+1,0,clients_.size()+1);
513 
514  certificationMap_->getTH2F()->GetYaxis()->SetBinLabel(1,"Summary");
515  (certificationMap_->getTH2F())->SetOption("textcolz");
516 
517  for (int i=0;i<(int)clients_.size();++i)
518  {
519  certificationMap_->getTH2F()->GetYaxis()->SetBinLabel(i+2,(clients_[i]->name()).c_str());
520  }
521  certificationMap_->getTH2F()->GetYaxis()->SetLabelSize(0.02);
522  certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(1,"HB");
523  certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(2,"HE");
524  certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(3,"HO");
525  certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(4,"HF");
526  certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(5,"HO0");
527  certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(6,"HO12");
528  certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(7,"HFlumi");
529  certificationMap_->getTH2F()->SetMinimum(-1);
530  certificationMap_->getTH2F()->SetMaximum(1);
531 
532  for (unsigned int i=0;i<clients_.size();++i)
533  {
534  certificationMap_->setBinContent(1,i+2,localHB[i]);
535  certificationMap_->setBinContent(2,i+2,localHE[i]);
536  certificationMap_->setBinContent(3,i+2,localHO[i]);
537  certificationMap_->setBinContent(4,i+2,localHF[i]);
538  certificationMap_->setBinContent(5,i+2,localHO0[i]);
539  certificationMap_->setBinContent(6,i+2,localHO12[i]);
540  certificationMap_->setBinContent(7,i+2,localHF[i]);
541  }
549  fillReportSummary(ib,ig,LS);
550 } // analyze
551 
553 {
554 
555  // We've now checked all tasks; now let's calculate summary values
556 
557  if (debug_>2) std::cout <<"<HcalSummaryClient::fillReportSummary>"<<std::endl;
558 
559  if (debug_>3)
560  {
561  std::cout <<"STATUS = "<<std::endl;
562  std::cout <<"HB = "<<status_HB_<<std::endl;
563  std::cout <<"HE = "<<status_HE_<<std::endl;
564  std::cout <<"HO = "<<status_HO_<<std::endl;
565  std::cout <<"HF = "<<status_HF_<<std::endl;
566  std::cout <<"HO0 = "<<status_HO0_<<std::endl;
567  std::cout <<"HO12 = "<<status_HO12_<<std::endl;
568  std::cout <<"HFlumi = "<<status_HFlumi_<<std::endl;
569  }
570 
571  // put the summary values into MonitorElements
572 
573  if (LS>0)
574  {
575  if (StatusVsLS_)
576  {
584  }
585  }
586 
587  MonitorElement* me;
589 
590  //me=dqmStore_->get(subdir_+"reportSummaryMap");
591  if (reportMap_)
592  {
600  // Set reportMap underflow bin based on whether enough total events have been processed
601  if (enoughevents_==false)
602  reportMap_->setBinContent(0,0,-1);
603  else
604  reportMap_->setBinContent(0,0,1);
605  }
606  else if (debug_>0) std::cout <<"<HcalSummaryClient::fillReportSummary> CANNOT GET REPORT SUMMARY MAP!!!!!"<<std::endl;
607 
608  if (reportMapShift_)
609  {
616  // Set reportMap underflow bin based on whether enough total events have been processed
617  if (enoughevents_==false)
619  else
621  }
622  else if (debug_>0) std::cout <<"<HcalSummaryClient::fillReportSummary> CANNOT GET REPORT SUMMARY MAP!!!!!"<<std::endl;
623 
624  me=ig.get(subdir_+"reportSummary");
625  // Clear away old versions
626  if (me) me->Fill(status_global_);
627 
628  // Create floats for each subdetector status
629  std::string subdets[7] = {"HB","HE","HO","HF","HO0","HO12","HFlumi"};
630  for (unsigned int i=0;i<7;++i)
631  {
632  // Create floats showing subtasks status
633  ig.setCurrentFolder( subdir_+ "reportSummaryContents" );
634  me=ig.get(subdir_+"reportSummaryContents/Hcal_"+subdets[i]);
635  if (me==0)
636  {
637  if (debug_>0) std::cout <<"<HcalSummaryClient::analyze()> Could not get Monitor Element named 'Hcal_"<<subdets[i]<<"'"<<std::endl;
638  continue;
639  }
640  if (subdets[i]=="HB") me->Fill(status_HB_);
641  else if (subdets[i]=="HE") me->Fill(status_HE_);
642  else if (subdets[i]=="HO") me->Fill(status_HO_);
643  else if (subdets[i]=="HF") me->Fill(status_HF_);
644  else if (subdets[i]=="HO0") me->Fill(status_HO0_);
645  else if (subdets[i]=="HO12") me->Fill(status_HO12_);
646  else if (subdets[i]=="HFlumi") me->Fill(status_HFlumi_);
647  } // for (unsigned int i=0;...)
648 
649 } // fillReportSummary()
650 
651 
653 {
654 
655  MonitorElement* me;
656  ig.setCurrentFolder(prefixME_+"LSbyLS_Hcal/LSvalues");
657 
658  bool enoughEvents=true;
659  int Nevents=0;
660  int TotalEvents=0;
661 
662  float status_HB=0;
663  float status_HE=0;
664  float status_HO=0;
665  float status_HF=0;
666  float status_HO0=0;
667  float status_HO12=0;
668  float status_HFlumi=0;
669  float status_global=-1;
670 
671  for (unsigned int i=0;i<TaskList_.size();++i)
672  {
673  std::string name=prefixME_+TaskList_[i]+"LSvalues/";
674  ig.setCurrentFolder(name.c_str());
675  // Do we need the 'name' prefix here?
676  me=ig.get(name+"ProblemsThisLS");
677  if (me==0)
678  {
679  if (debug_>0) std::cout <<"<HcalLSbyLSMonitor> Error! Could not get histogram "<<name.c_str()<<std::endl;
680  enoughEvents=false;
681  break;
682  }
683 
684  Nevents=(int)me->getBinContent(-1);
685  if (Nevents<minEvents_)
686  {
687  if (debug_>0)
688  std::cout <<"<HcalLSbyLSMonitor> Error! Number of events "<<Nevents<<" for histogram "<<name.c_str()<<" is less than the required minimum of "<<minEvents_<<std::endl;
689  enoughEvents=false;
690  break;
691  }
692  // Total events is the number of events processed in this LS
693  TotalEvents=std::max(TotalEvents,Nevents);
694  // errors are sum over all tests. This WILL lead to double counting in some subdetectors!
695  if ( enoughEvents==true ) {
696  status_HB+=(int)me->getBinContent(1,1);
697  status_HE+=(int)me->getBinContent(2,1);
698  status_HO+=(int)me->getBinContent(3,1);
699  status_HF+=(int)me->getBinContent(4,1);
700  status_HO0+=(int)me->getBinContent(5,1);
701  status_HO12+=(int)me->getBinContent(6,1);
702  status_HFlumi+=(int)me->getBinContent(7,1);
703  }
704  }
705 
706  if (TotalEvents>0)
707  {
708  std::map<std::string, int>::const_iterator it;
709  int totalcells=0;
710 
711  status_global=status_HB+status_HE+status_HO+status_HF;
712  if (debug_>1) std::cout <<"<HcalSummaryClient::fillReportsummaryLSbyLS> BAD CHANNELS*EVENTS = HB: "<<status_HB<<" HE: "<<status_HE<<" HO: "<<status_HO<<" HO0: "<<status_HO0<<" HO12: "<<status_HO12<<" HF:"<<status_HF<<" HFlumi: "<<status_HFlumi<<" TOTAL BAD CHANNELS*EVENTS = "<<status_global<<" TOTAL EVENTS = "<<TotalEvents<<std::endl;
713 
714  it=subdetCells_.find("HB");
715  totalcells+=it->second;
716  if (it->second>0)
717  status_HB=1-(status_HB)/TotalEvents/it->second;
718 
719  it=subdetCells_.find("HE");
720  totalcells+=it->second;
721  if (it->second>0)
722  status_HE=1-(status_HE)/TotalEvents/it->second;
723 
724  it=subdetCells_.find("HO");
725  totalcells+=it->second;
726  if (it->second>0)
727  status_HO=1-(status_HO)/TotalEvents/it->second;
728 
729  it=subdetCells_.find("HF");
730  totalcells+=it->second;
731  if (it->second>0)
732  status_HF=1-(status_HF)/TotalEvents/it->second;
733 
734  it=subdetCells_.find("HO0");
735  if (it->second>0)
736  status_HO0=1-(status_HO0)/TotalEvents/it->second;
737 
738  it=subdetCells_.find("HO12");
739  if (it->second>0)
740  status_HO12=1-(status_HO12)/TotalEvents/it->second;
741 
742  it=subdetCells_.find("HFlumi");
743  if (it->second>0)
744  status_HFlumi=1-(status_HFlumi)/TotalEvents/it->second;
745  if (totalcells>0)
746  status_global=1-status_global/TotalEvents/totalcells;
747  if (debug_>1) std::cout <<"<HcalSummaryClient::fillReportsummaryLSbyLS> STATUS= HB: "<<status_HB<<" HE: "<<status_HE<<" HO: "<<status_HO<<" HO0: "<<status_HO0<<" HO12: "<<status_HO12<<" HF:"<<status_HF<<" HFlumi: "<<status_HFlumi<<" GLOBAL STATUS = "<<status_global<<" TOTAL EVENTS = "<<TotalEvents<<std::endl;
748  } // if (TotalEvents(>0)
749 
750 
752  if (reportMap_)
753  {
754  reportMap_->setBinContent(1,1,status_HB);
755  reportMap_->setBinContent(2,1,status_HE);
756  reportMap_->setBinContent(3,1,status_HO);
757  reportMap_->setBinContent(4,1,status_HF);
758  reportMap_->setBinContent(5,1,status_HO0);
759  reportMap_->setBinContent(6,1,status_HO12);
760  reportMap_->setBinContent(7,1,status_HFlumi);
761  // Set reportMap underflow bin based on whether enough total events have been processed
762  if (enoughevents_==false)
763  reportMap_->setBinContent(0,0,-1);
764  else
765  reportMap_->setBinContent(0,0,1);
766 
767  }
768  else if (debug_>0) std::cout <<"<HcalSummaryClient::fillReportSummaryLSbyLS> CANNOT GET REPORT SUMMARY MAP!!!!!"<<std::endl;
769 
770  if (reportMapShift_)
771  {
772  reportMapShift_->setBinContent(1,1,status_HB);
773  reportMapShift_->setBinContent(2,1,status_HE);
774  reportMapShift_->setBinContent(3,1,status_HO);
775  reportMapShift_->setBinContent(4,1,status_HF);
776  reportMapShift_->setBinContent(5,1,status_HO0);
777  reportMapShift_->setBinContent(6,1,status_HO12);
778  // Set reportMap underflow bin based on whether enough total events have been processed
779  if (enoughevents_==false)
781  else
783 
784  }
785  else if (debug_>0) std::cout <<"<HcalSummaryClient::fillReportSummaryLSbyLS> CANNOT GET REPORT SUMMARY MAP!!!!!"<<std::endl;
786 
787  me=ig.get(subdir_+"reportSummary");
788  // Clear away old versions
789  if (me) me->Fill(status_global);
790 
791  // Create floats for each subdetector status
792  std::string subdets[7] = {"HB","HE","HO","HF","HO0","HO12","HFlumi"};
793  for (unsigned int i=0;i<7;++i)
794  {
795  // Create floats showing subtasks status
796  ig.setCurrentFolder( subdir_+ "reportSummaryContents" );
797  me=ig.get(subdir_+"reportSummaryContents/Hcal_"+subdets[i]);
798  if (me==0)
799  {
800  if (debug_>0) std::cout <<"<HcalSummaryClient::LSbyLS> Could not get Monitor Element named 'Hcal_"<<subdets[i]<<"'"<<std::endl;
801  continue;
802  }
803  if (subdets[i]=="HB") me->Fill(status_HB);
804  else if (subdets[i]=="HE") me->Fill(status_HE);
805  else if (subdets[i]=="HO") me->Fill(status_HO);
806  else if (subdets[i]=="HF") me->Fill(status_HF);
807  else if (subdets[i]=="HO0") me->Fill(status_HO0);
808  else if (subdets[i]=="HO12") me->Fill(status_HO12);
809  else if (subdets[i]=="HFlumi") me->Fill(status_HFlumi);
810  } // for (unsigned int i=0;...)
811 
812 
813  if (StatusVsLS_)
814  {
815  StatusVsLS_->setBinContent(LS,1,status_HB);
816  StatusVsLS_->setBinContent(LS,2,status_HE);
817  StatusVsLS_->setBinContent(LS,3,status_HO);
818  StatusVsLS_->setBinContent(LS,4,status_HF);
819  StatusVsLS_->setBinContent(LS,5,status_HO0);
820  StatusVsLS_->setBinContent(LS,6,status_HO12);
821  StatusVsLS_->setBinContent(LS,7,status_HFlumi);
822  }
823 
824  return;
825 
826 
827 } // void HcalSummaryClient::fillReportSummaryLSbyLS()
828 
829 
830 
832 
834 {
835 } // void HcalSummaryClient::beginRun(void)
836 
837 
838 //void HcalSummaryClient::endRun(void){}
839 
841  nevts_=0;
842 
844 
845  MonitorElement* me;
846  // reportSummary holds overall detector status
847  me=ig.get(subdir_+"reportSummary");
848  // Clear away old versions
849  if (me) ig.removeElement(me->getName());
850  me = ib.bookFloat("reportSummary");
851  me->Fill(-1); // set status to unknown at startup
852 
853  // Create floats for each subdetector status
854  std::string subdets[7] = {"HB","HE","HO","HF","HO0","HO12","HFlumi"};
855  for (unsigned int i=0;i<7;++i)
856  {
857  // Create floats showing subtasks status
858  ig.setCurrentFolder( subdir_+ "reportSummaryContents" );
859  me=ig.get(subdir_+"reportSummaryContents/Hcal_"+subdets[i]);
860  if (me) ig.removeElement(me->getName());
861  me = ib.bookFloat("Hcal_"+subdets[i]);
862  me->Fill(-1);
863  } // for (unsigned int i=0;...)
864 
865  ib.setCurrentFolder(prefixME_+"HcalInfo/SummaryClientPlots");
866  me=ig.get(prefixME_+"HcalInfo/SummaryClientPlots/HB HE HF Depth 1 Problem Summary Map");
867  if (me) ig.removeElement(me->getName());
868  me=ig.get(prefixME_+"HcalInfo/SummaryClientPlots/HB HE HF Depth 2 Problem Summary Map");
869  if (me) ig.removeElement(me->getName());
870  me=ig.get(prefixME_+"HcalInfo/SummaryClientPlots/HE Depth 3 Problem Summary Map");
871  if (me) ig.removeElement(me->getName());
872  me=ig.get(prefixME_+"HcalInfo/SummaryClientPlots/HO Depth 4 Problem Summary Map");
873  if (me) ig.removeElement(me->getName());
874 
875  if (EnoughEvents_==0)
876  EnoughEvents_=ib.book1D("EnoughEvents","Enough Events Passed From Each Task To Form Summary",1+(int)clients_.size(),0,1+(int)clients_.size());
878  EnoughEvents_->setBinLabel(i+1,clients_[i]->name());
879  EnoughEvents_->setBinLabel(1+(int)clients_.size(),"Summary");
880 
881  if (MinEvents_==0)
882  MinEvents_=ib.book1D("MinEvents","Minimum Events Required From Each Task To Form Summary",
883  1+(int)clients_.size(),0,1+(int)clients_.size());
884  int summin=0;
886  {
889  summin=std::max(summin,clients_[i]->minevents_);
890  }
891  if (MinErrorRate_==0)
892  MinErrorRate_=ib.book1D("MinErrorRate",
893  "Minimum Error Rate Required For Channel To Be Counted As Problem",
894  (int)clients_.size(),0,(int)clients_.size());
896  {
899  }
900 
901  // Extra fix provided by Giuseppe
902 
903  if (SummaryMapByDepth!=0)
904  {
905  delete SummaryMapByDepth;
907  }
908 
909  if (SummaryMapByDepth==0)
910  {
912  SummaryMapByDepth->setup(ib,"Problem Summary Map");
913  }
914  // Set histogram values to -1
915  // Set all bins to "unknown" to start
916  int etabins=0;
917  for (unsigned int depth=0;depth<4;++depth)
918  {
919  if (SummaryMapByDepth->depth[depth]==0) continue;
920  SummaryMapByDepth->depth[depth]->Reset();
921  etabins=(SummaryMapByDepth->depth[depth])->getNbinsX();
922  for (int ieta=0;ieta<etabins;++ieta)
923  {
924  for (int iphi=0;iphi<72;++iphi)
925  SummaryMapByDepth->depth[depth]->setBinContent(ieta+1,iphi+1,-1);
926  }
927  }
928 
929  // Make histogram of status vs LS
930  StatusVsLS_ = ig.get(prefixME_+"HcalInfo/SummaryClientPlots/StatusVsLS");
932  StatusVsLS_ = ib.book2D("StatusVsLS","Status vs. Luminosity Section",
933  NLumiBlocks_,0.5,NLumiBlocks_+0.5,
934  7,0,7);
935  // Set all status values to -1 to begin
936  for (int i=1;i<=NLumiBlocks_;++i)
937  for (int j=1;j<=7;++j)
939  (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(1,"HB");
940  (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(2,"HE");
941  (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(3,"HO");
942  (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(4,"HF");
943  (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(5,"HO0");
944  (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(6,"HO12");
945  (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(7,"HFlumi");
946  (StatusVsLS_->getTH2F())->GetXaxis()->SetTitle("Lumi Section");
947  (StatusVsLS_->getTH2F())->SetMinimum(-1);
948  (StatusVsLS_->getTH2F())->SetMaximum(1);
949 
950  // Finally, form report Summary Map
952 
953  reportMap_=ig.get(subdir_+"reportSummaryMap");
954  if (reportMap_)
956  reportMap_ = ib.book2D("reportSummaryMap","reportSummaryMap",
957  7,0,7,1,0,1);
958  (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(1,"HB");
959  (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(2,"HE");
960  (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(3,"HO");
961  (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(4,"HF");
962  (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(5,"HO0");
963  (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(6,"HO12");
964  (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(7,"HFlumi");
965  (reportMap_->getTH2F())->GetYaxis()->SetBinLabel(1,"Status");
966  (reportMap_->getTH2F())->SetMarkerSize(3);
967  (reportMap_->getTH2F())->SetOption("text90colz");
968  //(reportMap_->getTH2F())->SetOption("textcolz");
969  (reportMap_->getTH2F())->SetMinimum(-1);
970  (reportMap_->getTH2F())->SetMaximum(1);
971 
972  if (reportMapShift_)
974  reportMapShift_ = ib.book2D("reportSummaryMapShift","reportSummaryMapShift",
975  6,0,6,1,0,1);
976  (reportMapShift_->getTH2F())->GetXaxis()->SetBinLabel(1,"HB");
977  (reportMapShift_->getTH2F())->GetXaxis()->SetBinLabel(2,"HE");
978  (reportMapShift_->getTH2F())->GetXaxis()->SetBinLabel(3,"HO");
979  (reportMapShift_->getTH2F())->GetXaxis()->SetBinLabel(4,"HF");
980  (reportMapShift_->getTH2F())->GetXaxis()->SetBinLabel(5,"HO0");
981  (reportMapShift_->getTH2F())->GetXaxis()->SetBinLabel(6,"HO12");
982  (reportMapShift_->getTH2F())->GetYaxis()->SetBinLabel(1,"Status");
983  (reportMapShift_->getTH2F())->SetMarkerSize(3);
984  (reportMapShift_->getTH2F())->SetOption("text90colz");
985  //(reportMapShift_->getTH2F())->SetOption("textcolz");
986  (reportMapShift_->getTH2F())->SetMinimum(-1);
987  (reportMapShift_->getTH2F())->SetMaximum(1);
988 
989  // Set initial counters to -1 (unknown)
990  status_global_=-1;
991  status_HB_=-1;
992  status_HE_=-1;
993  status_HO_=-1;
994  status_HF_=-1;
995 
996  status_HO0_=-1;
997  status_HO12_=-1;
998  status_HFlumi_=-1;
999  for (int i=1;i<=(reportMap_->getTH2F())->GetNbinsX();++i)
1000  reportMap_->setBinContent(i,1,-1);
1001  for (int i=1;i<=(reportMapShift_->getTH2F())->GetNbinsX();++i)
1003 
1004  doSetup_ = false;
1005 
1006 }
1008 
1009 bool HcalSummaryClient::hasErrors_Temp(void){ return false;}
1010 
1011 bool HcalSummaryClient::hasWarnings_Temp(void){return false;}
1012 bool HcalSummaryClient::hasOther_Temp(void){return false;}
1013 bool HcalSummaryClient::test_enabled(void){return true;}
1014 
1015 void HcalSummaryClient::updateChannelStatus(std::map<HcalDetId, unsigned int>& myqual){return;}
1016 
1017 
1019 {
1020  if ( SummaryMapByDepth ) delete SummaryMapByDepth;
1021 }
bool isHO(int etabin, int depth)
std::vector< std::string > TaskList_
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
MonitorElement * ProblemCells
std::string name()
void setBinContent(int binx, double content)
set content of bin (1-D)
int ib
Definition: cuy.py:660
HcalSummaryClient()
Constructors.
std::map< std::string, int > subdetCells_
void updateChannelStatus(std::map< HcalDetId, unsigned int > &myqual)
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:301
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
bool isHE(int etabin, int depth)
MonitorElement * StatusVsLS_
virtual void setup(void)
uint16_t size_type
MonitorElement * EnoughEvents_
void Fill(long long x)
tuple d
Definition: ztail.py:151
std::vector< MonitorElement * > depth
int CalcIeta(int subdet, int eta, int depth)
void analyze(DQMStore::IBooker &, DQMStore::IGetter &, int LS=-1)
EtaPhiHists * ProblemCellsByDepth
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
void setup(DQMStore::IBooker &m_dbe, std::string Name, std::string Units="")
~HcalSummaryClient()
Destructor.
bool isHB(int etabin, int depth)
char const * subdets[11]
std::vector< HcalBaseDQClient * > clients_
bool isHF(int etabin, int depth)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:273
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
int64_t getIntValue(void) const
void fillReportSummary(DQMStore::IBooker &, DQMStore::IGetter &, int LS)
EtaPhiHists * SummaryMapByDepth
std::string subdir_
void FillUnphysicalHEHFBins(std::vector< TH2F > &hh)
MonitorElement * MinEvents_
MonitorElement * certificationMap_
MonitorElement * reportMap_
MonitorElement * reportMapShift_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:329
double getBinContent(int binx) const
get content of bin (1-D)
std::string prefixME_
if(dp >Float(M_PI)) dp-
tuple cout
Definition: gather_cfg.py:145
void fillReportSummaryLSbyLS(DQMStore::IBooker &, DQMStore::IGetter &, int LS)
MonitorElement * bookFloat(Args &&...args)
Definition: DQMStore.h:109
TH2F * getTH2F(void) const
void Reset(void)
reset ME (ie. contents, errors, etc)
void removeElement(Args &&...args)
Definition: DQMStore.h:202
tuple size
Write out results.
MonitorElement * MinErrorRate_