17import datetime, sys, os
18from array
import array
19from CoolRunQuery.utils.AtlRunQueryUtils
import importroot
21from ROOT
import TFile, TTree, TCanvas, gPad, TGraph, TColor, TStyle, TGaxis, gROOT, gStyle, TText, TH1F, TLegend, TF1
31 c_Canvas = TColor.GetColor(
"#f0f0f0" )
33 c_Canvas = TColor.GetColor( 10 )
35 c_TitleBox = TColor.GetColor(
"#dae1e6" )
37 myStyle = TStyle( gROOT.GetStyle(
"Plain") )
38 myStyle.SetName(
"myStyle")
40 myStyle.SetLineStyleString( 5,
"[52 12]" )
41 myStyle.SetLineStyleString( 6,
"[22 12]" )
42 myStyle.SetLineStyleString( 7,
"[22 10 7 10]" )
48 myStyle.SetFrameBorderMode(0)
49 myStyle.SetCanvasBorderMode(0)
50 myStyle.SetPadBorderMode(0)
51 myStyle.SetPadColor(0)
52 myStyle.SetFillStyle(0)
54 myStyle.SetLegendBorderSize(0)
56 myStyle.SetTitleFillColor( c_TitleBox )
57 myStyle.SetFrameFillColor( c_FrameFill )
58 myStyle.SetCanvasColor( c_Canvas )
61 myStyle.SetPaperSize(20,26)
62 myStyle.SetPadTopMargin(0.11)
63 myStyle.SetPadRightMargin(0.05)
64 myStyle.SetPadBottomMargin(0.11)
65 myStyle.SetPadLeftMargin(0.12)
68 myStyle.SetMarkerStyle(21)
69 myStyle.SetMarkerSize(0.3)
70 myStyle.SetHistLineWidth(2)
71 myStyle.SetLineStyleString(2,
"[12 12]")
74 myStyle.SetOptTitle(1)
75 myStyle.SetTitleH(0.052)
81 myStyle.SetPadTickX(1)
82 myStyle.SetPadTickY(1)
85 gROOT.GetListOfStyles().Add(myStyle)
86 gROOT.SetStyle(
"myStyle")
88def SaveGraphsToFile( filename, varnames, xvecs, yvecs, addparamName = None, addparamVal = None ):
89 f = TFile.Open( filename,
'RECREATE' )
90 if len(xvecs) != len(yvecs)
or len(varnames) != len(xvecs):
91 print (
'ERROR: wrong dimensions in "AtlRunQueryRoot.SaveGraphsToFile"')
93 for ik
in range(len(xvecs)):
97 g.SetName (
"graph%i" % (ik+1) )
98 g.SetTitle( varnames[ik] )
99 for i
in range(len(xv)):
100 g.SetPoint( i, xv[i], yv[i] )
104 if addparamName
is not None:
105 addparam = TF1( addparamName,
"[0]", 0, 1 )
106 addparam.SetParameter( 0, addparamVal )
117 print (
'ERROR: input tree is None')
123 dogerBlue = TColor.GetColor(
"#1569C7" )
124 dogerBlue3 = TColor.GetColor(
"#1569C7" )
126 markerCol = dogerBlue3
135 validtypes = [
'int',
'float',
'double',
'short',
'long' ]
138 leafList = tree.GetListOfLeaves()
141 for leaf
in leafList:
144 typename = leaf.GetTypeName().lower()
146 for vt
in validtypes:
150 varlist.append( leaf.GetName() )
153 TGaxis.SetMaxDigits(6)
160 if ref
not in varlist:
161 print (
'Big troubles in "MakePlots" --> reference variable "%s" not in TTree' % ref)
168 vreg = var.replace(
'-',
'_')
169 rreg = ref.replace(
'-',
'_')
171 hname =
"h_%s_%s" % (ref, var)
172 c.append( TCanvas(
"c_%s" % hname,
"ATLAS Run Query: %s vs. %s" % (var, ref), 0, 0, 600, 500 ) )
173 tree.Draw(
"%s:%s" % (vreg, rreg),
"",
"goff" )
174 g.append( TGraph( tree.GetSelectedRows(), tree.GetV2(), tree.GetV1() ) )
175 g[-1].SetTitle(
"ATLAS Run Query: %s vs. %s" % (var, ref) )
176 g[-1].SetMarkerStyle( 20 )
177 g[-1].SetMarkerColor( markerCol )
178 g[-1].SetMarkerSize( 1.2 )
179 g[-1].SetLineWidth( 2 )
180 g[-1].SetLineColor( graphCol )
181 g[-1].GetXaxis().SetTitleOffset( 1.25 )
182 g[-1].GetYaxis().SetTitleOffset( 1.75 )
183 g[-1].GetXaxis().SetTitle( ref )
184 g[-1].GetYaxis().SetTitle( var )
185 g[-1].GetXaxis().SetLabelOffset( 0.012 )
186 g[-1].GetYaxis().SetLabelOffset( 0.012 )
187 g[-1].GetXaxis().SetNdivisions( 506 )
192 gPad.SetLeftMargin ( 0.138*scale )
193 gPad.SetRightMargin ( 0.050*scale )
194 gPad.SetBottomMargin( 0.120*scale )
199 fnames.append(
'%s/atlrunquery_%s.png' % (datapath, hname) )
200 hnames.append(
'%s versus %s' % (var, ref ) )
201 c[-1].Print( fnames[-1] )
203 return hnames, fnames
215 store = (list(lbrange), xvecStb, yvec, runNr, datapath)
216 pf = open(
'%s/plotinput.json' % datapath,
'w' )
219 except Exception
as ex:
220 print (
'ERROR: could not store plotinput data')
221 print(
"Reason: %s" % ex)
226 if not lbrange
or len(yvec)==0
or not yvec[0]:
229 ylegend = [
'Intensity Beam-1',
'Intensity Beam-2',
'Beam energy',
'Online inst. luminosity' ]
232 name =
'LHCsummary_vs_lb_run_%i' % (runNr)
234 title =
'LHC summary vs. LB for run_%i' % (runNr)
236 c = TCanvas( name, title, 0, 0, int(530*szescale), int(400*szescale) )
237 c.GetPad(0).SetTopMargin(0.13)
238 c.GetPad(0).SetLeftMargin(0.09)
239 c.GetPad(0).SetRightMargin(1.3)
244 h = TH1F( name, title, x2 - x1 + 1, x1, x2 + 1 )
245 h.GetXaxis().SetTitle(
'Luminosity block number' )
246 h.GetXaxis().SetTitleOffset( 1.3 )
247 h.GetYaxis().SetTitle(
'Beam intensity (10^{11} protons)' )
248 h.GetYaxis().SetTitleOffset( 1.0 )
252 for iy,y
in enumerate(yvec):
253 hg.append( TH1F( name +
'g%i' % iy, title, x2 - x1 + 1, x1, x2 + 1 ) )
255 hg[iy].SetBinContent( lb, y[lb] )
258 ymax =
max(hg[0].GetMaximum(),hg[1].GetMaximum())
268 ebcol = TColor.GetColor(
"#306754" )
270 heb.Scale( 1./1000.0,
"nosw2" )
271 if heb.GetMaximum()==0:
273 ebmax = heb.GetMaximum()*1.3
279 heb.SetLineColor( ebcol )
280 heb.SetLineWidth( 1 )
281 scale = h.GetMaximum()/ebmax
282 heb.SetFillColor( TColor.GetColor(
"#C3FDB8") )
283 heb.Scale( scale,
"nosw2" )
288 if lbrange[lb]
in xvecStb:
289 h.SetBinContent( lbrange[lb], yvec[2][lb]*scale/1000.0 )
290 h.SetFillColor( TColor.GetColor(
"#63bD58" ) )
291 h.SetFillStyle( 3007 )
292 h.SetLineColor( TColor.GetColor(
"#C3FDB8" ) )
297 hebp.SetFillColor( 0 )
301 colorList = [TColor.GetColor(
"#255EC7" ), TColor.GetColor(
"#E42217" ), TColor.GetColor(
"#2212EE" ), TColor.GetColor(
"#22EE33" )]
304 if ig < len(colorList):
305 hg[ig].SetLineColor( colorList[ig] )
306 hg[ig].SetLineWidth( 2 )
310 now = str(datetime.datetime.today())
311 t = TText( h.GetXaxis().GetXmax(), y2*1.01,
'ATLAS Run Query %s' % now[:now.find(
'.')] )
313 t.SetTextSize( 0.035 )
314 t.SetTextSize( 0.030 )
315 t.SetTextColor( TColor.GetColor(
"#888888" ) )
319 dx = 1 - c.GetRightMargin() - c.GetLeftMargin() - 0.05
321 legend = TLegend( 1 - c.GetRightMargin() - dx, 1 - c.GetTopMargin() - dy - 0.035,
322 1 - c.GetRightMargin(), 1 - c.GetTopMargin() - 0.035)
325 legend.SetNColumns(2)
326 legend.SetBorderSize( 1 )
327 legend.SetMargin( 0.15 )
328 legend.SetLineColor( 0 )
329 legend.SetTextColor( 1 )
330 for ig,hgg
in enumerate(hg):
335 legend.AddEntry( hgg, ylegend[ig], opt )
339 legend.AddEntry( h,
"LBs with stable beams",
"F" )
348 if h.GetMaximum() > 0:
349 axis = TGaxis( x2 + 1, 0, x2 + 1, h.GetMaximum(), 0, ebmax, 510,
"+L" )
350 axis.SetLabelOffset( 0.007 )
351 axis.SetTitleOffset( 1.2 )
352 axis.SetTitleSize( h.GetXaxis().GetTitleSize() )
353 axis.SetLabelSize( 0.04 )
354 axis.SetLineColor( ebcol )
355 axis.SetTitleColor( ebcol )
356 axis.SetLabelColor( ebcol )
357 axis.SetTitle(
"Beam energy (TeV)" )
361 fnames =
'%s/atlrunquery_%s.png' % (datapath, name)
368 xtit, ytit, ylegend, name, title, datapath, printText = '' ):
371 if not xvec
or len(yvec)==0
or not yvec[0]:
376 gStyle.SetPadTickX(0)
377 gStyle.SetPadTickY(1)
379 c = TCanvas( name, title, 0, 0, 530, 430 )
380 c.GetPad(0).SetTopMargin(0.22)
381 c.GetPad(0).SetGrid()
387 for ig
in range(len(yvec)):
391 g.SetPoint( i, xvec[ig][i], yvec[ig][i] )
393 y1 =
min(y1,yvec[ig][i])
394 y2 =
max(y2,yvec[ig][i])
402 frame = TH1F( name, title, int(dt/2), 0, dt )
405 frame.GetXaxis().SetTimeDisplay(1)
412 frame.GetXaxis().SetTimeOffset(toffset,
"gmt")
414 frame.GetXaxis().SetTitle( xtit )
415 frame.GetXaxis().SetTitleOffset( 1.3 )
416 frame.GetYaxis().SetTitle( ytit )
417 frame.GetYaxis().SetTitleOffset( 1.4 )
418 frame.SetTitle( title )
419 frame.SetMinimum(y1 - (y2-y1)*0.1)
420 frame.SetMaximum(y2 + (y2-y1)*0.3)
423 colorList = [TColor.GetColor(
"#154EB7" ), TColor.GetColor(
"#82CAFF" ), TColor.GetColor(
"#D11B17" ), TColor.GetColor(
"#FF9A4D" )]
424 styleList = [1,1,1,1]
426 for ig,g
in enumerate(graphs):
427 if ig < len(colorList):
428 g.SetLineColor( colorList[ig] )
429 g.SetLineStyle( styleList[ig] )
434 t = TText( frame.GetXaxis().GetXmax(), y2*1.01, printText )
436 t.SetTextSize( 0.035 )
440 now = str(datetime.datetime.today())
441 tlogo = TText( frame.GetXaxis().GetXmax()*1.025 - frame.GetXaxis().GetXmin()*0.025, y1,
442 'ATLAS Run Query %s' % now[:now.find(
'.')] )
443 tlogo.SetTextSize( 0.030 )
444 tlogo.SetTextColor( TColor.GetColor(
"#aaaaaa" ) )
445 tlogo.SetTextAngle(90)
449 lbcol = TColor.GetColor(
"#777777" )
450 axis = TGaxis( frame.GetXaxis().GetXmin(), frame.GetMaximum(),
451 frame.GetXaxis().GetXmax(), frame.GetMaximum(),
452 1, len(xveclb), 505,
"-L" )
453 axis.SetLabelOffset( frame.GetXaxis().GetLabelOffset() )
454 axis.SetTitleOffset( 1.4 )
455 axis.SetTitleSize( frame.GetXaxis().GetTitleSize() )
456 axis.SetLabelSize( frame.GetXaxis().GetLabelSize() )
457 axis.SetLineColor( lbcol )
458 axis.SetTitleColor( lbcol )
459 axis.SetLabelColor( lbcol )
460 axis.SetTitle(
"Luminosity block number (indicative)" )
465 dx = 1 - c.GetRightMargin() - c.GetLeftMargin() - 0.05
467 legend = TLegend( 1 - c.GetRightMargin() - dx, 1 - c.GetTopMargin() - dy - 0.035,
468 1 - c.GetRightMargin(), 1 - c.GetTopMargin() - 0.035)
471 legend.SetNColumns(2)
472 legend.SetBorderSize( 1 )
473 legend.SetMargin( 0.15 )
474 legend.SetLineColor( 0 )
475 legend.SetTextColor( 1 )
476 legend.SetTextSize( 0.037 )
477 for ig,g
in enumerate(graphs):
480 h.SetLineColor( colorList[ig] )
481 h.SetLineStyle( styleList[ig] )
483 legend.AddEntry( h, ylegend[ig],
"l" )
489 frame.Draw(
"sameaxis" )
492 fnames =
'%s/atlrunquery_%s.png' % (datapath, name)
498def makeLBPlotList( xvec, xvecStb, yvec, xtitle, ytitle, ylegend, histname, histtitle, datapath, printText = '', ymin = None , ymax = None ):
501 if not xvec
or len(yvec)==0
or not yvec[0]:
505 c = TCanvas( histname, histtitle, 0, 0, 530, 400 )
506 c.GetPad(0).SetTopMargin(0.13)
507 c.GetPad(0).SetGrid()
511 h = TH1F( histname, histtitle, x2 - x1 + 1, x1, x2 + 1 )
513 for iy
in range(len(yvec)):
514 hg.append( TH1F( histname +
'g%i' % iy, histtitle, x2 - x1 + 1, x1, x2 + 1 ) )
515 h.GetXaxis().SetTitle( xtitle )
516 h.GetXaxis().SetTitleOffset( 1.3 )
517 h.GetYaxis().SetTitle( ytitle )
518 h.GetYaxis().SetTitleOffset( 1.4 )
519 h.SetTitle( histtitle )
522 for i
in range(len(xvec)):
523 for iy,y
in enumerate(yvec):
524 if type(y[i])
is tuple:
528 hg[iy].SetBinContent( xvec[i], val )
529 hg[iy].SetBinError( xvec[i], valerr )
530 if xvec[i]
in xvecStb:
531 h.SetBinContent( xvec[i], yvec[0][i] )
534 ymax =
max([h.GetMaximum()
for h
in hg])
546 h.SetFillColor( TColor.GetColor(
"#98AFC7" ) )
547 h.SetLineColor( TColor.GetColor(
"#788FA7" ) )
554 colorList = [TColor.GetColor(
"#255EC7" ), TColor.GetColor(
"#E42217" ), TColor.GetColor(
"#2212EE" ), TColor.GetColor(
"#22EE33" )]
556 for ig,hgg
in enumerate(hg):
557 if ig < len(colorList):
558 hgg.SetLineColor( colorList[ig] )
559 hgg.SetLineWidth( 2 )
563 t = TText( h.GetXaxis().GetXmax(), (ymax-ymin)*1.01 + ymin, printText )
565 t.SetTextSize( 0.035 )
569 now = str(datetime.datetime.today())
570 tlogo = TText( h.GetXaxis().GetXmax()*1.025, (ymax-ymin)*0.0+ymin,
'ATLAS Run Query %s' % now[:now.find(
'.')] )
571 tlogo.SetTextSize( 0.030 )
572 tlogo.SetTextColor( TColor.GetColor(
"#888888" ) )
573 tlogo.SetTextAngle(90)
578 dy = 0.10 + 0.03*(len(hg)-1)
579 legend = TLegend( 1 - c.GetRightMargin() - dx, 1 - c.GetTopMargin() - dy - 0.015,
580 1 - c.GetRightMargin(), 1 - c.GetTopMargin() - 0.015)
583 legend.SetBorderSize( 1 )
584 legend.SetMargin( 0.15 )
585 legend.SetLineColor( 0 )
586 legend.SetTextColor( 1 )
587 for ig,hgg
in enumerate(hg):
589 legend.AddEntry( hgg, ylegend[ig],
"l" )
593 legend.AddEntry( h,
"LBs with stable beams",
"F" )
602 fnames =
'%s/atlrunquery_%s.png' % (datapath, histname)
608def makeBSPlots( xvec, yvec, xtitle, ytitle, histname, histtitle, datapath, ymin, ymax, printText = '' ):
611 if not xvec
or len(yvec)==0
or not yvec[0]:
617 c = TCanvas( histname, histtitle, 0, 0, 530, 400 )
618 c.GetPad(0).SetTopMargin(0.13)
619 c.GetPad(0).SetGrid()
623 bounds += [bounds[-1]+nlb]
625 from array
import array
626 h = TH1F( histname +
'g', histtitle, len(bounds)-1,
array(
'f',bounds) )
627 h.GetXaxis().SetTitle( xtitle )
628 h.GetXaxis().SetTitleOffset( 1.3 )
629 h.GetYaxis().SetTitle( ytitle )
630 h.GetYaxis().SetTitleOffset( 1.4 )
631 h.SetTitle( histtitle )
634 h.SetFillColor( TColor.GetColor(
"#56A5EC" ) )
635 for bin,y
in enumerate(yvec):
637 h.SetBinContent( bin+1, val )
638 h.SetBinError ( bin+1, valerr )
642 hc.SetLineColor( ROOT.kBlack )
647 t = TText( h.GetXaxis().GetXmax(), (ymax-ymin)*1.01 + ymin, printText )
649 t.SetTextSize( 0.035 )
653 now = str(datetime.datetime.today())
654 tlogo = TText( h.GetXaxis().GetXmax()*1.025, (ymax-ymin)*0.0+ymin,
'ATLAS Run Query %s' % now[:now.find(
'.')] )
655 tlogo.SetTextSize( 0.030 )
656 tlogo.SetTextColor( TColor.GetColor(
"#888888" ) )
657 tlogo.SetTextAngle(90)
661 fnames =
'%s/atlrunquery_%s.png' % (datapath, histname)
668 xtitle, ytitle, ylegendScalar,
670 datapath, printText = '', ymin = None, ymax = None ):
672 ylegend = [ylegendScalar]
673 return makeLBPlotList( xvec, xvecStb, yvec, xtitle, ytitle, ylegend, histname, histtitle, datapath, printText, ymin, ymax )
678 vlist.append(
array(
'i', [ 0 ] ) )
679 vreg = var.replace(
'-',
'_')
680 tree.Branch( vreg, vlist[-1],
"%s/I" % vreg )
684 vlist[kcoord][0] = int(value)
685 except (ValueError, TypeError):
686 vlist[kcoord][0] = -1
691 vlist.append(
array(
'f', [ 0 ] ) )
692 vreg = var.replace(
'-',
'_')
693 tree.Branch( vreg, vlist[-1],
"%s/F" % vreg )
697 vlist[kcoord][0] = float(value)
698 except (ValueError, TypeError):
699 vlist[kcoord][0] = -1
704 vlist.append(
array(
'b',
'ab\0'.encode() ) )
705 tree.Branch( var, vlist[-1],
"%s/C" % var )
709 vlist[kcoord] =
array(
'b', (value +
'\0').encode() )
710 tree.SetBranchAddress( var, vlist[kcoord] )
711 except (ValueError, TypeError):
712 vlist[kcoord] =
array(
'b',
'unknown\0'.encode() )
713 tree.SetBranchAddress( var, vlist[kcoord] )
729 print (
'Unknown format in "DurationtypeTrf:"')
733 value = str( ( (int(d.replace(
'd',
'').
strip())*24 + int(h.replace(
'h',
'').
strip()))*60 +
734 int(m.replace(
'm',
'').
strip()) )*60 + int(s.replace(
's',
'').
strip()) )
735 except (ValueError, TypeError):
742def MakeHtml( hnames, fnames, uselarge = False, iconwidth = 70, nbreakline = 10 ):
743 windowstyle =
'openWindow'
745 windowstyle =
'openLargeWindow'
749 for i
in range(0,len(fnames)):
752 s +=
"""<td valign="top"><a STYLE="text-decoration: none" href=" """
753 s +=
"""javascript:%s('Plot','<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html xmlns:my><head><title>%s</title><LINK href="atlas-runquery.css" rel="stylesheet" type="text/css"><body><table style="font-family: sans-serif; font-size: 85%%"><tr><td valign="top">""" % (windowstyle,h)
754 s +=
"""<img src="%s">""" % f
755 s +=
"""<hr color="red" size=1><font color="#777777"><font size="-1"><i><font size="-2">Created by AtlRunQuery on: %s</font></i></font></td></tr></table><script type="text/javascript"></script></body></html>""" % str(datetime.datetime.now())
757 s +=
""" "><img vspace=0 src="%s" title="Plot showing query result for %s" width="%i"></a><br><font size="-2">%s</font></td>""" % (f,h,iconwidth,h)
758 s +=
"""<td> </td>"""
759 if (i+1)%nbreakline == 0:
768 actions = {
"run": (
True, InttypeTrf ),
769 "links": (
False, StringtypeTrf ),
770 "#lb": (
True, InttypeTrf ),
771 "#events": (
True, InttypeTrf ),
772 "smk": (
True, InttypeTrf ),
773 "start and endtime": (
True, TimetypeTrf ),
774 "duration": (
True, DurationtypeTrf ),
775 "torcurrent": (
True, FloattypeTrf ),
776 "solcurrent": (
True, FloattypeTrf ),
777 "detector systems": (
False, StringtypeTrf ),
778 "stream": (
True, InttypeTrf ),
779 "lumi": (
True, FloattypeTrf ),
780 "other": (
True, StringtypeTrf )
786 from CoolRunQuery.selector.AtlRunQuerySelectorBase
import DataKey
787 from CoolRunQuery.AtlRunQueryQueryConfig
import QC
788 datapath = QC.datapath
792 if 'data' not in os.listdir(
'.'):
795 f = open(
'%s/dummyroot.txt' % datapath,
'w' )
797 froot = TFile(
'%s/atlrunquery.root' % datapath,
'RECREATE' )
799 tree = TTree(
'RunQuery',
'ATLAS Run Query' )
808 f.write(
'key: %s \n' % (data_key.ResultKey))
813 k = data_key.ResultKey.lower()
814 if data_key.Type==DataKey.STREAM:
816 elif 'olc_' == data_key.ResultKey[0:4]:
823 useit, function = actions[k]
825 function( tree, var, varlist, -1, -1 )
826 keylist.append( (data_key,var, function) )
829 for ev
in range(len(dic[DataKey(
'Run')])):
830 for k,(data_key,var,function)
in enumerate(keylist):
832 val = dic[data_key][ev]
833 if data_key.Type==DataKey.STREAM:
836 function( tree, var, varlist, val, k )
841 hnames, fnames =
MakePlots( tree, datapath )
842 htmlstr =
MakeHtml( hnames, fnames )
848 return froot.GetName(), htmlstr
852def makeRatePlot( v, lbduration, plottriggers, averrate, xtit, ytit, name, title, datapath, printText = '' ):
868 c = TCanvas( name, title, 0, 0, 530, 400 )
869 c.GetPad(0).SetTopMargin(0.13)
870 c.GetPad(0).SetGrid()
872 firstlb =
min([lbinfo[0][0]
for lbinfo
in v.values()])
873 lastlb =
max([lbinfo[-1][0]
for lbinfo
in v.values()])
875 frame = TH1F( name, title, lastlb-firstlb+1, firstlb, lastlb+1 )
876 frame.GetXaxis().SetTitle( xtit )
877 frame.GetXaxis().SetTitleOffset( 1.3 )
878 frame.GetYaxis().SetTitle( ytit )
879 frame.GetYaxis().SetTitleOffset( 1.4 )
887 colorList = [ (ROOT.kBlue,ROOT.kAzure+1),
888 (ROOT.kGreen+2,ROOT.kGreen+2),
889 (ROOT.kRed+1,ROOT.kRed),
890 (ROOT.kTeal-1,ROOT.kTeal),
891 (ROOT.kOrange+8,ROOT.kOrange),
892 (ROOT.kYellow+1,ROOT.kYellow),
893 (ROOT.kOrange+3,ROOT.kOrange+5),
894 (ROOT.kPink+8,ROOT.kPink+9) ]
897 for trname,avrate
in plottriggers:
898 hTAP[trname] = TH1F(
'%s_ap_%s' % (name,trname), title, lastlb-firstlb+1, firstlb, lastlb+1 )
899 hTAV[trname] = TH1F(
'%s_av_%s' % (name,trname), title, lastlb-firstlb+1, firstlb, lastlb+1 )
902 hav.SetLineWidth( 2 )
903 if clrIdx < len(colorList):
904 dark,bright = colorList[clrIdx]
905 hav.SetLineColor( dark )
906 hap.SetFillColor( bright )
907 hap.SetMarkerColor( bright )
911 for (lb,bp,ap,av),(lb2,lbstart,dt)
in zip(counts,lbduration):
914 hap.SetBinContent( lb-firstlb+1, (_apr+_avr)/2 )
915 hap.SetBinError( lb-firstlb+1, (_apr-_avr)/2 )
916 hav.SetBinContent( lb-firstlb+1, _avr )
917 ymax =
max(ymax,_apr)
930 for h
in hTAP.values():
932 for h
in hTAV.values():
936 t = TText( frame.GetXaxis().GetXmax(), y2*1.01, printText )
938 t.SetTextSize( 0.035 )
942 now = str(datetime.datetime.today())
943 tlogo = TText( frame.GetXaxis().GetXmax()*1.025, y1,
'ATLAS Run QUERY %s' % now[:now.find(
'.')] )
944 tlogo.SetTextSize( 0.030 )
945 tlogo.SetTextColor( TColor.GetColor(
"#888888" ) )
946 tlogo.SetTextAngle(90)
950 dy = 0.10 + 0.01*(len(hTAV)-1)
951 legend = TLegend( 1 - c.GetRightMargin() - dx, 1 - c.GetTopMargin() - dy - 0.015,
952 1 - c.GetRightMargin(), 1 - c.GetTopMargin() - 0.015)
953 legend.SetNColumns(2)
954 legend.SetBorderSize( 0 )
955 legend.SetMargin( 0.15 )
956 legend.SetLineColor( 0 )
957 legend.SetTextColor( 1 )
959 for trname,avtrrate
in averrate:
960 if trname
not in hTAV:
962 legend.AddEntry( hTAV[trname], trname,
"l" )
966 frame.Draw(
"sameaxis" )
969 fnames =
'%s/atlrunquery_%s.png' % (datapath, name)
971 frame.SetMaximum(ymax*5)
974 fnames2 =
'%s/atlrunquery_%s_log.png' % (datapath, name)
984if __name__==
'__main__':
988 pf = open(
'%s/plotinput.json' % datapath,
'r' )
989 (lbrange, xvecStb, yvec, runNr, datapath) = json.load(pf)
990 lbrange = range(len(lbrange))
void print(char *figname, TCanvas *c1)
std::string replace(std::string s, const std::string &s2, const std::string &s3)
TimetypeTrf(tree, var, vlist, value, kcoord)
SaveGraphsToFile(filename, varnames, xvecs, yvecs, addparamName=None, addparamVal=None)
StringtypeTrf(tree, var, vlist, value, kcoord)
SetStyle(whiteCanvas=False)
makeRatePlot(v, lbduration, plottriggers, averrate, xtit, ytit, name, title, datapath, printText='')
FloattypeTrf(tree, var, vlist, value, kcoord)
DurationtypeTrf(tree, var, vlist, value, kcoord)
MakePlots(tree, datapath)
makeLBPlotList(xvec, xvecStb, yvec, xtitle, ytitle, ylegend, histname, histtitle, datapath, printText='', ymin=None, ymax=None)
makeLBPlot(xvec, xvecStb, yvecScalar, xtitle, ytitle, ylegendScalar, histname, histtitle, datapath, printText='', ymin=None, ymax=None)
makeBSPlots(xvec, yvec, xtitle, ytitle, histname, histtitle, datapath, ymin, ymax, printText='')
MakeHtml(hnames, fnames, uselarge=False, iconwidth=70, nbreakline=10)
InttypeTrf(tree, var, vlist, value, kcoord)
makeLBPlotSummaryForLHC(lbrange, xvecStb, yvec, runNr, datapath, printText='')
makeTimePlotList(xvec, xveclb, yvec, toffset, dt, ymin, ymax, xtit, ytit, ylegend, name, title, datapath, printText='')