Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MvtxMonDraw.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MvtxMonDraw.cc
1 #include "MvtxMonDraw.h"
2 
3 #include <onlmon/OnlMonClient.h>
4 #include <onlmon/OnlMonDB.h>
5 
6 #include <TAxis.h> // for TAxis
7 #include <TCanvas.h>
8 #include <TDatime.h>
9 #include <TGaxis.h>
10 #include <TGraphErrors.h>
11 #include <TH1.h>
12 #include <TH2.h>
13 #include <TH3.h>
14 #include <TH2Poly.h>
15 #include <TPad.h>
16 #include <TROOT.h>
17 #include <TSystem.h>
18 #include <TText.h>
19 #include <TStyle.h>
20 #include <TPaveText.h>
21 #include <TLatex.h>
22 #include <TColor.h>
23 #include <TEllipse.h>
24 
25 #include <cstring> // for memset
26 #include <ctime>
27 #include <fstream>
28 #include <iostream> // for operator<<, basic_ostream, basic_os...
29 #include <sstream>
30 #include <vector> // for vector
31 
33  : OnlMonDraw(name)
34 {
35  // this TimeOffsetTicks is neccessary to get the time axis right
36  TDatime T0(2003, 01, 01, 00, 00, 00);
37  TimeOffsetTicks = T0.Convert();
38  //dbvars = new OnlMonDB(ThisName);
39  for (int iFelix = 0; iFelix < NFlx; iFelix++){
40  dbvars[iFelix] = new OnlMonDB(Form("MVTXMON_%d",iFelix));
41  }
42  return;
43 }
44 
46 {
47  return 0;
48 }
49 
51 {
53  int xsize = cl->GetDisplaySizeX();
54  int ysize = cl->GetDisplaySizeY();
55  /* if (name == "MvtxMon1")
56  {
57  // xpos (-1) negative: do not draw menu bar
58  TC[0] = new TCanvas(name.c_str(), "MvtxMon Example Monitor", -1, 0, xsize / 2, ysize);
59  // root is pathetic, whenever a new TCanvas is created root piles up
60  // 6kb worth of X11 events which need to be cleared with
61  // gSystem->ProcessEvents(), otherwise your process will grow and
62  // grow and grow but will not show a definitely lost memory leak
63  gSystem->ProcessEvents();
64  Pad[0] = new TPad("mvtxpad1", "who needs this?", 0.1, 0.7, 0.9, 0.9, 0);
65  Pad[1] = new TPad("mvtxpad2", "who needs this?", 0.1, 0.3, 0.9, 0.7, 0);
66  Pad[2] = new TPad("mvtxpad3", "who needs this?", 0.1, 0.05, 0.9, 0.3, 0);
67  Pad[0]->Draw();
68  Pad[1]->Draw();
69  Pad[2]->Draw();
70  // this one is used to plot the run number on the canvas
71  transparent[0] = new TPad("transparent0", "this does not show", 0, 0, 1, 1);
72  transparent[0]->SetFillStyle(4000);
73  transparent[0]->Draw();
74  TC[0]->SetEditable(false);
75  }
76  else if (name == "MvtxMon2")
77  {
78  // xpos negative: do not draw menu bar
79  TC[1] = new TCanvas(name.c_str(), "MvtxMon2 Example Monitor", -xsize / 2, 0, xsize / 2, ysize);
80  gSystem->ProcessEvents();
81  Pad[3] = new TPad("mvtxpad4", "who needs this?", 0.1, 0.5, 0.9, 0.9, 0);
82  Pad[4] = new TPad("mvtxpad5", "who needs this?", 0.1, 0.05, 0.9, 0.45, 0);
83  Pad[3]->Draw();
84  Pad[4]->Draw();
85  // this one is used to plot the run number on the canvas
86  transparent[1] = new TPad("transparent1", "this does not show", 0, 0, 1, 1);
87  transparent[1]->SetFillStyle(4000);
88  transparent[1]->Draw();
89  TC[1]->SetEditable(false);
90  }
91  else if (name == "MvtxMon3")
92  {
93  TC[2] = new TCanvas(name.c_str(), "MvtxMon3 Example Monitor", xsize / 2, 0, xsize / 2, ysize);
94  gSystem->ProcessEvents();
95  Pad[5] = new TPad("mvtxpad6", "who needs this?", 0.1, 0.1, 0.9, 0.9, 0);
96  //Pad[6] = new TPad("mvtxpad7", "who needs this?", 0.1, 0.05, 0.9, 0.45, 0);
97  Pad[5]->Draw();
98  //Pad[6]->Draw();
99  // this one is used to plot the run number on the canvas
100  // transparent[2] = new TPad("transparent2", "this does not show", 0, 0, 1, 1);
101  // transparent[2]->SetFillStyle(4000);
102  // transparent[2]->Draw();
103  // TC[2]->SetEditable(0);
104  }*/
105  if (name == "MvtxMon_HitMap")
106  {
107  TC[0] = new TCanvas(name.c_str(), "MvtxMon Hitmaps", -1, 0, xsize, ysize);
108  gSystem->ProcessEvents();
109  //TC[3]->Divide(2,1/*NSTAVE*/);
110  Pad[0] = new TPad("mvtxpad0", "who needs this?", 0.05, 0.02, 0.98, 0.92, 0);
111  Pad[0]->Draw();
112  // this one is used to plot the run number on the canvas
113  transparent[0] = new TPad("transparent0", "this does not show", 0, 0, 1, 1);
114  transparent[0]->SetFillStyle(4000);
115  transparent[0]->Draw();
116  TC[0]->SetEditable(false);
117  TC[0]->SetTopMargin(0.05);
118  TC[0]->SetBottomMargin(0.05);
119  }
120  else if (name == "MvtxMon_General")
121  {
122  TC[1] = new TCanvas(name.c_str(), "MVTX Monitoring General", -1, 0, xsize, ysize);
123  gSystem->ProcessEvents();
124  TC[1]->cd();
125  Pad[1] = new TPad("mvtxpad1", "who needs this?", 0., 0.02, 0.98, 0.97, 0);
126  Pad[1]->Draw();
127  //Pad[7]->Divide(4,2);
128  // this one is used to plot the run number on the canvas
129  transparent[0] = new TPad("transparent0", "this does not show", 0, 0, 1, 1);
130  transparent[0]->SetFillStyle(4000);
131  transparent[0]->Draw();
132  TC[1]->SetEditable(false);
133  TC[1]->SetTopMargin(0.05);
134  TC[1]->SetBottomMargin(0.05);
135 //Pad[8]->SetRightMargin(0.13);
136  }
137  else if (name == "MvtxMon_FEE")
138  {
139  TC[2] = new TCanvas(name.c_str(), "MVTX Monitoring FEE", -1, 0, xsize, ysize);
140  gSystem->ProcessEvents();
141  Pad[2] = new TPad("mvtxpad2", "who needs this?", 0., 0.02, 0.98, 0.97, 0);
142  Pad[2]->Draw();
143 
144  // this one is used to plot the run number on the canvas
145  transparent[0] = new TPad("transparent0", "this does not show", 0, 0, 1, 1);
146  transparent[0]->SetFillStyle(4000);
147  transparent[0]->Draw();
148  TC[2]->SetEditable(false);
149  TC[2]->SetTopMargin(0.05);
150  TC[2]->SetBottomMargin(0.05);
151  }
152  else if (name == "MvtxMon_OCC")
153  {
154  TC[3] = new TCanvas(name.c_str(), "MVTX Monitoring Occupancy", -1, 0, xsize, ysize);
155  gSystem->ProcessEvents();
156  Pad[3] = new TPad("mvtxpad3", "who needs this?", 0., 0.02, 0.98, 0.97, 0);
157  Pad[3]->Draw();
158 
159  // this one is used to plot the run number on the canvas
160  transparent[0] = new TPad("transparent0", "this does not show", 0, 0, 1, 1);
161  transparent[0]->SetFillStyle(4000);
162  transparent[0]->Draw();
163  TC[3]->SetEditable(false);
164  TC[3]->SetTopMargin(0.05);
165  TC[3]->SetBottomMargin(0.05);
166  }
167  else if (name == "MvtxMon_FHR")
168  {
169  TC[4] = new TCanvas(name.c_str(), "MVTX Monitoring FHR", -1, 0, xsize, ysize);
170  gSystem->ProcessEvents();
171  Pad[4] = new TPad("mvtxpad4", "who needs this?", 0., 0.02, 0.98, 0.97, 0);
172  Pad[4]->Draw();
173 
174  // this one is used to plot the run number on the canvas
175  transparent[0] = new TPad("transparent0", "this does not show", 0, 0, 1, 1);
176  transparent[0]->SetFillStyle(4000);
177  transparent[0]->Draw();
178  TC[4]->SetEditable(false);
179  TC[4]->SetTopMargin(0.05);
180  TC[4]->SetBottomMargin(0.05);
181  }
182  else if (name == "MvtxMon3")
183  {
184  TC[5] = new TCanvas(name.c_str(), "MvtxMon3 Example Monitor", xsize / 2, 0, xsize / 2, ysize);
185  gSystem->ProcessEvents();
186  Pad[5] = new TPad("mvtxpad5", "who needs this?", 0.1, 0.1, 0.9, 0.9, 0);
187  //Pad[6] = new TPad("mvtxpad7", "who needs this?", 0.1, 0.05, 0.9, 0.45, 0);
188  Pad[5]->Draw();
189  transparent[0] = new TPad("transparent0", "this does not show", 0, 0, 1, 1);
190  transparent[0]->SetFillStyle(4000);
191  transparent[0]->Draw();
192  TC[5]->SetEditable(false);
193  TC[5]->SetTopMargin(0.05);
194  TC[5]->SetBottomMargin(0.05);
195  //Pad[6]->Draw();
196  // this one is used to plot the run number on the canvas
197  // transparent[2] = new TPad("transparent2", "this does not show", 0, 0, 1, 1);
198  // transparent[2]->SetFillStyle(4000);
199  // transparent[2]->Draw();
200  // TC[2]->SetEditable(0);
201  }
202  return 0;
203 }
204 
206 {
207  int iret = 0;
208  int idraw = 0;
209  if (what == "ALL" || what == "L0L"|| what == "L0R"|| what == "L1L"|| what == "L1R"|| what == "L2L"|| what == "L2R")
210  {
211  iret += DrawHitMap(what);
212  idraw++;
213  }
214  if (what == "ALL" || what == "GENERAL")
215  {
216  iret += DrawGeneral(what);
217  idraw++;
218  }
219  if (what == "ALL" || what == "FEE")
220  {
221  iret += DrawFEE(what);
222  idraw++;
223  }
224  if (what == "ALL" || what == "OCC")
225  {
226  iret += DrawOCC(what);
227  idraw++;
228  }
229  if (what == "ALL" || what == "FHR")
230  {
231  iret += DrawFHR(what);
232  idraw++;
233  }
234  if (what == "HISTORY")
235  {
236  iret += DrawHistory(what);
237  idraw++;
238  }
239  if (!idraw)
240  {
241  std::cout << __PRETTY_FUNCTION__ << " Unimplemented Drawing option: " << what << std::endl;
242  iret = -1;
243  }
244  return iret;
245 }
246 
248 {
250 
251  const int canvasID = 0;
252  const int padID = 0;
253  TH3 *mvtxmon_HitMap[NFlx+1] = {nullptr};
254  if (!gROOT->FindObject("MvtxMon_HitMap"))
255  {
256  MakeCanvas("MvtxMon_HitMap");
257  }
258  TC[canvasID]->SetEditable(true);
259  TC[canvasID]->Clear("D");
260 
261  int aLs = 0;
262  int aLe = 0;
263  int aSs = 0;
264  int aSe = 0;
265  if (what == "L0R" || what == "ALL"){
266  aLs = 0; aLe = 1;
267  aSs = 0; aSe = 6;
268  }
269  else if (what == "L0L"){
270  aLs = 0; aLe = 1;
271  aSs = 6; aSe = 12;
272  }
273  else if (what == "L1R"){
274  aLs = 1; aLe = 2;
275  aSs = 0; aSe = 8;
276  }
277  else if (what == "L1L"){
278  aLs = 1; aLe = 2;
279  aSs = 8; aSe = 16;
280  }
281  else if (what == "L2R"){
282  aLs = 2; aLe = 3;
283  aSs = 0; aSe = 10;
284  }
285  else if (what == "L2L"){
286  aLs = 2; aLe = 3;
287  aSs = 10; aSe = 20;
288  }
289  Pad[padID]->Divide(NCHIP,aSe-aSs/*NSTAVE*/);
290 
291  int ipad = 0;
292  int returnCode = 0;
293 
294  for (int iFelix = 0; iFelix <NFlx; iFelix++){
295  mvtxmon_HitMap[iFelix] = dynamic_cast<TH3*>(cl->getHisto(Form("MVTXMON_%d",iFelix),Form("MVTXMON_chipHitmapFLX%d", iFelix)));
296  }
297  MergeServers<TH3*>(mvtxmon_HitMap);
298  if(mvtxmon_HitMap[NFlx]){
299  mvtxmon_HitMap[NFlx]->GetXaxis()->CenterTitle();
300  mvtxmon_HitMap[NFlx]->GetYaxis()->CenterTitle();
301  mvtxmon_HitMap[NFlx]->GetYaxis()->SetTitleOffset(1.4);
302  mvtxmon_HitMap[NFlx]->GetXaxis()->SetTitleOffset(0.75);
303  mvtxmon_HitMap[NFlx]->GetXaxis()->SetTitleSize(0.06);
304  mvtxmon_HitMap[NFlx]->GetYaxis()->SetTitleOffset(0.75);
305  mvtxmon_HitMap[NFlx]->GetYaxis()->SetTitleSize(0.06);
306  }
307 
308  for (int aLayer = aLs; aLayer < aLe; aLayer++) {
309  for (int aStave = aSs; aStave < aSe; aStave++) {
310  for (int iChip = 0; iChip < 9; iChip++) {
311  //int stave = aLayer==0?aStave:NStaves[aLayer]+aStave;
312  TString prefix = Form("%d%d%d",aLayer,aStave,iChip);
313  mvtxmon_HitMap[NFlx]->GetZaxis()->SetRange(((chipmapoffset[aLayer]+aStave)*9+iChip+1),((chipmapoffset[aLayer]+aStave)*9+iChip+1));
314  returnCode += PublishHistogram(Pad[padID],ipad*9+iChip+1,mvtxmon_HitMap[NFlx]->Project3D(prefix+"yx"),"colz"); //publish merged one
315  gStyle->SetOptStat(0);
316  }
317  ipad++;
318  }
319  }
320 
321  TC[canvasID]->cd();
322  TPaveText *ptchip[9] = {nullptr};
323  for(int i = 0; i < 9; i++){
324  ptchip[i] = new TPaveText(0.05+0.1033*i,.92,0.05+0.1033*(i+1),0.97,"blNDC");
325  ptchip[i]->SetTextSize(0.03);
326  ptchip[i]->SetFillColor(4000);
327  ptchip[i]->SetLineColor(0);
328  ptchip[i]->SetBorderSize(1);
329  ptchip[i]->AddText(Form("Chip %d",i));
330  ptchip[i]->Draw();
331  }
332 
333  TPaveText *ptstave[10] = {nullptr};
334  for(int i = 0; i < aSe - aSs; i++){
335  ptstave[i] = new TPaveText(0.0,0.93- ((i+1) * 0.92/(aSe - aSs)),0.05,0.93- (i * 0.92/(aSe - aSs)),"blNDC");
336  ptstave[i]->SetTextSize(0.02);
337  ptstave[i]->SetFillColor(4000);
338  ptstave[i]->SetLineColor(0);
339  ptstave[i]->SetBorderSize(1);
340  ptstave[i]->AddText(Form("Stave %d",aSs + i));
341  ptstave[i]->Draw();
342  }
343 
344  TPaveText *ptlayer = {nullptr};
345  ptlayer = new TPaveText(0.01,.92,0.06,0.97,"blNDC");
346  ptlayer->SetTextSize(0.035);
347  ptlayer->SetFillColor(4000);
348  ptlayer->SetLineColor(0);
349  ptlayer->SetBorderSize(1);
350  if (what == "L0R" || what == "L0R"|| what == "ALL") ptlayer->AddText("Layer 0");
351  if (what == "L1R" || what == "L1R") ptlayer->AddText("Layer 1");
352  if (what == "L2R" || what == "L2R") ptlayer->AddText("Layer 2");
353  ptlayer->Draw();
354 
355  PublishStatistics(TC[canvasID],cl);
356 
357  //TC[canvasID]->Modified();
358  TC[canvasID]->Update();
359  TC[canvasID]->SetEditable(false);
360  return returnCode < 0 ? -1 : 0;
361 }
362 
363 int MvtxMonDraw::DrawGeneral(const std::string & /* what */)
364 {
366  const int canvasID = 1;
367  const int padID = 1;
368 
369  TH2Poly* mvtxmon_LaneStatusOverview[3][NFlx+1] = {nullptr};
370  TH2Poly* mvtxmon_mGeneralOccupancy[NFlx+1] = {nullptr};
371  TH1D* mvtxmon_mGeneralErrorPlots[NFlx+1] = {nullptr};
372  TH2D* mvtxmon_mGeneralErrorFile[NFlx+1] = {nullptr};
373 
374  for (int iFelix = 0; iFelix < NFlx; iFelix++){
375  mvtxmon_LaneStatusOverview[0][iFelix] = dynamic_cast<TH2Poly*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_LaneStatus_laneStatusOverviewFlagWARNING"));
376  mvtxmon_LaneStatusOverview[1][iFelix] = dynamic_cast<TH2Poly*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_LaneStatus_laneStatusOverviewFlagERROR"));
377  mvtxmon_LaneStatusOverview[2][iFelix] = dynamic_cast<TH2Poly*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_LaneStatus_laneStatusOverviewFlagFAULT"));
378  mvtxmon_mGeneralOccupancy[iFelix] = dynamic_cast<TH2Poly*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_General_Occupancy"));
379  mvtxmon_mGeneralErrorPlots[iFelix] = dynamic_cast<TH1D*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_General_ErrorPlots"));
380  mvtxmon_mGeneralErrorFile[iFelix] = dynamic_cast<TH2D*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_General_ErrorFile"));
381  }
382 
383  //injecting errors here
384  //mvtxmon_LaneStatusOverview[0][1] = mvtxmon_LaneStatusOverview[0][0];
385  //injecting errors done
386 
387  int bitset = 0;
388  int bitsetOR = 0;
389  int bitsetAND = 63;
390  bitset = MergeServers<TH2Poly*>(mvtxmon_LaneStatusOverview[0]);
391  bitsetOR |= bitset; bitsetAND &= bitset;
392  bitset = MergeServers<TH2Poly*>(mvtxmon_LaneStatusOverview[1]);
393  bitsetOR |= bitset; bitsetAND &= bitset;
394  bitset = MergeServers<TH2Poly*>(mvtxmon_LaneStatusOverview[2]);
395  bitsetOR |= bitset; bitsetAND &= bitset;
396  bitset = MergeServers<TH2Poly*>(mvtxmon_mGeneralOccupancy);
397  bitsetOR |= bitset; bitsetAND &= bitset;
398  bitset = MergeServers<TH1D*>(mvtxmon_mGeneralErrorPlots);
399  bitsetOR |= bitset; bitsetAND &= bitset;
400  bitset = MergeServers<TH2D*>(mvtxmon_mGeneralErrorFile);
401  bitsetOR |= bitset; bitsetAND &= bitset;
402 
403  for(int i = 0; i < 3; i++){
404  if(mvtxmon_LaneStatusOverview[i][NFlx]){
405  mvtxmon_LaneStatusOverview[i][NFlx]->SetStats(0);
406  mvtxmon_LaneStatusOverview[i][NFlx]->GetYaxis()->SetTitleOffset(0.6);
407  mvtxmon_LaneStatusOverview[i][NFlx]->SetMinimum(0);
408  mvtxmon_LaneStatusOverview[i][NFlx]->SetMaximum(1);
409  mvtxmon_LaneStatusOverview[i][NFlx]->SetBit(TH1::kIsAverage);
410  }
411  }
412  if(mvtxmon_mGeneralOccupancy[NFlx]) mvtxmon_mGeneralOccupancy[NFlx]->GetYaxis()->SetTitleOffset(0.6);
413 
414  if(mvtxmon_mGeneralErrorFile[NFlx]){
415  for(int bin = 1; bin < mvtxmon_mGeneralErrorFile[NFlx]->GetNbinsX()+1;bin++ ){
416  mvtxmon_mGeneralErrorFile[NFlx]->GetXaxis()->SetBinLabel(bin,Form("%d",(bin-1)%8));
417  }
418  mvtxmon_mGeneralErrorFile[NFlx]->GetXaxis()->SetTitleSize(0.045);
419  mvtxmon_mGeneralErrorFile[NFlx]->GetYaxis()->SetTitleSize(0.045);
420  }
421 
422  if (!gROOT->FindObject("MvtxMon_General"))
423  {
424  MakeCanvas("MvtxMon_General");
425  }
426 
427  TC[canvasID]->SetEditable(true);
428  TC[canvasID]->Clear("D");
429 
430  Pad[padID]->Divide(4,2);
431  int returnCode = 0;
432 
433  Pad[padID]->cd(4)->SetRightMargin(0.12);
434  Pad[padID]->cd(5)->SetLeftMargin(0.16);
435  Pad[padID]->cd(6)->SetTopMargin(0.16);
436 
437  //injecting errors here
438 /* mvtxmon_LaneStatusOverview[1][NFlx]->SetBinContent(5,0.5);
439  mvtxmon_LaneStatusOverview[2][NFlx]->SetBinContent(11,0.5);
440  mvtxmon_LaneStatusOverview[2][NFlx]->SetBinContent(12,0.5);
441  mvtxmon_LaneStatusOverview[2][NFlx]->SetBinContent(13,0.5);
442  mvtxmon_LaneStatusOverview[2][NFlx]->SetBinContent(14,0.5);
443  mvtxmon_LaneStatusOverview[2][NFlx]->SetBinContent(15,0.5);
444  mvtxmon_LaneStatusOverview[2][NFlx]->SetBinContent(16,0.5);
445  mvtxmon_LaneStatusOverview[2][NFlx]->SetBinContent(17,0.5);
446  mvtxmon_LaneStatusOverview[2][NFlx]->SetBinContent(18,0.5);
447  mvtxmon_LaneStatusOverview[2][NFlx]->SetBinContent(19,0.5);
448  mvtxmon_mGeneralErrorFile[NFlx]->SetBinContent(17,5,20);*/
449  //injecting errors done
450 
451  if(mvtxmon_mGeneralErrorPlots[NFlx]){
452  mvtxmon_mGeneralErrorPlots[NFlx]->GetXaxis()->SetTitleSize(0.045);
453  mvtxmon_mGeneralErrorPlots[NFlx]->GetYaxis()->SetTitleSize(0.045);
454  }
455 
456  std::vector<MvtxMonDraw::Quality> status;
457  status = analyseForError(mvtxmon_LaneStatusOverview[0][NFlx],mvtxmon_LaneStatusOverview[1][NFlx],mvtxmon_LaneStatusOverview[2][NFlx],mvtxmon_mGeneralErrorFile[NFlx]);
458 
459  returnCode += PublishHistogram(Pad[padID],1,mvtxmon_LaneStatusOverview[0][NFlx],"lcolz");
460  DrawPave(status, 0);
461  returnCode += PublishHistogram(Pad[padID],2,mvtxmon_LaneStatusOverview[1][NFlx],"lcolz");
462  DrawPave(status, 3);
463  returnCode += PublishHistogram(Pad[padID],3,mvtxmon_LaneStatusOverview[2][NFlx],"lcolz");
464  DrawPave(status, 6);
465  returnCode += PublishHistogram(Pad[padID],4,mvtxmon_mGeneralOccupancy[NFlx]);
466  returnCode += PublishHistogram(Pad[padID],4,mvtxmon_mGeneralOccupancy[NFlx],"colz same");
467  returnCode += PublishHistogram(Pad[padID],5,mvtxmon_mGeneralErrorPlots[NFlx]);
468  returnCode += PublishHistogram(Pad[padID],6,mvtxmon_mGeneralErrorFile[NFlx],"lcol");
469 
470  TPaveText *ptt5 = new TPaveText(.1,.85,.9,.95,"blNDC");
471  ptt5->SetTextSize(0.04);
472  ptt5->SetFillColor(0);
473  ptt5->SetLineColor(0);
474  ptt5->SetBorderSize(1);
475  ptt5->AddText(" FLX 0 FLX 1 FLX 2 FLX 3 FLX 4 FLX 5");
476  ptt5->Draw();
477 
478  Pad[padID]->cd(7);
479 
480  TPaveText *bulbRed = new TPaveText(0.1, 0.82, 0.9, 0.92, "NDC");
481  bulbRed->SetName("BulbRed");
482  formatPaveText(bulbRed, 0.05, kRed, 12, "#color[2]{It's Burning! Call The Expert!!!}");
483 
484  TPaveText *bulbYellow = new TPaveText(0.1, 0.82, 0.9, 0.92, "NDC");
485  bulbYellow->SetName("BulbYellow");
486  formatPaveText(bulbYellow, 0.05, kRed, 12, "#color[808]{Did you break it? Call The Expert!}");
487 
488  TPaveText *bulbGreen = new TPaveText(0.1, 0.82, 0.9, 0.92, "NDC");
489  bulbGreen->SetName("BulbGreen");
490  formatPaveText(bulbGreen, 0.05, kGreen, 12, "#color[418]{Chill, Have Some Coffee}");
491 
492  TPaveText *bulb = new TPaveText(0.05, 0.05, 0.95, 0.95, "NDC");
493 
494 
495  TPaveText *ptt4 = new TPaveText(.1,.07,.9,.58,"blNDC");
496  ptt4->SetTextSize(0.04);
497  ptt4->SetFillColor(0);
498  ptt4->SetTextAlign(22);
499  ptt4->SetLineColor(0);
500  ptt4->SetBorderSize(1);
501  ptt4->AddText("Alarms:");
502 
503 
504  if(status.at(9) == Quality::Good && status.at(10) == Quality::Good && status.at(11) == Quality::Good){
505  bulb->SetFillColor(kGreen);
506  bulb->Draw();
507  bulbGreen->Draw("same");
508  }
509 
510  if(status.at(9) == Quality::Medium || status.at(10) == Quality::Medium || status.at(11) == Quality::Medium){
511  if(status.at(9) == Quality::Medium) ptt4->AddText("#color[808]{QA Layer 0 Medium}");
512  if(status.at(10) == Quality::Medium) ptt4->AddText("#color[808]{QA Layer 1 Medium}");
513  if(status.at(11) == Quality::Medium) ptt4->AddText("#color[808]{QA Layer 2 Medium}");
514  bulb->SetFillColor(kYellow);
515  bulb->Draw();
516  bulbYellow->Draw("same");
517  }
518 
519  if(status.at(9) == Quality::Bad || status.at(10) == Quality::Bad || status.at(11) == Quality::Bad ||status.at(12) == Quality::Bad||status.at(13) == Quality::Bad||status.at(14) == Quality::Bad||status.at(15) == Quality::Bad||status.at(16) == Quality::Bad||status.at(17) == Quality::Bad ||(bitsetAND & 0x3F) != 0x3F){
520  if(status.at(9) == Quality::Bad) ptt4->AddText("#color[2]{QA Layer 0 Bad}");
521  if(status.at(10) == Quality::Bad) ptt4->AddText("#color[2]{QA Layer 1 Bad}");
522  if(status.at(11) == Quality::Bad) ptt4->AddText("#color[2]{QA Layer 2 Bad}");
523  if(status.at(12) == Quality::Bad) ptt4->AddText("#color[2]{Felix 0 Decoder Errors}");
524  if(status.at(13) == Quality::Bad) ptt4->AddText("#color[2]{Felix 1 Decoder Errors}");
525  if(status.at(14) == Quality::Bad) ptt4->AddText("#color[2]{Felix 2 Decoder Errors}");
526  if(status.at(15) == Quality::Bad) ptt4->AddText("#color[2]{Felix 3 Decoder Errors}");
527  if(status.at(16) == Quality::Bad) ptt4->AddText("#color[2]{Felix 4 Decoder Errors}");
528  if(status.at(17) == Quality::Bad) ptt4->AddText("#color[2]{Felix 5 Decoder Errors}");
529  if((bitsetAND & 0x3F) != 0x3F) ptt4->AddText("#color[2]{Some Servers are Offline or in Error}");
530  bulb->SetFillColor(kRed);
531  bulb->Draw();
532  bulbRed->Draw("same");
533  }
534 
535 
536 
537  ptt4->Draw();
538 
539  TPaveText *tlegend = new TPaveText(.2,.6,.8,.8,"blNDC");
540  tlegend->SetTextSize(0.04);
541  tlegend->SetFillColor(0);
542  tlegend->SetTextAlign(22);
543  tlegend->SetLineColor(0);
544  tlegend->SetBorderSize(1);
545  tlegend->AddText("Legend:");
546  tlegend->AddText("#color[418]{Green = QA OK}");
547  tlegend->AddText("#color[808]{Yellow = QA Medium}");
548  tlegend->AddText("#color[2]{Red = QA Bad}");
549  tlegend->Draw();
550 
551  Pad[padID]->cd(8);
552  TPaveText *pt = new TPaveText(.05,.1,.95,.8);
553  pt->AddText("Online Monitoring Server Status");
554  for (int iFelix = 0; iFelix < NFlx; iFelix++){
555  std::string serverStatus = "Felix " + std::to_string(iFelix);
556  if((bitsetOR & (1<<iFelix)) == 1<<iFelix && (bitsetAND & (1<<iFelix)) == 1<<iFelix) serverStatus += " #color[418]{ONLINE} ";
557  if((bitsetOR & (1<<iFelix)) == 0 && (bitsetAND & (1<<iFelix)) == 0) serverStatus += " #color[2]{OFFLINE}";
558  if((bitsetOR & (1<<iFelix)) == 1<<iFelix && (bitsetAND & (1<<iFelix)) == 0) serverStatus += " #color[2]{ERROR}";
559  pt->AddText(serverStatus.c_str());
560  }
561  pt->Draw();
562  PublishStatistics(TC[canvasID],cl);
563  TC[canvasID]->SetEditable(false);
564  return returnCode < 0 ? -1 : 0;
565 }
566 
567 int MvtxMonDraw::DrawFEE(const std::string & /* what */)
568 {
570  const int canvasID = 2;
571  const int padID = 2;
572 
573  TH2I* mTriggerVsFeeId[NFlx+1] = {nullptr};
574  TH1I* mTrigger[NFlx+1] ={nullptr};
575  //TH2I* mLaneInfo[NFlx+1] = {nullptr};
576  TH2I* mLaneStatus[3][NFlx+1] = {nullptr};
577  TH2I* mLaneStatusCumulative[3][NFlx+1] = {nullptr};
578  TH1I* mLaneStatusSummary[3][NFlx+1] = {nullptr};
579  TH1I* mLaneStatusSummaryIB[NFlx+1] = {nullptr};
580 
581  for (int iFelix = 0; iFelix <NFlx; iFelix++){
582  mTriggerVsFeeId[iFelix] = dynamic_cast<TH2I*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_FEE_TriggerVsFeeid"));
583  mTrigger[iFelix] = dynamic_cast<TH1I*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_FEE_TriggerFlag"));
584  //mLaneInfo[iFelix] = dynamic_cast<TH2I*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON/FEE/LaneInfo"));
585  mLaneStatusSummaryIB[iFelix]= dynamic_cast<TH1I*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_LaneStatusSummary_LaneStatusSummary"));
586  for (int i = 0; i < 3; i++) {
587  mLaneStatus[i][iFelix] = dynamic_cast<TH2I*>(cl->getHisto(Form("MVTXMON_%d",iFelix),Form("MVTXMON_LaneStatus_laneStatusFlag%s", mLaneStatusFlag[i].c_str())));
588  mLaneStatusCumulative[i][iFelix] = dynamic_cast<TH2I*>(cl->getHisto(Form("MVTXMON_%d",iFelix),Form("MVTXMON_LaneStatus_laneStatusFlagCumulative%s", mLaneStatusFlag[i].c_str())));
589  mLaneStatusSummary[i][iFelix] = dynamic_cast<TH1I*>(cl->getHisto(Form("MVTXMON_%d",iFelix),Form("MVTXMON_LaneStatusSummary_LaneStatusSummaryL%i", i)));
590  }
591  }
592 
593  for (int i = 0; i < 3; i++) {
594  MergeServers<TH2I*>(mLaneStatus[i]);
595  MergeServers<TH2I*>(mLaneStatusCumulative[i]);
596  MergeServers<TH1I*>(mLaneStatusSummary[i]);
597  }
598  MergeServers<TH2I*>(mTriggerVsFeeId);
599  MergeServers<TH1I*>(mTrigger);
600  //MergeServers<TH2I*>(mLaneInfo);
601  MergeServers<TH1I*>(mLaneStatusSummaryIB);
602 
603  if (!gROOT->FindObject("MvtxMon_FEE"))
604  {
605  MakeCanvas("MvtxMon_FEE");
606  }
607 
608  TC[canvasID]->SetEditable(true);
609  TC[canvasID]->Clear("D");
610  Pad[padID]->Divide(4,3);
611 
612  for (int i = 0; i < 3; i++) {
613  if(mLaneStatus[i][NFlx]){
614  mLaneStatus[i][NFlx]->GetXaxis()->SetTitleSize(0.055);
615  mLaneStatus[i][NFlx]->GetXaxis()->SetTitleOffset(0.85);
616  mLaneStatus[i][NFlx]->GetYaxis()->SetTitleSize(0.06);
617  mLaneStatus[i][NFlx]->GetXaxis()->SetLabelSize(0.05);
618  mLaneStatus[i][NFlx]->GetYaxis()->SetLabelSize(0.05);
619  }
620  if(mLaneStatusCumulative[i][NFlx]){
621  mLaneStatusCumulative[i][NFlx]->GetXaxis()->SetTitleSize(0.055);
622  mLaneStatusCumulative[i][NFlx]->GetXaxis()->SetTitleOffset(0.85);
623  mLaneStatusCumulative[i][NFlx]->GetYaxis()->SetTitleSize(0.06);
624  mLaneStatusCumulative[i][NFlx]->GetXaxis()->SetLabelSize(0.05);
625  mLaneStatusCumulative[i][NFlx]->GetYaxis()->SetLabelSize(0.05);
626  }
627  if(mLaneStatusSummary[i][NFlx]){
628  mLaneStatusSummary[i][NFlx]->GetXaxis()->SetLabelSize(0.07);
629  mLaneStatusSummary[i][NFlx]->GetYaxis()->SetTitleSize(0.06);
630  mLaneStatusSummary[i][NFlx]->GetYaxis()->SetLabelSize(0.05);
631  mLaneStatusSummary[i][NFlx]->GetYaxis()->SetTitleOffset(0.9);
632  }
633  }
634  if(mLaneStatusSummaryIB[NFlx]){
635  mLaneStatusSummaryIB[NFlx]->GetXaxis()->SetLabelSize(0.07);
636  mLaneStatusSummaryIB[NFlx]->GetYaxis()->SetTitleSize(0.06);
637  mLaneStatusSummaryIB[NFlx]->GetYaxis()->SetLabelSize(0.05);
638  mLaneStatusSummaryIB[NFlx]->GetYaxis()->SetTitleOffset(0.9);
639  }
640  if(mTriggerVsFeeId[NFlx]){
641  mTriggerVsFeeId[NFlx]->GetXaxis()->SetTitleSize(0.055);
642  mTriggerVsFeeId[NFlx]->GetXaxis()->SetTitleOffset(0.75);
643  mTriggerVsFeeId[NFlx]->GetYaxis()->SetTitleOffset(1.2);
644  mTriggerVsFeeId[NFlx]->GetYaxis()->SetTitleSize(0.06);
645  mTriggerVsFeeId[NFlx]->GetYaxis()->SetLabelSize(0.06);
646  mTriggerVsFeeId[NFlx]->GetXaxis()->SetLabelSize(0.05);
647  }
648  if(mTrigger[NFlx]){
649  mTrigger[NFlx]->GetXaxis()->SetTitleSize(0.055);
650  mTrigger[NFlx]->GetXaxis()->SetTitleOffset(0.85);
651  mTrigger[NFlx]->GetYaxis()->SetTitleSize(0.06);
652  mTrigger[NFlx]->GetYaxis()->SetLabelSize(0.06);
653  mTrigger[NFlx]->GetXaxis()->SetLabelSize(0.05);
654  mTrigger[NFlx]->GetYaxis()->SetTitleOffset(0.85);
655  }
656 
657  TPaveText *tlayer[3] = {nullptr};
658 
659  for (int i = 0; i < 3 ; i++){
660  double shift[3] = {0,0.25,0.55};
661  tlayer[i] = new TPaveText(.14+shift[i],.87,.24+shift[i],.93,"blNDC");
662  tlayer[i]->SetTextSize(0.05);
663  tlayer[i]->SetFillColor(0);
664  tlayer[i]->SetTextAlign(22);
665  tlayer[i]->SetLineColor(0);
666  tlayer[i]->SetBorderSize(1);
667  tlayer[i]->AddText(Form("Layer %d", i));
668  }
669 
670  Pad[padID]->cd(3)->SetTopMargin(0.16);
671  Pad[padID]->cd(4)->SetTopMargin(0.16);
672  Pad[padID]->cd(4)->SetTopMargin(0.145);
673  Pad[padID]->cd(7)->SetTopMargin(0.16);
674  Pad[padID]->cd(8)->SetTopMargin(0.16);
675  Pad[padID]->cd(11)->SetTopMargin(0.16);
676  Pad[padID]->cd(12)->SetTopMargin(0.16);
677 
678  int returnCode = 0;
679  Pad[padID]->cd(1)->SetLeftMargin(0.16);
680  returnCode += PublishHistogram(Pad[padID],1,mTriggerVsFeeId[NFlx],"lcol");
681  returnCode += PublishHistogram(Pad[padID],5,mTrigger[NFlx]);
682  //returnCode += PublishHistogram(Pad[9],3,mLaneInfo[NFlx]);
683  returnCode += PublishHistogram(Pad[padID],3,mLaneStatus[0][NFlx]);
684  for(int i = 0;i<3;i++)tlayer[i]->Draw();
685  returnCode += PublishHistogram(Pad[padID],7,mLaneStatus[1][NFlx]);
686  for(int i = 0;i<3;i++)tlayer[i]->Draw();
687  returnCode += PublishHistogram(Pad[padID],11,mLaneStatus[2][NFlx]);
688  for(int i = 0;i<3;i++)tlayer[i]->Draw();
689  returnCode += PublishHistogram(Pad[padID],4,mLaneStatusCumulative[0][NFlx]);
690  for(int i = 0;i<3;i++)tlayer[i]->Draw();
691  returnCode += PublishHistogram(Pad[padID],8,mLaneStatusCumulative[1][NFlx]);
692  for(int i = 0;i<3;i++)tlayer[i]->Draw();
693  returnCode += PublishHistogram(Pad[padID],12,mLaneStatusCumulative[2][NFlx]);
694  for(int i = 0;i<3;i++)tlayer[i]->Draw();
695  returnCode += PublishHistogram(Pad[padID],2,mLaneStatusSummary[0][NFlx]);
696  returnCode += PublishHistogram(Pad[padID],6,mLaneStatusSummary[1][NFlx]);
697  returnCode += PublishHistogram(Pad[padID],10,mLaneStatusSummary[2][NFlx]);
698  returnCode += PublishHistogram(Pad[padID],9,mLaneStatusSummaryIB[NFlx]);
699 
700  PublishStatistics(TC[canvasID],cl);
701  TC[canvasID]->SetEditable(false);
702  return returnCode < 0 ? -1 : 0;
703 }
704 
705 int MvtxMonDraw::DrawOCC(const std::string & /* what */)
706 {
708  const int canvasID = 3;
709  const int padID = 3;
710 
711  TH1D* hOccupancyPlot[3][NFlx+1] = {nullptr};
712  TH2D* hChipStaveOccupancy[3][NFlx+1] = {nullptr};
713  TH1D *mvtxmon_ChipStave1D[NFlx+1] = {nullptr};
714  TH1D *mvtxmon_ChipFiredHis[NFlx+1] = {nullptr};
715  TH1I *hChipStrobes[NFlx+1] = {nullptr};
716  TH1I *hChipL1[NFlx+1] = {nullptr};
717 
718  for (int aLayer = 0; aLayer < 3; aLayer++) {
719  for (int iFelix = 0; iFelix <NFlx; iFelix++){
720  hOccupancyPlot[aLayer][iFelix] = dynamic_cast<TH1D*>(cl->getHisto(Form("MVTXMON_%d",iFelix),Form("MVTXMON_Occupancy_Layer%dOccupancy", aLayer)));
721  hChipStaveOccupancy[aLayer][iFelix] = dynamic_cast<TH2D*>(cl->getHisto(Form("MVTXMON_%d",iFelix),Form("MVTXMON_Occupancy_Layer%d_Layer%dChipStave", aLayer, aLayer)));
722  }
723  }
724 
725  for (int iFelix = 0; iFelix <NFlx; iFelix++){
726  mvtxmon_ChipStave1D[iFelix] = dynamic_cast<TH1D*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_RawData_ChipStave1D"));
727  mvtxmon_ChipFiredHis[iFelix] = dynamic_cast<TH1D*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_RawData_ChipFiredHis"));
728  hChipStrobes[iFelix] = dynamic_cast<TH1I*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"hChipStrobes"));
729  hChipL1[iFelix] = dynamic_cast<TH1I*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"hChipL1"));
730  }
731 
732  for (int i = 0; i < 3; i++) {
733  MergeServers<TH1D*>(hOccupancyPlot[i]);
734  MergeServers<TH2D*>(hChipStaveOccupancy[i]);
735  }
736 
737  TH2D *hChipStaveOccupancy_low[3] = {nullptr};
738 
739  for (int i = 0; i < 3; i++) {
740  if(hOccupancyPlot[i][NFlx]){
741  hOccupancyPlot[i][NFlx]->GetXaxis()->SetLabelSize(0.05);
742  hOccupancyPlot[i][NFlx]->GetXaxis()->SetTitleSize(0.05);
743  hOccupancyPlot[i][NFlx]->GetXaxis()->SetTitleOffset(0.85);
744  hOccupancyPlot[i][NFlx]->GetYaxis()->SetLabelSize(0.045);
745  hOccupancyPlot[i][NFlx]->GetYaxis()->SetTitleSize(0.05);
746  hOccupancyPlot[i][NFlx]->GetYaxis()->SetTitleOffset(1);
747  hChipStaveOccupancy[i][NFlx]->SetMinimum(0);
748  }
749  if(hChipStaveOccupancy[i][NFlx]){
750  hChipStaveOccupancy[i][NFlx]->GetXaxis()->SetLabelSize(0.05);
751  hChipStaveOccupancy[i][NFlx]->GetXaxis()->SetTitleSize(0.05);
752  hChipStaveOccupancy[i][NFlx]->GetXaxis()->SetTitleOffset(0.85);
753  hChipStaveOccupancy[i][NFlx]->GetYaxis()->SetLabelSize(0.06);
754  hChipStaveOccupancy[i][NFlx]->GetYaxis()->SetTitleSize(0.05);
755  hChipStaveOccupancy[i][NFlx]->GetYaxis()->SetTitleOffset(0.7);
756 
757  hChipStaveOccupancy_low[i] = (TH2D*)(hChipStaveOccupancy[i][NFlx])->Clone(Form("hChipStaveOccupancy_low_%d",i));
758  TString tmp = "Chip Occupancy < 1\%";
759  hChipStaveOccupancy_low[i]->SetTitle(tmp + Form(" of average occupancy in layer %d",i));
760  }
761  }
762 
763 
764 
765  MergeServers<TH1D*>(mvtxmon_ChipStave1D);
766  MergeServers<TH1D*>(mvtxmon_ChipFiredHis);
767  MergeServers<TH1I*>(hChipStrobes);
768  MergeServers<TH1I*>(hChipL1);
769 
770  if(mvtxmon_ChipStave1D[NFlx]){
771  mvtxmon_ChipStave1D[NFlx]->GetXaxis()->SetLabelSize(0.05);
772  mvtxmon_ChipStave1D[NFlx]->GetXaxis()->SetTitleSize(0.055);
773  mvtxmon_ChipStave1D[NFlx]->GetXaxis()->SetTitleOffset(0.75);
774  mvtxmon_ChipStave1D[NFlx]->GetYaxis()->SetLabelSize(0.045);
775  mvtxmon_ChipStave1D[NFlx]->GetYaxis()->SetTitleSize(0.06);
776  mvtxmon_ChipStave1D[NFlx]->GetYaxis()->SetTitleOffset(1.2);
777  }
778 
779  if(mvtxmon_ChipFiredHis[NFlx]){
780  mvtxmon_ChipFiredHis[NFlx]->GetXaxis()->SetLabelSize(0.05);
781  mvtxmon_ChipFiredHis[NFlx]->GetXaxis()->SetTitleSize(0.055);
782  mvtxmon_ChipFiredHis[NFlx]->GetXaxis()->SetTitleOffset(0.75);
783  mvtxmon_ChipFiredHis[NFlx]->GetYaxis()->SetLabelSize(0.06);
784  mvtxmon_ChipFiredHis[NFlx]->GetYaxis()->SetTitleSize(0.06);
785  mvtxmon_ChipFiredHis[NFlx]->GetYaxis()->SetTitleOffset(1.2);
786  }
787 
788  double avr_occ[3] = {0};
789 
790  for (int iLayer = 0; iLayer < 3; iLayer++) {
791  for (int iStave = 0; iStave < NStaves[iLayer]; iStave++) {
792  for (int iChip = 0; iChip < 9; iChip++) {
793  double occ = hChipStaveOccupancy[iLayer][NFlx]->GetBinContent(iChip+1,iStave+1)/(hChipStrobes[NFlx]->GetBinContent((StaveBoundary[iLayer]+iStave)*9+iChip+1)*1024*512);
794  if(occ > 10e-50)hChipStaveOccupancy[iLayer][NFlx]->SetBinContent(iChip+1,iStave+1,occ);
795  if(occ > 10e-50)avr_occ[iLayer]+=occ;
796  }
797  }
798  }
799 
800 for (int iLayer = 0; iLayer < 3; iLayer++) {
801  avr_occ[iLayer]/=(NStaves[iLayer]*9);
802  for (int iStave = 0; iStave < NStaves[iLayer]; iStave++) {
803  for (int iChip = 0; iChip < 9; iChip++) {
804  double occ = hChipStaveOccupancy[iLayer][NFlx]->GetBinContent(iChip+1,iStave+1);
805  if(occ <0.01* avr_occ[iLayer]) hChipStaveOccupancy_low[iLayer]->SetBinContent(iChip+1,iStave+1,1);
806  else hChipStaveOccupancy_low[iLayer]->SetBinContent(iChip+1,iStave+1,0);
807  }
808  }
809  }
810 
811 
812 
813  if (!gROOT->FindObject("MvtxMon_OCC"))
814  {
815  MakeCanvas("MvtxMon_OCC");
816 
817 
818  }
819 
820  TC[canvasID]->SetEditable(true);
821  TC[canvasID]->Clear("D");
822  Pad[padID]->Divide(4,3);
823  Pad[padID]->cd(1)->SetLogy();
824  Pad[padID]->cd(2)->SetLogy();
825  Pad[padID]->cd(3)->SetLogy();
826 
827 
828  hChipStaveOccupancy[0][NFlx]->GetZaxis()->SetTitle("");
829  hChipStaveOccupancy[1][NFlx]->GetZaxis()->SetTitle("");
830  hChipStaveOccupancy[2][NFlx]->GetZaxis()->SetTitle("");
831 
832  hChipStrobes[NFlx]->SetTitle("Chip Strobes (L1 triggers) vs Chip*Stave");
833  hChipStrobes[NFlx]->GetYaxis()->SetTitle("Number of strobes");
834 
835 
836  int returnCode = 0;
837  returnCode += PublishHistogram(Pad[padID],1,hOccupancyPlot[0][NFlx]);
838  returnCode += PublishHistogram(Pad[padID],2,hOccupancyPlot[1][NFlx]);
839  returnCode += PublishHistogram(Pad[padID],3,hOccupancyPlot[2][NFlx]);
840  returnCode += PublishHistogram(Pad[padID],5,hChipStaveOccupancy[0][NFlx],"colz");
841  returnCode += PublishHistogram(Pad[padID],6,hChipStaveOccupancy[1][NFlx],"colz");
842  returnCode += PublishHistogram(Pad[padID],7,hChipStaveOccupancy[2][NFlx],"colz");
843  returnCode += PublishHistogram(Pad[padID],9,hChipStaveOccupancy_low[0],"col");
844  returnCode += PublishHistogram(Pad[padID],10,hChipStaveOccupancy_low[1],"col");
845  returnCode += PublishHistogram(Pad[padID],11,hChipStaveOccupancy_low[2],"col");
846  returnCode += PublishHistogram(Pad[padID],4,mvtxmon_ChipStave1D[NFlx]);
847  returnCode += PublishHistogram(Pad[padID],8,mvtxmon_ChipFiredHis[NFlx]);
848  returnCode += PublishHistogram(Pad[padID],12,hChipStrobes[NFlx]);
849 
850 //for( int i = 1; i<= hChipL1[NFlx]->GetNbinsX();i++) std::cout<<hChipL1[NFlx]->GetBinContent(i)<<" ";
851 
852  Float_t rightmax = 2*hChipL1[NFlx]->GetMaximum();
853  Float_t scale = hChipStrobes[NFlx]->GetMaximum()/rightmax;
854  hChipL1[NFlx]->SetLineColor(kRed);
855  hChipL1[NFlx]->Scale(scale);
856  //std::cout<<rightmax<<" "<<hChipStrobes[NFlx]->GetMaximum()<<" "<<scale<<std::endl;
857  returnCode += PublishHistogram(Pad[padID],12,hChipL1[NFlx],"same hist");
858 
859  TGaxis *axis = new TGaxis(48*9,hChipStrobes[NFlx]->GetMinimum(), 48*9, hChipStrobes[NFlx]->GetMaximum(),0,rightmax,510,"+L");
860  axis->SetLineColor(kRed);
861  axis->SetLabelColor(kRed);
862  axis->SetLabelFont(42);
863  axis->SetTitleFont(42);
864  axis->SetTitleColor(kRed);
865  axis->SetTitle("Number of L1 triggers");
866  axis->Draw();
867 
868  TPaveText *pt = new TPaveText(6,12,8.5,13);
869  pt->SetBorderSize(0);
870  pt->SetFillStyle(0);
871  TText *t1 = pt->AddText("Not saved in .root");
872  t1->SetTextColor(kRed);
873  Pad[padID]->cd(9);
874  pt->Draw();
875  Pad[padID]->cd(10);
876  pt->Draw();
877  Pad[padID]->cd(11);
878  pt->Draw();
879 
880  PublishStatistics(TC[canvasID],cl);
881  TC[canvasID]->SetEditable(false);
882  return returnCode < 0 ? -1 : 0;
883 }
884 
885 int MvtxMonDraw::DrawFHR(const std::string & /* what */)
886 {
888  const int canvasID = 4;
889  const int padID = 4;
890 
891  TH2D* mDeadChipPos[3][NFlx+1] = {nullptr};
892  TH2D* mAliveChipPos[3][NFlx+1] = {nullptr};
893  //TH2D* mChipStaveOccupancy[3][NFlx];
894  TH1D* mOccupancyPlot[3][NFlx+1] = {nullptr};
895 
896  TH2I* mErrorVsFeeid[NFlx+1] = {nullptr};
897  TH2Poly* mGeneralOccupancy[NFlx+1] = {nullptr};
898  TH2Poly* mGeneralNoisyPixel[NFlx+1] = {nullptr};
899  TH2D* mTotalDeadChipPos[NFlx+1] = {nullptr};
900  TH2D* mTotalAliveChipPos[NFlx+1] = {nullptr};
901  TH1D *mvtxmon_EvtHitChip[NFlx+1] = {nullptr};
902  TH1D *mvtxmon_EvtHitDis[NFlx+1] = {nullptr};
903 
904  TH1I *mRCDAQevt[NFlx+1] = {nullptr};
905 
906  TH2D* mChipStaveNoisy[3][NFlx+1];
907 
908  int nFLX[3]= {0};
909 
910  for (int iFelix = 0; iFelix <NFlx; iFelix++){
911  mErrorVsFeeid[iFelix] = dynamic_cast<TH2I*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_General_ErrorVsFeeid"));
912  mGeneralOccupancy[iFelix] = dynamic_cast<TH2Poly*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_General_Occupancy"));
913  mGeneralNoisyPixel[iFelix] = dynamic_cast<TH2Poly*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_General_Noisy_Pixel"));
914  mTotalDeadChipPos[iFelix] = dynamic_cast<TH2D*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_Occupancy_TotalDeadChipPos"));
915  mTotalAliveChipPos[iFelix] = dynamic_cast<TH2D*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_Occupancy_TotalAliveChipPos"));
916  mvtxmon_EvtHitChip[iFelix] = dynamic_cast<TH1D*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_RawData_EvtHitChip"));
917  mvtxmon_EvtHitDis[iFelix] = dynamic_cast<TH1D*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"MVTXMON_RawData_EvtHitDis"));
918  mRCDAQevt[iFelix] = dynamic_cast<TH1I*>(cl->getHisto(Form("MVTXMON_%d",iFelix),"RCDAQ_evt"));
919  for (int mLayer = 0; mLayer < 3; mLayer++) {
920  mDeadChipPos[mLayer][iFelix] = dynamic_cast<TH2D*>(cl->getHisto(Form("MVTXMON_%d",iFelix),Form("MVTXMON_Occupancy_Layer%d_Layer%dDeadChipPos", mLayer, mLayer)));
921  if(mDeadChipPos[mLayer][iFelix]) nFLX[mLayer]++;
922  mAliveChipPos[mLayer][iFelix] = dynamic_cast<TH2D*>(cl->getHisto(Form("MVTXMON_%d",iFelix),Form("MVTXMON_Occupancy_Layer%d_Layer%dAliveChipPos", mLayer, mLayer)));
923  // mChipStaveOccupancy[mLayer][iFelix] = dynamic_cast<TH2D*>(cl->getHisto(Form("MVTXMON/Occupancy/Layer%d/Layer%dChipStaveC", mLayer, mLayer)));
924  mOccupancyPlot[mLayer][iFelix] = dynamic_cast<TH1D*>(cl->getHisto(Form("MVTXMON_%d",iFelix),Form("MVTXMON_Occupancy_Layer%dOccupancy_LOG", mLayer)));
925 
926  mChipStaveNoisy[mLayer][iFelix] = dynamic_cast<TH2D*>(cl->getHisto(Form("MVTXMON_%d",iFelix),Form("MVTXMON_Noisy_Layer%d_ChipStave", mLayer)));
927  }
928  }
929 
930  for (int iFelix = 0; iFelix < NFlx; iFelix++) {
931  for (int mLayer = 0; mLayer < 3; mLayer++) {
932  if(mAliveChipPos[mLayer][iFelix] && mRCDAQevt[iFelix]) mAliveChipPos[mLayer][iFelix]->Scale(1./mRCDAQevt[iFelix]->Integral());
933 
934  if(mChipStaveNoisy[mLayer][iFelix] && mRCDAQevt[iFelix]) mChipStaveNoisy[mLayer][iFelix]->Scale(1./mRCDAQevt[iFelix]->Integral());
935  }
936  if(mGeneralNoisyPixel[iFelix] && mRCDAQevt[iFelix]) mGeneralNoisyPixel[iFelix]->Scale(1./mRCDAQevt[iFelix]->Integral());
937  }
938 
939  for (int mLayer = 0; mLayer < 3; mLayer++) {
940  MergeServers<TH2D*>(mDeadChipPos[mLayer]);
941  MergeServers<TH2D*>(mAliveChipPos[mLayer]);
942  MergeServers<TH1D*>(mOccupancyPlot[mLayer]);
943  MergeServers<TH2D*>(mChipStaveNoisy[mLayer]);
944  if(mDeadChipPos[mLayer][NFlx]){
945  mDeadChipPos[mLayer][NFlx]->SetMinimum(0);
946  mDeadChipPos[mLayer][NFlx]->SetMaximum(1);
947  }
948  /*if(mAliveChipPos[mLayer][NFlx]){
949  mAliveChipPos[mLayer][NFlx]->SetMinimum(0);
950  mAliveChipPos[mLayer][NFlx]->SetMaximum(1);
951  }*/
952  }
953 
954 
955 
956  MergeServers<TH2I*>(mErrorVsFeeid);
957  MergeServers<TH2Poly*>(mGeneralOccupancy);
958  MergeServers<TH2Poly*>(mGeneralNoisyPixel);
959  MergeServers<TH2D*>(mTotalDeadChipPos);
960  MergeServers<TH2D*>(mTotalAliveChipPos);
961  MergeServers<TH1D*>(mvtxmon_EvtHitChip);
962  MergeServers<TH1D*>(mvtxmon_EvtHitDis);
963  MergeServers<TH1I*>(mRCDAQevt);
964 
965  if(mTotalDeadChipPos[NFlx]){
966  mTotalDeadChipPos[NFlx]->SetMinimum(0);
967  mTotalDeadChipPos[NFlx]->SetMaximum(1);
968  }
969  /* if(mTotalAliveChipPos[NFlx]){
970  mTotalAliveChipPos[NFlx]->SetMinimum(0);
971  mTotalAliveChipPos[NFlx]->SetMaximum(1);
972  }*/
973 
974  for (int mLayer = 0; mLayer < 3; mLayer++) {
975  if(mDeadChipPos[mLayer][NFlx]){
976  for (int binx = 0; binx < mDeadChipPos[mLayer][NFlx]->GetNbinsX(); binx++) {
977  for (int biny = 0; biny < mDeadChipPos[mLayer][NFlx]->GetNbinsY(); biny++) {
978 
979  mDeadChipPos[mLayer][NFlx]->SetBinContent(binx+1,biny+1,mDeadChipPos[mLayer][NFlx]->GetBinContent(binx+1,biny+1)-nFLX[mLayer]+1);
980 }
981 }
982  }
983  }
984 
985 
986 
987  if (!gROOT->FindObject("MvtxMon_FHR"))
988  {
989  MakeCanvas("MvtxMon_FHR");
990  }
991 
992  TC[canvasID]->SetEditable(true);
993  TC[canvasID]->Clear("D");
994  Pad[padID]->Divide(5,3);
995 
996  int returnCode = 0;
997  // returnCode += PublishHistogram(Pad[padID],1,mErrorVsFeeid[0]);
998  // returnCode += PublishHistogram(Pad[padID],6,mGeneralOccupancy[NFlx],"COLZ");
999  returnCode += PublishHistogram(Pad[padID],5,mGeneralNoisyPixel[NFlx],"COLZ");
1000  returnCode += PublishHistogram(Pad[padID],1,mDeadChipPos[0][NFlx],"COL");
1001  returnCode += PublishHistogram(Pad[padID],6,mDeadChipPos[1][NFlx],"COL");
1002  returnCode += PublishHistogram(Pad[padID],11,mDeadChipPos[2][NFlx],"COL");
1003  returnCode += PublishHistogram(Pad[padID],2,mAliveChipPos[0][NFlx],"COLZ");
1004  returnCode += PublishHistogram(Pad[padID],7,mAliveChipPos[1][NFlx],"COLZ");
1005  returnCode += PublishHistogram(Pad[padID],12,mAliveChipPos[2][NFlx],"COLZ");
1006  // returnCode += PublishHistogram<TH2D*>(TC[canvasID],10,mChipStaveOccupancy[0][0]);
1007  // returnCode += PublishHistogram<TH2D*>(TC[canvasID],11,mChipStaveOccupancy[1][0]);
1008 // returnCode += PublishHistogram<TH2D*>(TC[canvasID],12,mChipStaveOccupancy[2][0]);
1009  returnCode += PublishHistogram(Pad[padID],3,mChipStaveNoisy[0][NFlx],"COLZ");
1010  returnCode += PublishHistogram(Pad[padID],8,mChipStaveNoisy[1][NFlx],"COLZ");
1011  returnCode += PublishHistogram(Pad[padID],13,mChipStaveNoisy[2][NFlx],"COLZ");
1012  returnCode += PublishHistogram(Pad[padID],4,mOccupancyPlot[0][NFlx]);
1013  returnCode += PublishHistogram(Pad[padID],9,mOccupancyPlot[1][NFlx]);
1014  returnCode += PublishHistogram(Pad[padID],14,mOccupancyPlot[2][NFlx]);
1015 
1016  PublishHistogram(Pad[padID],10,mvtxmon_EvtHitChip[NFlx]);
1017  PublishHistogram(Pad[padID],15,mvtxmon_EvtHitDis[NFlx]);
1018 
1019  //returnCode += PublishHistogram(Pad[11],16,mTotalDeadChipPos[NFlx],"COL");
1020  //returnCode += PublishHistogram(Pad[11],17,mTotalAliveChipPos[NFlx],"COL");
1021 
1022 
1023  PublishStatistics(TC[canvasID],cl);
1024  TC[canvasID]->SetEditable(false);
1025  return returnCode < 0 ? -1 : 0;
1026 }
1027 
1029 {
1030 
1032  int iret = Draw(what);
1033  if (iret) // on error no png files please
1034  {
1035  return iret;
1036  }
1037  int icnt = 0;
1038  for (TCanvas *canvas : TC)
1039  {
1040  if (canvas == nullptr)
1041  {
1042  continue;
1043  }
1044  icnt++;
1045  std::string filename = ThisName + "_" + std::to_string(icnt) + "_" +
1046  std::to_string(cl->RunNumber()) + "." + type;
1047  cl->CanvasToPng(canvas, filename);
1048  }
1049  return 0;
1050 }
1051 
1053 {
1054  int iret = Draw(what);
1055  if (iret) // on error no html output please
1056  {
1057  return iret;
1058  }
1059 
1061 
1062  int icnt = 0;
1063  for (TCanvas *canvas : TC)
1064  {
1065  if (canvas == nullptr)
1066  {
1067  continue;
1068  }
1069  icnt++;
1070  // Register the canvas png file to the menu and produces the png file.
1071  std::string pngfile = cl->htmlRegisterPage(*this, canvas->GetTitle(), std::to_string(icnt), "png");
1072  cl->CanvasToPng(canvas, pngfile);
1073  }
1074  // Now register also EXPERTS html pages, under the EXPERTS subfolder.
1075 
1076  // std::string logfile = cl->htmlRegisterPage(*this, "EXPERTS/Log", "log", "html");
1077  // std::ofstream out(logfile.c_str());
1078  // out << "<HTML><HEAD><TITLE>Log file for run " << cl->RunNumber()
1079  // << "</TITLE></HEAD>" << std::endl;
1080  // out << "<P>Some log file output would go here." << std::endl;
1081  // out.close();
1082 
1083  // std::string status = cl->htmlRegisterPage(*this, "EXPERTS/Status", "status", "html");
1084  // std::ofstream out2(status.c_str());
1085  // out2 << "<HTML><HEAD><TITLE>Status file for run " << cl->RunNumber()
1086  // << "</TITLE></HEAD>" << std::endl;
1087  // out2 << "<P>Some status output would go here." << std::endl;
1088  // out2.close();
1089  // cl->SaveLogFile(*this);
1090  return 0;
1091 }
1092 
1093 int MvtxMonDraw::DrawHistory(const std::string & /* what */)
1094 {
1095 
1096  const int canvasID = 5;
1097  const int padID = 5;
1098 
1099  int iret[NFlx] = {0,0,0,0,0,0};
1100  // you need to provide the following vectors
1101  // which are filled from the db
1102  std::vector<float> var[NFlx];
1103  std::vector<float> varerr[NFlx];
1104  std::vector<time_t> timestamp[NFlx];
1105  std::vector<int> runnumber[NFlx];
1106  std::string varname = "n_events";
1107  // this sets the time range from whihc values should be returned
1108  time_t begin = 0; // begin of time (1.1.1970)
1109  time_t end = time(nullptr); // current time (right NOW)
1110 
1111  for (int iFelix = 0; iFelix <NFlx; iFelix++){
1112  iret[iFelix] = dbvars[iFelix]->GetVar(begin, end, varname, timestamp[iFelix], runnumber[iFelix], var[iFelix], varerr[iFelix]);
1113  if (iret[iFelix]){
1114  std::cout << __PRETTY_FUNCTION__ << " Error in db access: FELIX "<<iFelix << std::endl;
1115  //return iret;
1116  }
1117  }
1118 
1119 
1120  if (!gROOT->FindObject("MvtxMon3"))
1121  {
1122  MakeCanvas("MvtxMon3");
1123  }
1124  TC[canvasID]->SetEditable(true);
1125  TC[canvasID]->Clear("D");
1126  Pad[padID]->Divide(3,2);
1127 
1128  for (int iFelix = 0; iFelix <NFlx; iFelix++){
1129  // timestamps come sorted in ascending order
1130  float *x = new float[var[iFelix].size()];
1131  float *y = new float[var[iFelix].size()];
1132  float *ex = new float[var[iFelix].size()];
1133  float *ey = new float[var[iFelix].size()];
1134  int n = var[iFelix].size();
1135  for (unsigned int i = 0; i < var[iFelix].size(); i++)
1136  {
1137  // std::cout << "timestamp: " << ctime(&timestamp[i])
1138  // << ", run: " << runnumber[i]
1139  // << ", var: " << var[i]
1140  // << ", varerr: " << varerr[i]
1141  // << std::endl;
1142  x[i] = timestamp[iFelix][i] - TimeOffsetTicks;
1143  y[i] = var[iFelix][i];
1144  ex[i] = 0;
1145  ey[i] = varerr[iFelix][i];
1146  }
1147  Pad[padID]->cd(iFelix+1);
1148  if (gr[iFelix])
1149  {
1150  delete gr[iFelix];
1151  }
1152  gr[iFelix] = new TGraphErrors(n, x, y, ex, ey);
1153  gr[iFelix]->SetMarkerColor(4);
1154  gr[iFelix]->SetMarkerStyle(21);
1155  gr[iFelix]->Draw("ALP");
1156  gr[iFelix]->GetXaxis()->SetTimeDisplay(1);
1157  gr[iFelix]->GetXaxis()->SetLabelSize(0.03);
1158  // the x axis labeling looks like crap
1159  // please help me with this, the SetNdivisions
1160  // don't do the trick
1161  gr[iFelix]->GetXaxis()->SetNdivisions(-1006);
1162  gr[iFelix]->GetXaxis()->SetTimeOffset(TimeOffsetTicks);
1163  gr[iFelix]->GetXaxis()->SetTimeFormat("%Y/%m/%d %H:%M");
1164  delete[] x;
1165  delete[] y;
1166  delete[] ex;
1167  delete[] ey;
1168  }
1169 
1170  /* varname = "mvtxmoncount";
1171  iret = dbvars->GetVar(begin, end, varname, timestamp, runnumber, var, varerr);
1172  if (iret)
1173  {
1174  std::cout << __PRETTY_FUNCTION__ << " Error in db access" << std::endl;
1175  return iret;
1176  }
1177  x = new float[var.size()];
1178  y = new float[var.size()];
1179  ex = new float[var.size()];
1180  ey = new float[var.size()];
1181  n = var.size();
1182  for (unsigned int i = 0; i < var.size(); i++)
1183  {
1184  // std::cout << "timestamp: " << ctime(&timestamp[i])
1185  // << ", run: " << runnumber[i]
1186  // << ", var: " << var[i]
1187  // << ", varerr: " << varerr[i]
1188  // << std::endl;
1189  x[i] = timestamp[i] - TimeOffsetTicks;
1190  y[i] = var[i];
1191  ex[i] = 0;
1192  ey[i] = varerr[i];
1193  }
1194  Pad[6]->cd();
1195  if (gr[1])
1196  {
1197  delete gr[1];
1198  }
1199  gr[1] = new TGraphErrors(n, x, y, ex, ey);
1200  gr[1]->SetMarkerColor(4);
1201  gr[1]->SetMarkerStyle(21);
1202  gr[1]->Draw("ALP");
1203  gr[1]->GetXaxis()->SetTimeDisplay(1);
1204  // TC[2]->Update();
1205  // h1->GetXaxis()->SetTimeDisplay(1);
1206  // h1->GetXaxis()->SetLabelSize(0.03);
1207  gr[1]->GetXaxis()->SetLabelSize(0.03);
1208  gr[1]->GetXaxis()->SetTimeOffset(TimeOffsetTicks);
1209  gr[1]->GetXaxis()->SetTimeFormat("%Y/%m/%d %H:%M");
1210  // h1->Draw();
1211  delete[] x;
1212  delete[] y;
1213  delete[] ex;
1214  delete[] ey;*/
1215 
1216  TC[canvasID]->Update();
1217  TC[canvasID]->SetEditable(false);
1218  return 0;
1219 }
1220 
1221 //template <typename T>
1222 int MvtxMonDraw::PublishHistogram(TCanvas *c, int pad, TH1 *h, const char* opt ){
1223  if(c && pad !=0){
1224  c->cd(pad);
1225  //std::cout<<"ups"<<std::endl;
1226  }
1227  if(h){
1228  h->DrawCopy(opt);
1229  return 0;
1230  }
1231  else{
1232  //DrawDeadServer(transparent[0]);
1233  return -1;
1234  }
1235 }
1236 
1237 //template <typename T>
1238 int MvtxMonDraw::PublishHistogram(TPad *p, int pad, TH1 *h, const char* opt ){
1239  if(p && pad !=0){
1240  p->cd(pad);
1241  TCanvas *c = nullptr;
1242  return PublishHistogram(c,0,h,opt);
1243  }
1244  else{
1245  return -1;
1246  }
1247 }
1248 
1249 //template <typename T>
1250 int MvtxMonDraw::PublishHistogram(TPad *p, TH1 *h, const char* opt ){
1251  if(p){
1252  p->cd();
1253  TCanvas *c = nullptr;
1254  return PublishHistogram(c,0,h,opt);
1255  }
1256 
1257  else{
1258  return -1;
1259  }
1260 }
1261 
1262 template <typename T>
1264  bool cloned = false;
1265  int bitset = 0;
1266  for (int iFelix = 0; iFelix < NFlx; iFelix++){
1267  if (cloned == false){
1268  if(h[iFelix]){
1269  h[NFlx] = dynamic_cast<T>(h[iFelix]->Clone());
1270  bitset |= (1U << (iFelix));
1271  cloned = true;
1272  }
1273  else continue;
1274  }
1275  else {
1276  if(h[iFelix]){
1277  h[NFlx]->Add(h[iFelix],1.);
1278  bitset |= (1U << (iFelix));
1279  }
1280  }
1281  }
1282  return bitset;
1283 }
1284 
1286  c->cd();
1287  TText PrintRun;
1288  PrintRun.SetTextFont(62);
1289  PrintRun.SetTextSize(0.04);
1290  PrintRun.SetNDC(); // set to normalized coordinates
1291  PrintRun.SetTextAlign(23); // center/top alignment
1292  std::ostringstream runnostream;
1293  std::string runstring;
1294  time_t evttime = cl->EventTime("CURRENT");
1295  // fill run number and event time into string
1296  runnostream << ThisName << "_1 Run " << cl->RunNumber()
1297  << ", Time: " << ctime(&evttime);
1298  runstring = runnostream.str();
1299  transparent[0]->cd();
1300  PrintRun.DrawText(0.5, 1., runstring.c_str());
1301  c->Update();
1302  c->Show();
1303 }
1304 
1305 void MvtxMonDraw::formatPaveText(TPaveText* aPT, float aTextSize, Color_t aTextColor, short aTextAlign, const char* aText)
1306 {
1307  aPT->SetTextSize(aTextSize);
1308  aPT->SetTextAlign(aTextAlign);
1309  aPT->SetFillColor(0);
1310  aPT->SetTextAlign(22);
1311  aPT->SetTextColor(aTextColor);
1312  aPT->AddText(aText);
1313 }
1314 
1315 std::vector<MvtxMonDraw::Quality> MvtxMonDraw::analyseForError(TH2Poly* over1, TH2Poly* over2,TH2Poly* over3, TH1* decErr){
1316  std::vector<Quality> result((NFlags+1)*NLAYERS+6);
1317  bool badStave[NFlags][NSTAVE];
1318  for (int iflag = 0; iflag < NFlags; iflag++) {
1319  for (int ilayer = 0; ilayer < NLAYERS; ilayer++) {
1320  result.at((3*iflag)+ilayer) = Quality::Good;
1321 }
1322 }
1323  //count dead staves
1324  for (int iflag = 0; iflag < NFlags; iflag++) {
1325  for (int ilayer = 0; ilayer < NLAYERS; ilayer++) {
1326  int countStave = 0;
1327  for (int ibin = StaveBoundary[ilayer] + 1; ibin <= StaveBoundary[ilayer + 1]; ++ibin) {
1328  badStave[iflag][ibin-1] = false;
1329  double bincontent = 0;
1330  if(iflag==0 && over1) bincontent = over1->GetBinContent(ibin);
1331  if(iflag==1 && over2) bincontent = over2->GetBinContent(ibin);
1332  if(iflag==2 && over3) bincontent = over3->GetBinContent(ibin);
1333  if (bincontent/*hp[iflag][NFlx]->GetBinContent(ibin)*/ > maxbadchips / 9.) {
1334  badStave[iflag][ibin-1] = true;
1335  //std::cout<<"bad stave"<<std::endl;
1336  countStave++;
1337  result.at((3*iflag)+ilayer) = Quality::Medium;
1338  }
1339  }
1340  if (countStave > 0.25 * NStaves[ilayer]) {
1341  result.at((3*iflag)+ilayer) = Quality::Bad;
1342  }
1343  }
1344  }
1345 
1346  // check if more than 25% staves with error, warning or fault
1347  for (int ilayer = 0; ilayer < NLAYERS; ilayer++) {
1348  int countStave = 0;
1349  result.at(ilayer+9) = Quality::Good;
1350  for (int ibin = StaveBoundary[ilayer] + 1; ibin <= StaveBoundary[ilayer + 1]; ++ibin) {
1351  if(badStave[0][ibin-1] || badStave[1][ibin-1] || badStave[2][ibin-1]){
1352  result.at(ilayer+9) = Quality::Medium;
1353  countStave++;
1354  }
1355  }
1356  if (countStave > 0.25 * NStaves[ilayer]) {
1357  result.at(ilayer+9) = Quality::Bad;
1358  }
1359  }
1360 
1361  for (int iflx = 0; iflx < 6; iflx++) {
1362  if(decErr){
1363  if(decErr->Integral(6*iflx+1,6*iflx+7)>0) result.at(12+iflx) = Quality::Bad;
1364  else result.at(12+iflx) = Quality::Good;
1365  }
1366  else result.at(12+iflx) = Quality::Good;
1367  }
1368 
1369  return result;
1370 
1371 
1372 
1373  /* if (mo->getName() == Form("LaneStatus/laneStatusFlag%s", mLaneStatusFlag[iflag].c_str())) {
1374  result = Quality::Good;
1375  auto* h = dynamic_cast<TH2I*>(mo->getObject());
1376  if (h->GetMaximum() > 0) {
1377  result.set(Quality::Bad);
1378  }
1379  }*/
1380  //if (mo->getName() == Form("LaneStatus/laneStatusOverviewFlag%s", mLaneStatusFlag[iflag].c_str())) {
1381  /* result.at(iflag) = Quality.Good;
1382  auto* hp = dynamic_cast<TH2Poly*>(mo->getObject());
1383  badStave = false;
1384  // Initialization of metaData for IB, ML, OL
1385  for (int ilayer = 0; ilayer < NLAYERS; ilayer++) {
1386  int countStave = 0;
1387  badStaveCount = false;
1388  for (int ibin = StaveBoundary[ilayer] + 1; ibin <= StaveBoundary[ilayer + 1]; ++ibin) {
1389  // Check if there are staves in the IB with lane in Bad (bins are filled with %)
1390  if (hp->GetBinContent(ibin) > maxbadchips / 9.) {
1391  badStave = true;
1392  result.at(iflag) = Quality.Medium;
1393  countStave++;
1394  }
1395  } // end loop bins (staves)
1396  // Initialize metadata for the 7 layers
1397  result.addMetadata(Form("Layer%d", ilayer), "good");
1398  // Check if there are more than 25% staves in Bad per layer
1399  if (countStave > 0.25 * NStaves[ilayer]) {
1400  badStaveCount = true;
1401  result.updateMetadata(Form("Layer%d", ilayer), "bad");
1402  }
1403  } // end loop over layers
1404  if (badStave) {
1405  result.at(iflag) = Quality.Medium;
1406  }
1407  if (badStaveCount) {
1408  result.at(iflag) = Quality.Bad;
1409  }
1410  // } // end lanestatusOverview
1411  }*/
1412 
1413 }
1414 
1415 void MvtxMonDraw::DrawPave(std::vector<MvtxMonDraw::Quality> status, int position, const char*/* what*/){
1416  TPaveText *pt = new TPaveText(.4,.4,.6,.6,"blNDC");
1417  pt->SetTextSize(0.04);
1418  pt->SetFillColor(0);
1419  pt->SetLineColor(0);
1420  pt->SetBorderSize(1);
1421  if(status.at(position) == Quality::Good && status.at(position+1) == Quality::Good && status.at(position+2) == Quality::Good) pt->AddText("#color[418]{QA OK}");
1422  if(status.at(position) == Quality::Medium) pt->AddText("#color[808]{QA Layer 0 Medium}");
1423  if(status.at(position+1) == Quality::Medium) pt->AddText("#color[808]{QA Layer 1 Medium}");
1424  if(status.at(position+2) == Quality::Medium) pt->AddText("#color[808]{QA Layer 2 Medium}");
1425  if(status.at(position) == Quality::Bad) pt->AddText("#color[2]{QA Layer 0 Bad}");
1426  if(status.at(position+1) == Quality::Bad) pt->AddText("#color[2]{QA Layer 1 Bad}");
1427  if(status.at(position+2) == Quality::Bad) pt->AddText("#color[2]{QA Layer 2 Bad}");
1428  pt->Draw();
1429 
1430 }
1431 
1433 {
1435  time_t currtime = cl->EventTime("CURRENT");
1436  return currtime;
1437 }