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]
371
372
373
374 if len(intolerable) > 0 :
375
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")
386
387
388 ttext = {}
389
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
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
428
429
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
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
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
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
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")
458 h2_DefectVsLB[2].LabelsOption("a","Y")
459 h2_DefectVsLB[3].LabelsOption("a","Y")
460
461
462 ttext = {}
463
464
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
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