Commit 87e0df64 authored by Daniel Hugo Campora Perez's avatar Daniel Hugo Campora Perez
Browse files

Merge branch 'dovombru_fix_nice_plotting' into 'master'

fix nice plotting

See merge request lhcb-parallelization/Allen!163
parents eb496908 487eb30c
Pipeline #933804 failed with stages
in 14 minutes and 1 second
......@@ -31,7 +31,7 @@ def ghostHistoDict():
basedict = {"eta": {}, "nPV": {}}
basedict["eta"]["xTitle"] = "#eta"
basedict["eta"]["variable"] = "Eta"
basedict["eta"]["variable"] = "eta"
basedict["nPV"]["xTitle"] = "# of PVs"
basedict["nPV"]["variable"] = "nPV"
......@@ -41,6 +41,7 @@ def ghostHistoDict():
def getCuts():
basedict = {"Velo": {}, "Upstream": {}, "Forward": {}}
# basedict["Forward"] = [
# "Long_eta25", "LongFromB_eta25"
# ]
......
......@@ -44,7 +44,7 @@ def setLHCbStyle():
# set the paper & margin sizes
lhcbStyle.SetPaperSize(20, 26)
lhcbStyle.SetPadTopMargin(0.05)
lhcbStyle.SetPadRightMargin(0.08) # increase for colz plots
lhcbStyle.SetPadRightMargin(0.10) # increase for colz plots
lhcbStyle.SetPadBottomMargin(0.16)
lhcbStyle.SetPadLeftMargin(0.14)
......
......@@ -116,7 +116,7 @@ def place_legend(canvas,
return canvas.BuildLegend(0.5, 0.67, 0.88, 0.88, header, option)
def find_place(canvas, x1=None, y1=None, x2=None, y2=None):
def find_place(canvas, default=3, x1=None, y1=None, x2=None, y2=None):
# Make sure all objects are correctly registered
canvas.Update()
......@@ -135,7 +135,7 @@ def find_place(canvas, x1=None, y1=None, x2=None, y2=None):
continue
return place
return PLACES[3] # fallback solution
return PLACES[default] # fallback solution
# Monkey patch ROOT objects to make it all work
......
......@@ -16,6 +16,7 @@ import ROOT
from ROOT import gStyle
from ROOT import gROOT
from ROOT import TStyle
from ROOT import TLegend
from ROOT import gPad
from ROOT import TMultiGraph
......@@ -100,7 +101,33 @@ for category in muonCategories:
g_efficiency.GetYaxis().SetTitle(muonCatDict[category]["title"])
g_efficiency.GetYaxis().SetRangeUser(0, 1)
# draw variable distribution in same canvas
norm = 0.9 / numerator.GetMaximum()
numerator.Scale(norm)
numerator.SetTitle(efficiencyHistoDict[histo]["title"] +
" distribution")
numerator.SetFillColorAlpha(ROOT.kBlack, 0.2)
numerator.SetLineColor(ROOT.kWhite)
numerator.Draw("hist bar same")
if (category == "matched_isMuon"):
place = find_place(canvas, 3)
else:
place = PLACES[0]
#place = find_place(canvas, 0)
legend = TLegend(place[0], place[1], place[2], place[3])
legend.AddEntry(g_efficiency, muonCatDict[category]["title"], "ep")
legend.AddEntry(numerator,
efficiencyHistoDict[histo]["title"] + " distribution",
"f")
legend.SetFillColorAlpha(ROOT.kWhite, 0.)
legend.Draw("same")
canvas.Write()
cleantitle = muonCatDict[category]["title"].replace(" ", "").replace(
",", "_").replace("<", "_")
canvas.SaveAs("../../../plotsfornote/muonID_isMuon_" + histo + "_" +
cleantitle + ".pdf")
# ghost histos
for histo in ghostHistos:
......@@ -127,6 +154,21 @@ for histo in ghostHistos:
g_efficiency.Draw("ap")
g_efficiency.GetYaxis().SetRangeUser(0, 1)
# draw variable distribution in same canvas
norm = 0.9 / numerator.GetMaximum()
numerator.Scale(norm)
numerator.SetTitle(efficiencyHistoDict[histo]["title"] + " distribution")
numerator.SetFillColorAlpha(ROOT.kBlack, 0.2)
numerator.SetLineColor(ROOT.kWhite)
numerator.Draw("hist bar same")
place = find_place(canvas, 0)
legend = TLegend(place[0], place[1], place[2], place[3])
legend.AddEntry(g_efficiency, "muon ID in ghost tracks", "ep")
legend.AddEntry(numerator,
efficiencyHistoDict[histo]["title"] + " distribution", "f")
legend.Draw("same")
canvas.Write()
canvas.SaveAs("../../../plotsfornote/muonID_isMuon_ghosts_" + histo +
".pdf")
......
......@@ -21,6 +21,7 @@ from ROOT import TLegend
from ROOT import gPad
from ROOT import TMultiGraph
from ROOT import THStack
from ROOT import TMath
sys.path.append('../')
from common.LHCbStyle import *
......@@ -39,7 +40,7 @@ def getTrackers():
def getGhostHistoNames():
# return ["eta", "nPV"] # currently no eta information available from track
#return ["nPV", "eta"] # currently no eta information available from track
return ["nPV"]
......@@ -160,7 +161,7 @@ for tracker in trackers:
else:
variable.SetTitle(efficiencyHistoDict[histo]["title"] +
" distribution")
variable.SetLineColor(ROOT.kBlack)
variable.SetLineColor(ROOT.kWhite)
variable.SetFillColorAlpha(ROOT.kBlack, 0.2)
variable.Draw("hist bar same")
......@@ -175,11 +176,11 @@ for tracker in trackers:
variable_electrons.Scale(norm)
variable_electrons.SetTitle(efficiencyHistoDict[histo]["title"]
+ " distribution, electrons")
variable_electrons.SetLineColor(ROOT.kAzure - 3)
variable_electrons.SetLineColor(ROOT.kWhite)
variable_electrons.SetFillColorAlpha(ROOT.kAzure - 3, 0.2)
variable_electrons.Draw("hist bar same")
place = find_place(canvas)
place = find_place(canvas, 3)
legend = TLegend(place[0], place[1], place[2], place[3])
if categories[tracker][cut]["plotElectrons"]:
legend.AddEntry(g_efficiency_notElectrons,
......@@ -202,8 +203,6 @@ for tracker in trackers:
" distribution, electrons", "f")
legend.SetFillColorAlpha(ROOT.kWhite, 0.)
legend.Draw("same")
#canvas.PlaceLegend("f")
#place_legend(canvas)
canvas.Write()
cleantitle = categories[tracker][cut]["title"].replace(
......@@ -242,6 +241,26 @@ for tracker in trackers:
g_efficiency.GetYaxis().SetTitle("ghost rate")
g_efficiency.Draw("ap")
# draw variable distribution in same canvas
max_point = TMath.MaxElement(g_efficiency.GetN(), g_efficiency.GetY())
norm = max_point / numerator.GetMaximum()
print("norm:")
print(norm)
numerator.Scale(norm)
numerator.SetTitle(efficiencyHistoDict[histo]["title"] +
" distribution")
numerator.SetFillColorAlpha(ROOT.kBlack, 0.2)
numerator.SetLineColor(ROOT.kWhite)
numerator.Draw("hist bar same")
place = find_place(canvas)
legend = TLegend(place[0], place[1], place[2], place[3])
legend.AddEntry(g_efficiency, "ghost rate", "ep")
legend.AddEntry(numerator,
efficiencyHistoDict[histo]["title"] + " distribution",
"f")
legend.Draw("same")
canvas.Write()
canvas.SaveAs("../../../plotsfornote/" + tracker + "GhostRate.pdf")
#canvas.Print("../../../output/checkerplots/forreviewdoc/"+histoBaseName.replace("/","_")+ghostHistoDict[histo]["variable"]+"_ghost.pdf")
......
......@@ -16,6 +16,8 @@ from ROOT import TStyle
from ROOT import gPad
from ROOT import TGraphErrors
from array import array
from ROOT import TMath
from ROOT import TLegend
sys.path.append('../')
from common.LHCbStyle import *
......@@ -100,9 +102,7 @@ def getResolutionInSlices(histo2D, var, var_dict):
gr.SetTitle("")
gr.SetName(name)
gr.Write()
canvas.Write()
canvas.SaveAs("../../../plotsfornote/" + tracker + "MomResVsP.pdf")
#gr.Write()
#name = "dp_vs_p_rms"
#title = "dp vs p, histogram RMS"
......@@ -121,6 +121,19 @@ def getResolutionInSlices(histo2D, var, var_dict):
# overall momentum resolution
histo1D = histo2D.ProjectionY("_py")
histo1D.Write()
# plot distribution in same canvas
max_point = TMath.MaxElement(gr.GetN(), gr.GetY())
norm = max_point / histo1D.GetMaximum()
histo1D.Scale(norm)
histo1D.SetFillColorAlpha(ROOT.kBlack, 0.2)
histo1D.SetLineColor(ROOT.kWhite)
#histo1D.Draw("hist bar same")
canvas.Write()
canvas.SaveAs("../../../plotsfornote/" + tracker + "MomResVs" + var +
".pdf")
histo1D.Fit("gaus")
sigma_p = histo1D.GetFunction("gaus").GetParameter(2)
delta_sigma_p = histo1D.GetFunction("gaus").GetParError(2)
......
......@@ -95,15 +95,10 @@ TrackCheckerHistos::TrackCheckerHistos(const std::vector<HistoCategory>& histo_c
std::make_unique<TH1D>("matched_isMuon_P_reconstructed", "matched_isMuon_P_reconstructed", 10, 0., 100000.);
h_not_matched_isMuon_P_reconstructed =
std::make_unique<TH1D>("not_matched_isMuon_P_reconstructed", "not_matched_isMuon_P_reconstructed", 10, 0., 100000.);
h_muon_Pt_reconstructible =
std::make_unique<TH1D>("muon_Pt_reconstructible", "muon_Pt_reconstructible", 30, 0., 100000.);
h_not_muon_Pt_reconstructible =
std::make_unique<TH1D>("not_muon_Pt_reconstructible", "not_muon_Pt_reconstructible", 30, 0., 100000.);
h_matched_isMuon_Pt_reconstructed =
std::make_unique<TH1D>("matched_isMuon_Pt_reconstructed", "matched_isMuon_Pt_reconstructed", 30, 0., 100000.);
h_not_matched_isMuon_Pt_reconstructed = std::make_unique<TH1D>(
"not_matched_isMuon_Pt_reconstructed", "not_matched_isMuon_Pt_reconstructed", 30, 0., 100000.);
h_muon_Pt_reconstructible = std::make_unique<TH1D>("muon_Pt_reconstructible", "muon_Pt_reconstructible", 30, 0., 5000.);
h_not_muon_Pt_reconstructible = std::make_unique<TH1D>("not_muon_Pt_reconstructible", "not_muon_Pt_reconstructible", 30, 0., 5000.);
h_matched_isMuon_Pt_reconstructed = std::make_unique<TH1D>("matched_isMuon_Pt_reconstructed", "matched_isMuon_Pt_reconstructed", 30, 0., 5000.);
h_not_matched_isMuon_Pt_reconstructed = std::make_unique<TH1D>("not_matched_isMuon_Pt_reconstructed", "not_matched_isMuon_Pt_reconstructed", 30, 0., 5000.);
h_muon_Phi_reconstructible =
std::make_unique<TH1D>("muon_Phi_reconstructible", "muon_Phi_reconstructible", 15, -3.142, 3.142);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment