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