Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CemcMonDraw.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CemcMonDraw.cc
1 #include "CemcMonDraw.h"
2 
3 #include <onlmon/OnlMonClient.h>
4 
5 #include <TAxis.h> // for TAxis
6 #include <TCanvas.h>
7 #include <TGraphErrors.h>
8 #include <TH1.h>
9 #include <TH2.h>
10 #include <TH2D.h>
11 #include <TPad.h>
12 #include <TROOT.h>
13 #include <TSystem.h>
14 #include <TText.h>
15 #include <TStyle.h>
16 #include <TLine.h>
17 #include <TPaveText.h>
18 #include <TLegend.h>
19 #include <TProfile.h>
20 
21 #include <cstring> // for memset
22 #include <ctime>
23 #include <fstream>
24 #include <iostream> // for operator<<, basic_ostream, basic_os...
25 #include <sstream>
26 #include <vector> // for vector
27 
29 : OnlMonDraw(name)
30 {
31 
32  return;
33 }
34 
36 {
37  std::cout << "initializing" << std::endl;
38 
39  cemcStyle = new TStyle("cemcStyle","cemcStyle");
40 
41  Int_t font=42; // Helvetica
42  cemcStyle->SetLabelFont(font,"x");
43  cemcStyle->SetTitleFont(font,"x");
44  cemcStyle->SetLabelFont(font,"y");
45  cemcStyle->SetTitleFont(font,"y");
46  cemcStyle->SetLabelFont(font,"z");
47  cemcStyle->SetTitleFont(font,"z");
48  cemcStyle->SetOptStat(0);
49  cemcStyle->SetPadTickX(1);
50  cemcStyle->SetPadTickY(1);
51 
52  gROOT->SetStyle("cemcStyle");
53  gROOT->ForceStyle();
54 
55  return 0;
56 }
57 
58 
60 {
62  int xsize = cl->GetDisplaySizeX();
63  int ysize = cl->GetDisplaySizeY();
64  if (name == "CemcMon1")
65  {
66  // xpos (-1) negative: do not draw menu bar
67  TC[0] = new TCanvas(name.c_str(), "CemcMon Tower Hits", xsize/3 , 0, xsize/3, ysize*0.9);
68  // root is pathetic, whenever a new TCanvas is created root piles up
69  // 6kb worth of X11 events which need to be cleared with
70  // gSystem->ProcessEvents(), otherwise your process will grow and
71  // grow and grow but will not show a definitely lost memory leak
72  gSystem->ProcessEvents();
73  Pad[0] = new TPad("cemcpad0","hit map",0.,0.2,1.,1.);
74  Pad[0]->Draw();
75  // this one is used to plot the run number on the canvas
76  transparent[0] = new TPad("transparent0", "this does not show", 0, 0, 1, 1);
77  transparent[0]->SetFillStyle(4000);
78  transparent[0]->Draw();
79 
80  // warning
81  warning[0] = new TPad("warning0", "hot tower warnings", 0, 0, 1, 0.2);
82  warning[0]->SetFillStyle(4000);
83  warning[0]->Draw();
84  TC[0]->SetEditable(0);
85  }
86  else if (name == "CemcMon2")
87  {
88  // xpos negative: do not draw menu bar
89  TC[1] = new TCanvas(name.c_str(), "CemcMon2 Packet Information", 2*xsize /3, 0,2*xsize / 3, ysize*0.9);
90  gSystem->ProcessEvents();
91  Pad[1] = new TPad("cemcpad1", "packet event check", 0.0, 0.6, 1.0/2, 0.95, 0);
92  Pad[2] = new TPad("cemcpad2", "packet size", 0.0, 0.3, 1.0/2, 0.6, 0);
93  Pad[3] = new TPad("cemcpad3", "packet channels", 0.0, 0.0, 1.0/2, 0.3, 0);
94  Pad[1]->Draw();
95  Pad[2]->Draw();
96  Pad[3]->Draw();
97  // this one is used to plot the run number on the canvas
98  transparent[1] = new TPad("transparent1", "this does not show", 0, 0, 1., 1);
99  transparent[1]->SetFillStyle(4000);
100  transparent[1]->Draw();
101 
102  //packet warnings
103  warning[1] = new TPad("warning1","packet warnings",0.5,0,1,1);
104  warning[1] -> SetFillStyle(4000);
105  warning[1] -> Draw();
106  TC[1]->SetEditable(0);
107  }
108  else if (name == "CemcMon3")
109  {
110  TC[2] = new TCanvas(name.c_str(), "CemcMon Waveform Processing", xsize/3 , 0, xsize/3, ysize*0.9);
111  gSystem->ProcessEvents();
112  Pad[4] = new TPad("cemcpad4", "who needs this?", 0.0, 0.6, 1.0, 0.95, 0);
113  Pad[5] = new TPad("cemcpad5", "who needs this?", 0.0, 0.3, 1.0, 0.6, 0);
114  Pad[6] = new TPad("cemcpad6", "who needs this?", 0.0, 0.0, 1.0, 0.3, 0);
115  Pad[4]->Draw();
116  Pad[5]->Draw();
117  Pad[6]->Draw();
118  // this one is used to plot the run number on the canvas
119  transparent[2] = new TPad("transparent3", "this does not show", 0, 0, 1, 1);
120  transparent[2]->SetFillStyle(4000);
121  transparent[2]->Draw();
122  TC[2]->SetEditable(0);
123  }
124  else if (name == "CemcMon4")
125  {
126  TC[3] = new TCanvas(name.c_str(), "CemcMon Waveform Processing Expert", xsize / 3, 0, xsize / 3, ysize*0.9);
127  gSystem->ProcessEvents();
128  Pad[7] = new TPad("cemcpad7", "who needs this?", 0.0, 0.6, 1.0, 0.95, 0);
129  Pad[8] = new TPad("cemcpad8", "who needs this?", 0.0, 0.3, 1.0, 0.6, 0);
130  Pad[9] = new TPad("cemcpad9", "who needs this?", 0.0, 0.0, 1.0, 0.3, 0);
131  Pad[7]->Draw();
132  Pad[8]->Draw();
133  Pad[9]->Draw();
134  // this one is used to plot the run number on the canvas
135  transparent[3] = new TPad("transparent3", "this does not show", 0, 0, 1, 1);
136  transparent[3]->SetFillStyle(4000);
137  transparent[3]->Draw();
138  TC[3]->SetEditable(0);
139  }
140  return 0;
141 }
142 
143 
144 
146 {
147  int iret = 0;
148  int idraw = 0;
149  if (what == "ALL" || what == "FIRST")
150  {
151  iret += DrawFirst(what);
152  idraw++;
153  }
154  if (what == "ALL" || what == "SECOND")
155  {
156  iret += DrawSecond(what);
157  idraw++;
158  }
159  if (what == "ALL" || what == "THIRD")
160  {
161  iret += DrawThird(what);
162  idraw++;
163  }
164  if (what == "ALL" || what == "FOURTH")
165  {
166  iret += DrawFourth(what);
167  idraw++;
168  }
169  if (!idraw)
170  {
171  std::cout << __PRETTY_FUNCTION__ << " Unimplemented Drawing option: " << what << std::endl;
172  iret = -1;
173  }
174  return iret;
175 }
176 
177 
178 
179 int CemcMonDraw::DrawFirst(const std::string & /* what */)
180 {
182  //watch the absolute insanity as we merge all these
183  //histograms from across seven different machines
184  TH2* hist1[nSEBs];
185  const int nHists = 4;
186  int start[nHists];
187  start[0] = -1;
188  for(int i = 0; i < nSEBs; i++)
189  {
190  hist1[i] = (TH2*)cl->getHisto(Form("CEMCMON_%d",i),"h2_cemc_rm");
191  if(hist1[i] && start[0] == -1) start[0] = i;
192  if(start[0] > -1 && hist1[i])
193  {
194  hist1[i] -> SetName(Form("h2_cemc_rm_%d",i));
195  if(i != start[0])hist1[start[0]] -> Add(hist1[i],1);
196  }
197  }
198 
199 
200  TH2* h2_cemc_mean[nSEBs];
201  start[1] = -1;
202  for(int i = 0; i < nSEBs; i++)
203  {
204  h2_cemc_mean[i] = (TH2*)cl->getHisto(Form("CEMCMON_%d",i),"h2_cemc_mean");
205  if( h2_cemc_mean[i] && start[1] == -1) start[1] = i;
206  if(start[1] > -1 && h2_cemc_mean[i])
207  {
208  h2_cemc_mean[i] -> SetName(Form("h2_cemc_mean_%d",i));
209  if(i != start[1])h2_cemc_mean[start[1]] -> Add(h2_cemc_mean[i],1);
210  }
211  }
212 
213  TH1* h_event[nSEBs];
214  TH1* h_eventSource[nSEBs];
215  start[2] = -1;
216  float maxEvent = 1;
217  for(int i = 0; i < nSEBs; i++)
218  {
219  h_eventSource[i] = (TH1*)cl->getHisto(Form("CEMCMON_%d",i),"h1_event");
220  if(h_eventSource[i] && start[2] == -1) start[2] = i;
221  if(start[2] > -1 && h_eventSource[i])
222  {
223  h_event[i] = (TH1*)h_eventSource[i] -> Clone();
224 
225  h_event[i] -> SetName(Form("h1_event_%d",i));
226  if(/*i != start[2]*/h_event[i] -> GetEntries() > maxEvent)
227  {
228  //h_event[start[2]] -> Add(h_event[i],1);
229  maxEvent = h_event[i] -> GetEntries();
230  }
231  }
232  }
233 
234  if (start[0] < 0)
235  {
237  TC[0]->SetEditable(0);
238  return -1;
239  }
240 
241  //h_event[start[2]] -> Scale(1./divisor);
242 
243  TH1* adcCount[nSEBs];
244  start[3] = -1;
245  for(int i = 0; i < nSEBs; i++)
246  {
247  adcCount[i] = (TH1*)cl->getHisto(Form("CEMCMON_%i",i),"h1_cemc_adc");
248 
249  if(adcCount[i] && start[3] == -1) start[3] = i;
250  if(start[3] > -1 && adcCount[i])
251  {
252  adcCount[i] -> SetName(Form("h1_cemc_adc_%d",i));
253  if(i != start[3])adcCount[start[3]] -> Add(adcCount[i],1);
254  }
255  }
256 
257  if (!gROOT->FindObject("CemcMon1"))
258  {
259  MakeCanvas("CemcMon1");
260  }
261 
262 
263  if(maxEvent > 0)
264  {
265 
266  if(maxEvent > templateDepth)h2_cemc_mean[start[1]]->Scale(1./templateDepth);
267  else h2_cemc_mean[start[1]]->Scale(1./maxEvent);
268 
269 
270  //hist1[start[0]] -> Divide(h2_cemc_mean[start[1]]);
271  //hist1[start[0]] -> Scale(1./hist1[start[0]] -> GetMean());
272  //hist1[start[0]] -> Scale(1/10.);
273  if(adcCount[start[3]]->GetMean())h2_cemc_mean[start[1]]->Scale(1./adcCount[start[3]]->GetMean());
274 
275  if(adcCount[start[3]]->GetMean())hist1[start[0]] -> Scale(1./adcCount[start[3]]->GetMean());
276 
277  for(int i = 0; i < nTowersEta; i++)
278  {
279  for(int j = 0; j < nTowersPhi; j++)
280  {
281  if(i < 8) continue;
282  if(h2_cemc_mean[start[1]]-> GetBinContent(i+1, j+1) < 0.75 && hist1[start[0]] -> GetBinContent(i+1, j+1) < 0.75) hist1[start[0]]->SetBinContent(i+1, j+1, h2_cemc_mean[start[1]] -> GetBinContent(i+1, j+1));
283  else hist1[start[0]] -> SetBinContent(i+1, j+1, hist1[start[0]]->GetBinContent(i+1,j+1)/h2_cemc_mean[start[1]]->GetBinContent(i+1,j+1));
284  }
285  }
286  }
287  else
288  {
289  for(int i = 0; i < nTowersEta; i++)
290  {
291  for(int j = 0; j < nTowersPhi; j++)
292  {
293  if(i < 8) continue;
294 
295  else hist1[start[0]]->SetBinContent(i+1, j+1, 0);
296  }
297  }
298  }
299  //hist1 = (TH2D*)hist1 -> Divide(h2_cemc_mean);
300  //TH1 *temp = (TH1*)h2_cemc_mean -> Clone();
301  //temp -> GetXaxis() -> SetRangeUser(8,temp -> GetNbinsX());//accounts for the fact that we're missing
302  //adc boards on the south side.
303 
304 
305 
306 
307  TC[0]->SetEditable(1);
308  TC[0]->Clear("D");
309  Pad[0]->cd();
310 
311  hist1[start[0]]->GetXaxis()->SetTitle("eta index");
312  hist1[start[0]]->GetYaxis()->SetTitle("phi index");
313  hist1[start[0]]->GetZaxis()->SetTitle("Tower Running Mean/ Histogram Running Mean");
314  hist1[start[0]]->GetXaxis()->CenterTitle();
315  hist1[start[0]]->GetYaxis()->CenterTitle();
316  hist1[start[0]]->GetZaxis()->CenterTitle();
317  hist1[start[0]]->GetXaxis()->SetNdivisions(12,kFALSE);
318  hist1[start[0]]->GetYaxis()->SetNdivisions(32,kFALSE);
319 
320  float tsize = 0.03;
321  hist1[start[0]]->GetXaxis()->SetLabelSize(tsize);
322  hist1[start[0]]->GetYaxis()->SetLabelSize(tsize);
323  hist1[start[0]]->GetYaxis()->SetTitleOffset(1.4);
324  hist1[start[0]]->GetZaxis()->SetLabelSize(tsize);
325  hist1[start[0]]->GetXaxis()->SetTitleSize(tsize);
326  hist1[start[0]]->GetYaxis()->SetTitleSize(tsize);
327  hist1[start[0]]->GetXaxis()->SetTickLength(0.02);
328 
329  //hist1->GetZaxis()->SetRangeUser(0,2);
330 
331  TLine *line_sector[32];
332  for(int i_line=0;i_line<32;i_line++)
333  {
334  line_sector[i_line] = new TLine(0,(i_line+1)*8,96,(i_line+1)*8);
335  line_sector[i_line]->SetLineColor(1);
336  line_sector[i_line]->SetLineWidth(1);
337  line_sector[i_line]->SetLineStyle(1);
338  }
339 
340 
341  const int numVertDiv = 12;
342  int dEI = 96/numVertDiv;
343  TLine *l_board[numVertDiv-1];
344  for(int il=1; il<numVertDiv; il++){
345  l_board[il-1] = new TLine(dEI*il,0,dEI*il,256);
346  l_board[il-1]->SetLineColor(1);
347  l_board[il-1]->SetLineWidth(1);
348  l_board[il-1]->SetLineStyle(1);
349  if(il==6) l_board[il-1]->SetLineWidth(2);
350  }
351 
352  gPad->SetTopMargin(0.08);
353  gPad->SetBottomMargin(0.07);
354  gPad->SetLeftMargin(0.08);
355  gPad->SetRightMargin(0.12);
356 
357 
358 
359  // modify palette to black, green, and red
360  Int_t palette[3] = {kGray+2,8,2};
361  cemcStyle->SetPalette(3,palette);
362  gROOT->SetStyle("cemcStyle");
363  gROOT->ForceStyle();
364  gStyle->SetPalette(3,palette);
365  double_t levels[4] = {0,0.75,1.25,2};
366  hist1[start[0]] -> GetZaxis() -> SetRangeUser(0,2);
367  hist1[start[0]] ->SetContour(4,levels);
368  gStyle -> SetOptStat(0);
369  hist1[start[0]]->DrawCopy("colz");
370  //h2_cemc_mean[start[1]]->DrawCopy("colz");
371  for(int i_line=0;i_line<32;i_line++) line_sector[i_line]->Draw();
372  for(int il=0; il<numVertDiv-1; il++) l_board[il]->Draw();
373 
374  FindHotTower(warning[0],hist1[start[0]]);
375  TText PrintRun;
376  PrintRun.SetTextFont(62);
377  PrintRun.SetTextSize(0.04);
378  PrintRun.SetNDC(); // set to normalized coordinates
379  PrintRun.SetTextAlign(23); // center/top alignment
380  std::ostringstream runnostream;
381  std::ostringstream runnostream2;
382  std::string runstring;
383  time_t evttime = cl->EventTime("CURRENT");
384  // fill run number and event time into string
385  runnostream << "Running mean of Tower Hits Normalized by All Towers " ;
386  runnostream2 << "Run " << cl->RunNumber() << ", Time: " << ctime(&evttime);
387  transparent[0]->cd();
388  runstring = runnostream.str();
389  PrintRun.DrawText(0.5, 0.99, runstring.c_str());
390  runstring = runnostream2.str();
391  PrintRun.DrawText(0.5, 0.966, runstring.c_str());
392 
393  TC[0]->Update();
394  TC[0]->Show();
395  TC[0]->SetEditable(0);
396  if(save)TC[0] -> SaveAs("plots/towerHits.pdf");
397  return 0;
398 }
399 
400 
401 
402 int CemcMonDraw::DrawSecond(const std::string & /* what */)
403 {
404 
406  gStyle -> SetOptStat(0);
407  TH1* h_event[nSEBs];
408  TH1* h_eventSource[nSEBs];
409  int start[4];
410  start[0] = -1;
411  float maxEvent = -1;
412  for(int i = 0; i < nSEBs; i++)
413  {
414  h_eventSource[i] = (TH1*) cl->getHisto(Form("CEMCMON_%d",i),"h1_event");
415  if(h_eventSource[i] && start[0] == -1) start[0] = i;
416  if(start[0] > -1 && h_eventSource[i])
417  {
418  h_event[i] = (TH1*)h_eventSource[i] -> Clone();
419  h_event[i] -> SetName(Form("h1_event_%d",i));
420  if(/*i != start[0] &&*/ h_event[i] -> GetEntries() > maxEvent)
421  {
422  //h_event[start[0]] -> Add(h_event[i],1);
423  maxEvent = h_event[i] -> GetEntries();
424  }
425  }
426  }
427 
428  TH1* h1_packet_number[nSEBs];
429  start[1] = -1;
430  for(int i = 0; i < nSEBs; i++)
431  {
432  h1_packet_number[i] = (TH1*) cl->getHisto(Form("CEMCMON_%d",i),"h1_packet_number");
433  if(h1_packet_number[i] && start[1] == -1) start[1] = i;
434  if(start[1] > -1 && h1_packet_number[i])
435  {
436  h1_packet_number[i] -> SetName(Form("h1_papcket_number_%d",i));
437  if(i != start[1])h1_packet_number[start[1]] -> Add(h1_packet_number[i],1);
438  }
439  }
440 
441  TH1* h1_packet_length[nSEBs];
442  start[2] = -1;
443  for(int i = 0; i < nSEBs; i++)
444  {
445  h1_packet_length[i] = (TH1*) cl->getHisto(Form("CEMCMON_%d",i),"h1_packet_length");
446  if(h1_packet_length[i] && start[2] == -1) start[2] = i;
447  if(start[2] > -1 && h1_packet_length[i])
448  {
449  h1_packet_length[i] -> SetName(Form("h1_papcket_length_%d",i));
450  if(i != start[2])h1_packet_length[start[2]] -> Add(h1_packet_length[i],1);
451  }
452  }
453 
454 
455  TH1* h1_packet_chans[nSEBs];
456  start[3] = -1;
457  for(int i = 0; i < nSEBs; i++)
458  {
459  h1_packet_chans[i] = (TH1*) cl->getHisto(Form("CEMCMON_%d",i),"h1_packet_chans");
460  if(h1_packet_chans[i] && start[3] == -1) start[3] = i;
461  if(start[3] > -1 && h1_packet_chans[i])
462  {
463  h1_packet_chans[i] -> SetName(Form("h1_papcket_chans_%d",i));
464  if(i != start[3])h1_packet_chans[start[3]] -> Add(h1_packet_chans[i],1);
465  }
466  }
467 
468  if (start[0] < 0 || start[1] < 0 || start[2] < 0)
469  {
471  TC[1]->SetEditable(0);
472  return -1;
473  }
474 
475  //h_event[start[0]] -> Scale(1./divisor);
476 
477  if(maxEvent > 0)
478  {
479  // h1_packet_number[start[1]] -> Scale(1./h_event[start[0]] -> GetBinContent(1));
480  // h1_packet_length[start[2]] -> Scale(1./h_event[start[0]] -> GetBinContent(1));
481  // h1_packet_chans[start[3]] -> Scale(1./h_event[start[0]] -> GetBinContent(1));
482  h1_packet_number[start[1]] -> Scale(1./maxEvent);
483  h1_packet_length[start[2]] -> Scale(1./maxEvent);
484  h1_packet_chans[start[3]] -> Scale(1./maxEvent);
485  }
486 
487  if (!gROOT->FindObject("CemcMon2"))
488  {
489  MakeCanvas("CemcMon2");
490  }
491 
492  TC[1]->SetEditable(1);
493  TC[1]->Clear("D");
494 
495  TLine *one = new TLine(6000.5,1,6128.5,1);
496  one -> SetLineStyle(7);
497 
498  TLine *goodSize = new TLine(6000.5,5981,6128.5,5981);
499  goodSize -> SetLineStyle(7);
500 
501  TLine *goodChans = new TLine(6000.5,192,6128.5,192);
502  goodChans -> SetLineStyle(7);
503 
504  float param = 0.95;
505  //float param = 0.99;
506 
507  TLegend *leg = new TLegend(0.3,0.70,0.95,0.90);
508  leg -> SetFillStyle(0);
509  leg -> SetBorderSize(0);
510 
511  TLine *warnLineOne = new TLine(6000.5,param*1,6128.5,param*1);
512  warnLineOne -> SetLineStyle(7);
513  warnLineOne -> SetLineColor(2);
514 
515  leg -> AddEntry(warnLineOne,Form("%g%% Threshold",param*100),"l");
516 
517  TLine *warnLineOneS = new TLine(6000.5,param*1,6128.5,param*1);
518  warnLineOneS -> SetLineStyle(10);
519  warnLineOneS -> SetLineColor(2);
520 
521  leg -> AddEntry(warnLineOneS,Form("%g%% Threshold, High Eta, South",100*param),"l");
522 
523  TLine *warnLineSize = new TLine(6000.5,param*5981.,6128.5,param*5981.);
524  warnLineSize -> SetLineStyle(7);
525  warnLineSize -> SetLineColor(2);
526 
527  TLine *warnLineSizeS = new TLine(6000.5,param*3991.,6128.5,param*3991.);
528  warnLineSizeS -> SetLineStyle(10);
529  warnLineSizeS -> SetLineColor(2);
530 
531  TLine *warnLineChans = new TLine(6000.5,param*192.,6128.5,param*192.);
532  warnLineChans -> SetLineStyle(7);
533  warnLineChans -> SetLineColor(2);
534 
535  TLine *warnLineChansS = new TLine(6000.5,param*128.,6128.5,param*128.);
536  warnLineChansS -> SetLineStyle(10);
537  warnLineChansS -> SetLineColor(2);
538 
539  Pad[1]->cd();
540  float tsize = 0.08;
541  h1_packet_number[start[1]] -> GetYaxis() -> SetRangeUser(0.0,1.3);
542  std::vector<std::vector<int>> badPackets;
543  badPackets.push_back(getBadPackets(h1_packet_number[start[1]],0,param));
544 
545  h1_packet_number[start[1]]->GetXaxis()->SetNdivisions(510,kTRUE);
546  h1_packet_number[start[1]]->GetXaxis()->SetTitle("packet #");
547  h1_packet_number[start[1]]->GetYaxis()->SetTitle("% Of Events Present");
548  h1_packet_number[start[1]]->GetXaxis()->SetLabelSize(tsize-0.01);
549  h1_packet_number[start[1]]->GetYaxis()->SetLabelSize(tsize-0.01);
550  h1_packet_number[start[1]]->GetXaxis()->SetTitleSize(tsize-0.01);
551  h1_packet_number[start[1]]->GetYaxis()->SetTitleSize(tsize-0.01);
552  h1_packet_number[start[1]]->GetXaxis()->SetTitleOffset(1);
553  gPad->SetBottomMargin(0.16);
554  gPad->SetLeftMargin(0.16);
555  gPad->SetRightMargin(0.05);
556  gPad->SetLeftMargin(0.15);
557  gPad->SetTicky();
558  gPad->SetTickx();
559  h1_packet_number[start[1]] -> DrawCopy("hist");
560  one -> Draw("same");
561  warnLineOne -> Draw("same");
562 
563  Pad[2]->cd();
564  h1_packet_length[start[2]] -> GetYaxis() -> SetRangeUser(0,6500);
565  badPackets.push_back(getBadPackets(h1_packet_length[start[2]],1,param));
566 
567  h1_packet_length[start[2]]->GetXaxis()->SetNdivisions(510,kTRUE);
568  h1_packet_length[start[2]]->GetXaxis()->SetTitle("packet #");
569  h1_packet_length[start[2]]->GetYaxis()->SetTitle("Average Packet Size");
570  h1_packet_length[start[2]]->GetXaxis()->SetLabelSize(tsize-.01);
571  h1_packet_length[start[2]]->GetYaxis()->SetLabelSize(tsize);
572  h1_packet_length[start[2]]->GetXaxis()->SetTitleSize(tsize-.01);
573  h1_packet_length[start[2]]->GetYaxis()->SetTitleSize(tsize);
574  h1_packet_length[start[2]]->GetXaxis()->SetTitleOffset(1);
575  h1_packet_length[start[2]]->GetYaxis()->SetTitleOffset(0.9);
576  h1_packet_length[start[2]]->GetYaxis()->SetRangeUser(0,10000);
577  gPad->SetBottomMargin(0.16);
578  gPad->SetLeftMargin(0.16);
579  gPad->SetRightMargin(0.05);
580  gPad->SetLeftMargin(0.15);
581  gPad->SetTicky();
582  gPad->SetTickx();
583  h1_packet_length[start[2]] -> DrawCopy("hist");
584  goodSize -> Draw("same");
585  warnLineSize -> Draw("same");
586  warnLineSizeS -> Draw("same");
587  leg -> Draw("same");
588 
589 
590  Pad[3]->cd();
591  h1_packet_chans[start[3]] -> GetYaxis() -> SetRangeUser(0,212);
592  badPackets.push_back(getBadPackets(h1_packet_chans[start[3]],2,param));
593  h1_packet_chans[start[3]]->GetXaxis()->SetNdivisions(510,kTRUE);
594  h1_packet_chans[start[3]]->GetXaxis()->SetTitle("packet #");
595  h1_packet_chans[start[3]]->GetYaxis()->SetTitle("Average # of Channels");
596  h1_packet_chans[start[3]]->GetXaxis()->SetLabelSize(tsize-.01);
597  h1_packet_chans[start[3]]->GetYaxis()->SetLabelSize(tsize);
598  h1_packet_chans[start[3]]->GetXaxis()->SetTitleSize(tsize-.01);
599  h1_packet_chans[start[3]]->GetYaxis()->SetTitleSize(tsize);
600  h1_packet_chans[start[3]]->GetXaxis()->SetTitleOffset(0.8);
601  h1_packet_chans[start[3]]->GetYaxis()->SetTitleOffset(0.8);
602  gPad->SetBottomMargin(0.16);
603  gPad->SetLeftMargin(0.16);
604  gPad->SetRightMargin(0.05);
605  gPad->SetLeftMargin(0.15);
606  gPad->SetTicky();
607  gPad->SetTickx();
608  h1_packet_chans[start[3]] -> DrawCopy("hist");
609  goodChans -> Draw("same");
610  warnLineChans -> Draw("same");
611  warnLineChansS -> Draw("same");
612 
613  warning[1] -> cd();
614  TLegend *badPacks = new TLegend(0,1/4.,1,0.9);
615  TPaveText *title = new TPaveText(0,0.9,1,0.95);
616  title -> AddText("Bad Packets");
617  badPacks -> SetNColumns(8);
618  badPacks -> SetTextSize(0.03);
619  float badboys = 0;
620  if(maxEvent > 0)
621  {
622  for(int i = 0; i < 3; i++)
623  {
624  for(int j = 0; j < (int)badPackets[i].size(); j++)
625  {
626  //there's most certainly a better way to do this but it's 5:00 on day 5 of owl shift
627  //just want to prevent a packet showing up multiple times and crowding the screen
628  if(badPackets[i][j] == 0) continue;//need this to prevent seg faulting
629 
630  if(i == 0)
631  {
632  badPacks -> AddEntry("",Form("%d",badPackets[i][j]),"");
633  badboys++;
634  }
635  else if(i == 1)
636  {
637  if(!(std::count(badPackets[i-1].begin(),badPackets[i-1].end(),badPackets[i][j])))
638  {
639  badPacks -> AddEntry("",Form("%d",badPackets[i].at(j)),"");
640  badboys++;
641  }
642  }
643  else if(i == 2)
644  {
645  if(!(std::count(badPackets[i-1].begin(),badPackets[i-1].end(),badPackets[i][j])))
646  {
647  badPacks -> AddEntry("",Form("%d",badPackets[i].at(j)),"");
648  badboys++;
649  }
650  if(!(std::count(badPackets[i-2].begin(),badPackets[i-2].end(),badPackets[i][j])) && !(std::count(badPackets[i-1].begin(),badPackets[i-1].end(),badPackets[i][j])))
651  {
652  badPacks -> AddEntry("",Form("%d",badPackets[i].at(j)),"");
653  badboys++;
654  }
655  }
656  }
657  }
658  }
659  badPacks -> Draw();
660  title -> Draw();
661  TPaveText *desc = new TPaveText(0,0,1,0.25);
662  desc -> AddText(Form("Currently %.2g%% of packets are reporting a problem",badboys/128.*100));
663  desc -> AddText("Packets will be reported bad as above for the following reasons:" );
664  desc -> AddText(Form("A packet appears in less than %g %% of events",param*100));
665  desc -> AddText(Form("A packet is less than %g %% of size 5981",param*100));
666  desc -> AddText(Form("A packet sees fewer than %g %% of 192 channels",param*100));
667  desc -> Draw();
668  TText PrintRun;
669  PrintRun.SetTextFont(62);
670  PrintRun.SetTextSize(0.02);
671  PrintRun.SetNDC(); // set to normalized coordinates
672  PrintRun.SetTextAlign(23); // center/top alignment
673  std::ostringstream runnostream;
674  std::string runstring;
675  std::ostringstream runnostream2;
676  time_t evttime = cl->EventTime("CURRENT");
677  // fill run number and event time into string
678 
679  runnostream << "Packet Information";
680  runnostream2 << " Run " << cl->RunNumber() << ", Time: " << ctime(&evttime);
681  transparent[1]->cd();
682 
683  runstring = runnostream.str();
684  PrintRun.DrawText(0.5,.99, runstring.c_str());
685 
686  runstring = runnostream2.str();
687  PrintRun.DrawText(0.5, .966, runstring.c_str());
688  TC[1]->Update();
689  TC[1]->Show();
690  TC[1]->SetEditable(0);
691  if(save)TC[1] -> SaveAs("plots/packets.pdf");
692  return 0;
693 }
694 
695 
696 
697 int CemcMonDraw::DrawThird(const std::string & /* what */)
698 {
700 
701  TH2* h2_waveform_twrAvg[nSEBs];
702  int start[3];
703  start[0] = -1;
704 
705  for(int i = 0; i < nSEBs; i++)
706  {
707  h2_waveform_twrAvg[i] = (TH2*) cl->getHisto(Form("CEMCMON_%d",i),"h2_waveform_twrAvg");
708  if(h2_waveform_twrAvg[i] && start[0] == -1) start[0] = i;
709  if(start[0] > -1 && h2_waveform_twrAvg[i])
710  {
711  h2_waveform_twrAvg[i] -> SetName(Form("h2_waveform_twrAvg_%d",i));
712  h2_waveform_twrAvg[start[0]] -> Add(h2_waveform_twrAvg[i],1);
713  }
714  }
715 
716  TH1* h1_waveform_time[nSEBs];
717  start[1] = -1;
718  for(int i = 0; i < nSEBs; i++)
719  {
720  h1_waveform_time[i] = (TH1*) cl->getHisto(Form("CEMCMON_%d",i),"h1_waveform_time");
721  if(h1_waveform_time[i] && start[1] == -1) start[1] = i;
722  if(start[1] > -1 && h1_waveform_time[i])
723  {
724  h1_waveform_time[i] -> SetName(Form("h1_waveform_time_%d",i));
725  h1_waveform_time[start[1]] -> Add(h1_waveform_time[i],1);
726  }
727  }
728 
729  TH1* h1_waveform_pedestal[nSEBs];
730  start[2] = -1;
731  for(int i = 0; i < nSEBs; i++)
732  {
733  h1_waveform_pedestal[i] = (TH1*) cl->getHisto(Form("CEMCMON_%d",i),"h1_waveform_pedestal");
734 
735  if(h1_waveform_pedestal[i] && start[2] == -1) start[2] = i;
736  if(start[2] > -1 && h1_waveform_pedestal[i])
737  {
738  h1_waveform_pedestal[i] -> SetName(Form("h1_waveform_pedestal_%d",i));
739  h1_waveform_pedestal[start[2]] -> Add(h1_waveform_pedestal[i],1);
740  }
741  }
742 
743  if (!gROOT->FindObject("CemcMon3"))
744  {
745  MakeCanvas("CemcMon3");
746  }
747 
748  TC[2]->SetEditable(1);
749  TC[2]->Clear("D");
750  Pad[4]->cd();
751  if (start[0] < 0 || start[1] < 0|| start[2] < 0)
752  {
754  TC[2]->SetEditable(0);
755  return -1;
756  }
757 
758  gStyle->SetTitleFontSize(0.03);
759  float ymaxp = h2_waveform_twrAvg[start[0]]->ProfileX()->GetMaximum();
760  h2_waveform_twrAvg[start[0]] -> GetYaxis() -> SetRangeUser(0,ymaxp*10);
761 
762  float tsize = 0.06;
763  float tsize2 = 0.08;
764 
765  h2_waveform_twrAvg[start[0]]->GetXaxis()->SetNdivisions(16);
766  h2_waveform_twrAvg[start[0]]->GetXaxis()->SetTitle("sample #");
767  h2_waveform_twrAvg[start[0]]->GetYaxis()->SetTitle("Waveform ADC in latest event [ADC]");
768  h2_waveform_twrAvg[start[0]]->GetXaxis()->SetLabelSize(tsize-.01);
769  h2_waveform_twrAvg[start[0]]->GetYaxis()->SetLabelSize(tsize);
770  h2_waveform_twrAvg[start[0]]->GetXaxis()->SetTitleSize(tsize-.01);
771  h2_waveform_twrAvg[start[0]]->GetYaxis()->SetTitleSize(tsize);
772  h2_waveform_twrAvg[start[0]]->GetXaxis()->SetTitleOffset(1.);
773  h2_waveform_twrAvg[start[0]]->GetYaxis()->SetTitleOffset(1.2);
774  TLine *windowLow1 = new TLine(4,0,4,ymaxp*10);
775  TLine *windowHigh1 = new TLine(10,0,10,ymaxp*10);
776  gStyle -> SetOptStat(0);
777  gPad->SetBottomMargin(0.16);
778  gPad->SetLeftMargin(0.16);
779  gPad->SetRightMargin(0.05);
780  gPad->SetLeftMargin(0.15);
781  gPad->SetTicky();
782  gPad->SetTickx();
783  h2_waveform_twrAvg[start[0]]->DrawCopy("colz");
784  windowLow1 -> Draw("same");
785  windowHigh1 -> Draw("same");
786  gStyle -> SetPalette(57);
787  gPad -> SetLogz();
788 
789  TText PrintRun;
790  PrintRun.SetTextFont(62);
791  PrintRun.SetTextSize(0.03);
792  PrintRun.SetNDC(); // set to normalized coordinates
793  PrintRun.SetTextAlign(23); // center/top alignment
794  std::ostringstream runnostream;
795  std::ostringstream runnostream2;
796  std::string runstring;
797  time_t evttime = cl->EventTime("CURRENT");
798  // fill run number and event time into string
799  runnostream << "Waveform fitting";
800  runnostream2 <<"Run " << cl->RunNumber() << ", Time: " << ctime(&evttime);
801 
802  transparent[2]->cd();
803 
804  runstring = runnostream.str();
805  PrintRun.DrawText(0.5, 0.99, runstring.c_str());
806 
807  runstring = runnostream2.str();
808  PrintRun.DrawText(0.5, 0.966, runstring.c_str());
809 
810  Pad[5]->cd();
811 
812  gStyle->SetTitleFontSize(0.06);
813 
814  h1_waveform_time[start[1]]->GetXaxis()->SetNdivisions(16);
815  h1_waveform_time[start[1]]->GetXaxis()->SetTitle("waveform peak position [sample #]");
816  h1_waveform_time[start[1]]->GetYaxis()->SetTitle("Fraction of Towers");
817  h1_waveform_time[start[1]]->GetXaxis()->SetLabelSize(tsize2);
818  h1_waveform_time[start[1]]->GetYaxis()->SetLabelSize(tsize2);
819  h1_waveform_time[start[1]]->GetXaxis()->SetTitleSize(tsize2);
820  h1_waveform_time[start[1]]->GetYaxis()->SetTitleSize(tsize2);
821  h1_waveform_time[start[1]]->GetXaxis()->SetTitleOffset(1.0);
822  h1_waveform_time[start[1]]->GetYaxis()->SetTitleOffset(.85);
823 
824  if(h1_waveform_time[start[1]]->GetEntries())h1_waveform_time[start[1]] -> Scale(1./h1_waveform_time[start[1]]->GetEntries());
825  TLine *windowLow2 = new TLine(4,0,4,h1_waveform_time[start[1]]->GetMaximum());
826  TLine *windowHigh2 = new TLine(10,0,10,h1_waveform_time[start[1]]->GetMaximum());
827  gPad->SetTopMargin(0.06);
828  gPad->SetBottomMargin(0.18);
829  gPad->SetRightMargin(0.05);
830  gStyle -> SetOptStat(0);
831  gPad->SetLeftMargin(0.15);
832  gPad->SetTicky();
833  gPad->SetTickx();
834  h1_waveform_time[start[1]]->DrawCopy("hist");
835  windowLow2 -> Draw("same");
836  windowHigh2 -> Draw("same");
837 
838  Pad[6]->cd();
839 
840  gStyle->SetTitleFontSize(0.06);
841 
842  h1_waveform_pedestal[start[2]]->GetXaxis()->SetNdivisions(8);
843  h1_waveform_pedestal[start[2]]->GetXaxis()->SetTitle("ADC Pedestal");
844  h1_waveform_pedestal[start[2]]->GetYaxis()->SetTitle("Fraction of Towers");
845  h1_waveform_pedestal[start[2]]->GetXaxis()->SetLabelSize(tsize2);
846  h1_waveform_pedestal[start[2]]->GetYaxis()->SetLabelSize(tsize2);
847  h1_waveform_pedestal[start[2]]->GetXaxis()->SetTitleSize(tsize2);
848  h1_waveform_pedestal[start[2]]->GetYaxis()->SetTitleSize(tsize2);
849  h1_waveform_pedestal[start[2]]->GetXaxis()->SetTitleOffset(1);
850  h1_waveform_pedestal[start[2]]->GetYaxis()->SetTitleOffset(0.85);
851  if(h1_waveform_pedestal[start[2]]->GetEntries())h1_waveform_pedestal[start[2]] -> Scale(1./h1_waveform_pedestal[start[2]]->GetEntries());
852  //h1_waveform_pedestal -> GetXaxis() -> SetRangeUser(1000,2000);
853  gPad->SetTopMargin(0.06);
854  gPad->SetBottomMargin(0.18);
855  gPad->SetRightMargin(0.05);
856  gStyle -> SetOptStat(0);
857  gPad->SetLeftMargin(0.15);
858  gPad->SetTicky();
859  gPad->SetTickx();
860  h1_waveform_pedestal[start[2]]->DrawCopy("hist");
861 
862  TC[2]->Update();
863  TC[2]->Show();
864  TC[2]->SetEditable(0);
865  if(save)TC[2] -> SaveAs("plots/waveform.pdf");
866  return 0;
867 }
868 
869 int CemcMonDraw::DrawFourth(const std::string & /* what */)
870 {
871 
873 
874  TH1 *h_waveform_sigDiff[nSEBs];
875  int start[3];
876  start[0] = -1;
877  for(int i = 0; i < nSEBs; i++)
878  {
879  h_waveform_sigDiff[i] = (TH1*) cl->getHisto(Form("CEMCMON_%d",i),"h1_fitting_sigDiff");
880  if(h_waveform_sigDiff[i] && start[0] == -1) start[0] = i;
881  if(start[0] > -1 && h_waveform_sigDiff[i])
882  {
883  h_waveform_sigDiff[i] -> SetName(Form("h_fitting_sigDiff_%d",i));
884  h_waveform_sigDiff[start[0]] -> Add(h_waveform_sigDiff[i],1);
885  }
886  }
887 
888  TH1 *h_waveform_pedDiff[nSEBs];
889  start[1] = -1;
890  for(int i = 0; i < nSEBs; i++)
891  {
892  h_waveform_pedDiff[i] = (TH1*) cl->getHisto(Form("CEMCMON_%d",i),"h1_fitting_pedDiff");
893  if(h_waveform_pedDiff[i] && start[1] == -1) start[1] = i;
894  if(start[1] > -1 && h_waveform_pedDiff[i])
895  {
896  h_waveform_pedDiff[i] -> SetName(Form("h_fitting_pedDiff_%d",i));
897  h_waveform_pedDiff[start[1]] -> Add(h_waveform_pedDiff[i],1);
898  }
899  }
900 
901  TH1 *h_waveform_timeDiff[nSEBs];
902  start[2] = -1;
903  for(int i = 0; i < nSEBs; i++)
904  {
905  h_waveform_timeDiff[i] = (TH1*) cl->getHisto(Form("CEMCMON_%d",i),"h1_fitting_timeDiff");
906  if(h_waveform_timeDiff[i] && start[2] == -1) start[2] = i;
907  if(start[2] > -1 && h_waveform_timeDiff[i])
908  {
909  h_waveform_timeDiff[i] -> SetName(Form("h_fitting_timeDiff_%d",i));
910  h_waveform_timeDiff[start[2]] -> Add(h_waveform_timeDiff[i],1);
911  }
912  }
913 
914  if(!gROOT -> FindObject("CemcMon4"))
915  {
916  MakeCanvas("CemcMon4");
917  }
918 
919  TC[3]->SetEditable(1);
920  TC[3]->Clear("D");
921  if(start[0] < 0|| start[1] < 0 || start[2] < 0)
922  {
924  TC[3]->SetEditable(0);
925  return -1;
926  }
927 
928  gStyle->SetTitleFontSize(0.03);
929 
930 
931  TText PrintRun;
932  PrintRun.SetTextFont(62);
933  PrintRun.SetTextSize(0.03);
934  PrintRun.SetNDC(); // set to normalized coordinates
935  PrintRun.SetTextAlign(23); // center/top alignment
936  std::ostringstream runnostream;
937  std::ostringstream runnostream2;
938  std::string runstring;
939  time_t evttime = cl->EventTime("CURRENT");
940  // fill run number and event time into string
941  runnostream << "Waveform Template vs. Fast Fitting";
942  runnostream2 << "Run " << cl->RunNumber() << ", Time: " << ctime(&evttime);
943 
944  transparent[3]->cd();
945 
946  runstring = runnostream.str();
947  PrintRun.DrawText(0.5, 0.99, runstring.c_str());
948 
949 
950  runstring = runnostream2.str();
951  PrintRun.DrawText(0.5, 0.966, runstring.c_str());
952 
953 
954  Pad[7]->cd();
955 
956  gStyle->SetTitleFontSize(0.06);
957 
958  float tsize2 = 0.08;
959  h_waveform_sigDiff[start[0]]->GetXaxis()->SetNdivisions(16);
960  h_waveform_sigDiff[start[0]]->GetXaxis()->SetTitle("Fast ADC/Template ADC");
961  h_waveform_sigDiff[start[0]]->GetYaxis()->SetTitle("Fraction of Towers");
962  h_waveform_sigDiff[start[0]]->GetXaxis()->SetLabelSize(tsize2-.01);
963  h_waveform_sigDiff[start[0]]->GetYaxis()->SetLabelSize(tsize2-.01);
964  h_waveform_sigDiff[start[0]]->GetXaxis()->SetTitleSize(tsize2-.01);
965  h_waveform_sigDiff[start[0]]->GetYaxis()->SetTitleSize(tsize2-.01);
966  h_waveform_sigDiff[start[0]]->GetXaxis()->SetTitleOffset(.9);
967  h_waveform_sigDiff[start[0]]->GetYaxis()->SetTitleOffset(1.1);
968  if(h_waveform_sigDiff[start[0]] -> GetEntries())h_waveform_sigDiff[start[0]] -> Scale(1./h_waveform_sigDiff[start[0]] -> GetEntries());
969  gPad->SetTopMargin(0.06);
970  gPad->SetBottomMargin(0.18);
971  gPad->SetRightMargin(0.05);
972  gPad->SetLeftMargin(0.15);
973  gStyle->SetOptStat(0);
974  gPad->SetTicky();
975  gPad->SetTickx();
976  h_waveform_sigDiff[start[0]]->DrawCopy("hist");
977 
978  Pad[8]->cd();
979 
980  gStyle->SetTitleFontSize(0.06);
981 
982  h_waveform_pedDiff[start[1]]->GetXaxis()->SetNdivisions(16);
983  h_waveform_pedDiff[start[1]]->GetXaxis()->SetTitle("Fast Pedestal/Template Pedestal");
984  h_waveform_pedDiff[start[1]]->GetYaxis()->SetTitle("Fraction of Towers");
985  h_waveform_pedDiff[start[1]]->GetXaxis()->SetLabelSize(tsize2);
986  h_waveform_pedDiff[start[1]]->GetYaxis()->SetLabelSize(tsize2);
987  h_waveform_pedDiff[start[1]]->GetXaxis()->SetTitleSize(tsize2);
988  h_waveform_pedDiff[start[1]]->GetYaxis()->SetTitleSize(tsize2);
989  h_waveform_pedDiff[start[1]]->GetXaxis()->SetTitleOffset(0.9);
990  h_waveform_pedDiff[start[1]]->GetYaxis()->SetTitleOffset(0.9);
991  if(h_waveform_pedDiff[start[1]] -> GetEntries())h_waveform_pedDiff[start[1]] -> Scale(1./ h_waveform_pedDiff[start[1]] -> GetEntries());
992  gPad->SetTopMargin(0.06);
993  gPad->SetBottomMargin(0.18);
994  gPad->SetRightMargin(0.05);
995  gPad->SetLeftMargin(0.15);
996  gStyle->SetOptStat(0);
997  gPad->SetTicky();
998  gPad->SetTickx();
999  h_waveform_pedDiff[start[1]]->DrawCopy("hist");
1000 
1001  Pad[9]->cd();
1002 
1003  h_waveform_timeDiff[start[2]]->GetXaxis()->SetNdivisions(16);
1004  h_waveform_timeDiff[start[2]]->GetXaxis()->SetTitle("Fast Peak Time - Template Peak Time");
1005  h_waveform_timeDiff[start[2]]->GetYaxis()->SetTitle("Fraction of Towers");
1006  h_waveform_timeDiff[start[2]]->GetXaxis()->SetLabelSize(tsize2);
1007  h_waveform_timeDiff[start[2]]->GetYaxis()->SetLabelSize(tsize2);
1008  h_waveform_timeDiff[start[2]]->GetXaxis()->SetTitleSize(tsize2);
1009  h_waveform_timeDiff[start[2]]->GetYaxis()->SetTitleSize(tsize2);
1010  h_waveform_timeDiff[start[2]]->GetXaxis()->SetTitleOffset(0.9);
1011  h_waveform_timeDiff[start[2]]->GetYaxis()->SetTitleOffset(0.9);
1012  if(h_waveform_timeDiff[start[2]]->GetEntries())h_waveform_timeDiff[start[2]] -> Scale(1./ h_waveform_timeDiff[start[2]]->GetEntries());
1013  gPad->SetTopMargin(0.06);
1014  gPad->SetBottomMargin(0.18);
1015  gPad->SetRightMargin(0.05);
1016  gPad->SetLeftMargin(0.15);
1017  gPad->SetTicky();
1018  gPad->SetTickx();
1019  h_waveform_timeDiff[start[2]]->DrawCopy("hist");
1020 
1021 
1022  TC[3]->Update();
1023  TC[3]->Show();
1024  TC[3]->SetEditable(0);
1025  gStyle->SetOptStat(0);
1026  if(save)TC[3] -> SaveAs("plots/waveformExpert.pdf");
1027  return 0;
1028 }
1029 
1030 
1031 int CemcMonDraw::FindHotTower(TPad *warningpad,TH2* hhit){
1032  float nhott = 0;
1033  float ndeadt = 0;
1034  float hot_threshold = 1.25;
1035  float dead_threshold = 0.75;
1036  float nTowerTotal = 24576.-2048.;//-2048 to account for the non-functioning towers at the edge of the south
1037  for(int ieta=0; ieta<nTowersEta; ieta++){
1038  for(int iphi=0; iphi<nTowersPhi; iphi++){
1039 
1040  if(ieta < 8) continue;
1041  if(hhit -> GetBinContent(ieta+1, iphi+1) == 0)continue;
1042  double nhit = hhit->GetBinContent(ieta+1, iphi+1);
1043 
1044  if(nhit > hot_threshold) nhott++;
1045 
1046 
1047  if(nhit < dead_threshold) ndeadt++;
1048 
1049  }
1050  }
1051 
1052  //draw warning here
1053  warningpad->cd();
1054  TPaveText *dead = new TPaveText(0.01,0.7,0.33,1);
1055  dead -> SetFillColor(kGray+2);
1056  dead -> SetTextColor(kWhite);
1057  dead -> AddText(Form("Cold towers: %.3g%%",100*ndeadt/nTowerTotal));
1058  // if(100*ndeadt/nTowerTotal > 2.5)
1059  // {
1060  // dead -> AddText("");
1061  // }
1062  TPaveText *good = new TPaveText(0.33,0.7,0.66,1);
1063  good -> SetFillColor(kGreen+1);
1064  good -> AddText(Form("Good towers: %.3g%%",100*(nTowerTotal-ndeadt-nhott)/nTowerTotal));
1065  TPaveText *hot = new TPaveText(0.66,0.7,1,1);
1066  hot -> SetFillColor(kRed-9);
1067  hot -> AddText(Form("Hot towers: %.3g%%",100*nhott/nTowerTotal));
1068  // if(100*nhott/nTowerTotal > 3.5)
1069  // {
1070  // hot -> AddText("");
1071  // }
1072  TPaveText *warn = new TPaveText(0.01,0.1,1,0.7);
1073  warn -> SetTextSize(0.1);
1074  warn -> AddText("Helpful Numbers: 1 Box = Interface Board (IB)");
1075  warn -> AddText("3 Boxes (horiz) = 1 Packet; 6 Boxes (horiz) = 1 Sector");
1076  //warn -> AddText("Inform Expert if Number of Dead Towers Exceeds: 2.5%");
1077  //warn -> AddText("Inform Expert if Number of Hot Towers Exceeds: 3.5%");
1078  warn -> AddText("For now, watch for entire IB's or sectors going dead");
1079  dead -> Draw();
1080  good -> Draw();
1081 
1082  hot -> Draw();
1083  warn -> Draw();
1084  warningpad->Update();
1085  return 0;
1086 }
1087 
1088 
1089 
1091 {
1093  int iret = Draw(what);
1094  if (iret) // on error no png files please
1095  {
1096  return iret;
1097  }
1098  int icnt = 0;
1099  for (TCanvas *canvas : TC)
1100  {
1101  if (canvas == nullptr)
1102  {
1103  continue;
1104  }
1105  icnt++;
1106  std::string filename = ThisName + "_" + std::to_string(icnt) + "_" +
1107  std::to_string(cl->RunNumber()) + "." + type;
1108  cl->CanvasToPng(canvas, filename);
1109  }
1110  return 0;
1111 }
1112 
1114 {
1115  int iret = Draw(what);
1116  if (iret) // on error no html output please
1117  {
1118  return iret;
1119  }
1120 
1122 
1123  int icnt = 0;
1124  for (TCanvas *canvas : TC)
1125  {
1126  if (canvas == nullptr)
1127  {
1128  continue;
1129  }
1130  icnt++;
1131  // Register the canvas png file to the menu and produces the png file.
1132  std::string pngfile = cl->htmlRegisterPage(*this, canvas->GetTitle(), std::to_string(icnt), "png");
1133  cl->CanvasToPng(canvas, pngfile);
1134  }
1135  // Now register also EXPERTS html pages, under the EXPERTS subfolder.
1136 
1137  // std::string logfile = cl->htmlRegisterPage(*this, "EXPERTS/Log", "log", "html");
1138  // std::ofstream out(logfile.c_str());
1139  // out << "<HTML><HEAD><TITLE>Log file for run " << cl->RunNumber()
1140  // << "</TITLE></HEAD>" << std::endl;
1141  // out << "<P>Some log file output would go here." << std::endl;
1142  // out.close();
1143 
1144  // std::string status = cl->htmlRegisterPage(*this, "EXPERTS/Status", "status", "html");
1145  // std::ofstream out2(status.c_str());
1146  // out2 << "<HTML><HEAD><TITLE>Status file for run " << cl->RunNumber()
1147  // << "</TITLE></HEAD>" << std::endl;
1148  // out2 << "<P>Some status output would go here." << std::endl;
1149  // out2.close();
1150  // cl->SaveLogFile(*this);
1151  return 0;
1152 }
1153 
1154 
1155 std::vector<int> CemcMonDraw::getBadPackets(TH1 *hist, int what, float cutoff)
1156 {
1157  float params[3] = {1., 5981., 192.};
1158  float params2[3] = {1., 3991., 128.};
1159  //float cutoff = 0.75;
1160  std::vector<int> badpacks = {0};
1161 
1162  for(int i = 1; i < hist -> GetNbinsX(); i++)
1163  {
1164  if((hist -> GetBinContent(i) < params[what]*cutoff || hist -> GetBinContent(i) > params[what]) && !(((6000 + i - 2.)/4.) == floor(((6000 + i - 2)/4))) ) badpacks.push_back(i+6000);
1165 
1166  else if((hist -> GetBinContent(i) < params2[what]*cutoff || hist -> GetBinContent(i) > params2[what]) && (((6000 + i - 2.)/4.) == floor(((6000 + i - 2)/4))) ) badpacks.push_back(i+6000);
1167  }
1168 
1169  return badpacks;
1170 }
1171 
1173 {
1175  time_t currtime = cl->EventTime("CURRENT");
1176  return currtime;
1177 }