230 def plotbarycenter(bc,coord,plotConfigJson, substructure,runsPerYear,pixelLocalRecos,accumulatedLumiPerRun, withPixelQuality,showLumi) :
231 runs = list(accumulatedLumiPerRun.keys())
233 years = list(runsPerYear.keys())
235 labels = list(bc.keys())
237 can = ROOT.TCanvas(
"barycentre_"+substructure+
"_"+coord,
"", 2000, 900)
248 for label
in labels :
249 gr[label] = ROOT.TGraph()
250 gr[label] = bc[label][coord+
"_"+substructure]
252 gr[label].SetMarkerStyle(8)
253 gr[label].SetMarkerSize(0)
254 gr[label].SetMarkerStyle(8)
255 gr[label].SetMarkerSize(0)
256 gr[label].SetLineColor(plotConfigJson[
"colorScheme"][label])
258 width_ = gr[label].GetXaxis().GetXmax() - gr[label].GetXaxis().GetXmin()
259 xmax = gr[label].GetXaxis().GetXmax()
262 upper = bc[label][coord+
"max_"+substructure]
263 lower = bc[label][coord+
"min_"+substructure]
266 upper =
max(upper, bc[label][coord+
"max_"+substructure])
267 lower =
min(lower, bc[label][coord+
"min_"+substructure])
271 upper = upper * scale
273 upper = upper / scale
275 lower = lower / scale
277 lower = lower * scale
278 range_ = upper - lower
281 for label
in labels :
283 gr[label].GetYaxis().SetRangeUser(lower, upper)
284 gr[label].GetYaxis().SetTitle(plotConfigJson[
"substructures"][substructure]+
" barycentre ("+coord+
") [#mum]")
285 gr[label].GetXaxis().SetTitle(
"Run Number")
286 gr[label].GetYaxis().CenterTitle(
True)
287 gr[label].GetXaxis().CenterTitle(
True)
288 gr[label].GetYaxis().SetTitleOffset(0.80)
289 gr[label].GetYaxis().SetTitleSize(0.055)
290 gr[label].GetXaxis().SetTitleOffset(0.80)
291 gr[label].GetXaxis().SetTitleSize(0.055)
292 gr[label].GetXaxis().SetMaxDigits(6)
294 gr[label].GetXaxis().SetTitle(
"Delivered luminosity [1/fb]")
302 gr_dummyFirstRunOfTheYear =
blackBox(-999, 10000, -999, -10000)
303 gr_dummyFirstRunOfTheYear.SetLineColor(ROOT.kBlack)
304 gr_dummyFirstRunOfTheYear.SetLineStyle(1)
305 gr_dummyFirstRunOfTheYear.Draw(
"L")
306 gr_dummyPixelReco =
blackBox(-999, 10000, -999, -10000)
307 gr_dummyPixelReco.SetLineColor(ROOT.kGray+1)
308 gr_dummyPixelReco.SetLineStyle(3)
309 gr_dummyPixelReco.Draw(
"L")
310 gr_dummyFirstRunOfTheYear.SetTitle(
"First run of the year")
311 gr_dummyPixelReco.SetTitle(
"Pixel calibration update")
313 for label
in labels :
314 gr[label].SetTitle(plotConfigJson[
"baryCentreLabels"][label])
315 legend = can.BuildLegend()
316 legend.SetShadowColor(0)
317 legend.SetFillColor(0)
318 legend.SetLineColor(1)
320 for label
in labels :
321 gr[label].SetTitle(
"")
327 years_label +=
str(year)
329 years_label = years_label.rstrip(
"+")
332 CMSworkInProgress = ROOT.TPaveText( xmax-0.3*width_, upper+range_*0.005,
333 xmax, upper+range_*0.055,
"nb")
334 CMSworkInProgress.AddText(
"CMS #bf{#it{Preliminary} ("+years_label+
" pp collisions)}")
335 CMSworkInProgress.SetTextAlign(32)
336 CMSworkInProgress.SetTextSize(0.04)
337 CMSworkInProgress.SetFillColor(10)
338 CMSworkInProgress.Draw()
343 for since
in pixelLocalRecos :
346 integrated_lumi = accumulatedLumiPerRun[runs[run_index]]
347 line_pixels[since] = ROOT.TLine(integrated_lumi, lower, integrated_lumi, upper)
350 line_pixels[since] = ROOT.TLine(since, lower, since, upper)
352 line_pixels[since].SetLineColor(ROOT.kGray+1)
353 line_pixels[since].SetLineStyle(3)
354 line_pixels[since].Draw()
360 if(len(years)>1
or (
not showLumi) ) :
365 integrated_lumi = accumulatedLumiPerRun[runs[run_index]]
366 line_years[year] = ROOT.TLine(integrated_lumi, lower, integrated_lumi, upper)
367 text_years[year] = ROOT.TPaveText( integrated_lumi+0.01*width_, upper-range_*0.05,
368 integrated_lumi+0.05*width_, upper-range_*0.015,
"nb")
369 box_years[year] =
blackBox(integrated_lumi+0.005*width_, upper-range_*0.01, integrated_lumi+0.055*width_, upper-range_*0.055)
371 line_years[year] = ROOT.TLine(runsPerYear[year][0], lower, runsPerYear[year][0], upper)
372 text_years[year] = ROOT.TPaveText( runsPerYear[year][0]+0.01*width_, upper-range_*0.05,
373 runsPerYear[year][0]+0.05*width_, upper-range_*0.015,
"nb")
374 box_years[year] =
blackBox(runsPerYear[year][0]+0.01*width_, upper-range_*0.015, runsPerYear[year][0]+0.05*width_, upper-range_*0.05)
377 box_years[year].Draw(
"L")
378 line_years[year].Draw()
381 text_years[year].AddText(
str(year))
382 text_years[year].SetTextAlign(22)
383 text_years[year].SetTextSize(0.025)
384 text_years[year].SetFillColor(10)
385 text_years[year].Draw()
391 can.SaveAs(
"baryCentre"+withPixelQuality+
"_"+coord+
"_"+substructure+
"_"+years_label+
"_IntegratedLumi.pdf")
392 can.SaveAs(
"baryCentre"+withPixelQuality+
"_"+coord+
"_"+substructure+
"_"+years_label+
"_IntegratedLumi.png")
394 can.SaveAs(
"baryCentre"+withPixelQuality+
"_"+coord+
"_"+substructure+
"_"+years_label+
"_RunNumber.pdf")
395 can.SaveAs(
"baryCentre"+withPixelQuality+
"_"+coord+
"_"+substructure+
"_"+years_label+
"_RunNumber.png")