Skip to content

Commit 81f11e1

Browse files
committed
[skip-ci][tutorials] fix legend style in roofit tutorial
1 parent 9c3ebcc commit 81f11e1

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

tutorials/roofit/roofit/rf615_simulation_based_inference.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
## \date July 2024
3434
## \author Robin Syring
3535

36-
import ROOT
3736
import numpy as np
37+
import ROOT
3838
from sklearn.neural_network import MLPClassifier
3939

4040
# The samples used for training the classifier in this tutorial / rescale for more accuracy
@@ -45,8 +45,7 @@
4545

4646

4747
# Morphing as a baseline
48-
def morphing(setting):
49-
48+
def morphing(setting, workspace):
5049
# Define binning for morphing
5150
grid = ROOT.RooMomentMorphFuncND.Grid(ROOT.RooBinning(4, 0.0, 4.0))
5251
x_var.setBins(50)
@@ -199,7 +198,7 @@ def learned_likelihood_ratio(x, mu):
199198
ROOT.SetOwnership(nllr_learned, True)
200199

201200
# Compute the morphed nll
202-
morphing(ROOT.RooMomentMorphFuncND.Linear)
201+
morphing(ROOT.RooMomentMorphFuncND.Linear, workspace)
203202
nll_morph = workspace["morph"].createNLL(obs_data)
204203
ROOT.SetOwnership(nll_morph, True)
205204

@@ -228,8 +227,8 @@ def learned_likelihood_ratio(x, mu):
228227
frame1.Draw()
229228

230229
legend1 = ROOT.TLegend(0.43, 0.63, 0.8, 0.87)
231-
legend1.SetFillColor("kWhite")
232-
legend1.SetLineColor("kWhite")
230+
legend1.SetFillColor(ROOT.kWhite)
231+
legend1.SetLineColor(ROOT.kWhite)
233232
legend1.SetTextSize(0.04)
234233
legend1.AddEntry("learned", "learned (SBI)", "L")
235234
legend1.AddEntry("gauss", "true NLL", "L")
@@ -247,8 +246,8 @@ def learned_likelihood_ratio(x, mu):
247246
frame2.Draw()
248247

249248
legend2 = ROOT.TLegend(0.53, 0.73, 0.87, 0.87)
250-
legend2.SetFillColor("kWhite")
251-
legend2.SetLineColor("kWhite")
249+
legend2.SetFillColor(ROOT.kWhite)
250+
legend2.SetLineColor(ROOT.kWhite)
252251
legend2.SetTextSize(0.04)
253252
legend2.AddEntry("learned_ratio", "learned (SBI)", "L")
254253
legend2.AddEntry("exact", "true ratio", "L")

0 commit comments

Comments
 (0)