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