CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ZDCMonitorClient.cc
Go to the documentation of this file.
6 
7 #include "TROOT.h"
8 #include "TTree.h"
9 #include "TGaxis.h"
10 #include "TH1F.h"
11 #include "TH2F.h"
12 #include "TFile.h"
13 
14 #include <memory>
15 #include <iostream>
16 #include <fstream>
17 #include <vector>
18 #include <string>
19 #include <sys/time.h>
20 
23 
25 // Use to hold/get channel status
30 
34 
42 
45 
46 
47 //--------------------------------------------------------
49  name_=myname;
50 
51  inputFile_ = ps.getUntrackedParameter<std::string>("inputFile","");
52  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
53  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
54  prescaleFactor_ = ps.getUntrackedParameter<int>("prescaleFactor", -1);
55  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
56  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
57  prefixME_.append("/");
58  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
59 
60  updateTime_ = ps.getUntrackedParameter<int>("UpdateTime",0);
61  baseHtmlDir_ = ps.getUntrackedParameter<std::string>("baseHtmlDir", "");
62  htmlUpdateTime_ = ps.getUntrackedParameter<int>("htmlUpdateTime", 0);
63  htmlFirstUpdate_ = ps.getUntrackedParameter<int>("htmlFirstUpdate",20);
64  databasedir_ = ps.getUntrackedParameter<std::string>("databaseDir","");
65  databaseUpdateTime_ = ps.getUntrackedParameter<int>("databaseUpdateTime",0);
66  databaseFirstUpdate_ = ps.getUntrackedParameter<int>("databaseFirstUpdate",10);
67 
68  saveByLumiSection_ = ps.getUntrackedParameter<bool>("saveByLumiSection",false);
69  Online_ = ps.getUntrackedParameter<bool>("online",false);
70 
71  subdir_ = ps.getUntrackedParameter<std::string>("ZDCFolder","ZDCMonitor_Hcal/"); // DeadCellMonitor_Hcal
72  if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
73  subdir_.append("/");
74  subdir_=prefixME_+subdir_;
75 
76  debug_ = ps.getUntrackedParameter<int>("debug",0);
77  ZDCGoodLumi_ = ps.getUntrackedParameter<std::vector<double> > ("ZDC_QIValueForGoodLS");
78 
79 }
80 
81 
82 //--------------------------------------------------------
84 
85  if (debug_>0) std::cout << "ZDCMonitorClient: Exit ..." << std::endl;
86 }
87 
88 
89 //--------------------------------------------------------
91 {
93  if (debug_>0)
94  {
95  std::cout <<"<ZDCMonitorClient::beginJob()> Displaying dqmStore directory structure:"<<std::endl;
97  }
98 }
99 
100 //--------------------------------------------------------
102 
103  begin_run_ = true;
104  end_run_ = false;
105 
106  evt_=0;
107  jevt_=0;
108  htmlcounter_=0;
109  /* if (!dqmStore_)
110  {
111  if (debug_>0) std::cout <<"<ZDCMonitorClient::beginRun> dqmStore does not exist!"<<std::endl;
112  return;
113  }*/
114  //subdir_="Hcal/";
115  dqmStore_->setCurrentFolder(subdir_); // what is Hcal/ZDCMonitor/EventInfoDUMMY folder
116 
117  // Add new histograms; remove those created in previous runs
118  // prefixMe = Hcal/
119 
120  ZDCChannelSummary_=dqmStore_->get(subdir_ + "ZDC_Channel_Summary");
122  ZDCChannelSummary_= dqmStore_->book2D("ZDC_Channel_Summary", "Fraction of Events where ZDC Channels had no Errors" , 2, 0, 2, 9, 0, 9); //This is the histo which will show the health of each ZDC Channel
123  for (int i=0;i<18;++i)
124  {
126  }
127  (ZDCChannelSummary_->getTH2F())->GetXaxis()->SetBinLabel(1,"ZDC+");
128  (ZDCChannelSummary_->getTH2F())->GetXaxis()->SetBinLabel(2,"ZDC-");
129  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(1,"EM1");
130  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(2,"EM2");
131  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(3,"EM3");
132  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(4,"EM4");
133  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(5,"EM5");
134  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(6,"HAD1");
135  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(7,"HAD2");
136  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(8,"HAD3");
137  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(9,"HAD4");
138  (ZDCChannelSummary_->getTH2F())->SetOption("textcolz");
139  (ZDCChannelSummary_->getTH2F())->SetMinimum(-1);
140  (ZDCChannelSummary_->getTH2F())->SetMaximum(1);
141 
142 
143 
144  ZDCReportSummary_ = dqmStore_->get(subdir_ + "ZDC_ReportSummary");
146  ZDCReportSummary_= dqmStore_->book2D("ZDC_ReportSummary","Fraction of Good Lumis for either ZDC",2,0,2,1,0,1);
147  for (int i=0;i<3;++i)
148  {
150  }
151  (ZDCReportSummary_->getTH2F())->GetXaxis()->SetBinLabel(1,"ZDC+");
152  (ZDCReportSummary_->getTH2F())->GetXaxis()->SetBinLabel(2,"ZDC-");
153  (ZDCReportSummary_->getTH2F())->SetOption("textcolz");
154  (ZDCReportSummary_->getTH2F())->SetMinimum(-1);
155  (ZDCReportSummary_->getTH2F())->SetMaximum(1);
156 
157  ZDCHotChannelFraction_ = dqmStore_->get(subdir_+"Errors/HotChannel/ZDC_Hot_Channel_Fraction");
159  dqmStore_->setCurrentFolder(subdir_ + "Errors/HotChannel");
160  ZDCHotChannelFraction_ = dqmStore_->book2D("ZDC_Hot_Channel_Fraction", "Hot Channel Rates in the ZDC Channels", 2, 0, 2, 9, 0, 9); //Hot channel checker for ZDC
161  for (int i=0;i<18;++i)
162  {
164  }
165  (ZDCHotChannelFraction_->getTH2F())->GetXaxis()->SetBinLabel(1,"ZDC+");
166  (ZDCHotChannelFraction_->getTH2F())->GetXaxis()->SetBinLabel(2,"ZDC-");
167  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(1,"EM1");
168  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(2,"EM2");
169  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(3,"EM3");
170  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(4,"EM4");
171  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(5,"EM5");
172  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(6,"HAD1");
173  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(7,"HAD2");
174  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(8,"HAD3");
175  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(9,"HAD4");
176  (ZDCHotChannelFraction_->getTH2F())->SetOption("textcolz");
177  (ZDCHotChannelFraction_->getTH2F())->SetMinimum(-1);
178  (ZDCHotChannelFraction_->getTH2F())->SetMaximum(1);
179 
180  ZDCColdChannelFraction_ = dqmStore_->get(subdir_ + "Errors/ColdChannel/ZDC_Cold_Channel_Fraction");
182  dqmStore_->setCurrentFolder(subdir_ + "Errors/ColdChannel");
183  ZDCColdChannelFraction_=dqmStore_->book2D("ZDC_Cold_Channel_Fraction", "Cold Channel Rates in the ZDC Channels", 2, 0, 2,9, 0, 9); //Cold channel checker for ZDC
184  for (int i=0;i<18;++i)
185  {
187  }
188  (ZDCColdChannelFraction_->getTH2F())->GetXaxis()->SetBinLabel(1,"ZDC+");
189  (ZDCColdChannelFraction_->getTH2F())->GetXaxis()->SetBinLabel(2,"ZDC-");
190  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(1,"EM1");
191  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(2,"EM2");
192  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(3,"EM3");
193  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(4,"EM4");
194  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(5,"EM5");
195  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(6,"HAD1");
196  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(7,"HAD2");
197  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(8,"HAD3");
198  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(9,"HAD4");
199  (ZDCColdChannelFraction_->getTH2F())->SetOption("textcolz");
200  (ZDCColdChannelFraction_->getTH2F())->SetMinimum(-1);
201  (ZDCColdChannelFraction_->getTH2F())->SetMaximum(1);
202 
203 
204  ZDCDeadChannelFraction_ = dqmStore_->get(subdir_ + "Errors/DeadChannel/ZDC_Dead_Channel_Fraction");
206  dqmStore_->setCurrentFolder(subdir_+ "Errors/DeadChannel");
207  ZDCDeadChannelFraction_=dqmStore_->book2D("ZDC_Dead_Channel_Fraction","Dead Channel Rates in the ZDC Channels",2,0,2,9,0,9);
208  for (int i=0;i<18;++i)
209  {
211  }
212  (ZDCDeadChannelFraction_->getTH2F())->GetXaxis()->SetBinLabel(1,"ZDC+");
213  (ZDCDeadChannelFraction_->getTH2F())->GetXaxis()->SetBinLabel(2,"ZDC-");
214  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(1,"EM1");
215  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(2,"EM2");
216  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(3,"EM3");
217  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(4,"EM4");
218  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(5,"EM5");
219  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(6,"HAD1");
220  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(7,"HAD2");
221  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(8,"HAD3");
222  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(9,"HAD4");
223  (ZDCDeadChannelFraction_->getTH2F())->SetOption("textcolz");
224  (ZDCDeadChannelFraction_->getTH2F())->SetMinimum(-1);
225  (ZDCDeadChannelFraction_->getTH2F())->SetMaximum(1);
226 
227  ZDCDigiErrorFraction_ = dqmStore_->get(subdir_ + "Errors/Digis/ZDC_Digi_Error_Fraction");
229  dqmStore_->setCurrentFolder(subdir_ + "Errors/Digis");
230  ZDCDigiErrorFraction_=dqmStore_->book2D("ZDC_Digi_Error_Fraction", "Digi Error Rates in the ZDC Channels", 2, 0, 2,9, 0, 9); //Hot channel checker for ZDC
231  for (int i=0;i<18;++i)
232  {
234  }
235  (ZDCDigiErrorFraction_->getTH2F())->GetXaxis()->SetBinLabel(2,"ZDC-");
236  (ZDCDigiErrorFraction_->getTH2F())->GetXaxis()->SetBinLabel(1,"EM1");
237  (ZDCDigiErrorFraction_->getTH2F())->GetYaxis()->SetBinLabel(2,"EM2");
238  (ZDCDigiErrorFraction_->getTH2F())->GetYaxis()->SetBinLabel(3,"EM3");
239  (ZDCDigiErrorFraction_->getTH2F())->GetYaxis()->SetBinLabel(4,"EM4");
240  (ZDCDigiErrorFraction_->getTH2F())->GetYaxis()->SetBinLabel(5,"EM5");
241  (ZDCDigiErrorFraction_->getTH2F())->GetYaxis()->SetBinLabel(6,"HAD1");
242  (ZDCDigiErrorFraction_->getTH2F())->GetYaxis()->SetBinLabel(7,"HAD2");
243  (ZDCDigiErrorFraction_->getTH2F())->GetYaxis()->SetBinLabel(8,"HAD3");
244  (ZDCDigiErrorFraction_->getTH2F())->GetYaxis()->SetBinLabel(9,"HAD4");
245  (ZDCDigiErrorFraction_->getTH2F())->SetOption("textcolz");
246  (ZDCDigiErrorFraction_->getTH2F())->SetMinimum(-1);
247  (ZDCDigiErrorFraction_->getTH2F())->SetMaximum(1);
248 }
249 
250 
251 //--------------------------------------------------------
253 
254  if( debug_>0 )
255  std::cout << "ZDCMonitorClient: endJob, ievt = " << ievt_ << std::endl;
256 
257  return;
258 }
259 
260 //--------------------------------------------------------
262 
265 
267 {
268  if (debug_>0)
269  std::cout <<"<ZDCMonitorClient> Entered ZDCMonitorClient::analyze()"<<std::endl;
270  if(debug_>1) std::cout<<"\nZDC Monitor Client heartbeat...."<<std::endl;
271 
272  float ChannelRatio[18]={0};
273  //dqmStore_->runQTests();
274 
275  // Make a rate plot, by first getting plots from tasks
276  MonitorElement* me;
277  std::string s;
278 
282 
283  s=subdir_+"Errors/Digis/ZDC_Digi_Errors"; // prefixME_ = "Hcal/"
284  me=dqmStore_->get(s.c_str());
285 
286  TH2F* ZdcDigiErrors=0;
287  if (me!=0)
288  {
289  ZdcDigiErrors=HcalUtilsClient::getHisto<TH2F*>(me,false,0,0);
290  if (ZdcDigiErrors!=0)
291  {
292  int num_events_digis = ZdcDigiErrors->GetBinContent(-1,-1);
293  if(num_events_digis != 0)
294  {
295  for (int i=0;i<18;++i)
296  {
297  ZDCDigiErrorFraction_->setBinContent((i/9)+1,(i%9)+1,(ZdcDigiErrors->GetBinContent((i/9)+1,(i%9)+1)*1./num_events_digis));
298  }
299  }
300  }
301  }
302 
306 
307  // Now get Hot Channel plot, used normalized values (num hot/event) in ZDCHotChannelFraction_
308  s=subdir_+"Errors/HotChannel/ZDC_Hot_Channel_Errors";
309  me=dqmStore_->get(s.c_str());
310  TH2F* ZdcHotChannel=0;
311  if (me!=0)
312  {
313  ZdcHotChannel=HcalUtilsClient::getHisto<TH2F*>(me,false,0,0);
314  if (ZdcHotChannel!=0)
315  {
316  int num_events_hot = ZdcHotChannel->GetBinContent(-1,-1);
317  if(num_events_hot!=0)
318  {
319  for (int i=0;i<18;++i)
320  {
321  ZDCHotChannelFraction_->setBinContent((i/9)+1,(i%9)+1,((ZdcHotChannel->GetBinContent((i/9)+1,(i%9)+1))*1./num_events_hot));
322  }
323  }
324  }
325  } // if (me!=0)
326 
330 
331  //Now get Cold Channel plot, used normalized values (num Cold/event) in ZDCColdChannelFraction_
332  s=subdir_+"Errors/ColdChannel/ZDC_Cold_Channel_Errors";
333  me=dqmStore_->get(s.c_str());
334  TH2F* ZdcColdChannel=0;
335  if (me!=0)
336  {
337  ZdcColdChannel=HcalUtilsClient::getHisto<TH2F*>(me,false,0,0);
338  if ((ZdcColdChannel)!=0)
339  {
340  int num_events_cold = ZdcColdChannel->GetBinContent(-1,-1);
341  if(num_events_cold!=0)
342  {
343  for (int i=0;i<18;++i)
344  {
345  ZDCColdChannelFraction_->setBinContent((i/9)+1,(i%9)+1,((ZdcColdChannel->GetBinContent((i/9)+1,(i%9)+1))*1./num_events_cold));
346  }
347  }
348  }
349  }
350 
354 
355  //Now get Cold Channel plot, used normalized values (num Cold/event) in ZDCHotChannelFraction_
356  s=subdir_+"Errors/DeadChannel/ZDC_Dead_Channel_Errors";
357  me=dqmStore_->get(s.c_str());
358  TH2F* ZdcDeadChannel=0;
359  if (me!=0)
360  {
361  ZdcDeadChannel=HcalUtilsClient::getHisto<TH2F*>(me,false,0,0);
362  if ((ZdcDeadChannel)!=0)
363  {
364  int num_events_dead = ZdcDeadChannel->GetBinContent(-1,-1);
365  if(num_events_dead!=0)
366  {
367  for (int i=0;i<18;++i)
368  {
369  ZDCDeadChannelFraction_->setBinContent((i/9)+1,(i%9)+1,(ZdcDeadChannel->GetBinContent((i/9)+1,(i%9)+1))*1./num_events_dead);
370  }
371  }
372  }
373  }
374 
375 
376 
377 
378 
381  // This simply takes the total errors that each channel got (Cold,hot, digi error) sums them up from the
382  // totalchannelerrors plot and turns them into a rate. 1-errorrate be the number displayed. //
385 
386 
388  s=subdir_+"Errors/ZDC_TotalChannelErrors";
389  me=dqmStore_->get(s.c_str());
390  TH2F* ZdcTotalErrors=0;
391  if (me!=0)
392  {
393  ZdcTotalErrors=HcalUtilsClient::getHisto<TH2F*>(me,false,0,0);
394  int num_events_errors = ZdcTotalErrors->GetBinContent(-1,-1);
395  if(num_events_errors!=0)
396  {
397  for (int i=0;i<18;++i)
398  {
399  ChannelRatio[i]=(ZdcTotalErrors->GetBinContent((i/9)+1,(i%9)+1))*1./num_events_errors;
400  ZDCChannelSummary_->setBinContent((i/9)+1,(i%9)+1,1-ChannelRatio[i]);
401  }
402  }
403  }
404 
405 
408  // This is a ratio of GoodLumis/TotalLumis. The determination of which is made by the Quality Index plots. //
411 
412  LumiCounter=0;
414  PZDC_LumiRatio=0.;
416  NZDC_LumiRatio=0.;
417  s=subdir_+"EventsVsLS";
418  me=dqmStore_->get(s.c_str());
419  TH1F* EventsvsLs=0;
420  if (me!=0)
421  EventsvsLs=HcalUtilsClient::getHisto<TH1F*>(me,false,0,0);
422  s=subdir_+"PZDC_QualityIndexVSLB";
423  me=dqmStore_->get(s.c_str());
424  TH1F* Pzdc_QI=0;
425  if (me!=0)
426  Pzdc_QI=HcalUtilsClient::getHisto<TH1F*>(me,false,0,0);
427  s=subdir_+"NZDC_QualityIndexVSLB";
428  me=dqmStore_->get(s.c_str());
429  TH1F* Nzdc_QI=0;
430  if (me!=0)
431  Nzdc_QI=HcalUtilsClient::getHisto<TH1F*>(me,false,0,0);
432 
433  if(EventsvsLs!=0 && Pzdc_QI!=0 && Nzdc_QI!=0)
434  {
435  for (int i=1;i<=EventsvsLs->GetNbinsX();++i)
436  {
437  if (EventsvsLs->GetBinContent(i)==0)
438  continue;
439  LumiCounter+=1;
440 
441  if(Pzdc_QI!=0)
442  if(Pzdc_QI->GetBinContent(i)>ZDCGoodLumi_[0])
444 
445  if(Nzdc_QI!=0)
446  if(Nzdc_QI->GetBinContent(i)>ZDCGoodLumi_[1])
448 
451  }
452  }
453 
456 
457  return;
458 }
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
void setBinContent(int binx, double content)
set content of bin (1-D)
void endRun()
EndRun.
std::string inputFile_
void endJob(void)
EndJob.
ZDCMonitorClient(std::string myname, const edm::ParameterSet &ps)
Constructors.
MonitorElement * ZDCColdChannelFraction_
MonitorElement * ZDCReportSummary_
void cleanup(void)
Cleanup.
MonitorElement * ZDCHotChannelFraction_
std::string prefixME_
void setup(void)
Setup.
void removeElement(const std::string &name)
Definition: DQMStore.cc:2572
MonitorElement * ZDCChannelSummary_
void analyze(void)
Analyze.
void beginJob()
BeginJob.
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1468
MonitorElement * ZDCDigiErrorFraction_
std::string databasedir_
virtual ~ZDCMonitorClient()
Destructor.
std::string baseHtmlDir_
void beginRun()
BeginRun.
std::vector< double > ZDCGoodLumi_
tuple cout
Definition: gather_cfg.py:121
MonitorElement * ZDCDeadChannelFraction_
void showDirStructure(void) const
Definition: DQMStore.cc:2761
TH2F * getTH2F(void) const
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:845
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429