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