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