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: 2010/07/15 22:39:02 $
5  * $Revision: 1.99 $
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 
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<HcalChannelQualityRcd>().get(p);
195 
196  if (dqmStore_ && ChannelStatus==0)
197  {
198  dqmStore_->setCurrentFolder(prefixME_+"HcalInfo/ChannelStatus");
200  ChannelStatus->setup(dqmStore_,"ChannelStatus");
201  std::stringstream x;
202  for (unsigned int d=0;d<ChannelStatus->depth.size();++d)
203  {
204  ChannelStatus->depth[d]->Reset();
205  x<<"1+log2(status) for HCAL depth "<<d+1;
206  if (ChannelStatus->depth[d]) ChannelStatus->depth[d]->setTitle(x.str().c_str());
207  x.str("");
208  }
209  }
210 
211  edm::ESHandle<HcalDbService> conditions;
212  c.get<HcalDbRecord>().get(conditions);
213  // Now let's setup pedestals
214  if (dqmStore_ )
215  {
216  dqmStore_->setCurrentFolder(prefixME_+"HcalInfo/PedestalsFromCondDB");
218  {
220  ADC_PedestalFromDBByDepth->setup(dqmStore_,"ADC Pedestals From Conditions DB");
221  }
222  if (ADC_WidthFromDBByDepth==0)
223  {
225  ADC_WidthFromDBByDepth->setup(dqmStore_,"ADC Widths From Conditions DB");
226  }
228  {
230  fC_PedestalFromDBByDepth->setup(dqmStore_,"fC Pedestals From Conditions DB");
231  }
232  if (fC_WidthFromDBByDepth==0)
233  {
235  fC_WidthFromDBByDepth->setup(dqmStore_,"fC Widths From Conditions DB");
236  }
237  PlotPedestalValues(*conditions);
238  }
239 
240  // Find only channels with non-zero quality, and add them to badchannelmap
241  std::vector<DetId> mydetids = chanquality_->getAllChannels();
242  for (std::vector<DetId>::const_iterator i = mydetids.begin();i!=mydetids.end();++i)
243  {
244  if (i->det()!=DetId::Hcal) continue; // not an hcal cell
245  HcalDetId id=HcalDetId(*i);
246  int status=(chanquality_->getValues(id))->getValue();
247  //if (status!=status) status=-1; // protects against NaN values
248  // 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)
249  if (status==0) continue;
250  badchannelmap[id]=status;
251 
252  // Fill Channel Status histogram
253  if (dqmStore_==0) continue;
254  int depth=id.depth();
255  if (depth<1 || depth>4) continue;
256  int ieta=id.ieta();
257  int iphi=id.iphi();
258  if (id.subdet()==HcalForward)
259  ieta>0 ? ++ieta: --ieta;
260 
261  double logstatus = 0;
262  // Fill ChannelStatus value with '-1' when a 'NaN' occurs
263  if (status<0)
264  logstatus=-1*(log2(-1.*status)+1);
265  else
266  logstatus=log2(1.*status)+1;
267  if (ChannelStatus->depth[depth-1]) ChannelStatus->depth[depth-1]->Fill(ieta,iphi,logstatus);
268  }
269 
270  for (unsigned int i=0;i<clients_.size();++i)
271  {
272  if (clients_[i]->name()=="RawDataMonitor") clients_[i]->setEventSetup(c);
273  clients_[i]->beginRun();
274  clients_[i]->setStatusMap(badchannelmap);
275  }
276 
277  if (summaryClient_!=0)
278  {
281  }
282 
283 } // void HcalMonitorClient::beginRun(const Run& r, const EventSetup& c)
284 
286 {
287  // What is the difference between this and beginRun above?
288  // When would this be called?
289  begin_run_ = true;
290  end_run_ = false;
291  jevt_ = 0;
292  htmlcounter_=0;
293 
294  if (dqmStore_==0 || ChannelStatus!=0) return;
295  dqmStore_->setCurrentFolder(prefixME_+"HcalInfo");
297  ChannelStatus->setup(dqmStore_,"ChannelStatus");
298  std::stringstream x;
299  for (unsigned int d=0;d<ChannelStatus->depth.size();++d)
300  {
301  x<<"1+log2(status) for HCAL depth "<<d+1;
302  if (ChannelStatus->depth[d]) ChannelStatus->depth[d]->setTitle(x.str().c_str());
303  x.str("");
304  }
305 } // void HcalMonitorClient::beginRun()
306 
308 {
309  // no setup required
310 }
311 
313 {
314  if (debug_>0) std::cout <<"<HcalMonitorClient::beginLuminosityBlock>"<<std::endl;
315 } // void HcalMonitorClient::beginLuminosityBlock
316 
318 {
319  if (debug_>4)
320  std::cout <<"HcalMonitorClient::analyze(const edm::Event&, const edm::EventSetup&) ievt_ = "<<ievt_<<std::endl;
321  ievt_++;
322  jevt_++;
323 
324  run_=e.id().run();
325  evt_=e.id().event();
327 
328 } // void HcalMonitorClient::analyze(const edm::Event & e, const edm::EventSetup & c)
329 
331 {
332  if (debug_>0)
333  std::cout <<"HcalMonitorClient::analyze() "<<std::endl;
335  // no ievt_, jevt_ counters needed here: this function gets called at endlumiblock, after default analyze function runs
336  for (unsigned int i=0;i<clients_.size();++i)
337  clients_[i]->analyze();
338  if (summaryClient_!=0)
339  {
340  // Always call basic analyze to form histograms for each task
341  summaryClient_->analyze(LS);
342  // Call this if LS-by-LS enabling is set to true
343  if (saveByLumiSection_==true)
345  }
346 } // void HcalMonitorClient::analyze()
347 
348 
350 {
351  if (debug_>0) std::cout <<"<HcalMonitorClient::endLuminosityBlock>"<<std::endl;
353  if (updateTime_>0)
354  {
356  return;
358  }
359  this->analyze(l.luminosityBlock());
360 
361  if (databaseUpdateTime_>0)
362  {
363  if (
364  // first update occurs at after databaseFirstUpdate_ minutes
366  ||
367  // following updates follow once every databaseUpdateTime_ minutes
369  )
370  {
371  this->writeChannelStatus();
373  }
374  }
375 
376  if (htmlUpdateTime_>0)
377  {
378  if (
380  //
382  ) // htmlUpdateTime_ in minutes
383  {
384  this->writeHtml();
386  }
387  }
388 
389 } // void HcalMonitorClient::endLuminosityBlock
390 
392 {
393  begin_run_ = false;
394  end_run_ = true;
395 
396  // Always fill summaryClient at end of run (as opposed to the end-lumi fills, which may just contain info for a single LS)
397  // At the end of this run, set LS=-1 (LS-based plotting in doesn't work yet anyway)
398  if (summaryClient_)
399  summaryClient_->analyze(-1);
400 
401  if (databasedir_.size()>0)
402  this->writeChannelStatus();
403  // writeHtml takes longer; run it last
404  // Also, don't run it if htmlUpdateTime_>0 -- it should have already been run
405  if (baseHtmlDir_.size()>0 && htmlUpdateTime_==0)
406  this->writeHtml();
407 }
408 
410 {
411  this->analyze();
412  this->endRun();
413 }
414 
416 {
417  if (! end_run_)
418  {
419  this->analyze();
420  this->endRun();
421  }
422  this->cleanup();
423 
424  for ( unsigned int i=0; i<clients_.size(); i++ )
425  clients_[i]->endJob();
426  //if ( summaryClient_ ) summaryClient_->endJob();
427 
428 } // void HcalMonitorClient::endJob(void)
429 
431 {
432  if (!enableCleanup_) return;
433  // other cleanup?
434 } // void HcalMonitorClient::cleanup(void)
435 
436 
438 {
439  if (debug_>0) std::cout << "Preparing HcalMonitorClient html output ..." << std::endl;
440 
441 
442  // global ROOT style
443  gStyle->Reset("Default");
444  gStyle->SetCanvasColor(0);
445  gStyle->SetPadColor(0);
446  gStyle->SetFillColor(0);
447  gStyle->SetTitleFillColor(10);
448  // gStyle->SetOptStat(0);
449  gStyle->SetOptStat("ouemr");
450  gStyle->SetPalette(1);
451 
452  char tmp[20];
453 
454  if(run_!=-1) sprintf(tmp, "DQM_%s_R%09d_%i", prefixME_.substr(0,prefixME_.size()-1).c_str(),run_,htmlcounter_);
455  else sprintf(tmp, "DQM_%s_R%09d_%i", prefixME_.substr(0,prefixME_.size()-1).c_str(),0,htmlcounter_);
456  std::string htmlDir = baseHtmlDir_ + "/" + tmp + "/";
457  system(("/bin/mkdir -p " + htmlDir).c_str());
458 
459  ++htmlcounter_;
460 
461  ofstream htmlFile;
462  htmlFile.open((htmlDir + "index.html").c_str());
463 
464  // html page header
465  htmlFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> " << std::endl;
466  htmlFile << "<html> " << std::endl;
467  htmlFile << "<head> " << std::endl;
468  htmlFile << " <meta content=\"text/html; charset=ISO-8859-1\" " << std::endl;
469  htmlFile << " http-equiv=\"content-type\"> " << std::endl;
470  htmlFile << " <title>Hcal Data Quality Monitor</title> " << std::endl;
471  htmlFile << "</head> " << std::endl;
472  htmlFile << "<body> " << std::endl;
473  htmlFile << "<br> " << std::endl;
474  htmlFile << "<center><h1>Hcal Data Quality Monitor</h1></center>" << std::endl;
475  htmlFile << "<h2>Run Number:&nbsp;&nbsp;&nbsp;" << std::endl;
476  htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << run_ <<"</span></h2> " << std::endl;
477  htmlFile << "<h2>Events processed:&nbsp;&nbsp;&nbsp;" << std::endl;
478  htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << ievt_ <<"</span></h2> " << std::endl;
479  htmlFile << "<hr>" << std::endl;
480  htmlFile << "<ul>" << std::endl;
481 
482  for (unsigned int i=0;i<clients_.size();++i)
483  {
484  if (clients_[i]->validHtmlOutput()==true)
485  {
486  clients_[i]->htmlOutput(htmlDir);
487  // Always print this out? Or only when validHtmlOutput is true?
488  htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << std::endl;
489  htmlFile << "<td WIDTH=\"35%\"><a href=\"" << clients_[i]->name_ << ".html"<<"\">"<<clients_[i]->name_<<"</a></td>" << std::endl;
490  if(clients_[i]->hasErrors_Temp()) htmlFile << "<td bgcolor=red align=center>This monitor task has errors.</td>" << std::endl;
491  else if(clients_[i]->hasWarnings_Temp()) htmlFile << "<td bgcolor=yellow align=center>This monitor task has warnings.</td>" << std::endl;
492  else if(clients_[i]->hasOther_Temp()) htmlFile << "<td bgcolor=aqua align=center>This monitor task has messages.</td>" << std::endl;
493  else htmlFile << "<td bgcolor=lime align=center>This monitor task has no problems</td>" << std::endl;
494  htmlFile << "</tr></table>" << std::endl;
495  }
496  }
497 
498  // Add call to reportSummary html output
499  if (summaryClient_)
500  {
501  summaryClient_->htmlOutput(htmlDir);
502  htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << std::endl;
503  htmlFile << "<td WIDTH=\"35%\"><a href=\"" << summaryClient_->name_ << ".html"<<"\">"<<summaryClient_->name_<<"</a></td>" << std::endl;
504  if(summaryClient_->hasErrors_Temp()) htmlFile << "<td bgcolor=red align=center>This monitor task has errors.</td>" << std::endl;
505  else if(summaryClient_->hasWarnings_Temp()) htmlFile << "<td bgcolor=yellow align=center>This monitor task has warnings.</td>" << std::endl;
506  else if(summaryClient_->hasOther_Temp()) htmlFile << "<td bgcolor=aqua align=center>This monitor task has messages.</td>" << std::endl;
507  else htmlFile << "<td bgcolor=lime align=center>This monitor task has no problems</td>" << std::endl;
508  htmlFile << "</tr></table>" << std::endl;
509  }
510 
511  htmlFile << "</ul>" << std::endl;
512 
513  // html page footer
514  htmlFile << "</body> " << std::endl;
515  htmlFile << "</html> " << std::endl;
516 
517  htmlFile.close();
518  if (debug_>0) std::cout << "HcalMonitorClient html output done..." << std::endl;
519 
520 } // void HcalMonitorClient::writeHtml()
521 
523 {
524  if (databasedir_.size()==0) return;
525  if (debug_>0) std::cout <<"<HcalMonitorClient::writeDBfile> Writing file for database"<<std::endl;
526 
527  std::map<HcalDetId, unsigned int> myquality; //map of quality flags as reported by each client
528  // Get status from all channels (we need to store all channels in case a bad channel suddenly becomes good)
530  clients_[i]->updateChannelStatus(myquality);
531 
532  if (debug_>0) std::cout <<"<HcalMonitorClient::writeChannelStatus()> myquality size = "<<myquality.size()<<std::endl;
533 
534  std::vector<DetId> mydetids = chanquality_->getAllChannels();
535  HcalChannelQuality* newChanQual = new HcalChannelQuality();
536 
537  for (unsigned int i=0;i<mydetids.size();++i)
538  {
539  if (mydetids[i].det()!=DetId::Hcal) continue; // not hcal
540 
541  HcalDetId id=mydetids[i];
542  // get original channel status item
543  const HcalChannelStatus* origstatus=chanquality_->getValues(mydetids[i]);
544  // make copy of status
545  HcalChannelStatus* mystatus=new HcalChannelStatus(origstatus->rawId(),origstatus->getValue());
546  // loop over myquality flags
547  if (myquality.find(id)!=myquality.end())
548  {
549 
550  // check dead cells
551  if ((myquality[id]>>HcalChannelStatus::HcalCellDead)&0x1)
553  else
555  // check hot cells
556  if ((myquality[id]>>HcalChannelStatus::HcalCellHot)&0x1)
558  else
560  } // if (myquality.find_...)
561  newChanQual->addValues(*mystatus);
562  } // for (unsigned int i=0;...)
563 
564  //Now dump out to text file
565  std::ostringstream file;
566  databasedir_=databasedir_+"/"; // add extra slash, just in case
567  //file <<databasedir_<<"HcalDQMstatus_"<<run_<<".txt";
568  file <<databasedir_<<"HcalDQMstatus.txt";
569  std::ofstream outStream(file.str().c_str());
570  outStream<<"### Run # "<<run_<<std::endl;
571  HcalDbASCIIIO::dumpObject (outStream, (*newChanQual));
572  return;
573 } // void HcalMonitorClient::writeChannelStatus()
574 
575 
577 {
578  const HcalQIEShape* shape_ = cond.getHcalShape(); // this one is generic
579 
580  double ADC_ped=0;
581  double ADC_width=0;
582  double fC_ped=0;
583  double fC_width=0;
584  double temp_ADC=0;
585  double temp_fC=0;
586 
587  int ieta=-9999;
588  int iphi=-9999;
589  HcalCalibrations calibs_;
590 
595 
596 
597  for (int subdet=1; subdet<=4;++subdet)
598  {
599  for (int depth=0;depth<4;++depth)
600  {
601  int etabins= ADC_PedestalFromDBByDepth->depth[depth]->getNbinsX();
602  int phibins = ADC_PedestalFromDBByDepth->depth[depth]->getNbinsY();
603  for (int eta=0;eta<etabins;++eta)
604  {
605  ieta=CalcIeta(subdet,eta,depth+1);
606  if (ieta==-9999) continue;
607  for (int phi=0;phi<phibins;++phi)
608  {
609  iphi=phi+1;
610  if (!validDetId((HcalSubdetector)(subdet), ieta, iphi, depth+1)) continue;
611  HcalDetId detid((HcalSubdetector)(subdet), ieta, iphi, depth+1);
612  ADC_ped=0;
613  ADC_width=0;
614  fC_ped=0;
615  fC_width=0;
616  calibs_= cond.getHcalCalibrations(detid);
617  const HcalPedestalWidth* pedw = cond.getPedestalWidth(detid);
618  const HcalQIECoder* channelCoder_ = cond.getHcalCoder(detid);
619 
620  // Loop over capIDs
621  for (unsigned int capid=0;capid<4;++capid)
622  {
623  // Still need to determine how to convert widths to ADC or fC
624  // calibs_.pedestal value is always in fC, according to Radek
625  temp_fC = calibs_.pedestal(capid);
626  fC_ped+= temp_fC;
627  // convert to ADC from fC
628  temp_ADC=channelCoder_->adc(*shape_,
629  (float)calibs_.pedestal(capid),
630  capid);
631  ADC_ped+=temp_ADC;
632  // Pedestals assumed to be read out in fC
633  temp_fC=pedw->getSigma(capid,capid);
634  fC_width+=temp_fC;
635  temp_ADC=pedw->getSigma(capid,capid)*pow(1.*channelCoder_->adc(*shape_,(float)calibs_.pedestal(capid),capid)/calibs_.pedestal(capid),2);
636  ADC_width+=temp_ADC;
637  }//capid loop
638 
639  // Pedestal values are average over four cap IDs
640  // widths are sqrt(SUM [sigma_ii^2])/4.
641  fC_ped/=4.;
642  ADC_ped/=4.;
643 
644  // Divide width by 2, or by four?
645  // Dividing by 2 gives subtracted results closer to zero -- estimate of variance?
646  fC_width=pow(fC_width,0.5)/2.;
647  ADC_width=pow(ADC_width,0.5)/2.;
648 
649  if (debug_>1)
650  {
651  std::cout <<"<HcalMonitorClient::PlotPedestalValues> HcalDet ID = "<<(HcalSubdetector)subdet<<": ("<<ieta<<", "<<iphi<<", "<<depth<<")"<<std::endl;
652  std::cout <<"\tADC pedestal = "<<ADC_ped<<" +/- "<<ADC_width<<std::endl;
653  std::cout <<"\tfC pedestal = "<<fC_ped<<" +/- "<<fC_width<<std::endl;
654  }
655  // Shift HF by -/+1 when filling eta-phi histograms
656  int zside=0;
657  if (subdet==4)
658  {
659  if (ieta<0) zside=-1;
660  else zside=1;
661  }
662  ADC_PedestalFromDBByDepth->depth[depth]->Fill(ieta+zside,iphi,ADC_ped);
663  ADC_WidthFromDBByDepth->depth[depth]->Fill(ieta+zside, iphi, ADC_width);
664  fC_PedestalFromDBByDepth->depth[depth]->Fill(ieta+zside,iphi,fC_ped);
665  fC_WidthFromDBByDepth->depth[depth]->Fill(ieta+zside, iphi, fC_width);
666  } // phi loop
667  } // eta loop
668  } //depth loop
669 
670  } // subdet loop
675 
676  // Center ADC pedestal values near 3 +/- 1
677  for (unsigned int i=0;i<ADC_PedestalFromDBByDepth->depth.size();++i)
678  {
679  ADC_PedestalFromDBByDepth->depth[i]->getTH2F()->SetMinimum(0);
680  if (ADC_PedestalFromDBByDepth->depth[i]->getTH2F()->GetMaximum()<6)
681  ADC_PedestalFromDBByDepth->depth[i]->getTH2F()->SetMaximum(6);
682  }
683 
684  for (unsigned int i=0;i<ADC_WidthFromDBByDepth->depth.size();++i)
685  {
686  ADC_WidthFromDBByDepth->depth[i]->getTH2F()->SetMinimum(0);
687  if (ADC_WidthFromDBByDepth->depth[i]->getTH2F()->GetMaximum()<2)
688  ADC_WidthFromDBByDepth->depth[i]->getTH2F()->SetMaximum(2);
689  }
690 
691 }
692 
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:43
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
list file
Definition: dbtoweb.py:253
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
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
T eta() const
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_
void getFriends(std::vector< HcalBaseDQClient * > clients)
std::vector< DetId > getAllChannels() const
HcalSubdetector
Definition: HcalAssistant.h:32
void beginRun()
BeginRun.
HcalSummaryClient * summaryClient_
int CalcIeta(int subdet, int eta, int depth)
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(EtaPhiHists &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:2198
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:41
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:237
const HcalQIEShape * getHcalShape() const
Definition: Run.h:31
bool validDetId(HcalSubdetector sd, int ies, int ip, int dp)
Definition: DDAxes.h:10