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  * $Date: 2013/01/21 12:53:20 $
19  * $Revision: 1.111 $
20  * \author J. Temple
21  * \brief Summary Client class
22  */
23 
25 {
26  name_=myname;
28  minevents_=0;
29  minerrorrate_=0;
31  ProblemCells=0;
33  StatusVsLS_=0;
35  reportMap_=0;
37 }
38 
40 {
41  name_=myname;
42  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
43  debug_ = ps.getUntrackedParameter<int>("debug",0);
44  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
45  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
46  prefixME_.append("/");
47  subdir_ = ps.getUntrackedParameter<std::string>("SummaryFolder","EventInfo/"); // SummaryMonitor_Hcal
48  if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
49  subdir_.append("/");
50  subdir_=prefixME_+subdir_;
51  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
52 
53  NLumiBlocks_ = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
54  UseBadChannelStatusInSummary_ = ps.getUntrackedParameter<bool>("UseBadChannelStatusInSummary",false);
55  excludeBadQPLLs_ = ps.getUntrackedParameter<bool>("excludeBadQPLL",false);
56 
57  // These aren't used in summary client, are they?
58  badChannelStatusMask_ = ps.getUntrackedParameter<int>("Summary_BadChannelStatusMask",
59  ps.getUntrackedParameter<int>("BadChannelStatusMask",0));
60  minerrorrate_ = ps.getUntrackedParameter<double>("Summary_minerrorrate",
61  ps.getUntrackedParameter<double>("minerrorrate",0));
62  minevents_ = ps.getUntrackedParameter<int>("Summary_minevents",
63  ps.getUntrackedParameter<int>("minevents",0));
64  Online_ = ps.getUntrackedParameter<bool>("online",false);
65 
67  ProblemCells=0;
69  StatusVsLS_=0;
71  reportMap_=0;
73 }
74 
76 {
77  if (debug_>2) std::cout <<"\tHcalSummaryClient::analyze()"<<std::endl;
78 
79  //
80 
81  // Start with counters in 'unknown' status; they'll be set by analyze_everything routines
82  status_global_=-1;
83  status_HB_=-1;
84  status_HE_=-1;
85  status_HO_=-1;
86  status_HF_=-1;
87 
88  status_HO0_=-1;
89  status_HO12_=-1;
90  status_HFlumi_=-1;
91  status_global_=-1;
92 
94  enoughevents_=true; // assume we have enough events for all tests to have run
96  {
97  if (debug_>2) std::cout <<"<HcalSummaryClient::analyze> CLIENT = "<<clients_[i]->name_<<" ENOUGH = "<<clients_[i]->enoughevents_<<std::endl;
98  enoughevents_&=clients_[i]->enoughevents_;
100  {
101  if (clients_[i]->enoughevents_==false && debug_>1)
102  std::cout <<"Failed enoughevents test for monitor "<<clients_[i]->name()<<std::endl;
103  }
104  }
105 
106  // check to find which subdetectors are present -- need to do this prior to checking whether enoughevents_ == false!
107  MonitorElement* temp_present;
108  if (HBpresent_!=1)
109  {
110  temp_present=dqmStore_->get(prefixME_+"HcalInfo/HBpresent");
111  if (temp_present!=0)
112  HBpresent_=temp_present->getIntValue();
113  }
114  if (HEpresent_!=1)
115  {
116  temp_present=dqmStore_->get(prefixME_+"HcalInfo/HEpresent");
117  if (temp_present!=0)
118  HEpresent_=temp_present->getIntValue();
119  }
120  if (HOpresent_!=1)
121  {
122  temp_present=dqmStore_->get(prefixME_+"HcalInfo/HOpresent");
123  if (temp_present!=0)
124  HOpresent_=temp_present->getIntValue();
125  }
126  if (HFpresent_!=1)
127  {
128  temp_present=dqmStore_->get(prefixME_+"HcalInfo/HFpresent");
129  if (temp_present!=0)
130  HFpresent_=temp_present->getIntValue();
131  }
132 
133  if (debug_>1)
134  std::cout <<"<HcalSummaryClient::analyze> HB present = "<<HBpresent_<<" "<<"HE present = "<<HEpresent_<<" "<<"HO present = "<<HOpresent_<<" "<<"HF present = "<<HFpresent_<<std::endl;
135 
136  if (enoughevents_==false)
137  {
138  if (debug_>0) std::cout <<"<HcalSummaryClient::analyze> Not enough events processed to evaluate summary status!"<<std::endl;
139 
140  // 'HXpresent_' values are set to -1 by default.
141  // They are set to +1 when a channel is present.
142  // I don't think there are any cases where values =0,
143  // but I'm not positive of this yet -- Jeff, 10 Aug 2010
144 
145  // Check whether any events are found for each subdetector
146  if (HBpresent_>0) status_HB_=1;
147  else status_HB_=-1; // HB not present or unknown
148  if (HEpresent_>0) status_HE_=1;
149  else status_HE_=-1; // HE not present or unknown
150  if (HOpresent_>0) status_HO_=1;
151  else status_HO_=-1; // HO not present or unknown
152  if (HFpresent_>0) status_HF_=1;
153  else status_HF_=-1; // HF not present or unknown
154 
155  // Update this in the future? Use '||' instead of '&&'?
156  if (HBpresent_<=0 && HEpresent_<=0 && HOpresent_<=0 && HFpresent_<=0)
157  status_global_=-1;
158  else
159  status_global_=1;
160 
161  // Set other statuses based on subdetectors
165 
166  if (debug_>1)
167  {
168  std::cout <<"Insufficient events processed. Subdetector status is:"<<std::endl;
169  std::cout<<"\tHB: "<<status_HB_<<std::endl;
170  std::cout<<"\tHE: "<<status_HE_<<std::endl;
171  std::cout<<"\tHO: "<<status_HO_<<std::endl;
172  std::cout<<"\tHF: "<<status_HF_<<std::endl;
173  std::cout<<"\tHO0: "<<status_HO0_<<std::endl;
174  std::cout<<"\tHO12: "<<status_HO12_<<std::endl;
175  std::cout<<"\tHFlumi: "<<status_HFlumi_<<std::endl;
176  }
177 
178  fillReportSummary(LS);
179  return;
180  }
181  if (EnoughEvents_!=0) EnoughEvents_->setBinContent(clients_.size()+1,1); // summary is good to go!
182 
183  // set status to 0 if subdetector is present (or assumed present)
184  if (HBpresent_>0) status_HB_=0;
185  if (HEpresent_>0) status_HE_=0;
187  if (HFpresent_>0) {status_HF_=0; status_HFlumi_=0;}
188 
189  if (HBpresent_>0 || HEpresent_>0 ||
190  HOpresent_>0 || HFpresent_>0 )
191  status_global_=0;
192 
193  // don't want to fool with variable-sized arrays at the moment; revisit later
194  //const unsigned int csize=clients_.size();
195  double localHB[20]={0};
196  double localHE[20]={0};
197  double localHF[20]={0};
198  double localHO[20]={0};
199  double localHFlumi[20]={0};
200  double localHO0[20]={0};
201  double localHO12[20]={0};
202 
203  // Check if the RBX data-loss has lasted for more than 2LS. If not, discard from problem rate counts
204  // # of channels in HB and HE = 2592 in each
205  // # of channels in HF = 1728
206  // # of channels in HO = 2160
207  // # of channels in HO01 = 1440
208  // RBX index, HB RBX indices are 0-35
209  // RBX index, HE RBX indices are 36-71
210  TH2F* checkIgnore;
211  MonitorElement* me;
212  checkIgnore = 0;
213 
214  // Get the DeadVSLS plots from DeadCellMonitor task
215  std::string s="Hcal/DeadCellMonitor_Hcal/RBX_loss_VS_LB";
216  me=dqmStore_->get(s.c_str());
217  if (me!=0) checkIgnore=HcalUtilsClient::getHisto<TH2F*>(me, cloneME_, checkIgnore, debug_);
218 
219  // find the RBX-indices, and how long the data-losses lasted
220  float ignoreDeadRate[156]={0.};
221 
222  if (checkIgnore!=0)
223  {
224  for (int i=1;i<=checkIgnore->GetNbinsY();++i) // RBX list
225  for (int j=2;j<=checkIgnore->GetNbinsX();++j) // LS list, start from LS=2
226  if ( checkIgnore->GetBinContent(j,i)>0 )
227  {
228  if(checkIgnore->GetBinContent(j-1,i)<1 || (checkIgnore->GetBinContent(j-1,i)>0 && checkIgnore->GetBinContent(j-2,i)<1))
229  ignoreDeadRate[i]=72.;
230 
231  if(checkIgnore->GetBinContent(j-1,i)>0 && checkIgnore->GetBinContent(j-2,i)>0 )
232  {ignoreDeadRate[i] = 0.; break;}
233  }
234  }
235 
236  float ignoreShortDeadRate_HB=0;
237  float ignoreShortDeadRate_HE=0;
238  for (int i =0; i<156; i++)
239  {
240  if(i<=35) // HB
241  ignoreShortDeadRate_HB = ignoreShortDeadRate_HB+ignoreDeadRate[i];
242  if(i>=36 && i<=71) // HE
243  ignoreShortDeadRate_HE = ignoreShortDeadRate_HE+ignoreDeadRate[i];
244  }
245  ignoreShortDeadRate_HB = ignoreShortDeadRate_HB/2592;
246  ignoreShortDeadRate_HE = ignoreShortDeadRate_HE/2592;
247  //
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(dqmStore_->get(prefixME_+"HcalInfo/ChannelStatus/HB HE HF Depth 1 ChannelStatus"));
266  chStat.push_back(dqmStore_->get(prefixME_+"HcalInfo/ChannelStatus/HB HE HF Depth 2 ChannelStatus"));
267  chStat.push_back(dqmStore_->get(prefixME_+"HcalInfo/ChannelStatus/HE Depth 3 ChannelStatus"));
268  chStat.push_back(dqmStore_->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]->name()=="ZDCMonitor") continue;
294  if ((clients_[cl]->ProblemCellsByDepth)->depth[d]==0) continue;
295 
296  if ((clients_[cl]->ProblemCellsByDepth)->depth[d]->getBinContent(eta,phi)>clients_[cl]->minerrorrate_)
297  {
298  // QPLL unlocking channels, have to ignore unpacker errors (fix requires opening CMS)
299  // skip DigiErrors for these channels when feeding the Summary maps
300  if(excludeBadQPLLs_)
301  if(clients_[cl]->name()=="DigiMonitor")
302  {
303  bool HEM15A = true ? (isHE(eta-1,d+1) && (phi>56 && phi<59 && ieta<0)) : false;
304  bool HEM15B = true ? (isHE(eta-1,d+1) && (phi>54 && phi<57 && ieta<0)) : false;
305  bool HBP14A = true ? (isHB(eta-1,d+1) && (phi>50 && phi<53 && ieta>0)) : false;
306 
307  if( HEM15A || HEM15B || HBP14A )
308  continue;
309  }
310 
311  if (isHF(eta-1,d+1))
312  {
313  ++localHF[cl];
314  if ((d==0 && (abs(ieta)==33 || abs(ieta)==34)) || // depth 1, rings 33,34
315  (d==1 && (abs(ieta)==35 || abs(ieta)==36))) // depth 2, rings 35,36
316  ++localHFlumi[cl];
317  }
318  else if (isHO(eta-1,d+1))
319  {
320  ++localHO[cl];
321  if (abs(ieta)<5) ++localHO0[cl];
322  else ++localHO12[cl];
323  }
324  else if (isHB(eta-1,d+1)) ++localHB[cl];
325  else if (isHE(eta-1,d+1)) ++localHE[cl];
326  }
327  } // for (loop on clients_.size() to determine individual client error rates)
328 
329  // Check for certification errors -- do we want to add some extra warnings (filling channel status db plot with new value, etc?) in this case?
330 
331  if (UseBadChannelStatusInSummary_ && chStat[d]!=0)
332  {
333  double chanStat=chStat[d]->getBinContent(eta,phi);
334  // chanStat<0 indicates original status from database was <0; this is counted as an error,
335  // since such values should never appear in the database.
336  if (chanStat<0)
337  {
338  if (isHF(eta-1,d+1))
339  {
340  ++status_HF_;
341  if ((d==0 && (abs(ieta)==33 || abs(ieta)==34)) || // depth 1, rings 33,34
342  (d==1 && (abs(ieta)==35 || abs(ieta)==36))) // depth 2, rings 35,36
343  {
344  ++status_HFlumi_;
345  }
346  continue; // don't bother looking at individual clients for results; channel status is already corrupted
347  }
348  else if (isHO(eta-1,d+1))
349  {
350  ++status_HO_;
351  if (abs(ieta)<5)
352  ++status_HO0_;
353  else ++status_HO12_;
354  continue;
355  }
356  else if (isHB(eta-1,d+1))
357  {
358  ++status_HB_;
359  continue;
360  }
361  else if (isHE(eta-1,d+1))
362  {
363  ++status_HE_;
364  continue;
365  }
366  } // if (chanStat<0)
367  } // if (UseBadChannelStatusInSummary_)
368 
369  // loop over all client tests
370 
371  // SummaryMapByDepth is slightly different from previous version -- it now just shows cells
372  // that contribute as "problems", rather than giving good channels a status of 1, and bad a status of 0
373  for (unsigned int cl=0;cl<clients_.size();++cl)
374  {
375  // Best way to handle this?
376  // We know that first element is HcalMonitorModule info, which has
377  // no problem cells defined. Create some, or start counting from cl=1?
378  if (debug_>4 && eta==1 && phi==1) std::cout <<"Checking summary for client "<<clients_[cl]->name()<<std::endl;
379  if(clients_[cl]->name()=="ZDCMonitor") continue;
380 
381  if (clients_[cl]->ProblemCellsByDepth==0) continue;
382 
383  if ((clients_[cl]->ProblemCellsByDepth)->depth[d]==0) continue;
384  if ((clients_[cl]->ProblemCellsByDepth)->depth[d]->getBinContent(eta,phi)>clients_[cl]->minerrorrate_)
385  {
386  // QPLL unlocking channels, have to ignore unpacker errors (fix requires opening CMS)
387  // skip DigiErrors for these channels when feeding the Summary maps
388  if(excludeBadQPLLs_)
389  if(clients_[cl]->name()=="DigiMonitor")
390  {
391  bool HEM15A = true ? (isHE(eta-1,d+1) && (phi>56 && phi<59 && ieta<0)) : false;
392  bool HEM15B = true ? (isHE(eta-1,d+1) && (phi>54 && phi<57 && ieta<0)) : false;
393  bool HBP14A = true ? (isHB(eta-1,d+1) && (phi>50 && phi<53 && ieta>0)) : false;
394 
395  if( HEM15A || HEM15B || HBP14A )
396  continue;
397  }
398 
399  if ((clients_[cl]->ProblemCellsByDepth)->depth[d]->getBinContent(eta,phi)<999)
400  SummaryMapByDepth->depth[d]->setBinContent(eta,phi,1);
401  else
402  SummaryMapByDepth->depth[d]->setBinContent(eta,phi,999); // known problems filled with a value of 999
403  if (isHF(eta-1,d+1))
404  {
405  ++status_HF_;
406  if ((d==0 && (abs(ieta)==33 || abs(ieta)==34)) || // depth 1, rings 33,34
407  (d==1 && (abs(ieta)==35 || abs(ieta)==36))) // depth 2, rings 35,36
408  {
409  ++status_HFlumi_;
410  }
411  }
412  else if (isHO(eta-1,d+1))
413  {
414  ++status_HO_;
415  if (abs(ieta)<5)
416  ++status_HO0_;
417  else ++status_HO12_;
418  }
419  else if (isHB(eta-1,d+1)) ++status_HB_;
420  else if (isHE(eta-1,d+1)) ++status_HE_;
421  break; // man, this break causes problems for certificationMap!!! -- Jason; WHY? -- Jeff
422  }
423  } // for (main loop on clients_.size() to calculate reportSummary statuses)
424  }
425  }
426  } // for (int d=0;d<4;++d)
427 
429  } // else (SummaryMapByDepth exists)
430 
431  // We've checked all problems; now compute overall status
432  int totalcells=0;
433  std::map<std::string, int>::const_iterator it;
434 
435  if (HBpresent_>0)
436  {
438  it=subdetCells_.find("HB");
439  totalcells+=it->second;
440  status_HB_= 1-(status_HB_/it->second);
441  status_HB_=std::min(1.0, status_HB_+ignoreShortDeadRate_HB);
442  for (unsigned int i=0;i<clients_.size();++i)
443  {
444  localHB[i]=1-(1.*localHB[i]/it->second);
445  if(clients_[i]->name()=="DeadCellMonitor") // correct the rate, removing the effect of short RBX losses
446  localHB[i]=std::min(1.0, localHB[i]+ignoreShortDeadRate_HB);
447  localHB[i]=std::max(0.,localHB[i]);
448  }
449  status_HB_=std::max(0.,status_HB_); // converts fraction of bad channels to good fraction
450  }
451  else status_HB_=-1; // enoughevents_ can be true even if HB not present; need to set status_HB_=-1 in both cases
452 
453  if (HEpresent_>0)
454  {
456  it=subdetCells_.find("HE");
457  totalcells+=it->second;
458  status_HE_= 1-(status_HE_/it->second);
459  status_HE_=std::min(1.0, status_HE_+ignoreShortDeadRate_HE);
460  for (unsigned int i=0;i<clients_.size();++i)
461  {
462  localHE[i]=1-(1.*localHE[i]/it->second);
463  if(clients_[i]->name()=="DeadCellMonitor") // correct the rate, removing the effect of short RBX losses
464  localHE[i]=std::min(1.0, localHE[i]+ignoreShortDeadRate_HE);
465  localHE[i]=std::max(0.,localHE[i]);
466  }
467  status_HE_=std::max(0.,status_HE_); // converts fraction of bad channels to good fraction
468  }
469  else status_HE_=-1;
470 
471  if (HOpresent_>0)
472  {
474  it=subdetCells_.find("HO");
475  totalcells+=it->second;
476  status_HO_= 1-(status_HO_/it->second);
477  status_HO_=std::max(0.,status_HO_); // converts fraction of bad channels to good fraction
478  for (unsigned int i=0;i<clients_.size();++i)
479  {
480  localHO[i]=1-(1.*localHO[i]/it->second);
481  localHO[i]=std::max(0.,localHO[i]);
482  }
483  it=subdetCells_.find("HO0");
484  status_HO0_= 1-(status_HO0_/it->second);
485  for (unsigned int i=0;i<clients_.size();++i)
486  {
487  localHO0[i]=1-(1.*localHO0[i]/it->second);
488  localHO0[i]=std::max(0.,localHO0[i]);
489  }
490  status_HO0_=std::max(0.,status_HO0_); // converts fraction of bad channels to good fraction
491  it=subdetCells_.find("HO12");
492  status_HO12_= 1-(status_HO12_/it->second);
493  status_HO12_=std::max(0.,status_HO12_); // converts fraction of bad channels to good fraction
494  for (unsigned int i=0;i<clients_.size();++i)
495  {
496  localHO12[i]=1-(1.*localHO12[i]/it->second);
497  localHO12[i]=std::max(0.,localHO12[i]);
498  }
499  }
500  else
501  {
502  status_HO_=-1;
503  status_HO0_=-1;
504  status_HO12_=-1;
505  }
506  if (HFpresent_>0)
507  {
509  it=subdetCells_.find("HF");
510  totalcells+=it->second;
511  status_HF_= 1-(status_HF_/it->second);
512  status_HF_=std::max(0.,status_HF_); // converts fraction of bad channels to good fraction
513  for (unsigned int i=0;i<clients_.size();++i)
514  {
515  localHF[i]=1-(1.*localHF[i]/it->second);
516  localHF[i]=std::max(0.,localHF[i]);
517  }
518  it=subdetCells_.find("HFlumi");
519  status_HFlumi_= 1-(status_HFlumi_/it->second);
520  status_HFlumi_=std::max(0.,status_HFlumi_); // converts fraction of bad channels to good fraction
521  for (unsigned int i=0;i<clients_.size();++i)
522  {
523  localHFlumi[i]=1-(1.*localHFlumi[i]/it->second);
524  localHFlumi[i]=std::max(0.,localHFlumi[i]);
525  }
526  }
527  else
528  {
529  status_HF_=-1;
530  status_HFlumi_=-1;
531  }
532 
533  if (totalcells==0)
534  status_global_=-1;
535  else
536  {
537  status_global_=1-status_global_/totalcells;
538  status_global_=std::max(0.,status_global_); // convert to good fraction
539  }
540 
541 
542  // Fill certification map here
543 
544  dqmStore_->setCurrentFolder(prefixME_+"HcalInfo");
545  certificationMap_=dqmStore_->get(prefixME_+"HcalInfo/CertificationMap");
547  certificationMap_=dqmStore_->book2D("CertificationMap","Certification Map",7,0,7,
548  clients_.size()+1,0,clients_.size()+1);
549 
550  certificationMap_->getTH2F()->GetYaxis()->SetBinLabel(1,"Summary");
551  (certificationMap_->getTH2F())->SetOption("textcolz");
552 
553  for (int i=0;i<(int)clients_.size();++i)
554  {
555  certificationMap_->getTH2F()->GetYaxis()->SetBinLabel(i+2,(clients_[i]->name()).c_str());
556  }
557  certificationMap_->getTH2F()->GetYaxis()->SetLabelSize(0.02);
558  certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(1,"HB");
559  certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(2,"HE");
560  certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(3,"HO");
561  certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(4,"HF");
562  certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(5,"HO0");
563  certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(6,"HO12");
564  certificationMap_->getTH2F()->GetXaxis()->SetBinLabel(7,"HFlumi");
565  certificationMap_->getTH2F()->SetMinimum(-1);
566  certificationMap_->getTH2F()->SetMaximum(1);
567 
568  for (unsigned int i=0;i<clients_.size();++i)
569  {
570  certificationMap_->setBinContent(1,i+2,localHB[i]);
571  certificationMap_->setBinContent(2,i+2,localHE[i]);
572  certificationMap_->setBinContent(3,i+2,localHO[i]);
573  certificationMap_->setBinContent(4,i+2,localHF[i]);
574  certificationMap_->setBinContent(5,i+2,localHO0[i]);
575  certificationMap_->setBinContent(6,i+2,localHO12[i]);
576  certificationMap_->setBinContent(7,i+2,localHF[i]);
577  }
585  fillReportSummary(LS);
586 } // analyze
587 
589 {
590 
591  // We've now checked all tasks; now let's calculate summary values
592 
593  if (debug_>2) std::cout <<"<HcalSummaryClient::fillReportSummary>"<<std::endl;
594 
595  if (debug_>3)
596  {
597  std::cout <<"STATUS = "<<std::endl;
598  std::cout <<"HB = "<<status_HB_<<std::endl;
599  std::cout <<"HE = "<<status_HE_<<std::endl;
600  std::cout <<"HO = "<<status_HO_<<std::endl;
601  std::cout <<"HF = "<<status_HF_<<std::endl;
602  std::cout <<"HO0 = "<<status_HO0_<<std::endl;
603  std::cout <<"HO12 = "<<status_HO12_<<std::endl;
604  std::cout <<"HFlumi = "<<status_HFlumi_<<std::endl;
605  }
606 
607  // put the summary values into MonitorElements
608 
609  if (LS>0)
610  {
611  if (StatusVsLS_)
612  {
620  }
621  }
622 
623  MonitorElement* me;
625 
626  //me=dqmStore_->get(subdir_+"reportSummaryMap");
627  if (reportMap_)
628  {
636  // Set reportMap underflow bin based on whether enough total events have been processed
637  if (enoughevents_==false)
638  reportMap_->setBinContent(0,0,-1);
639  else
640  reportMap_->setBinContent(0,0,1);
641  }
642  else if (debug_>0) std::cout <<"<HcalSummaryClient::fillReportSummary> CANNOT GET REPORT SUMMARY MAP!!!!!"<<std::endl;
643 
644  if (reportMapShift_)
645  {
652  // Set reportMap underflow bin based on whether enough total events have been processed
653  if (enoughevents_==false)
655  else
657  }
658  else if (debug_>0) std::cout <<"<HcalSummaryClient::fillReportSummary> CANNOT GET REPORT SUMMARY MAP!!!!!"<<std::endl;
659 
660  me=dqmStore_->get(subdir_+"reportSummary");
661  // Clear away old versions
662  if (me) me->Fill(status_global_);
663 
664  // Create floats for each subdetector status
665  std::string subdets[7] = {"HB","HE","HO","HF","HO0","HO12","HFlumi"};
666  for (unsigned int i=0;i<7;++i)
667  {
668  // Create floats showing subtasks status
669  dqmStore_->setCurrentFolder( subdir_+ "reportSummaryContents" );
670  me=dqmStore_->get(subdir_+"reportSummaryContents/Hcal_"+subdets[i]);
671  if (me==0)
672  {
673  if (debug_>0) std::cout <<"<HcalSummaryClient::analyze()> Could not get Monitor Element named 'Hcal_"<<subdets[i]<<"'"<<std::endl;
674  continue;
675  }
676  if (subdets[i]=="HB") me->Fill(status_HB_);
677  else if (subdets[i]=="HE") me->Fill(status_HE_);
678  else if (subdets[i]=="HO") me->Fill(status_HO_);
679  else if (subdets[i]=="HF") me->Fill(status_HF_);
680  else if (subdets[i]=="HO0") me->Fill(status_HO0_);
681  else if (subdets[i]=="HO12") me->Fill(status_HO12_);
682  else if (subdets[i]=="HFlumi") me->Fill(status_HFlumi_);
683  } // for (unsigned int i=0;...)
684 
685 } // fillReportSummary()
686 
687 
689 {
690 
691  MonitorElement* me;
692  dqmStore_->setCurrentFolder(prefixME_+"LSbyLS_Hcal/LSvalues");
693 
694  float status_HB=-1;
695  float status_HE=-1;
696  float status_HO=-1;
697  float status_HF=-1;
698  float status_HO0=-1;
699  float status_HO12=-1;
700  float status_HFlumi=-1;
701  float status_global=-1;
702 
703  me=dqmStore_->get(prefixME_+"LSbyLS_Hcal/LSvalues/ProblemsThisLS");
704  if (me!=0)
705  {
706  //check to see if enough events were processed to make tests
707  int events=(int)me->getBinContent(-1);
708  if (events>0)
709  {
710  std::map<std::string, int>::const_iterator it;
711  int totalcells=0;
712 
713  status_HB=me->getBinContent(1,1);
714  status_HE=me->getBinContent(2,1);
715  status_HO=me->getBinContent(3,1);
716  status_HF=me->getBinContent(4,1);
717  status_HO0=me->getBinContent(5,1);
718  status_HO12=me->getBinContent(6,1);
719  status_HFlumi=me->getBinContent(7,1);
720 
721  status_global=status_HB+status_HE+status_HO+status_HF;
722  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 = "<<events<<std::endl;
723 
724  it=subdetCells_.find("HB");
725  totalcells+=it->second;
726  if (it->second>0)
727  status_HB=1-(status_HB)/events/it->second;
728 
729  it=subdetCells_.find("HE");
730  totalcells+=it->second;
731  if (it->second>0)
732  status_HE=1-(status_HE)/events/it->second;
733 
734  it=subdetCells_.find("HO");
735  totalcells+=it->second;
736  if (it->second>0)
737  status_HO=1-(status_HO)/events/it->second;
738 
739  it=subdetCells_.find("HF");
740  totalcells+=it->second;
741  if (it->second>0)
742  status_HF=1-(status_HF)/events/it->second;
743 
744  it=subdetCells_.find("HO0");
745  if (it->second>0)
746  status_HO0=1-(status_HO0)/events/it->second;
747 
748  it=subdetCells_.find("HO12");
749  if (it->second>0)
750  status_HO12=1-(status_HO12)/events/it->second;
751 
752  it=subdetCells_.find("HFlumi");
753  if (it->second>0)
754  status_HFlumi=1-(status_HFlumi)/events/it->second;
755  if (totalcells>0)
756  status_global=1-status_global/events/totalcells;
757  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 = "<<events<<std::endl;
758  } // if (events(>0)
759  } // if (me!=0)
760 
762  if (reportMap_)
763  {
764  reportMap_->setBinContent(1,1,status_HB);
765  reportMap_->setBinContent(2,1,status_HE);
766  reportMap_->setBinContent(3,1,status_HO);
767  reportMap_->setBinContent(4,1,status_HF);
768  reportMap_->setBinContent(5,1,status_HO0);
769  reportMap_->setBinContent(6,1,status_HO12);
770  reportMap_->setBinContent(7,1,status_HFlumi);
771  // Set reportMap underflow bin based on whether enough total events have been processed
772  if (enoughevents_==false)
773  reportMap_->setBinContent(0,0,-1);
774  else
775  reportMap_->setBinContent(0,0,1);
776 
777  }
778  else if (debug_>0) std::cout <<"<HcalSummaryClient::fillReportSummaryLSbyLS> CANNOT GET REPORT SUMMARY MAP!!!!!"<<std::endl;
779 
780  if (reportMapShift_)
781  {
782  reportMapShift_->setBinContent(1,1,status_HB);
783  reportMapShift_->setBinContent(2,1,status_HE);
784  reportMapShift_->setBinContent(3,1,status_HO);
785  reportMapShift_->setBinContent(4,1,status_HF);
786  reportMapShift_->setBinContent(5,1,status_HO0);
787  reportMapShift_->setBinContent(6,1,status_HO12);
788  // Set reportMap underflow bin based on whether enough total events have been processed
789  if (enoughevents_==false)
791  else
793 
794  }
795  else if (debug_>0) std::cout <<"<HcalSummaryClient::fillReportSummaryLSbyLS> CANNOT GET REPORT SUMMARY MAP!!!!!"<<std::endl;
796 
797  me=dqmStore_->get(subdir_+"reportSummary");
798  // Clear away old versions
799  if (me) me->Fill(status_global);
800 
801  // Create floats for each subdetector status
802  std::string subdets[7] = {"HB","HE","HO","HF","HO0","HO12","HFlumi"};
803  for (unsigned int i=0;i<7;++i)
804  {
805  // Create floats showing subtasks status
806  dqmStore_->setCurrentFolder( subdir_+ "reportSummaryContents" );
807  me=dqmStore_->get(subdir_+"reportSummaryContents/Hcal_"+subdets[i]);
808  if (me==0)
809  {
810  if (debug_>0) std::cout <<"<HcalSummaryClient::LSbyLS> Could not get Monitor Element named 'Hcal_"<<subdets[i]<<"'"<<std::endl;
811  continue;
812  }
813  if (subdets[i]=="HB") me->Fill(status_HB);
814  else if (subdets[i]=="HE") me->Fill(status_HE);
815  else if (subdets[i]=="HO") me->Fill(status_HO);
816  else if (subdets[i]=="HF") me->Fill(status_HF);
817  else if (subdets[i]=="HO0") me->Fill(status_HO0);
818  else if (subdets[i]=="HO12") me->Fill(status_HO12);
819  else if (subdets[i]=="HFlumi") me->Fill(status_HFlumi);
820  } // for (unsigned int i=0;...)
821 
822 
823  if (StatusVsLS_)
824  {
825  StatusVsLS_->setBinContent(LS,1,status_HB);
826  StatusVsLS_->setBinContent(LS,2,status_HE);
827  StatusVsLS_->setBinContent(LS,3,status_HO);
828  StatusVsLS_->setBinContent(LS,4,status_HF);
829  StatusVsLS_->setBinContent(LS,5,status_HO0);
830  StatusVsLS_->setBinContent(LS,6,status_HO12);
831  StatusVsLS_->setBinContent(LS,7,status_HFlumi);
832  }
833 
834  return;
835 
836 
837 } // void HcalSummaryClient::fillReportSummaryLSbyLS()
838 
839 
840 
842 {
844  // set total number of cells in each subdetector
845  subdetCells_.insert(std::make_pair("HB",2592));
846  subdetCells_.insert(std::make_pair("HE",2592));
847  subdetCells_.insert(std::make_pair("HO",2160));
848  subdetCells_.insert(std::make_pair("HF",1728));
849  subdetCells_.insert(std::make_pair("HO0",576));
850  subdetCells_.insert(std::make_pair("HO12",1584));
851  subdetCells_.insert(std::make_pair("HFlumi",288)); // 8 rings, 36 cells/ring
852  // Assume subdetectors are 'unknown'
853  HBpresent_=-1;
854  HEpresent_=-1;
855  HOpresent_=-1;
856  HFpresent_=-1;
857 
858  EnoughEvents_=0;
859  MinEvents_=0;
860  MinErrorRate_=0;
861 }
862 
864 
866 {
867  if (!dqmStore_)
868  {
869  if (debug_>0) std::cout <<"<HcalSummaryClient::beginRun> dqmStore does not exist!"<<std::endl;
870  return;
871  }
872  nevts_=0;
873 
875 
876  MonitorElement* me;
877  // reportSummary holds overall detector status
878  me=dqmStore_->get(subdir_+"reportSummary");
879  // Clear away old versions
880  if (me) dqmStore_->removeElement(me->getName());
881  me = dqmStore_->bookFloat("reportSummary");
882  me->Fill(-1); // set status to unknown at startup
883 
884  // Create floats for each subdetector status
885  std::string subdets[7] = {"HB","HE","HO","HF","HO0","HO12","HFlumi"};
886  for (unsigned int i=0;i<7;++i)
887  {
888  // Create floats showing subtasks status
889  dqmStore_->setCurrentFolder( subdir_+ "reportSummaryContents" );
890  me=dqmStore_->get(subdir_+"reportSummaryContents/Hcal_"+subdets[i]);
891  if (me) dqmStore_->removeElement(me->getName());
892  me = dqmStore_->bookFloat("Hcal_"+subdets[i]);
893  me->Fill(-1);
894  } // for (unsigned int i=0;...)
895 
896  dqmStore_->setCurrentFolder(prefixME_+"HcalInfo/SummaryClientPlots");
897  me=dqmStore_->get(prefixME_+"HcalInfo/SummaryClientPlots/HB HE HF Depth 1 Problem Summary Map");
898  if (me) dqmStore_->removeElement(me->getName());
899  me=dqmStore_->get(prefixME_+"HcalInfo/SummaryClientPlots/HB HE HF Depth 2 Problem Summary Map");
900  if (me) dqmStore_->removeElement(me->getName());
901  me=dqmStore_->get(prefixME_+"HcalInfo/SummaryClientPlots/HE Depth 3 Problem Summary Map");
902  if (me) dqmStore_->removeElement(me->getName());
903  me=dqmStore_->get(prefixME_+"HcalInfo/SummaryClientPlots/HO Depth 4 Problem Summary Map");
904  if (me) dqmStore_->removeElement(me->getName());
905 
906  if (EnoughEvents_==0)
907  EnoughEvents_=dqmStore_->book1D("EnoughEvents","Enough Events Passed From Each Task To Form Summary",1+(int)clients_.size(),0,1+(int)clients_.size());
909  EnoughEvents_->setBinLabel(i+1,clients_[i]->name());
910  EnoughEvents_->setBinLabel(1+(int)clients_.size(),"Summary");
911 
912  if (MinEvents_==0)
913  MinEvents_=dqmStore_->book1D("MinEvents","Minimum Events Required From Each Task To Form Summary",
914  1+(int)clients_.size(),0,1+(int)clients_.size());
915  int summin=0;
917  {
920  summin=std::max(summin,clients_[i]->minevents_);
921  }
922  if (MinErrorRate_==0)
923  MinErrorRate_=dqmStore_->book1D("MinErrorRate",
924  "Minimum Error Rate Required For Channel To Be Counted As Problem",
925  (int)clients_.size(),0,(int)clients_.size());
927  {
930  }
931 
932  // Extra fix provided by Giuseppe
933 
934  if (SummaryMapByDepth!=0)
935  {
936  delete SummaryMapByDepth;
938  }
939 
940  if (SummaryMapByDepth==0)
941  {
943  SummaryMapByDepth->setup(dqmStore_,"Problem Summary Map");
944  }
945  // Set histogram values to -1
946  // Set all bins to "unknown" to start
947  int etabins=0;
948  for (unsigned int depth=0;depth<4;++depth)
949  {
950  if (SummaryMapByDepth->depth[depth]==0) continue;
951  SummaryMapByDepth->depth[depth]->Reset();
952  etabins=(SummaryMapByDepth->depth[depth])->getNbinsX();
953  for (int ieta=0;ieta<etabins;++ieta)
954  {
955  for (int iphi=0;iphi<72;++iphi)
956  SummaryMapByDepth->depth[depth]->setBinContent(ieta+1,iphi+1,-1);
957  }
958  }
959 
960  // Make histogram of status vs LS
961  StatusVsLS_ = dqmStore_->get(prefixME_+"HcalInfo/SummaryClientPlots/StatusVsLS");
963  StatusVsLS_ = dqmStore_->book2D("StatusVsLS","Status vs. Luminosity Section",
964  NLumiBlocks_,0.5,NLumiBlocks_+0.5,
965  7,0,7);
966  // Set all status values to -1 to begin
967  for (int i=1;i<=NLumiBlocks_;++i)
968  for (int j=1;j<=7;++j)
970  (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(1,"HB");
971  (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(2,"HE");
972  (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(3,"HO");
973  (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(4,"HF");
974  (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(5,"HO0");
975  (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(6,"HO12");
976  (StatusVsLS_->getTH2F())->GetYaxis()->SetBinLabel(7,"HFlumi");
977  (StatusVsLS_->getTH2F())->GetXaxis()->SetTitle("Lumi Section");
978  (StatusVsLS_->getTH2F())->SetMinimum(-1);
979  (StatusVsLS_->getTH2F())->SetMaximum(1);
980 
981  // Finally, form report Summary Map
983 
984  reportMap_=dqmStore_->get(subdir_+"reportSummaryMap");
985  if (reportMap_)
987  reportMap_ = dqmStore_->book2D("reportSummaryMap","reportSummaryMap",
988  7,0,7,1,0,1);
989  (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(1,"HB");
990  (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(2,"HE");
991  (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(3,"HO");
992  (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(4,"HF");
993  (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(5,"HO0");
994  (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(6,"HO12");
995  (reportMap_->getTH2F())->GetXaxis()->SetBinLabel(7,"HFlumi");
996  (reportMap_->getTH2F())->GetYaxis()->SetBinLabel(1,"Status");
997  (reportMap_->getTH2F())->SetMarkerSize(3);
998  (reportMap_->getTH2F())->SetOption("text90colz");
999  //(reportMap_->getTH2F())->SetOption("textcolz");
1000  (reportMap_->getTH2F())->SetMinimum(-1);
1001  (reportMap_->getTH2F())->SetMaximum(1);
1002 
1003  if (reportMapShift_)
1005  reportMapShift_ = dqmStore_->book2D("reportSummaryMapShift","reportSummaryMapShift",
1006  6,0,6,1,0,1);
1007  (reportMapShift_->getTH2F())->GetXaxis()->SetBinLabel(1,"HB");
1008  (reportMapShift_->getTH2F())->GetXaxis()->SetBinLabel(2,"HE");
1009  (reportMapShift_->getTH2F())->GetXaxis()->SetBinLabel(3,"HO");
1010  (reportMapShift_->getTH2F())->GetXaxis()->SetBinLabel(4,"HF");
1011  (reportMapShift_->getTH2F())->GetXaxis()->SetBinLabel(5,"HO0");
1012  (reportMapShift_->getTH2F())->GetXaxis()->SetBinLabel(6,"HO12");
1013  (reportMapShift_->getTH2F())->GetYaxis()->SetBinLabel(1,"Status");
1014  (reportMapShift_->getTH2F())->SetMarkerSize(3);
1015  (reportMapShift_->getTH2F())->SetOption("text90colz");
1016  //(reportMapShift_->getTH2F())->SetOption("textcolz");
1017  (reportMapShift_->getTH2F())->SetMinimum(-1);
1018  (reportMapShift_->getTH2F())->SetMaximum(1);
1019 
1020  // Set initial counters to -1 (unknown)
1021  status_global_=-1;
1022  status_HB_=-1;
1023  status_HE_=-1;
1024  status_HO_=-1;
1025  status_HF_=-1;
1026 
1027  status_HO0_=-1;
1028  status_HO12_=-1;
1029  status_HFlumi_=-1;
1030  for (int i=1;i<=(reportMap_->getTH2F())->GetNbinsX();++i)
1031  reportMap_->setBinContent(i,1,-1);
1032  for (int i=1;i<=(reportMapShift_->getTH2F())->GetNbinsX();++i)
1034 } // void HcalSummaryClient::beginRun(void)
1035 
1036 
1038 
1041 
1042 bool HcalSummaryClient::hasErrors_Temp(void){ return false;}
1043 
1044 bool HcalSummaryClient::hasWarnings_Temp(void){return false;}
1045 bool HcalSummaryClient::hasOther_Temp(void){return false;}
1046 bool HcalSummaryClient::test_enabled(void){return true;}
1047 
1048 void HcalSummaryClient::updateChannelStatus(std::map<HcalDetId, unsigned int>& myqual){return;}
1049 
1050 
1052 {}
bool isHO(int etabin, int depth)
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)
HcalSummaryClient()
Constructors.
std::map< std::string, int > subdetCells_
void updateChannelStatus(std::map< HcalDetId, unsigned int > &myqual)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
void fillReportSummaryLSbyLS(int LS)
void setup(DQMStore *&m_dbe, std::string Name, std::string Units="")
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)
#define abs(x)
Definition: mlp_lapack.h:159
#define min(a, b)
Definition: mlp_lapack.h:161
bool isHE(int etabin, int depth)
T eta() const
MonitorElement * StatusVsLS_
uint16_t size_type
MonitorElement * EnoughEvents_
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:654
void Fill(long long x)
std::vector< MonitorElement * > depth
int CalcIeta(int subdet, int eta, int depth)
static std::string subdets[11]
const T & max(const T &a, const T &b)
EtaPhiHists * ProblemCellsByDepth
void removeElement(const std::string &name)
Definition: DQMStore.cc:2572
int j
Definition: DBlmapReader.cc:9
~HcalSummaryClient()
Destructor.
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1468
bool isHB(int etabin, int depth)
float cl
Definition: Combine.cc:71
std::vector< HcalBaseDQClient * > clients_
bool isHF(int etabin, int depth)
int64_t getIntValue(void) const
EtaPhiHists * SummaryMapByDepth
std::string subdir_
void FillUnphysicalHEHFBins(std::vector< TH2F > &hh)
MonitorElement * MinEvents_
MonitorElement * certificationMap_
MonitorElement * reportMap_
MonitorElement * reportMapShift_
double getBinContent(int binx) const
get content of bin (1-D)
std::string prefixME_
tuple events
Definition: patZpeak.py:19
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
tuple cout
Definition: gather_cfg.py:121
virtual void analyze(void)
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:845
void Reset(void)
reset ME (ie. contents, errors, etc)
DQMStore * dqmStore_
tuple size
Write out results.
MonitorElement * MinErrorRate_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
void fillReportSummary(int LS)
Definition: DDAxes.h:10