CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalMonitorClient.cc
Go to the documentation of this file.
1 /*
2  * \file HcalMonitorClient.cc
3  *
4  * \author J. Temple
5  *
6  */
7 
24 
32 
35 
40 
43 
44 #include <iostream>
45 #include <iomanip>
46 #include <fstream>
47 
48 #include "TROOT.h"
49 #include "TH1.h"
50 
51 //'using' declarations should only be used within classes/functions, and 'using namespace std;' should not be used,
52 // according to Bill Tanenbaum (DQM development hypernews, 25 March 2010)
53 
55 {
56  debug_ = ps.getUntrackedParameter<int>("debug",0);
57  inputFile_ = ps.getUntrackedParameter<std::string>("inputFile","");
58  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
59  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
60  prescaleFactor_ = ps.getUntrackedParameter<int>("prescaleFactor", -1);
61  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder", "Hcal/");
62  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
63  prefixME_.append("/");
64  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
65  enabledClients_ = ps.getUntrackedParameter<std::vector<std::string> >("enabledClients", enabledClients_);
66 
67  updateTime_ = ps.getUntrackedParameter<int>("UpdateTime",0);
68  baseHtmlDir_ = ps.getUntrackedParameter<std::string>("baseHtmlDir", "");
69  htmlUpdateTime_ = ps.getUntrackedParameter<int>("htmlUpdateTime", 0);
70  htmlFirstUpdate_ = ps.getUntrackedParameter<int>("htmlFirstUpdate",20);
71  databasedir_ = ps.getUntrackedParameter<std::string>("databaseDir","");
72  databaseUpdateTime_ = ps.getUntrackedParameter<int>("databaseUpdateTime",0);
73  databaseFirstUpdate_ = ps.getUntrackedParameter<int>("databaseFirstUpdate",10);
74 
75  saveByLumiSection_ = ps.getUntrackedParameter<bool>("saveByLumiSection",false);
76  Online_ = ps.getUntrackedParameter<bool>("online",false);
77 
78 
79  if (debug_>0)
80  {
81  std::cout <<"HcalMonitorClient:: The following clients are enabled:"<<std::endl;
82  for (unsigned int i=0;i<enabledClients_.size();++i)
83  std::cout <<enabledClients_[i]<<std::endl;
84  } // if (debug_>0)
85 
86  // Set all EtaPhiHists pointers to 0 to start
87  ChannelStatus=0;
92 
93  // Add all relevant clients
94  clients_.clear();
95  clients_.reserve(14); // any reason to reserve ahead of time?
97 
98  clients_.push_back(new HcalBaseDQClient((std::string)"HcalMonitorModule",ps));
99  if (find(enabledClients_.begin(), enabledClients_.end(),"DeadCellMonitor")!=enabledClients_.end())
100  clients_.push_back(new HcalDeadCellClient((std::string)"DeadCellMonitor",ps));
101  if (find(enabledClients_.begin(), enabledClients_.end(),"HotCellMonitor")!=enabledClients_.end())
102  clients_.push_back(new HcalHotCellClient((std::string)"HotCellMonitor",ps));
103  if (find(enabledClients_.begin(), enabledClients_.end(),"RecHitMonitor")!=enabledClients_.end())
104  clients_.push_back(new HcalRecHitClient((std::string)"RecHitMonitor",ps));
105  if (find(enabledClients_.begin(), enabledClients_.end(),"DigiMonitor")!=enabledClients_.end())
106  clients_.push_back(new HcalDigiClient((std::string)"DigiMonitor",ps));
107  if (find(enabledClients_.begin(), enabledClients_.end(),"RawDataMonitor")!=enabledClients_.end())
108  clients_.push_back(new HcalRawDataClient((std::string)"RawDataMonitor",ps));
109  if (find(enabledClients_.begin(), enabledClients_.end(),"TrigPrimMonitor")!=enabledClients_.end())
110  clients_.push_back(new HcalTrigPrimClient((std::string)"TrigPrimMonitor",ps));
111  if (find(enabledClients_.begin(), enabledClients_.end(),"NZSMonitor")!=enabledClients_.end())
112  clients_.push_back(new HcalNZSClient((std::string)"NZSMonitor",ps));
113  if (find(enabledClients_.begin(), enabledClients_.end(),"BeamMonitor")!=enabledClients_.end())
114  clients_.push_back(new HcalBeamClient((std::string)"BeamMonitor",ps));
115  if (find(enabledClients_.begin(), enabledClients_.end(),"DetDiagPedestalMonitor")!=enabledClients_.end())
116  clients_.push_back(new HcalDetDiagPedestalClient((std::string)"DetDiagPedestalMonitor",ps));
117  if (find(enabledClients_.begin(), enabledClients_.end(),"DetDiagLaserMonitor")!=enabledClients_.end())
118  clients_.push_back(new HcalDetDiagLaserClient((std::string)"DetDiagLaserMonitor",ps));
119  if (find(enabledClients_.begin(), enabledClients_.end(),"DetDiagLEDMonitor")!=enabledClients_.end())
120  clients_.push_back(new HcalDetDiagLEDClient((std::string)"DetDiagLEDMonitor",ps));
121  if (find(enabledClients_.begin(), enabledClients_.end(),"DetDiagNoiseMonitor")!=enabledClients_.end())
122  clients_.push_back(new HcalDetDiagNoiseMonitorClient((std::string)"DetDiagNoiseMonitor",ps));
123  if (find(enabledClients_.begin(), enabledClients_.end(),"DetDiagTimingMonitor")!=enabledClients_.end())
124  clients_.push_back(new HcalDetDiagTimingClient((std::string)"DetDiagTimingMonitor",ps));
125  if (find(enabledClients_.begin(), enabledClients_.end(),"CoarsePedestalMonitor")!=enabledClients_.end())
126  clients_.push_back(new HcalCoarsePedestalClient((std::string)"CoarsePedestalMonitor",ps));
127 
128  if (find(enabledClients_.begin(), enabledClients_.end(),"Summary")!=enabledClients_.end())
129  summaryClient_ = new HcalSummaryClient((std::string)"ReportSummaryClient",ps);
130 
131 } // HcalMonitorClient constructor
132 
133 
135 {
136  if (debug_>0) std::cout <<"<HcalMonitorClient> Exiting..."<<std::endl;
137  for (unsigned int i=0;i<clients_.size();++i)
138  delete clients_[i];
139  //if (summaryClient_) delete summaryClient_;
140 
141 }
142 
144 {
145 
146  begin_run_ = false;
147  end_run_ = false;
148 
149  run_=-1;
150  evt_=-1;
151  ievt_=0;
152  jevt_=0;
153 
155  last_time_html_ = 0;
156  last_time_db_ = 0;
157 
158  // get hold of back-end interface
159 
161 
162  if ( inputFile_.size() != 0 )
163  {
165  }
166 
167  for ( unsigned int i=0; i<clients_.size();++i )
168  clients_[i]->beginJob();
169 
171 
172 
173 } // void HcalMonitorClient::beginJob(void)
174 
175 
177 {
178  if (debug_>0) std::cout <<"<HcalMonitorClient::beginRun(r,c)>"<<std::endl;
179  begin_run_ = true;
180  end_run_ = false;
181 
182  run_=r.id().run();
183  evt_=0;
184  jevt_=0;
185  htmlcounter_=0;
186 
187  // Store list of bad channels and their values
188  std::map <HcalDetId, unsigned int> badchannelmap;
189  badchannelmap.clear();
190 
191  // Let's get the channel status quality
193  c.get<IdealGeometryRecord>().get(topo);
194 
196  c.get<HcalChannelQualityRcd>().get(p);
198  if (!chanquality_->topo()) chanquality_->setTopo(topo.product());
199 
200  if (dqmStore_ && ChannelStatus==0)
201  {
202  dqmStore_->setCurrentFolder(prefixME_+"HcalInfo/ChannelStatus");
204  ChannelStatus->setup(dqmStore_,"ChannelStatus");
205  std::stringstream x;
206  for (unsigned int d=0;d<ChannelStatus->depth.size();++d)
207  {
208  ChannelStatus->depth[d]->Reset();
209  x<<"1+log2(status) for HCAL depth "<<d+1;
210  if (ChannelStatus->depth[d]) ChannelStatus->depth[d]->setTitle(x.str().c_str());
211  x.str("");
212  }
213  }
214 
215  edm::ESHandle<HcalDbService> conditions;
216  c.get<HcalDbRecord>().get(conditions);
217  // Now let's setup pedestals
218  if (dqmStore_ )
219  {
220  dqmStore_->setCurrentFolder(prefixME_+"HcalInfo/PedestalsFromCondDB");
222  {
224  ADC_PedestalFromDBByDepth->setup(dqmStore_,"ADC Pedestals From Conditions DB");
225  }
226  if (ADC_WidthFromDBByDepth==0)
227  {
229  ADC_WidthFromDBByDepth->setup(dqmStore_,"ADC Widths From Conditions DB");
230  }
232  {
234  fC_PedestalFromDBByDepth->setup(dqmStore_,"fC Pedestals From Conditions DB");
235  }
236  if (fC_WidthFromDBByDepth==0)
237  {
239  fC_WidthFromDBByDepth->setup(dqmStore_,"fC Widths From Conditions DB");
240  }
241  PlotPedestalValues(*conditions);
242  }
243 
244  // Find only channels with non-zero quality, and add them to badchannelmap
245  std::vector<DetId> mydetids = chanquality_->getAllChannels();
246  for (std::vector<DetId>::const_iterator i = mydetids.begin();i!=mydetids.end();++i)
247  {
248  if (i->det()!=DetId::Hcal) continue; // not an hcal cell
249  HcalDetId id=HcalDetId(*i);
250  int status=(chanquality_->getValues(id))->getValue();
251  //if (status!=status) status=-1; // protects against NaN values
252  // The above line doesn't seem to work in identifying NaNs; ints for bad values come back as negative numbers (at least in run 146501)
253  if (status==0) continue;
254  badchannelmap[id]=status;
255 
256  // Fill Channel Status histogram
257  if (dqmStore_==0) continue;
258  int depth=id.depth();
259  if (depth<1 || depth>4) continue;
260  int ieta=id.ieta();
261  int iphi=id.iphi();
262  if (id.subdet()==HcalForward)
263  ieta>0 ? ++ieta: --ieta;
264 
265  double logstatus = 0;
266  // Fill ChannelStatus value with '-1' when a 'NaN' occurs
267  if (status<0)
268  logstatus=-1*(log2(-1.*status)+1);
269  else
270  logstatus=log2(1.*status)+1;
271  if (ChannelStatus->depth[depth-1]) ChannelStatus->depth[depth-1]->Fill(ieta,iphi,logstatus);
272  }
273 
274  for (unsigned int i=0;i<clients_.size();++i)
275  {
276  if (clients_[i]->name()=="RawDataMonitor") clients_[i]->setEventSetup(c);
277  clients_[i]->beginRun();
278  clients_[i]->setStatusMap(badchannelmap);
279  }
280 
281  if (summaryClient_!=0)
282  {
285  }
286 
287 } // void HcalMonitorClient::beginRun(const Run& r, const EventSetup& c)
288 
290 {
291  // What is the difference between this and beginRun above?
292  // When would this be called?
293  begin_run_ = true;
294  end_run_ = false;
295  jevt_ = 0;
296  htmlcounter_=0;
297 
298  if (dqmStore_==0 || ChannelStatus!=0) return;
299  dqmStore_->setCurrentFolder(prefixME_+"HcalInfo");
301  ChannelStatus->setup(dqmStore_,"ChannelStatus");
302  std::stringstream x;
303  for (unsigned int d=0;d<ChannelStatus->depth.size();++d)
304  {
305  x<<"1+log2(status) for HCAL depth "<<d+1;
306  if (ChannelStatus->depth[d]) ChannelStatus->depth[d]->setTitle(x.str().c_str());
307  x.str("");
308  }
309 } // void HcalMonitorClient::beginRun()
310 
312 {
313  // no setup required
314 }
315 
317 {
318  if (debug_>0) std::cout <<"<HcalMonitorClient::beginLuminosityBlock>"<<std::endl;
319 } // void HcalMonitorClient::beginLuminosityBlock
320 
322 {
323  if (debug_>4)
324  std::cout <<"HcalMonitorClient::analyze(const edm::Event&, const edm::EventSetup&) ievt_ = "<<ievt_<<std::endl;
325  ievt_++;
326  jevt_++;
327 
328  run_=e.id().run();
329  evt_=e.id().event();
330  if (prescaleFactor_>0 && jevt_%prescaleFactor_==0) {
331 
332  for (unsigned int i=0;i<clients_.size();++i)
333  clients_[i]->getLogicalMap(c); // actually runs just once internally
334 
335  this->analyze(e.luminosityBlock());
336  }
337 
338 } // void HcalMonitorClient::analyze(const edm::Event & e, const edm::EventSetup & c)
339 
341 {
342  if (debug_>0)
343  std::cout <<"HcalMonitorClient::analyze() "<<std::endl;
345  // no ievt_, jevt_ counters needed here: this function gets called at endlumiblock, after default analyze function runs
346  for (unsigned int i=0;i<clients_.size();++i)
347  clients_[i]->analyze();
348  if (summaryClient_!=0)
349  {
350  // Always call basic analyze to form histograms for each task
351  summaryClient_->analyze(LS);
352  // Call this if LS-by-LS enabling is set to true
353  if (saveByLumiSection_==true)
355  }
356 } // void HcalMonitorClient::analyze()
357 
358 
360 {
361  if (debug_>0) std::cout <<"<HcalMonitorClient::endLuminosityBlock>"<<std::endl;
363  if (updateTime_>0)
364  {
366  return;
368  }
369  this->analyze(l.luminosityBlock());
370 
371  if (databaseUpdateTime_>0)
372  {
373  if (
374  // first update occurs at after databaseFirstUpdate_ minutes
376  ||
377  // following updates follow once every databaseUpdateTime_ minutes
379  )
380  {
381  this->writeChannelStatus();
383  }
384  }
385 
386  if (htmlUpdateTime_>0)
387  {
388  if (
390  //
392  ) // htmlUpdateTime_ in minutes
393  {
394  this->writeHtml();
396  }
397  }
398 
399 } // void HcalMonitorClient::endLuminosityBlock
400 
402 {
403  begin_run_ = false;
404  end_run_ = true;
405 
406  // Always fill summaryClient at end of run (as opposed to the end-lumi fills, which may just contain info for a single LS)
407  // At the end of this run, set LS=-1 (LS-based plotting in doesn't work yet anyway)
408  if (summaryClient_)
409  summaryClient_->analyze(-1);
410 
411  if (databasedir_.size()>0)
412  this->writeChannelStatus();
413  // writeHtml takes longer; run it last
414  // Also, don't run it if htmlUpdateTime_>0 -- it should have already been run
415  if (baseHtmlDir_.size()>0 && htmlUpdateTime_==0)
416  this->writeHtml();
417 }
418 
420 {
421  // Set values here, because the "analyze" method occasionally times out,
422  // which keeps the endRun() call from being made. This causes endJob to
423  // crash, since end_run_ is still set to false at that point.
424  begin_run_ = false;
425  end_run_ = true;
426 
427  this->analyze();
428  this->endRun();
429 }
430 
432 {
433  // Temporary fix for crash of April 2011 in online DQM
434  if (Online_==true)
435  return;
436 
437  if (! end_run_)
438  {
439  this->analyze();
440  this->endRun();
441  }
442  this->cleanup(); // currently does nothing
443 
444  for ( unsigned int i=0; i<clients_.size(); i++ )
445  clients_[i]->endJob();
446  //if ( summaryClient_ ) summaryClient_->endJob();
447 
448 } // void HcalMonitorClient::endJob(void)
449 
451 {
452  if (!enableCleanup_) return;
453  // other cleanup?
454 } // void HcalMonitorClient::cleanup(void)
455 
456 
458 {
459  if (debug_>0) std::cout << "Preparing HcalMonitorClient html output ..." << std::endl;
460 
461 
462  // global ROOT style
463  gStyle->Reset("Default");
464  gStyle->SetCanvasColor(0);
465  gStyle->SetPadColor(0);
466  gStyle->SetFillColor(0);
467  gStyle->SetTitleFillColor(10);
468  // gStyle->SetOptStat(0);
469  gStyle->SetOptStat("ouemr");
470  gStyle->SetPalette(1);
471 
472  char tmp[20];
473 
474  if(run_!=-1) sprintf(tmp, "DQM_%s_R%09d_%i", prefixME_.substr(0,prefixME_.size()-1).c_str(),run_,htmlcounter_);
475  else sprintf(tmp, "DQM_%s_R%09d_%i", prefixME_.substr(0,prefixME_.size()-1).c_str(),0,htmlcounter_);
476  std::string htmlDir = baseHtmlDir_ + "/" + tmp + "/";
477  system(("/bin/mkdir -p " + htmlDir).c_str());
478 
479  ++htmlcounter_;
480 
481  std::ofstream htmlFile;
482  htmlFile.open((htmlDir + "index.html").c_str());
483 
484  // html page header
485  htmlFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> " << std::endl;
486  htmlFile << "<html> " << std::endl;
487  htmlFile << "<head> " << std::endl;
488  htmlFile << " <meta content=\"text/html; charset=ISO-8859-1\" " << std::endl;
489  htmlFile << " http-equiv=\"content-type\"> " << std::endl;
490  htmlFile << " <title>Hcal Data Quality Monitor</title> " << std::endl;
491  htmlFile << "</head> " << std::endl;
492  htmlFile << "<body> " << std::endl;
493  htmlFile << "<br> " << std::endl;
494  htmlFile << "<center><h1>Hcal Data Quality Monitor</h1></center>" << std::endl;
495  htmlFile << "<h2>Run Number:&nbsp;&nbsp;&nbsp;" << std::endl;
496  htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << run_ <<"</span></h2> " << std::endl;
497  htmlFile << "<h2>Events processed:&nbsp;&nbsp;&nbsp;" << std::endl;
498  htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << ievt_ <<"</span></h2> " << std::endl;
499  htmlFile << "<hr>" << std::endl;
500  htmlFile << "<ul>" << std::endl;
501 
502  for (unsigned int i=0;i<clients_.size();++i)
503  {
504  if (clients_[i]->validHtmlOutput()==true)
505  {
506  clients_[i]->htmlOutput(htmlDir);
507  // Always print this out? Or only when validHtmlOutput is true?
508  htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << std::endl;
509  htmlFile << "<td WIDTH=\"35%\"><a href=\"" << clients_[i]->name_ << ".html"<<"\">"<<clients_[i]->name_<<"</a></td>" << std::endl;
510  if(clients_[i]->hasErrors_Temp()) htmlFile << "<td bgcolor=red align=center>This monitor task has errors.</td>" << std::endl;
511  else if(clients_[i]->hasWarnings_Temp()) htmlFile << "<td bgcolor=yellow align=center>This monitor task has warnings.</td>" << std::endl;
512  else if(clients_[i]->hasOther_Temp()) htmlFile << "<td bgcolor=aqua align=center>This monitor task has messages.</td>" << std::endl;
513  else htmlFile << "<td bgcolor=lime align=center>This monitor task has no problems</td>" << std::endl;
514  htmlFile << "</tr></table>" << std::endl;
515  }
516  }
517 
518  // Add call to reportSummary html output
519  if (summaryClient_)
520  {
521  summaryClient_->htmlOutput(htmlDir);
522  htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << std::endl;
523  htmlFile << "<td WIDTH=\"35%\"><a href=\"" << summaryClient_->name_ << ".html"<<"\">"<<summaryClient_->name_<<"</a></td>" << std::endl;
524  if(summaryClient_->hasErrors_Temp()) htmlFile << "<td bgcolor=red align=center>This monitor task has errors.</td>" << std::endl;
525  else if(summaryClient_->hasWarnings_Temp()) htmlFile << "<td bgcolor=yellow align=center>This monitor task has warnings.</td>" << std::endl;
526  else if(summaryClient_->hasOther_Temp()) htmlFile << "<td bgcolor=aqua align=center>This monitor task has messages.</td>" << std::endl;
527  else htmlFile << "<td bgcolor=lime align=center>This monitor task has no problems</td>" << std::endl;
528  htmlFile << "</tr></table>" << std::endl;
529  }
530 
531  htmlFile << "</ul>" << std::endl;
532 
533  // html page footer
534  htmlFile << "</body> " << std::endl;
535  htmlFile << "</html> " << std::endl;
536 
537  htmlFile.close();
538  if (debug_>0) std::cout << "HcalMonitorClient html output done..." << std::endl;
539 
540 } // void HcalMonitorClient::writeHtml()
541 
543 {
544  if (databasedir_.size()==0) return;
545  if (debug_>0) std::cout <<"<HcalMonitorClient::writeDBfile> Writing file for database"<<std::endl;
546 
547  std::map<HcalDetId, unsigned int> myquality; //map of quality flags as reported by each client
548  // Get status from all channels (we need to store all channels in case a bad channel suddenly becomes good)
550  clients_[i]->updateChannelStatus(myquality);
551 
552  if (debug_>0) std::cout <<"<HcalMonitorClient::writeChannelStatus()> myquality size = "<<myquality.size()<<std::endl;
553 
554  std::vector<DetId> mydetids = chanquality_->getAllChannels();
556 
557  for (unsigned int i=0;i<mydetids.size();++i)
558  {
559  if (mydetids[i].det()!=DetId::Hcal) continue; // not hcal
560 
561  HcalDetId id=mydetids[i];
562  // get original channel status item
563  const HcalChannelStatus* origstatus=chanquality_->getValues(mydetids[i]);
564  // make copy of status
565  HcalChannelStatus* mystatus=new HcalChannelStatus(origstatus->rawId(),origstatus->getValue());
566  // loop over myquality flags
567  if (myquality.find(id)!=myquality.end())
568  {
569 
570  // check dead cells
571  if ((myquality[id]>>HcalChannelStatus::HcalCellDead)&0x1)
573  else
575  // check hot cells
576  if ((myquality[id]>>HcalChannelStatus::HcalCellHot)&0x1)
578  else
580  } // if (myquality.find_...)
581  newChanQual->addValues(*mystatus);
582  } // for (unsigned int i=0;...)
583 
584  //Now dump out to text file
585  std::ostringstream file;
586  databasedir_=databasedir_+"/"; // add extra slash, just in case
587  //file <<databasedir_<<"HcalDQMstatus_"<<run_<<".txt";
588  file <<databasedir_<<"HcalDQMstatus.txt";
589  std::ofstream outStream(file.str().c_str());
590  outStream<<"### Run # "<<run_<<std::endl;
591  HcalDbASCIIIO::dumpObject (outStream, (*newChanQual));
592  return;
593 } // void HcalMonitorClient::writeChannelStatus()
594 
595 
597 {
598 
599  double ADC_ped=0;
600  double ADC_width=0;
601  double fC_ped=0;
602  double fC_width=0;
603  double temp_ADC=0;
604  double temp_fC=0;
605 
606  int ieta=-9999;
607  int iphi=-9999;
608  HcalCalibrations calibs_;
609 
614 
615 
616  for (int subdet=1; subdet<=4;++subdet)
617  {
618  for (int depth=0;depth<4;++depth)
619  {
620  int etabins= ADC_PedestalFromDBByDepth->depth[depth]->getNbinsX();
621  int phibins = ADC_PedestalFromDBByDepth->depth[depth]->getNbinsY();
622  for (int eta=0;eta<etabins;++eta)
623  {
624  ieta=CalcIeta(subdet,eta,depth+1);
625  if (ieta==-9999) continue;
626  for (int phi=0;phi<phibins;++phi)
627  {
628  iphi=phi+1;
629  if (!validDetId((HcalSubdetector)(subdet), ieta, iphi, depth+1)) continue;
630  HcalDetId detid((HcalSubdetector)(subdet), ieta, iphi, depth+1);
631  ADC_ped=0;
632  ADC_width=0;
633  fC_ped=0;
634  fC_width=0;
635  calibs_= cond.getHcalCalibrations(detid);
636  const HcalPedestalWidth* pedw = cond.getPedestalWidth(detid);
637  const HcalQIECoder* channelCoder_ = cond.getHcalCoder(detid);
638  const HcalQIEShape* shape_ = cond.getHcalShape(channelCoder_);
639 
640  // Loop over capIDs
641  for (unsigned int capid=0;capid<4;++capid)
642  {
643  // Still need to determine how to convert widths to ADC or fC
644  // calibs_.pedestal value is always in fC, according to Radek
645  temp_fC = calibs_.pedestal(capid);
646  fC_ped+= temp_fC;
647  // convert to ADC from fC
648  temp_ADC=channelCoder_->adc(*shape_,
649  (float)calibs_.pedestal(capid),
650  capid);
651  ADC_ped+=temp_ADC;
652  // Pedestals assumed to be read out in fC
653  temp_fC=pedw->getSigma(capid,capid);
654  fC_width+=temp_fC;
655  temp_ADC=pedw->getSigma(capid,capid)*pow(1.*channelCoder_->adc(*shape_,(float)calibs_.pedestal(capid),capid)/calibs_.pedestal(capid),2);
656  ADC_width+=temp_ADC;
657  }//capid loop
658 
659  // Pedestal values are average over four cap IDs
660  // widths are sqrt(SUM [sigma_ii^2])/4.
661  fC_ped/=4.;
662  ADC_ped/=4.;
663 
664  // Divide width by 2, or by four?
665  // Dividing by 2 gives subtracted results closer to zero -- estimate of variance?
666  fC_width=pow(fC_width,0.5)/2.;
667  ADC_width=pow(ADC_width,0.5)/2.;
668 
669  if (debug_>1)
670  {
671  std::cout <<"<HcalMonitorClient::PlotPedestalValues> HcalDet ID = "<<(HcalSubdetector)subdet<<": ("<<ieta<<", "<<iphi<<", "<<depth<<")"<<std::endl;
672  std::cout <<"\tADC pedestal = "<<ADC_ped<<" +/- "<<ADC_width<<std::endl;
673  std::cout <<"\tfC pedestal = "<<fC_ped<<" +/- "<<fC_width<<std::endl;
674  }
675  // Shift HF by -/+1 when filling eta-phi histograms
676  int zside=0;
677  if (subdet==4)
678  {
679  if (ieta<0) zside=-1;
680  else zside=1;
681  }
682  ADC_PedestalFromDBByDepth->depth[depth]->Fill(ieta+zside,iphi,ADC_ped);
683  ADC_WidthFromDBByDepth->depth[depth]->Fill(ieta+zside, iphi, ADC_width);
684  fC_PedestalFromDBByDepth->depth[depth]->Fill(ieta+zside,iphi,fC_ped);
685  fC_WidthFromDBByDepth->depth[depth]->Fill(ieta+zside, iphi, fC_width);
686  } // phi loop
687  } // eta loop
688  } //depth loop
689 
690  } // subdet loop
695 
696  // Center ADC pedestal values near 3 +/- 1
697  for (unsigned int i=0;i<ADC_PedestalFromDBByDepth->depth.size();++i)
698  {
699  ADC_PedestalFromDBByDepth->depth[i]->getTH2F()->SetMinimum(0);
700  if (ADC_PedestalFromDBByDepth->depth[i]->getTH2F()->GetMaximum()<6)
701  ADC_PedestalFromDBByDepth->depth[i]->getTH2F()->SetMaximum(6);
702  }
703 
704  for (unsigned int i=0;i<ADC_WidthFromDBByDepth->depth.size();++i)
705  {
706  ADC_WidthFromDBByDepth->depth[i]->getTH2F()->SetMinimum(0);
707  if (ADC_WidthFromDBByDepth->depth[i]->getTH2F()->GetMaximum()<2)
708  ADC_WidthFromDBByDepth->depth[i]->getTH2F()->SetMaximum(2);
709  }
710 
711 }
712 
RunNumber_t run() const
Definition: EventID.h:42
std::vector< std::string > enabledClients_
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
void setup(void)
Setup.
void analyze(int LS=-1)
int i
Definition: DBlmapReader.cc:9
void cleanup(void)
Cleanup.
EtaPhiHists * fC_WidthFromDBByDepth
RunID const & id() const
Definition: RunBase.h:41
EtaPhiHists * ADC_PedestalFromDBByDepth
void PlotPedestalValues(const HcalDbService &cond)
RunNumber_t run() const
Definition: RunID.h:43
std::string databasedir_
void analyze(int LS=-1)
Analyze.
float getSigma(int fCapId1, int fCapId2) const
get correlation element for capId1/2 = 0..3
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void fillReportSummaryLSbyLS(int LS)
void Reset(void)
EtaPhiHists * fC_PedestalFromDBByDepth
void beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &c)
BeginLumiBlock.
void beginJob(void)
BeginJob.
void setup(DQMStore *&m_dbe, std::string Name, std::string Units="")
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
void setTopo(const HcalTopology *topo) const
#define NULL
Definition: scimark2.h:8
void endLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &c)
EndLumiBlock.
double pedestal(int fCapId) const
get pedestal for capid=0..3
EtaPhiHists * ADC_WidthFromDBByDepth
const Item * getValues(DetId fId, bool throwOnFail=true) const
int zside(DetId const &)
T eta() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
void unsetBit(unsigned int bitnumber)
uint16_t size_type
void setBit(unsigned int bitnumber)
uint32_t rawId() const
LuminosityBlockNumber_t luminosityBlock() const
void endRun()
EndRun.
const HcalPedestalWidth * getPedestalWidth(const HcalGenericDetId &fId) const
std::string baseHtmlDir_
HcalMonitorClient(const edm::ParameterSet &ps)
std::vector< MonitorElement * > depth
std::string inputFile_
int CalcIeta(int subdet, int eta, int depth)
std::vector< DetId > getAllChannels() const
HcalSubdetector
Definition: HcalAssistant.h:31
void beginRun()
BeginRun.
HcalSummaryClient * summaryClient_
std::vector< HcalBaseDQClient * > clients_
HcalChannelQuality * chanquality_
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
virtual void htmlOutput(std::string htmlDir)
void FillUnphysicalHEHFBins(std::vector< TH2F > &hh)
EtaPhiHists * ChannelStatus
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
edm::EventID id() const
Definition: EventBase.h:56
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
unsigned adc(const HcalQIEShape &fShape, float fCharge, unsigned fCapId) const
fC + capid [0..3] -&gt; ADC conversion
Definition: HcalQIECoder.cc:27
void endJob(void)
EndJob.
bool open(const std::string &filename, bool overwrite=false, const std::string &path="", const std::string &prepend="", OpenRunDirs stripdirs=KeepRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:2845
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
tuple cout
Definition: gather_cfg.py:121
Definition: DDAxes.h:10
tuple status
Definition: ntuplemaker.py:245
uint32_t getValue() const
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
bool addValues(const Item &myItem)
void getFriends(const std::vector< HcalBaseDQClient * > &clients)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
Definition: Run.h:41
const HcalTopology * topo() const
bool validDetId(HcalSubdetector sd, int ies, int ip, int dp)
Definition: DDAxes.h:10