209def makeLBPlotSummaryForLHC( lbrange, xvecStb, yvec, runNr, datapath, printText = '' ):
210
211 plotDevelop = False
212 if plotDevelop:
213
214 import json
215 store = (list(lbrange), xvecStb, yvec, runNr, datapath)
216 pf = open( '%s/plotinput.json' % datapath, 'w' )
217 try:
218 json.dump(store, pf)
219 except Exception as ex:
220 print ('ERROR: could not store plotinput data')
221 print(
"Reason: %s" % ex)
222 sys.exit(1)
223 pf.close()
224
225
226 if not lbrange or len(yvec)==0 or not yvec[0]:
227 return "None"
228
229 ylegend = ['Intensity Beam-1', 'Intensity Beam-2', 'Beam energy', 'Online inst. luminosity' ]
230
231 SetStyle()
232 name = 'LHCsummary_vs_lb_run_%i' % (runNr)
233
234 title = 'LHC summary vs. LB for run_%i' % (runNr)
235 szescale = 1.2
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)
240
241 x1 = lbrange[0]
242 x2 = lbrange[-1]
243
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 )
249 h.SetTitle( title )
250
251 hg = []
252 for iy,y in enumerate(yvec):
253 hg.append( TH1F( name + 'g%i' % iy, title, x2 - x1 + 1, x1, x2 + 1 ) )
254 for lb in lbrange:
255 hg[iy].SetBinContent( lb, y[lb] )
256
257
258 ymax =
max(hg[0].GetMaximum(),hg[1].GetMaximum())
259 y2 = ymax*1.3
260 if y2 <= 0:
261 y2 = 1
262 h.SetMinimum(0)
263 h.SetMaximum(y2)
264 h.Draw("0")
265 gPad.SetTicks(1, 0)
266
267
268 ebcol = TColor.GetColor( "#306754" )
269 heb = hg[2]
270 heb.Scale( 1./1000.0, "nosw2" )
271 if heb.GetMaximum()==0:
272 heb.SetMaximum(1)
273 ebmax = heb.GetMaximum()*1.3
274
275
276 if ebmax == 0:
277 return "None"
278
279 heb.SetLineColor( ebcol )
280 heb.SetLineWidth( 1 )
281 scale = h.GetMaximum()/ebmax
282 heb.SetFillColor( TColor.GetColor("#C3FDB8") )
283 heb.Scale( scale, "nosw2" )
284 heb.Draw("same")
285
286 if xvecStb:
287 for lb in lbrange:
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" ) )
293 h.SetLineWidth( 1 )
294 h.SetLineStyle( 1 )
295 h.Draw("same")
296 hebp = TH1F( heb )
297 hebp.SetFillColor( 0 )
298 hebp.Draw("same")
299
300
301 colorList = [TColor.GetColor( "#255EC7" ), TColor.GetColor( "#E42217" ), TColor.GetColor( "#2212EE" ), TColor.GetColor( "#22EE33" )]
302
303 for ig in range(2):
304 if ig < len(colorList):
305 hg[ig].SetLineColor( colorList[ig] )
306 hg[ig].SetLineWidth( 2 )
307 hg[ig].Draw("same")
308
309
310 now = str(datetime.datetime.today())
311 t = TText( h.GetXaxis().GetXmax(), y2*1.01, 'ATLAS Run Query %s' % now[:now.find('.')] )
312 t.SetTextAlign( 31 )
313 t.SetTextSize( 0.035 )
314 t.SetTextSize( 0.030 )
315 t.SetTextColor( TColor.GetColor( "#888888" ) )
316 t.Draw()
317
318 drawLegend = False
319 dx = 1 - c.GetRightMargin() - c.GetLeftMargin() - 0.05
320 dy = 0.1
321 legend = TLegend( 1 - c.GetRightMargin() - dx, 1 - c.GetTopMargin() - dy - 0.035,
322 1 - c.GetRightMargin(), 1 - c.GetTopMargin() - 0.035)
323
324
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):
331 if ylegend[ig]:
332 opt = "l"
333 if ig == 2:
334 opt = "FL"
335 legend.AddEntry( hgg, ylegend[ig], opt )
336 drawLegend = True
337
338 if xvecStb:
339 legend.AddEntry( h, "LBs with stable beams","F" )
340 drawLegend = True
341 if drawLegend:
342 legend.Draw("same")
343
344
345 h.Draw( "sameaxis" )
346
347
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)" )
358 axis.Draw()
359
360 c.Update()
361 fnames = '%s/atlrunquery_%s.png' % (datapath, name)
362 c.Print( fnames )
363
364
365 return fnames
366
void print(char *figname, TCanvas *c1)