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