ATLAS Offline Software
AtlRunQueryDQSummary.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 
5 import time, math
6 
7 from ROOT import TColor, TText, TH1F, TH2F, TCanvas, THStack, TLegend
8 from ROOT import gPad, gStyle, kPink, kBlue, kOrange, kYellow, kRed, kGreen, kAzure, kGray
9 from CoolRunQuery.AtlRunQueryQueryConfig import QC
10 from CoolRunQuery.selector.AtlRunQuerySelectorBase import DataKey
11 from CoolRunQuery.utils.AtlRunQueryUtils import importroot
12 importroot()
13 
14 from CoolRunQuery.output.AtlRunQueryRoot import SetStyle
15 from CoolRunQuery.utils.AtlRunQueryUtils import timer
16 from CoolRunQuery.AtlRunQueryRun import Run
17 from CoolRunQuery.AtlRunQueryCOMA import ARQ_COMA
18 
19 import xmlrpc.client
20 global server
21 server = xmlrpc.client.ServerProxy('http://atlasdqm.cern.ch')
22 
23 from DQDefects import DefectsDB
24 
25 global readylb
26 global lumifolder
27 global usenb
28 global unit
29 global livetrigger
30 
31 
32 def MapToSystem(defect):
33 
34  # Store detectors/cp per "family" for readability
35  global_systems_map = {'LAR':'Calo','TILE':'Calo','CALO':'Calo',
36  'TAU':'Calo','EGAMMA':'Calo','JET':'Calo','MET':'Calo',
37  'ALFA':'Trigger & Lumi','LCD':'Trigger & Lumi',
38  'ZDC':'Trigger & Lumi','BCM':'Trigger & Lumi',
39  'LUMI':'Trigger & Lumi','TRIG':'Trigger & Lumi',
40  'GLOBAL':'Trigger & Lumi',
41  'MS_CSC':'Muon','MS_RPC':'Muon','MS_TGC':'Muon','MS_MDT':'Muon',
42  'MS':'Muon','MBTS':'Muon','MCP':'Muon',
43  'PIXEL':'Tracking','SCT':'Tracking','TRT':'Tracking',
44  'ID':'Tracking','BTAG':'Tracking'}
45  words = defect.split('_')
46  for w in words:
47  for item in global_systems_map:
48  if w in item:
49  return global_systems_map[item]
50  return ' '
51 
52 
53 
54 def ComputeRunLumi(dic,run,lumiperlb):
55  # consider ATLAS ready only
56  global readylb
57  total = 0.
58  for lbl in lumiperlb:
59  if lbl not in readylb:
60  continue
61  total += lumiperlb[lbl]
62  return total
63 
64 
65 def GetLBLumi(dic,run):
66  global lumifolder
67  global usenb
68 
69  lumifolder = ''
70  lumiperlb = {}
71  for k,v in dic.items():
72  if 'ofllumi' not in k.ResultKey:
73  continue
74  lumifolder = k.ResultKey
75  if lumifolder == '':
76  return lumiperlb
77 
78  lbdic = dic[DataKey(lumifolder)][run]
79  lbtime = dic[DataKey('#LB')][run][1]
80 
81  for i,item in enumerate(lbdic):
82  for lb in range(int(item.startlb),int(item.endlb)):
83  lumiperlb[lb] = 0.
84  if item.value == "n.a.":
85  continue
86  if (lbtime[lb]-lbtime[lb-1])<0:
87  continue
88  # change unit (pb/nb)
89  scale = 0.001
90  if usenb:
91  scale = 1.
92  lumiperlb[lb] = float(item.value)*(lbtime[lb]-lbtime[lb-1])*0.001*scale # output in nb-1/pb-1
93  #print ("DEBUG",run,lb,float(item.value),lbtime[lb]-lbtime[lb-1])
94  return lumiperlb
95 
96 def GetLBLiveFraction(dic,run):
97  global livetrigger
98  livefraction = {}
99  #trigrate = dic[DataKey('TriggerRates')][run][0].value['L1_EM5']
100  triggerRates = dic[DataKey('TriggerRates')][run][0].value
101  if triggerRates != "No match":
102  try:
103  trigrate = triggerRates[livetrigger]
104  for item in trigrate:
105  (lb, tbp, tap, tav) = map(int, item)
106  livefraction[lb]= 0.
107  if tap != 0:
108  livefraction[lb] = float(tav)/tap
109  except KeyError:
110  print ("%s trigger not found - no live fraction computation" % livetrigger)
111  return livefraction
112 
113 def GetLBReady(dic,run):
114  rlb = []
115  for b in dic[DataKey('Ready for physics')][run]:
116  for lb in range(b.startlb,b.endlb):
117  if b.value == "1" :
118  rlb.append(lb)
119  return rlb
120 
121 
122 
123 def MakePlot_SummaryLumiLoss(loss,colors,dicsum,name):
124 
125  global usenb
126  global unit
127 
128  SetStyle()
129  gStyle.SetTitleX(0.5)
130  gStyle.SetTitleAlign(23)
131 
132 
133  TotalLumi = dicsum[DataKey('TotalLumi')][0]
134 
135 
136  xlabels = [s for s in loss]
137 
138 
139  runs = [item for item in loss[xlabels[0]]]
140  runs.sort()
141 
142 
143  lumi = {}
144  max = 0.
145  for sys in loss:
146  lumi[sys] = 0.
147  for r in runs:
148  lumi[sys] += loss[sys][r]
149  if lumi[sys] > max:
150  max=lumi[sys]
151  max = max*1.5
152 
153  # if no entry, print no plot
154  empty = False
155  if max == 0.:
156  empty = True
157  max = 1.
158 
159 
160 
161  t1 = " Runs [%i-%i]"%(runs[0],runs[-1])
162  if len(runs) == 1:
163  t1 = " Run [%i]"%runs[0]
164  t2 = "ATLAS Ready Lumi: %.2f %s"%(TotalLumi,unit)
165  h1_frame = TH1F("h1_frame","#splitline{%s}{%s}"%(t1,t2),len(loss),-0.5,len(loss)-0.5)
166  SetXLabel(h1_frame,xlabels)
167  h1_frame.SetMinimum(0.)
168  h1_frame.SetMaximum(max)
169  h1_frame.SetTickLength(0.,"X")
170  h1_frame.GetYaxis().SetTitle("Luminosity Loss during ATLAS Ready [%s]"%unit)
171  h1_frame.LabelsOption("a","X") # order X label by alphabetical order
172 
173 
174  h1_lumi = []
175  text_lumi = []
176  for sys in loss:
177  h1_lumi.append(TH1F("h1_lumi_%s"%sys,"",len(loss),-0.5,len(loss)-0.5))
178  SetXLabel(h1_lumi[-1],xlabels)
179  h1_lumi[-1].LabelsOption("a","X") # order X label by alphabetical order
180  h1_lumi[-1].SetBarWidth(0.90)
181  h1_lumi[-1].SetTickLength(0.,"X")
182  h1_lumi[-1].SetMinimum(0.)
183  h1_lumi[-1].SetMaximum(max)
184  h1_lumi[-1].SetFillColor(colors[sys])
185  if sys == '_TOTAL':
186  h1_lumi[-1].SetFillStyle(3244)
187  ibin = h1_lumi[-1].GetXaxis().FindBin(sys)
188  #print (sys,ibin,colors[sys],lumi[sys]/TotalLumi,h1_lumi[-1].GetName())
189  h1_lumi[-1].SetBinContent(ibin,lumi[sys])
190  if lumi[sys] > 0. :
191  text_lumi.append(TText(lumi[sys]*1.1,ibin-1,"%.2f %%"%(100*lumi[sys]/TotalLumi)))
192  else:
193  text_lumi.append(TText(lumi[sys]*1.1,ibin-1,""))
194 
195 
196 
197  canvas = TCanvas( 'c_SummaryLumiLoss',"Summary Lumi Losses", 200, 10, 600, 700)
198  canvas.Divide(1,1)
199  canvas.cd(1)
200  gPad.SetTopMargin(0.15)
201  h1_frame.Draw("HBAR")
202  subtitle = TText(max,0.,name)
203  subtitle.SetTextSize(0.03)
204  subtitle.SetTextAngle(90)
205  subtitle.SetTextColor(kGray+1)
206  subtitle.Draw()
207  if empty:
208  bgtext = TText(0.5,round(len(loss)/2)-0.5,"No Luminosity Losses")
209  bgtext.SetTextAlign(22)
210  bgtext.SetTextColor(kRed)
211  bgtext.SetTextFont(43)
212  bgtext.SetTextSize(40)
213  bgtext.SetTextAngle(45)
214  bgtext.Draw()
215 
216  for i,h in enumerate(h1_lumi):
217  text_lumi[i].SetTextAlign(12) # Vertical align
218  text_lumi[i].SetTextSize(0.04) # Text Size
219  if not empty:
220  h.Draw("HBAR SAME")
221  text_lumi[i].Draw()
222  canvas.Update()
223  from CoolRunQuery.AtlRunQueryQueryConfig import QC
224  pname = QC.datapath+'/'+name+'_lumiloss.png'
225  canvas.Print(pname)
226  return pname
227 
228 def MakePlot_PerRunLumiLoss(loss,colors,dicsum,name):
229 
230  global usenb
231  global unit
232 
233 
234  runs = []
235  for r in loss['_TOTAL']:
236  if loss['_TOTAL'][r]>0. :
237  runs.append(r)
238  #if len(runs) == 0 : return
239  empty = False
240  if len(runs) == 0 :
241  empty = True
242  runs.append("-")
243  runs.sort()
244 
245 
246  TotalLumi = dicsum[DataKey('TotalLumi')][0]
247 
248 
249  SetStyle()
250  gStyle.SetTitleX(0.5)
251  gStyle.SetTitleAlign(23)
252 
253 
254  h_stack = THStack("hs_PerRun","Luminosity Loss during ATLAS Ready [%s]"%unit)
255 
256 
257  x0=0.17
258  y0=0.62
259  nsplits = 4
260  dx = 0.2
261  dy = 0.05
262  leg = TLegend(x0,y0,x0+dx,y0+nsplits*dy)
263  nhists = 0
264 
265 
266  SHIFT = 0.1
267  WIDTH = 0.4
268 
269 
270  h1_total = TH1F("h1_total","",len(runs),-0.5,len(runs)-0.5)
271  h1_total.SetMinimum(0.)
272  h1_total.SetFillColor(colors['_TOTAL'])
273  h1_total.SetFillStyle(3244)
274  h1_total.SetBarWidth(WIDTH)
275  h1_total.SetBarOffset(SHIFT+WIDTH)
276 
277  for r,run in enumerate(runs):
278  if run != "-" and loss['_TOTAL'][run] > 0:
279  h1_total.Fill(r,loss['_TOTAL'][run])
280  nhists +=1
281  leg.AddEntry(h1_total,'TOTAL',"f")
282 
283 
284  h1_lumi = {}
285  for i,sys in enumerate(loss):
286 
287  if sys == '_TOTAL':
288  continue
289 
290  h1_lumi[sys] = TH1F("h1_lumi_%s"%sys,"",len(runs),-0.5,len(runs)-0.5)
291  h1_lumi[sys].SetMinimum(0.)
292  h1_lumi[sys].SetFillColor(colors[sys])
293  h1_lumi[sys].SetBarWidth(WIDTH)
294  h1_lumi[sys].SetBarOffset(SHIFT)
295  for r,run in enumerate(runs):
296  if run != "-" and loss[sys][run]> 0.:
297  h1_lumi[sys].Fill(r,loss[sys][run])
298 
299 
300  for sys in h1_lumi:
301  if h1_lumi[sys].GetEntries() > 0:
302  h_stack.Add(h1_lumi[sys])
303  leg.AddEntry(h1_lumi[sys],sys,"f")
304  nhists +=1
305 
306 
307  hmax = h_stack.GetMaximum()*1.6
308 
309 
310  if len(runs) == 1:
311  if runs[0] == "-":
312  t1 = " Run [-]"
313  else:
314  t1 = " Run [%i]"%runs[0]
315  else:
316  t1 = " Runs [%i-%i]"%(runs[0],runs[-1])
317 
318  t2 = "ATLAS Ready Lumi: %.2f %s"%(TotalLumi,unit)
319  h1_frame = TH1F("h1_frame_runs","#splitline{%s}{%s}"%(t1,t2),len(runs),-0.5,len(runs)-0.5)
320  SetXLabel(h1_frame,runs)
321  h1_frame.SetLabelSize(0.06,"X")
322  h1_frame.SetMinimum(0.)
323  h1_frame.GetYaxis().SetTitle("Luminosity Loss during ATLAS Ready [%s]"%unit)
324  h1_frame.GetYaxis().SetTitleOffset(1.3)
325 
326 
327  canvas = TCanvas( 'c_PerRunLumiLoss',"Luminosity Losses Per Run", 200, 10, 600, 700)
328  canvas.Divide(1,1)
329  canvas.cd(1)
330  gPad.SetTopMargin(0.15)
331  h1_frame.SetMaximum(hmax)
332  h_stack.SetMaximum(hmax)
333  #h_total.SetBarOffset((shift)
334 
335  h1_frame.Draw("")
336  h_stack.Draw("BARsame")
337  h1_total.Draw("BARsame")
338  ncolumns = int(math.ceil(float(nhists)/float(nsplits)))
339  leg.SetNColumns(ncolumns)
340  leg.Paint() # Draw once to access coordinates
341  leg.SetX2NDC(leg.GetX1NDC()+ncolumns*dx) # Modify legend size w.r.t number of columns
342  nrows = leg.GetNRows()
343  leg.SetY2NDC(leg.GetY1NDC()+nrows*dy) # Modify legend size w.r.t number of rows
344  if not empty:
345  leg.Draw() # Draw again
346 
347  subtitle = TText(len(runs)-0.35,0.,name)
348  subtitle.SetTextSize(0.03)
349  subtitle.SetTextAngle(90)
350  subtitle.SetTextColor(kGray+1)
351  subtitle.Draw()
352  if empty:
353  bgtext = TText(0.0,0.5,"No Luminosity Losses")
354  bgtext.SetTextAlign(22)
355  bgtext.SetTextColor(kRed)
356  bgtext.SetTextFont(43)
357  bgtext.SetTextSize(40)
358  bgtext.SetTextAngle(45)
359  bgtext.Draw()
360 
361  canvas.Update()
362  from CoolRunQuery.AtlRunQueryQueryConfig import QC
363  pname = QC.datapath+'/'+name+'_lumiloss_perrun.png'
364  canvas.Print(pname)
365  return pname
366 
367 def MakePlot_DefectsPerSystem(sys,intolerable,tolerable,ignored,dic,run):
368 
369  global readylb
370 
371  from CoolRunQuery.AtlRunQueryQueryConfig import QC
372 
373  hname = ['','','']
374  h2_DefectVsLB = ['','','','']
375 
376 
377  SetStyle()
378  gStyle.SetTitleX(0.5)
379  gStyle.SetTitleAlign(23)
380 
381  lbrange = readylb[-1]-readylb[0] # can be disconnected !
382  #print (run,len(readylb),lbrange)
383 
384 
385  if len(intolerable) > 0 :
386  #TCol = TColor.GetColor( "#5D6B7D")
387  TCol = TColor.GetColor( "#0f3a60")
388  hname[0]= "%s_Intolerable_Run%s"%(sys,str(dic[DataKey('Run')][run]))
389  htitle = "%s - Intolerable defects - Run %s"%(sys,str(dic[DataKey('Run')][run]))
390  h2_DefectVsLB[0] = TH2F("h2_defectVsLB_%s"%hname[0],htitle,
391  lbrange,readylb[0]-0.5,readylb[-1]+0.5,
392  len(intolerable),0.,len(intolerable))
393  h2_DefectVsLB[0].SetFillColor(TCol)
394  h2_DefectVsLB[0].GetXaxis().SetTitle("Lumiblocks with ATLAS Ready")
395  SetYLabel(h2_DefectVsLB[0],[defect for defect in intolerable])
396  h2_DefectVsLB[0].LabelsOption("a","Y") # order Y label by alphabetical order
397 
398  # Text to store lumi loss number
399  ttext = {}
400  # Fill & Compute lumi losses
401  for i,item in enumerate(intolerable):
402  ibiny = h2_DefectVsLB[0].GetYaxis().FindBin(item)
403  binxmax = h2_DefectVsLB[0].GetXaxis().GetXmax()
404  frac = 100*float(len(intolerable[item]))/float(len(readylb))
405  if frac> 0.:
406  ttext[item] = TText(binxmax,ibiny-0.8," %.2f %%"%frac)
407  else:
408  ttext[item] = TText(binxmax,ibiny-0.8,"")
409  ttext[item].SetTextSize(0.03)
410  ttext[item].SetTextColor(TCol)
411  for lb in intolerable[item]:
412  if lb not in readylb:
413  continue
414  ibinx = h2_DefectVsLB[0].GetXaxis().FindBin(lb)
415  h2_DefectVsLB[0].SetBinContent(ibinx,ibiny,1.)
416 
417  # create png
418  canvas = TCanvas( 'c_Int',"Systems Defects - %s"%hname[0], 200, 10, 1000, 800)
419  canvas.Divide(1,1)
420  canvas.cd(1)
421  gPad.SetLeftMargin(0.40)
422  gPad.SetRightMargin(0.1)
423  h2_DefectVsLB[0].Draw("BOX")
424  for item in intolerable:
425  ttext[item].Draw()
426  canvas.Update()
427  hname[0] = QC.datapath+"/"+hname[0]+".png"
428  canvas.Print(hname[0])
429 
430 
431  if len(tolerable) > 0 :
432 
433  all = {**tolerable, **intolerable, **ignored}
434 
435  TCol1 = TColor.GetColor("#0f3a60")
436  TCol2 = TColor.GetColor("#a3c0d9")
437  TCol3 = TColor.GetColor("#4681b3")
438  #TCol1 = TColor.GetColor("#015669")
439  #TCol2 = TColor.GetColor("#5cbad0")
440  #TCol3 = TColor.GetColor("#258aa1")
441  hname[1]= "%s_All_Run%s"%(sys,str(dic[DataKey('Run')][run]))
442  htitle = "%s - All defects - Run %s"%(sys,str(dic[DataKey('Run')][run]))
443 
444  # intolerable
445  h2_DefectVsLB[1] = TH2F("h2_defectVsLB_int_%s"%hname[1],htitle,
446  lbrange,readylb[0]-0.5,readylb[-1]+0.5,
447  len(all),0.,len(all))
448  # tolerable
449  h2_DefectVsLB[2] = TH2F("h2_defectVsLB_tol_%s"%hname[1],htitle,
450  lbrange,readylb[0]-0.5,readylb[-1]+0.5,
451  len(all),0.,len(all))
452 
453  # ignored
454  h2_DefectVsLB[3] = TH2F("h2_defectVsLB_ign_%s"%hname[1],htitle,
455  lbrange,readylb[0]-0.5,readylb[-1]+0.5,
456  len(all),0.,len(all))
457 
458  h2_DefectVsLB[1].SetFillColor(TCol1)
459  h2_DefectVsLB[2].SetFillColor(TCol2)
460  h2_DefectVsLB[3].SetFillColor(TCol3)
461  #h2_DefectVsLB[3].SetFillStyle(3004) # not a great idea for single LBs
462  h2_DefectVsLB[1].GetXaxis().SetTitle("Lumiblocks with ATLAS Ready")
463  h2_DefectVsLB[2].GetXaxis().SetTitle("Lumiblocks with ATLAS Ready")
464  h2_DefectVsLB[3].GetXaxis().SetTitle("Lumiblocks with ATLAS Ready")
465  SetYLabel(h2_DefectVsLB[1],[defect for defect in all])
466  SetYLabel(h2_DefectVsLB[2],[defect for defect in all])
467  SetYLabel(h2_DefectVsLB[3],[defect for defect in all])
468  h2_DefectVsLB[1].LabelsOption("a","Y") # order Y label by alphabetical order
469  h2_DefectVsLB[2].LabelsOption("a","Y") # order Y label by alphabetical order
470  h2_DefectVsLB[3].LabelsOption("a","Y") # order Y label by alphabetical order
471 
472  # Text to store lumi loss number
473  ttext = {}
474 
475  # Fill
476  for i,item in enumerate(all):
477  ibiny = h2_DefectVsLB[1].GetYaxis().FindBin(item)
478  binxmax = h2_DefectVsLB[1].GetXaxis().GetXmax()
479  frac = 100*float(len(all[item]))/float(len(readylb))
480  if frac >0.:
481  ttext[item] = TText(binxmax,ibiny-0.8," %.2f %%"%frac)
482  else:
483  ttext[item] = TText(binxmax,ibiny-0.8,"")
484  ttext[item].SetTextSize(0.03)
485  if item in intolerable:
486  ttext[item].SetTextColor(TCol1)
487  if item in tolerable:
488  ttext[item].SetTextColor(TCol2)
489  if item in ignored:
490  ttext[item].SetTextColor(TCol3)
491  for lb in all[item]:
492  ibinx = h2_DefectVsLB[1].GetXaxis().FindBin(lb)
493  if item in intolerable:
494  h2_DefectVsLB[1].SetBinContent(ibinx,ibiny,1.)
495  if item in tolerable:
496  h2_DefectVsLB[2].SetBinContent(ibinx,ibiny,1.)
497  if item in ignored:
498  h2_DefectVsLB[3].SetBinContent(ibinx,ibiny,1.)
499 
500  # create png
501  canvas = TCanvas( 'c_Tol',"Systems Defects - %s"%hname[1], 200, 10, 1000, 800)
502  canvas.Divide(1,1)
503  canvas.cd(1)
504  gPad.SetLeftMargin(0.40)
505  gPad.SetRightMargin(0.1)
506  h2_DefectVsLB[2].Draw("BOX")
507  h2_DefectVsLB[3].Draw("BOXSAME")
508  h2_DefectVsLB[1].Draw("BOXSAME")
509 
510  for item in all:
511  ttext[item].Draw()
512  canvas.Update()
513  hname[1] = QC.datapath+"/"+hname[1]+".png"
514  canvas.Print(hname[1])
515 
516  return hname
517 
518 
519 def SetXLabel(h,labels):
520  for i in range(len(labels)):
521  h.GetXaxis().SetBinLabel(i+1,str(labels[i]))
522  return
523 
524 def SetYLabel(h,labels):
525  for i in range(len(labels)):
526  h.GetYaxis().SetBinLabel(i+1,str(labels[i]))
527  return
528 
529 def listify(lbl): # compactify lb lists
530  if len(lbl) == 0 :
531  return ''
532  i = 0
533  newlist=[]
534  while i < len(lbl):
535  start=lbl[i]
536  j=i
537  while(j+1<len(lbl) and lbl[j+1]==lbl[j]+1):
538  j+=1
539  end=lbl[j]
540  i=j+1
541  if start==end:
542  newlist.append(start)
543  else:
544  newlist.append(str(start)+'-'+str(end))
545  return ", ".join([str(x) for x in newlist])
546 
547 
548 class DQSummary:
549 
550  @classmethod
551  def makeHTML(cls, dic, dicsum, doPickle=True, doDQSummary=True, doDQPlots=True, dqsumGRL="PHYS_StandardGRL_All_Good_25ns", dbbTag=("HEAD", "HEAD")):
552  """ method returns a string (unicode is fine) of html code, with out tag <div>...</div> """
553 
554 
558 
559 
560  warning = ''
561 
562 
563  with timer("DQSummary"):
564 
565 
566  global usenb
567  usenb = False
568  global livetrigger
569  livetrigger ='L1_EM30'
570  for r,run in enumerate(dic[DataKey('Run')]):
571  ptag = dic[DataKey('Project tag')][r][0].value
572  if 'data13' in ptag:
573  usenb = True
574  livetrigger = 'L1_EM5'
575  elif 'data16_hip5TeV' in ptag or 'data16_hip8TeV' in ptag:
576  usenb = True
577  livetrigger = 'L1_EM12'
578  elif 'data15' in ptag or 'data16' in ptag or 'data17' in ptag or 'data18' in ptag:
579  usenb = False
580  livetrigger = 'L1_EM12'
581 
582 
584  if len(dbbTag) != 2:
585  warning += '<font color="red"> WARNING (DQSummary): The defect database tag "%s" must be a 2-element sequence. Will use "HEAD" tag instead!</font><br>' %(dbbTag)
586  dbbTag = ("HEAD", "HEAD")
587  #Create dbb dummy with HEAD tag
588  ddb = DefectsDB()
589  #check if defect tag is defined in defect database
590  if dbbTag[0] not in ['HEAD'] + ddb.defects_tags:
591  warning += '<font color="red"> WARNING (DQSummary): The defined defect tag "%s" is not defined in defect database. Will use "HEAD" tag instead!</font><br>' %(dbbTag[0])
592  dbbTag = ("HEAD", dbbTag[1])
593  #check if defect and logic tag is defined in defect database
594  if dbbTag[1] not in ['HEAD'] + ddb.logics_tags:
595  warning += '<font color="red"> WARNING (DQSummary): The defined logic tag "%s" is not defined in defect database. Will use "HEAD" tag instead!</font><br>' %(dbbTag[1])
596  dbbTag = (dbbTag[0], "HEAD")
597  #Now set tags
598  ddb = DefectsDB(tag=(dbbTag[0], dbbTag[1]))
599  #Check if virtual defect is defined in logic
600  if dqsumGRL in ddb.virtual_defect_logics.keys():
601  defects_primary_grl = ddb.resolve_primary_defects(ddb._resolve_evaluation_order([dqsumGRL]))
602  else:
603  warning += '<font color="red"> WARNING (DQSummary): The defined virtual defect or GRL "%s" is not defined in logic. Will use no GRL for calculation!</font><br>' %(dqsumGRL)
604  dqsumGRL = 'no'
605 
606  #Check if cosmic run
607  cosmics = False
608  if 'Cosmics' in dqsumGRL:
609  cosmics = True
610 
611  global unit
612  unit = 'pb^{-1}'
613  if usenb:
614  unit ='nb^{-1}'
615  if cosmics:
616  unit = '%'
617 
618 
619  dicsum[DataKey('TotalLumi')] = [0.,0.]
620 
621 
622  dicsum[DataKey('TotalNotReady')] = 0.
623  dicsum[DataKey('TotalBusy')] = 0.
624 
625 
626  detectors = ['ALFA','LCD','ZDC','BCM','PIXEL','SCT','TRT','LAR','TILE',
627  'MS_CSC','MS_RPC','MS_TGC','MS_MDT','MBTS','TRIG','GLOBAL']
628  detectors_color = {'ALFA':kYellow-9,'LCD':kYellow-7,'ZDC':kYellow-4,
629  'BCM':kOrange+1,'PIXEL':kOrange-3,'SCT':kOrange+7,'TRT':kRed-3,
630  'LAR':kRed+2,'TILE':kPink-7,
631  'MS_CSC':kBlue+4,'MS_RPC':kBlue-2,'MS_MDT':kAzure+3,'MS_TGC':kBlue-9,'MBTS':kBlue-6,
632  'TRIG':kGreen-3,'GLOBAL':kGreen+3,'_TOTAL':TColor.GetColor("#585858")}
633  detectors_lumiloss = {}
634  detectors_affectedLBs = {}
635 
636  for d in detectors:
637  detectors_lumiloss[d]={}
638  detectors_affectedLBs[d]={}
639 
640 
641  detectors_lumiloss['_TOTAL']={}
642  detectors_affectedLBs['_TOTAL']={}
643 
644 
645  performances = ['LUMI','ID','CALO','TAU','EGAMMA','JET','MET','MCP','BTAG']
646  performances_color = {'LUMI':kYellow-9,'ID':kOrange+7,'CALO':kRed+2,'TAU':kBlue+2,
647  'EGAMMA':kGreen-3,'JET':kAzure+3,'MET':kGreen-6,'MCP':kBlue-3,
648  'BTAG':kPink,'_TOTAL':TColor.GetColor("#585858")}
649  performances_lumiloss = {}
650  performances_affectedLBs = {}
651 
652  for p in performances:
653  performances_lumiloss[p]={}
654  performances_affectedLBs[p]={}
655 
656 
657  performances_lumiloss['_TOTAL']={}
658  performances_affectedLBs['_TOTAL']={}
659 
660 
661  columns = []
662  global_systems = []
663  columns = ['Run Info','ES1','BLK']
664  global_systems = ['Calo','Tracking','Muon','Trigger & Lumi']
665  columns += global_systems
666 
667 
668  with timer('Create summary results table'):
669 
670  summarytable = '<div><table id="resulttable" class="resulttable" style="margin-left: 13px; margin-right: 13px;" >'
671 
672  summarytable += '<tr>'
673  summarytable += '<th colspan="1"></th>' # run info column
674 
675  #summarytable += '<th colspan="2">Tier0 Reco Status</th>'
676  summarytable += '<th colspan="2">Missing Sign-Off</th>'
677 
678  summarytable += '<th colspan="%i">Defects in ATLAS Ready<br>'%len(global_systems)
679  summarytable += '<div style="font-size: xx-small; cursor: pointer;" onclick="toggle_dq(this)">[show tolerable]</div></th>'
680  summarytable += '</tr>'
681 
682 
683  summarytable += '<tr>'
684  #for item in columns: summarytable += '<th>%s</th>'%item.split(":")[0]
685  for item in columns:
686  summarytable += '<th>%s</th>'%item
687  summarytable += '</tr>'
688 
689  totalNumberOfReadyLB = 0
690 
691  tot_nlb = 0
692  #determine total number of lbs in case of cosmics
693  if cosmics:
694  for r,run in enumerate(dic[DataKey('Run')]):
695  tot_nlb += dic[DataKey('#LB')][r][0]
696 
697  runsWithoutReadyForPhysics = []
698  runsWithoutOfflineLumiInfo = []
699 
700 
701  for r,run in enumerate(dic[DataKey('Run')]):
702 
703 
704  global readylb
705  #ignore ATLAS not ready for Cosmics
706  nlb = dic[DataKey('#LB')][r][0]
707 
708  if cosmics:
709  readylb = range(1,nlb+1)
710  else:
711  readylb = GetLBReady(dic,r)
712 
713  totalNumberOfReadyLB += len(readylb)
714 
715 
716  if len(readylb) == 0:
717  runsWithoutReadyForPhysics += [ str(run) ]
718  continue
719 
720 
722  if cosmics:
723  lumiperlb = dict(zip(readylb, [100./tot_nlb] * nlb))
724  livefrac = dict(zip(readylb, [1] * nlb))
725  else:
726  lumiperlb = GetLBLumi(dic,r)
727  livefrac = GetLBLiveFraction(dic,r)
728 
729  if len(lumiperlb) == 0:
730  runsWithoutOfflineLumiInfo += [ str(run) ]
731  continue
732 
733 
735  for lbl in lumiperlb:
736  # IF statement used when len(lumiperlb)!= len(livefrac)
737  if lbl not in readylb:
738  continue
739  if lbl not in livefrac:
740  pass # in run 3 we don't have trigger rates yet, as they are no longer in COOL
741  # print ("--> Warning: live fraction not available for LB %i. Setting live fraction to 1." % lbl)
742  else:
743  lumiperlb[lbl]*=livefrac[lbl]
744 
745 
746 
747  content = {}
748  for i,item in enumerate(columns):
749  content[item]=''
750 
751 
752  dp = '?'
753  ptag = dic[DataKey('Project tag')][r][0].value
754  year = '20'+ptag.split('_')[0][4:]
755  DP = ARQ_COMA.get_periods_for_run(run)
756  if len(DP)>0:
757  dp=DP[0]
758  content['Run Info'] = '<b>%s</b>&nbsp;<font style="font-size:10px;">data period <b>%s</b></font><br>'%(str(run),dp)
759 
760 
761  tobeignored = ['ALFA','ZDC','LCD']
762  import re
763  if re.match('data1[3-9]', ptag[0:6]):
764  tobeignored = []
765 
766 
767  target='target="blank"'
768  somelinks = '<font style="font-size:10px;color:#0000FF">'
769  somelinks += '<a href="https://atlas-tagservices.cern.ch/tagservices/RunBrowser/runBrowserReport/runBrowserReport.php?runs=%s&pn=%s&fnt=%s" %s>COMA</a>'%(run,dp,ptag,target)
770  somelinks += ', <a href="https://atlasdqm.web.cern.ch/atlasdqm/DQBrowser/makeMatrix.php?selection=All&run=%s&runup=&dbinstance=CONDBR2_DCS&tag=DEFAULT" %s>DCS</a>'%(run,target)
771  somelinks += ', <a href="https://atlas.web.cern.ch/Atlas/GROUPS/DATAPREPARATION/DataSummary/%s/run.py?run=%s" %s>DS</a>'%(year,run,target)
772  somelinks += ', <a href="https://atlasdqm.cern.ch/defectentry/?run=%s" %s>defects</a>'%(run,target)
773  somelinks += '<br><a href="https://atlasdqm.cern.ch/dqsignoff/%s/" %s>DQlogbook</a>'%(run,target)
774  somelinks += ', <a href="https://atlasdqm.cern.ch/webdisplay/tier0?lowrun=%s&highrun=%s&show_all=on" %s>DQWebDisplay</a>'%(run,run,target)
775  somelinks += '</font><br>'
776 
777  content['Run Info'] += somelinks
778 
779 
780  rundate = dic[DataKey('Start and endtime')][r].split(",")
781  tstart = time.strftime("%a, %d %b %Y %H:%M:%S",time.localtime(float(rundate[0])))
782  tend = time.strftime("%a, %d %b %Y %H:%M:%S",time.localtime(float(rundate[1])))
783  content['Run Info'] += '<font style="font-size:10px;">'
784  content['Run Info'] += '<br>Start:&nbsp;<font style="color:#4C7D7E;">%s</font>'%tstart
785  content['Run Info'] += '<br>End:&nbsp;<font style="color:#4C7D7E;">%s</font>'%tend
786  content['Run Info'] += '</font>'
787 
788  #nevents = str(dic[DataKey('#Events')][r][0].value)
789  #content['Run Info'] += 'Recorded events: '+nevents+'<br>'
790  #content['Run Info'] += 'Number of LBs : '+dic[DataKey('#LB')][r][0]+'<br>'
791  #content['Run Info'] += 'LHC Fill : %s<br>'%(dic[DataKey('lhc:fillnumber')][r][0].value)+'<br>'
792 
793 
794  lhctable = '<br><font style="font-size:10px;">'
795  lhctable += '<table><tr><td>'
796  lhctable += '<b>Stable&nbsp;Beam</b><br>%s'%'<br>'.join([ '%s-%s:&nbsp<font style="color:#4C7D7E">%s</font>'%(b.startlb,b.endlb,b.value) for b in dic[DataKey('lhc:stablebeams')][r]])
797  lhctable += '</td><td>'
798  lhctable += '<b>ATLAS&nbsp;Ready</b><br>%s'% '<br>'.join([ '%s-%s:&nbsp<font style="color:#4C7D7E">%s</font>'%(b.startlb,b.endlb,b.value) for b in dic[DataKey('Ready for physics')][r]])
799  lhctable += '</td></tr></table>'
800  lhctable += '</font>'
801  content['Run Info'] += lhctable
802 
803 
804  lumitot = ComputeRunLumi(dic,r,lumiperlb)
805  dicsum[DataKey('TotalLumi')][0]+= lumitot
806  content['Run Info'] += '<font style="font-size:10px;">'
807  content['Run Info'] += 'Ready Recorded: <b>%.2f</b> %s'%(lumitot,unit)
808  content['Run Info'] += '</font><br>'
809 
810 
811  defects = dic[DataKey('DQ')][r]
812 
813  defects_primary = [d for d in defects if d.value.primary]
814 
815 
817  for d in detectors:
818  detectors_lumiloss[d][run]= 0.
819  detectors_affectedLBs[d][run]=[]
820  for p in performances:
821  performances_lumiloss[p][run]=0.
822  performances_affectedLBs[p][run]=[]
823 
824  # Total per run
825  detectors_lumiloss['_TOTAL'][run]= 0.
826  detectors_affectedLBs['_TOTAL'][run]=[]
827  performances_lumiloss['_TOTAL'][run]= 0.
828  performances_affectedLBs['_TOTAL'][run]=[]
829 
830  # And the big sums
831  total_affectedLBs = []
832  GlobalNotReady = []
833  GlobalBusy = []
834 
835 
836  ListOfIntolerableDefects = {}
837  ListOfTolerableDefects = {}
838  ListOfIgnoredDefects = {}
839 
840 
841  for item in defects_primary:
842  defect = item.value.defect
843  comment = item.value.comment
844  user = item.value.user
845  startlb = item.startlb
846  endlb = item.endlb
847  tolerable = item.value.tolerable
848  system = MapToSystem(defect)
849  grl_ignored = False
850 
851  #Make it relative to GRL
852  if not dqsumGRL == 'no' and not tolerable:
853  if defect not in defects_primary_grl:
854  grl_ignored = True
855 
856 
857  if 'GLOBAL_NOTREADY' in defect:
858  GlobalNotReady += [ lb for lb in range(startlb,endlb)]
859 
860  if 'GLOBAL_BUSY' in defect:
861  GlobalBusy += [ lb for lb in range(startlb,endlb) if lb in readylb]
862 
863 
864 
865 
866  if 'UNCHECKED_FINAL' in defect:
867  continue
868 
869 
870  if 'BULK_UNCHECKED' in defect:
871  short = defect.split('_UNCHECKED')[0]
872  content['BLK']+='<font style="font-size:8px;font-weight:bold;">%s</font><br>'%short
873  continue
874 
875  if 'UNCHECKED' in defect:
876  short = defect.split('_UNCHECKED')[0]
877  content['ES1']+='<font style="font-size:8px;font-weight:bold;">%s</font><br>'%short
878  continue
879 
880 
881  if system =='':
882  print ('run %s: this defect is fishy %s '%(run,defect))
883  continue
884 
885 
886  word = defect.split('_')
887  cpdet = word[0]
888  if word[0]=='MS':
889  cpdet += "_"+word[1] # MS systems
890  if cpdet not in detectors and cpdet not in performances:
891  print ('This system is not included: %s (%s)'%(cpdet,defect))
892  continue
893 
894 
895  if not tolerable:
896  RangeDefect = [ lb for lb in range(startlb,endlb) if lb in readylb ]
897  if len(RangeDefect)>0:
898  if not grl_ignored:
899  if defect not in ListOfIntolerableDefects:
900  ListOfIntolerableDefects[defect]= [[],'']
901  ListOfIntolerableDefects[defect][0] = RangeDefect
902  ListOfIntolerableDefects[defect][1] = user+':'+comment
903  else:
904  ListOfIntolerableDefects[defect][0]+= RangeDefect
905  if comment not in ListOfIntolerableDefects[defect][1]:
906  ListOfIntolerableDefects[defect][1]+= ' '+user+':'+comment
907  # This is used to compute lumilosses
908  # Here, we do not include systems "to be ignored"
909  if cpdet in tobeignored:
910  continue
911  # Store list of affected LBs per detector/cp group
912  # we can have a double counting of LBs if defects overlap - fixed later
913  if cpdet in detectors:
914  detectors_affectedLBs[cpdet][run]+=RangeDefect
915  if cpdet in performances:
916  performances_affectedLBs[cpdet][run]+=RangeDefect
917  total_affectedLBs += RangeDefect
918  #treat differently if ignored by GRL although intolerable
919  elif grl_ignored:
920  if defect not in ListOfIgnoredDefects:
921  ListOfIgnoredDefects[defect]= [[],'']
922  ListOfIgnoredDefects[defect][0]= RangeDefect
923  ListOfIgnoredDefects[defect][1]= '[%s]:%s '%(user,comment)
924  else:
925  ListOfIgnoredDefects[defect][0]+= RangeDefect
926  if comment not in ListOfIgnoredDefects[defect][1]:
927  ListOfIgnoredDefects[defect][1] += '[%s]:%s '%(user,comment)
928 
929  else:
930  RangeDefect = [ lb for lb in range(startlb,endlb) if lb in readylb]
931  if len(RangeDefect)>0:
932  if defect not in ListOfTolerableDefects:
933  ListOfTolerableDefects[defect]= [[],'']
934  ListOfTolerableDefects[defect][0]= RangeDefect
935  ListOfTolerableDefects[defect][1]= '[%s]:%s '%(user,comment)
936  else:
937  ListOfTolerableDefects[defect][0]+= RangeDefect
938  if comment not in ListOfTolerableDefects[defect][1]:
939  ListOfTolerableDefects[defect][1] += '[%s]:%s '%(user,comment)
940 
941 
942 
943  for item in global_systems:
944  content[item]='<table class="dqdefects">'
945 
946  for item in ListOfIntolerableDefects:
947  system = MapToSystem(item)
948  if system not in global_systems:
949  continue
950  lbs = listify(ListOfIntolerableDefects[item][0])
951  tip = ListOfIntolerableDefects[item][1]
952  tipkey = "dqcomment_int_%s_%s"%(item,run)
953  Run.addGlobalToolTip(tipkey,tip)
954  content[system]+='<tr class="showTip %s" >'%(tipkey)
955  content[system]+='<td class="intolerable">%s</td>'%(item)
956  content[system]+='<td class="lb">%s</td>'%(lbs)
957  content[system]+='</tr>'
958 
959  for item in ListOfIgnoredDefects:
960  system = MapToSystem(item)
961  if system not in global_systems:
962  continue
963  lbs = listify(ListOfIgnoredDefects[item][0])
964  tip = ListOfIgnoredDefects[item][1]
965  tipkey = "dqcomment_ign_%s_%s"%(item,run)
966  Run.addGlobalToolTip(tipkey,tip)
967  content[system]+='<tr class="showTip %s" >'%(tipkey)
968  content[system]+='<td class="ignored">%s</td>'%(item)
969  content[system]+='<td class="lb">%s</td>'%(lbs)
970  content[system]+='</tr>'
971 
972  for item in ListOfTolerableDefects:
973  system = MapToSystem(item)
974  if system not in global_systems:
975  continue
976  lbs = listify(ListOfTolerableDefects[item][0])
977  tip = ListOfTolerableDefects[item][1]
978  tipkey = "dqcomment_tol_%s_%s"%(item,run)
979  Run.addGlobalToolTip(tipkey,tip)
980  content[system]+='<tr class="showTip %s tolerable" style="visibility:collapse;">'%(tipkey)
981  content[system]+='<td>%s</td>'%(item)
982  content[system]+='<td class="lb">%s</td>'%(lbs)
983  content[system]+='</tr>'
984 
985 
986  for item in global_systems:
987  content[item]+='</table><br>'
988 
989 
990  thumbsize = 70
991  imgsize = 600
992  for gsys in global_systems:
993  tol = {}
994  int = {}
995  ign = {}
996  for defect in ListOfTolerableDefects:
997  # remove systems to be ignored from the plots
998  word = defect.split('_')
999  cpdet = word[0]
1000  if word[0]=='MS':
1001  cpdet += "_"+word[1] # MS systems
1002  if cpdet in tobeignored:
1003  continue
1004  if gsys==MapToSystem(defect):
1005  tol[defect]=ListOfTolerableDefects[defect][0]
1006  for defect in ListOfIntolerableDefects:
1007  # remove systems to be ignored from the plots
1008  word = defect.split('_')
1009  cpdet = word[0]
1010  if word[0]=='MS':
1011  cpdet += "_"+word[1] # MS systems
1012  if cpdet in tobeignored:
1013  continue
1014  if gsys==MapToSystem(defect):
1015  int[defect]=ListOfIntolerableDefects[defect][0]
1016  for defect in ListOfIgnoredDefects:
1017  # remove systems to be ignored from the plots
1018  word = defect.split('_')
1019  cpdet = word[0]
1020  if word[0]=='MS':
1021  cpdet += "_"+word[1] # MS systems
1022  if cpdet in tobeignored:
1023  continue
1024  if gsys==MapToSystem(defect):
1025  ign[defect]=ListOfIgnoredDefects[defect][0]
1026 
1027  hname = MakePlot_DefectsPerSystem(gsys,int,tol,ign,dic,r)
1028  for h in hname:
1029  if len(h)== 0:
1030  continue
1031  title = "Click to zoom"
1032  wincontent = "<img src=&quot;%s&quot; height=%s/>"%(h,imgsize)
1033  openwin = "javascript:openLargeWindow('Print1','"
1034  openwin += "<!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>"
1035  openwin += "<html xmlns:&quot;my&quot;><head><title>Defects for run %s</title></head>"%run
1036  openwin += "<body style=&quot;background-color:#ffffff&quot;>%s</body></html>"%wincontent
1037  openwin += "')"
1038  content[gsys]+='<a title="%s" href="%s" ><img src="%s" height=%s/></a>'%(title,openwin,h,thumbsize)
1039 
1040 
1041  _lblumi = 0.
1042  if not GlobalNotReady:
1043  for lb in GlobalNotReady:
1044  _lblumi += lumiperlb[lb]
1045  dicsum[DataKey('TotalNotReady')] += _lblumi
1046  content['Run Info'] += '<font style="font-size:10px;">'
1047  content['Run Info'] += 'Global Not Ready: <b>%.2f</b> %s'%(_lblumi,unit)
1048  content['Run Info'] += '</font><br>'
1049 
1050 
1051  _lblumi = 0.
1052  for lb in GlobalBusy:
1053  _lblumi += lumiperlb[lb]
1054  dicsum[DataKey('TotalBusy')]+= _lblumi
1055  content['Run Info'] += '<font style="font-size:10px;">'
1056  content['Run Info'] += 'Global Busy: <b>%.2f</b> %s'%(_lblumi,unit)
1057  content['Run Info'] += '</font><br>'
1058 
1059 
1060  for d in detectors:
1061  if len(detectors_affectedLBs[d][run]) == 0:
1062  continue
1063  # Remove double counting (defects overlap)
1064  dll = list(set(detectors_affectedLBs[d][run]))
1065  detectors_affectedLBs['_TOTAL'][run]+= dll
1066  for lb in dll:
1067  detectors_lumiloss[d][run]+= lumiperlb[lb]
1068  for p in performances:
1069  if len(performances_affectedLBs[p][run]) == 0:
1070  continue
1071  # Remove double counting (defects overlap)
1072  pll = list(set(performances_affectedLBs[p][run]))
1073  performances_affectedLBs['_TOTAL'][run]+= pll
1074  for lb in pll:
1075  performances_lumiloss[p][run]+= lumiperlb[lb]
1076 
1077 
1079  detectors_affectedLBs['_TOTAL'][run]=list(set(detectors_affectedLBs['_TOTAL'][run]))
1080  performances_affectedLBs['_TOTAL'][run]=list(set(performances_affectedLBs['_TOTAL'][run]))
1081  total_affectedLBs = list(set(total_affectedLBs))
1082  totallossperrun = 0.
1083  # Store the values
1084  for lb in total_affectedLBs:
1085  totallossperrun += lumiperlb[lb]
1086  dicsum[DataKey('TotalLumi')][1] += totallossperrun
1087  # Store the values
1088  for lb in detectors_affectedLBs['_TOTAL'][run]:
1089  detectors_lumiloss['_TOTAL'][run] += lumiperlb[lb]
1090  # Store the values
1091  for lb in performances_affectedLBs['_TOTAL'][run]:
1092  performances_lumiloss['_TOTAL'][run] += lumiperlb[lb]
1093 
1094 
1095  content['Run Info'] += '<font style="font-size:10px;">'
1096  content['Run Info'] += 'DQ Lumi Loss: <b>%.2f</b> %s'%(totallossperrun,unit)
1097  content['Run Info'] += '</font><br>'
1098 
1099 
1100  summarytable+='<tr class="out2">'
1101  for item in columns:
1102  summarytable+='<td>%s</td>'%content[item]
1103  summarytable+='</tr>'
1104 
1105 
1106  summarytable += '</table></div><br>'
1107 
1108  if runsWithoutReadyForPhysics:
1109  warning += '<div style="margin-left: 13px; color: darkred; width: 90%%;">WARNING! The following runs have no lumi block with ATLAS Ready: %s</div><br>' % ", ".join(runsWithoutReadyForPhysics)
1110  if runsWithoutOfflineLumiInfo:
1111  warning += '<div style="margin-left: 13px; color: darkred; width: 90%%;">WARNING! The following runs have no offline lumi info: %s</div><br>' % ", ".join(runsWithoutOfflineLumiInfo)
1112 
1113 
1114 
1115 
1118 
1119  summaryplot = ''
1120  plots = []
1121  if totalNumberOfReadyLB > 0:
1122  plots.append(MakePlot_SummaryLumiLoss(detectors_lumiloss,detectors_color,dicsum,'detectors'))
1123  plots.append(MakePlot_SummaryLumiLoss(performances_lumiloss,performances_color,dicsum,'performances'))
1124  plots.append(MakePlot_PerRunLumiLoss(detectors_lumiloss,detectors_color,dicsum,'detectors'))
1125  plots.append(MakePlot_PerRunLumiLoss(performances_lumiloss,performances_color,dicsum,'performances'))
1126 
1127  imgsize=500
1128  thumbsize=300
1129  title = "Click to zoom"
1130 
1131 
1132  summaryplot += '<table align="center" width="90%">'
1133  summaryplot += '<th>'
1134 
1135  for p in plots:
1136 
1137  wincontent = "<img src=&quot;%s&quot; width=%s/>"%(p,imgsize)
1138 
1139  #openwincmd = "javascript:openLargeWindow('Print%i','"%(r)
1140  openwincmd = "javascript:openWindow('Print%i','"%(run)
1141  openwincmd += "<!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>"
1142  openwincmd += "<html xmlns:&quot;my&quot;><head><title>DQ Summary Plot - Run %s</title></head>"%(run)
1143  openwincmd += "<body style=&quot;background-color:#ffffff&quot;>%s</body></html>"%wincontent
1144  openwincmd += "')"
1145 
1146  summaryplot+='<td><a title="%s" href="%s" ><img src="%s" height=%s/></a></td>'%(title,openwincmd,p,thumbsize)
1147 
1148 
1149  summaryplot += '</th></table>'
1150 
1151 
1155 
1156 
1159 
1160  totalLumiRecorded = dicsum[DataKey('TotalLumi')][0]
1161  totalLumiLoss = dicsum[DataKey('TotalLumi')][1]
1162  lumiLossFraction = (100. * totalLumiLoss / totalLumiRecorded) if totalLumiRecorded > 0 else 0
1163 
1164 
1165  print ('+++++++++++++++++++++++++ Summary +++++++++++++++++++')
1166  print (' Total Ready Recorded Luminosity: %.2f %s-1' % ( totalLumiRecorded, unit ))
1167  print (' Total Luminosity Loss (ATLAS Ready) : %.2f %s-1' % ( totalLumiLoss, unit ))
1168  print (' Total Global Not Ready (Stable Beams): %.2f %s-1'%(dicsum[DataKey('TotalNotReady')],unit))
1169  print (' Total Global Busy (Stable Beams): %.2f %s-1'%(dicsum[DataKey('TotalBusy')],unit))
1170  print ('+++++++++++++++++++++++++++++++++++++++++++++++++++++')
1171 
1172  global lumifolder
1173 
1174  if totalNumberOfReadyLB>0:
1175  summaryinfo = '<table align="center" style="font-size:80%;"><tr>'
1176  summaryinfo += '<td> Total Luminosity Loss: <b>%.2f %s</b> (%.2f%%)' % ( totalLumiLoss, unit, lumiLossFraction )
1177  summaryinfo += '<br>Excluded Systems: %s</td></tr>' % tobeignored
1178  if not cosmics:
1179  summaryinfo += '<tr><td style="font-size:70%%">using %s // %s</td></tr>'%(lumifolder.split(':')[2],livetrigger)
1180  summaryinfo += '</table>'
1181  else:
1182  summaryinfo = '<table align="center" style="font-size:80%;"><tr>'
1183  summaryinfo += '<td> No ready lumi block </td>'
1184  summaryinfo += '</tr></table>'
1185 
1186 
1189 
1190  pagecontent = summaryplot +'<br>'
1191  pagecontent += summaryinfo +'<br>'
1192  if doDQSummary:
1193  pagecontent += summarytable
1194  pagecontent += warning
1195  return pagecontent
1196 
1197 
1198 
1199 
1200 if __name__ == "__main__":
1201  # for standalone tests (without querying) just run this and view under test.html
1202 
1203  import pickle
1204  QC.datapath = "data"
1205 
1206  pageinfo = pickle.load(open('%s/dqsum_pi.pickle' % QC.datapath))
1207 
1208  from CoolRunQuery.html.AtlRunQueryHTML import ResultPageMaker as RPM
1209  RPM.makePage(pageinfo, doDQPickle=False)
1210 
1211 
python.html.AtlRunQueryDQSummary.MakePlot_SummaryLumiLoss
def MakePlot_SummaryLumiLoss(loss, colors, dicsum, name)
Definition: AtlRunQueryDQSummary.py:123
python.utils.AtlRunQueryUtils.importroot
def importroot(batch=True)
Definition: AtlRunQueryUtils.py:57
python.html.AtlRunQueryDQSummary.listify
def listify(lbl)
Definition: AtlRunQueryDQSummary.py:529
RootHelpers::FindBin
Int_t FindBin(const TAxis *axis, const double x)
Definition: RootHelpers.cxx:14
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
GetEntries
TGraphErrors * GetEntries(TH2F *histo)
Definition: TRTCalib_makeplots.cxx:4019
python.html.AtlRunQueryDQSummary.SetXLabel
def SetXLabel(h, labels)
Definition: AtlRunQueryDQSummary.py:519
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
while
while((inf=(TStreamerInfo *) nextinfo()) !=0)
Definition: liststreamerinfos.cxx:13
python.output.AtlRunQueryRoot.SetStyle
def SetStyle(whiteCanvas=False)
Definition: AtlRunQueryRoot.py:28
python.utils.AtlRunQueryTimer.timer
def timer(name, disabled=False)
Definition: AtlRunQueryTimer.py:85
python.html.AtlRunQueryDQSummary.SetYLabel
def SetYLabel(h, labels)
Definition: AtlRunQueryDQSummary.py:524
python.html.AtlRunQueryDQSummary.ComputeRunLumi
def ComputeRunLumi(dic, run, lumiperlb)
Definition: AtlRunQueryDQSummary.py:54
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.html.AtlRunQueryDQSummary.DQSummary.makeHTML
def makeHTML(cls, dic, dicsum, doPickle=True, doDQSummary=True, doDQPlots=True, dqsumGRL="PHYS_StandardGRL_All_Good_25ns", dbbTag=("HEAD", "HEAD"))
Definition: AtlRunQueryDQSummary.py:551
python.html.AtlRunQueryDQSummary.MapToSystem
def MapToSystem(defect)
Definition: AtlRunQueryDQSummary.py:32
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.html.AtlRunQueryDQSummary.MakePlot_PerRunLumiLoss
def MakePlot_PerRunLumiLoss(loss, colors, dicsum, name)
Definition: AtlRunQueryDQSummary.py:228
python.html.AtlRunQueryDQSummary.DQSummary
Definition: AtlRunQueryDQSummary.py:548
python.html.AtlRunQueryDQSummary.GetLBLiveFraction
def GetLBLiveFraction(dic, run)
Definition: AtlRunQueryDQSummary.py:96
python.html.AtlRunQueryDQSummary.GetLBReady
def GetLBReady(dic, run)
Definition: AtlRunQueryDQSummary.py:113
Trk::open
@ open
Definition: BinningType.h:40
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
python.html.AtlRunQueryDQSummary.GetLBLumi
def GetLBLumi(dic, run)
Definition: AtlRunQueryDQSummary.py:65
str
Definition: BTagTrackIpAccessor.cxx:11
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
python.html.AtlRunQueryDQSummary.MakePlot_DefectsPerSystem
def MakePlot_DefectsPerSystem(sys, intolerable, tolerable, ignored, dic, run)
Definition: AtlRunQueryDQSummary.py:367
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65