test
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  HcalBaseDQClient(myname, ps),
50  ZDCGoodLumi_(ps.getUntrackedParameter<std::vector<double> > ("ZDC_QIValueForGoodLS")),
51  ZDCsubdir_(ps.getUntrackedParameter<std::string>("ZDCsubdir", "ZDCMonitor/ZDCMonitor_Hcal/"))
52 {
53 
54  if (ZDCsubdir_.size()>0 && ZDCsubdir_.substr(ZDCsubdir_.size()-1,ZDCsubdir_.size())!="/")
55  ZDCsubdir_.append("/");
57 }
58 
59 
60 //--------------------------------------------------------
62 
63  if (debug_>0) std::cout << "ZDCMonitorClient: Exit ..." << std::endl;
64 }
65 
66 
67 //--------------------------------------------------------
69 
70  begin_run_ = true;
71  end_run_ = false;
72 
73  evt_=0;
74  jevt_=0;
75 }
76 
77 
78 //--------------------------------------------------------
80 
81  if( debug_>0 )
82  std::cout << "ZDCMonitorClient: endJob, ievt = " << ievt_ << std::endl;
83 
84  return;
85 }
86 
87 //--------------------------------------------------------
88 
90 {
91  if (debug_>0)
92  std::cout <<"<ZDCMonitorClient> Entered ZDCMonitorClient::analyze()"<<std::endl;
93  if(debug_>1) std::cout<<"\nZDC Monitor Client heartbeat...."<<std::endl;
94 
96  ZDCChannelSummary_= ib.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
98  for (int i=0;i<18;++i)
99  {
101  }
102  (ZDCChannelSummary_->getTH2F())->GetXaxis()->SetBinLabel(1,"ZDC+");
103  (ZDCChannelSummary_->getTH2F())->GetXaxis()->SetBinLabel(2,"ZDC-");
104  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(1,"EM1");
105  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(2,"EM2");
106  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(3,"EM3");
107  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(4,"EM4");
108  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(5,"EM5");
109  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(6,"HAD1");
110  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(7,"HAD2");
111  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(8,"HAD3");
112  (ZDCChannelSummary_->getTH2F())->GetYaxis()->SetBinLabel(9,"HAD4");
113  (ZDCChannelSummary_->getTH2F())->SetOption("textcolz");
114  (ZDCChannelSummary_->getTH2F())->SetMinimum(-1);
115  (ZDCChannelSummary_->getTH2F())->SetMaximum(1);
116 
117 
118 
119  ZDCReportSummary_= ib.book2D("ZDC_ReportSummary","Fraction of Good Lumis for either ZDC",2,0,2,1,0,1);
121  for (int i=0;i<3;++i)
122  {
124  }
125  (ZDCReportSummary_->getTH2F())->GetXaxis()->SetBinLabel(1,"ZDC+");
126  (ZDCReportSummary_->getTH2F())->GetXaxis()->SetBinLabel(2,"ZDC-");
127  (ZDCReportSummary_->getTH2F())->SetOption("textcolz");
128  (ZDCReportSummary_->getTH2F())->SetMinimum(-1);
129  (ZDCReportSummary_->getTH2F())->SetMaximum(1);
130 
131  ib.setCurrentFolder(subdir_+"Errors/HotChannel/");
132  ZDCHotChannelFraction_ = ib.book2D("ZDC_Hot_Channel_Fraction", "Hot Channel Rates in the ZDC Channels", 2, 0, 2, 9, 0, 9); //Hot channel checker for ZDC
134  for (int i=0;i<18;++i)
135  {
137  }
138  (ZDCHotChannelFraction_->getTH2F())->GetXaxis()->SetBinLabel(1,"ZDC+");
139  (ZDCHotChannelFraction_->getTH2F())->GetXaxis()->SetBinLabel(2,"ZDC-");
140  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(1,"EM1");
141  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(2,"EM2");
142  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(3,"EM3");
143  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(4,"EM4");
144  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(5,"EM5");
145  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(6,"HAD1");
146  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(7,"HAD2");
147  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(8,"HAD3");
148  (ZDCHotChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(9,"HAD4");
149  (ZDCHotChannelFraction_->getTH2F())->SetOption("textcolz");
150  (ZDCHotChannelFraction_->getTH2F())->SetMinimum(-1);
151  (ZDCHotChannelFraction_->getTH2F())->SetMaximum(1);
152 
153  ib.setCurrentFolder(subdir_ + "Errors/ColdChannel");
154  ZDCColdChannelFraction_=ib.book2D("ZDC_Cold_Channel_Fraction", "Cold Channel Rates in the ZDC Channels", 2, 0, 2,9, 0, 9); //Cold channel checker for ZDC
156  for (int i=0;i<18;++i)
157  {
159  }
160  (ZDCColdChannelFraction_->getTH2F())->GetXaxis()->SetBinLabel(1,"ZDC+");
161  (ZDCColdChannelFraction_->getTH2F())->GetXaxis()->SetBinLabel(2,"ZDC-");
162  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(1,"EM1");
163  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(2,"EM2");
164  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(3,"EM3");
165  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(4,"EM4");
166  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(5,"EM5");
167  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(6,"HAD1");
168  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(7,"HAD2");
169  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(8,"HAD3");
170  (ZDCColdChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(9,"HAD4");
171  (ZDCColdChannelFraction_->getTH2F())->SetOption("textcolz");
172  (ZDCColdChannelFraction_->getTH2F())->SetMinimum(-1);
173  (ZDCColdChannelFraction_->getTH2F())->SetMaximum(1);
174 
175 
176  ib.setCurrentFolder(subdir_+ "Errors/DeadChannel");
177  ZDCDeadChannelFraction_=ib.book2D("ZDC_Dead_Channel_Fraction","Dead Channel Rates in the ZDC Channels",2,0,2,9,0,9);
179  for (int i=0;i<18;++i)
180  {
182  }
183  (ZDCDeadChannelFraction_->getTH2F())->GetXaxis()->SetBinLabel(1,"ZDC+");
184  (ZDCDeadChannelFraction_->getTH2F())->GetXaxis()->SetBinLabel(2,"ZDC-");
185  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(1,"EM1");
186  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(2,"EM2");
187  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(3,"EM3");
188  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(4,"EM4");
189  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(5,"EM5");
190  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(6,"HAD1");
191  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(7,"HAD2");
192  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(8,"HAD3");
193  (ZDCDeadChannelFraction_->getTH2F())->GetYaxis()->SetBinLabel(9,"HAD4");
194  (ZDCDeadChannelFraction_->getTH2F())->SetOption("textcolz");
195  (ZDCDeadChannelFraction_->getTH2F())->SetMinimum(-1);
196  (ZDCDeadChannelFraction_->getTH2F())->SetMaximum(1);
197 
198  ib.setCurrentFolder(subdir_ + "Errors/Digis");
199  ZDCDigiErrorFraction_=ib.book2D("ZDC_Digi_Error_Fraction", "Digi Error Rates in the ZDC Channels", 2, 0, 2,9, 0, 9); //Hot channel checker for ZDC
201  for (int i=0;i<18;++i)
202  {
204  }
205  (ZDCDigiErrorFraction_->getTH2F())->GetXaxis()->SetBinLabel(2,"ZDC-");
206  (ZDCDigiErrorFraction_->getTH2F())->GetXaxis()->SetBinLabel(1,"EM1");
207  (ZDCDigiErrorFraction_->getTH2F())->GetYaxis()->SetBinLabel(2,"EM2");
208  (ZDCDigiErrorFraction_->getTH2F())->GetYaxis()->SetBinLabel(3,"EM3");
209  (ZDCDigiErrorFraction_->getTH2F())->GetYaxis()->SetBinLabel(4,"EM4");
210  (ZDCDigiErrorFraction_->getTH2F())->GetYaxis()->SetBinLabel(5,"EM5");
211  (ZDCDigiErrorFraction_->getTH2F())->GetYaxis()->SetBinLabel(6,"HAD1");
212  (ZDCDigiErrorFraction_->getTH2F())->GetYaxis()->SetBinLabel(7,"HAD2");
213  (ZDCDigiErrorFraction_->getTH2F())->GetYaxis()->SetBinLabel(8,"HAD3");
214  (ZDCDigiErrorFraction_->getTH2F())->GetYaxis()->SetBinLabel(9,"HAD4");
215  (ZDCDigiErrorFraction_->getTH2F())->SetOption("textcolz");
216  (ZDCDigiErrorFraction_->getTH2F())->SetMinimum(-1);
217  (ZDCDigiErrorFraction_->getTH2F())->SetMaximum(1);
218 
219  float ChannelRatio[18]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
220 
221  // booking
222 
223  // Make a rate plot, by first getting plots from tasks
224  MonitorElement* me;
225 
229 
230  me=ig.get(subdir_+"Errors/Digis/ZDC_Digi_Errors");
231 
232  TH2F* ZdcDigiErrors=0;
233  if (me!=0)
234  {
235  ZdcDigiErrors=HcalUtilsClient::getHisto<TH2F*>(me,false,0,0);
236  if (ZdcDigiErrors!=0)
237  {
238  int num_events_digis = ZdcDigiErrors->GetBinContent(-1,-1);
239  if(num_events_digis != 0)
240  {
241  for (int i=0;i<18;++i)
242  {
243  ZDCDigiErrorFraction_->setBinContent((i/9)+1,(i%9)+1,(ZdcDigiErrors->GetBinContent((i/9)+1,(i%9)+1)*1./num_events_digis));
244  }
245  }
246  }
247  }
248 
252 
253  // Now get Hot Channel plot, used normalized values (num hot/event) in ZDCHotChannelFraction_
254  me=ig.get(subdir_+"Errors/HotChannel/ZDC_Hot_Channel_Errors");
255  TH2F* ZdcHotChannel=0;
256  if (me!=0)
257  {
258  ZdcHotChannel=HcalUtilsClient::getHisto<TH2F*>(me,false,0,0);
259  if (ZdcHotChannel!=0)
260  {
261  int num_events_hot = ZdcHotChannel->GetBinContent(-1,-1);
262  if(num_events_hot!=0)
263  {
264  for (int i=0;i<18;++i)
265  {
266  ZDCHotChannelFraction_->setBinContent((i/9)+1,(i%9)+1,((ZdcHotChannel->GetBinContent((i/9)+1,(i%9)+1))*1./num_events_hot));
267  }
268  }
269  }
270  } // if (me!=0)
271 
275 
276  //Now get Cold Channel plot, used normalized values (num Cold/event) in ZDCColdChannelFraction_
277  me=ig.get(subdir_+"Errors/ColdChannel/ZDC_Cold_Channel_Errors");
278  TH2F* ZdcColdChannel=0;
279  if (me!=0)
280  {
281  ZdcColdChannel=HcalUtilsClient::getHisto<TH2F*>(me,false,0,0);
282  if ((ZdcColdChannel)!=0)
283  {
284  int num_events_cold = ZdcColdChannel->GetBinContent(-1,-1);
285  if(num_events_cold!=0)
286  {
287  for (int i=0;i<18;++i)
288  {
289  ZDCColdChannelFraction_->setBinContent((i/9)+1,(i%9)+1,((ZdcColdChannel->GetBinContent((i/9)+1,(i%9)+1))*1./num_events_cold));
290  }
291  }
292  }
293  }
294 
298 
299  //Now get Cold Channel plot, used normalized values (num Cold/event) in ZDCHotChannelFraction_
300  me=ig.get(subdir_+"Errors/DeadChannel/ZDC_Dead_Channel_Errors");
301  TH2F* ZdcDeadChannel=0;
302  if (me!=0)
303  {
304  ZdcDeadChannel=HcalUtilsClient::getHisto<TH2F*>(me,false,0,0);
305  if ((ZdcDeadChannel)!=0)
306  {
307  int num_events_dead = ZdcDeadChannel->GetBinContent(-1,-1);
308  if(num_events_dead!=0)
309  {
310  for (int i=0;i<18;++i)
311  {
312  ZDCDeadChannelFraction_->setBinContent((i/9)+1,(i%9)+1,(ZdcDeadChannel->GetBinContent((i/9)+1,(i%9)+1))*1./num_events_dead);
313  }
314  }
315  }
316  }
317 
318 
321  // This simply takes the total errors that each channel got (Cold,hot, digi error) sums them up from the
322  // totalchannelerrors plot and turns them into a rate. 1-errorrate be the number displayed. //
325 
326 
328  me=ig.get(subdir_+"Errors/ZDC_TotalChannelErrors");
329  TH2F* ZdcTotalErrors=0;
330  if (me!=0)
331  {
332  ZdcTotalErrors=HcalUtilsClient::getHisto<TH2F*>(me,false,0,0);
333  int num_events_errors = ZdcTotalErrors->GetBinContent(-1,-1);
334  if(num_events_errors!=0)
335  {
336  for (int i=0;i<18;++i)
337  {
338  ChannelRatio[i]=(ZdcTotalErrors->GetBinContent((i/9)+1,(i%9)+1))*1./num_events_errors;
339  ZDCChannelSummary_->setBinContent((i/9)+1,(i%9)+1,1-ChannelRatio[i]);
340  }
341  }
342  }
343 
344 
347  // This is a ratio of GoodLumis/TotalLumis. The determination of which is made by the Quality Index plots. //
350 
351  LumiCounter=0;
353  PZDC_LumiRatio=0.;
355  NZDC_LumiRatio=0.;
356  me=ig.get(subdir_+"EventsVsLS");
357  TH1F* EventsvsLs=0;
358  if (me!=0)
359  EventsvsLs=HcalUtilsClient::getHisto<TH1F*>(me,false,0,0);
360  me=ig.get(subdir_+"PZDC_QualityIndexVSLB");
361  TH1F* Pzdc_QI=0;
362  if (me!=0)
363  Pzdc_QI=HcalUtilsClient::getHisto<TH1F*>(me,false,0,0);
364  me=ig.get(subdir_+"NZDC_QualityIndexVSLB");
365  TH1F* Nzdc_QI=0;
366  if (me!=0)
367  Nzdc_QI=HcalUtilsClient::getHisto<TH1F*>(me,false,0,0);
368 
369  if(EventsvsLs!=0 && Pzdc_QI!=0 && Nzdc_QI!=0)
370  {
371  for (int i=1;i<=EventsvsLs->GetNbinsX();++i)
372  {
373  if (EventsvsLs->GetBinContent(i)==0)
374  continue;
375  LumiCounter+=1;
376 
377  if(Pzdc_QI!=0)
378  if(Pzdc_QI->GetBinContent(i)>ZDCGoodLumi_[0])
380 
381  if(Nzdc_QI!=0)
382  if(Nzdc_QI->GetBinContent(i)>ZDCGoodLumi_[1])
384 
387  }
388  }
389 
392 
393  return;
394 }
int i
Definition: DBlmapReader.cc:9
void setBinContent(int binx, double content)
set content of bin (1-D)
int ib
Definition: cuy.py:660
ZDCMonitorClient(std::string myname, const edm::ParameterSet &ps)
Constructors.
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:302
MonitorElement * ZDCColdChannelFraction_
MonitorElement * ZDCReportSummary_
void endJob(void) override
BeginJob.
MonitorElement * ZDCHotChannelFraction_
MonitorElement * ZDCChannelSummary_
MonitorElement * ZDCDigiErrorFraction_
virtual ~ZDCMonitorClient()
Destructor.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
virtual void analyze(DQMStore::IBooker &, DQMStore::IGetter &) override
Analyze.
std::string subdir_
std::string prefixME_
std::string ZDCsubdir_
std::vector< double > ZDCGoodLumi_
tuple cout
Definition: gather_cfg.py:121
MonitorElement * ZDCDeadChannelFraction_
TH2F * getTH2F(void) const
void beginRun() override
BeginRun.
void Reset(void)
reset ME (ie. contents, errors, etc)