Skip to content

Commit ca5199c

Browse files
committed
[RF] Avoid error in getVal() in RooFit Python tutorials
In some tutorials, `getVal()` is not called with a not explicitly created RooArgSet, which can result in the following error: ```txt [#0] FATAL:Eval -- calling RooAbsReal::getVal() with r-value references to the normalization set is not allowed, because it breaks RooFits caching logic and potentially introduces significant overhead. Please explicitly create the RooArgSet outside the call to getVal(). ``
1 parent 5793d0f commit ca5199c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tutorials/roofit/roofit/rf110_normintegration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
print("gx = ", gx.getVal())
3030

3131
# Return value of gx normalized over x in range [-10,10]
32-
nset = {x}
32+
nset = ROOT.RooArgSet(x)
3333
print("gx_Norm[x] = ", gx.getVal(nset))
3434

3535
# Create object representing integral over gx

tutorials/roofit/roofit/rf308_normintegration2d.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
print("gxy = ", gxy.getVal())
3535

3636
# Return value of gxy normalized over x _and_ y in range [-10,10]
37-
nset_xy = {x, y}
37+
nset_xy = ROOT.RooArgSet(x, y)
3838
print("gx_Norm[x,y] = ", gxy.getVal(nset_xy))
3939

4040
# Create object representing integral over gx
@@ -47,12 +47,12 @@
4747

4848
# Return value of gxy normalized over x in range [-10,10] (i.e. treating y
4949
# as parameter)
50-
nset_x = {x}
50+
nset_x = ROOT.RooArgSet(x)
5151
print("gx_Norm[x] = ", gxy.getVal(nset_x))
5252

5353
# Return value of gxy normalized over y in range [-10,10] (i.e. treating x
5454
# as parameter)
55-
nset_y = {y}
55+
nset_y = ROOT.RooArgSet(y)
5656
print("gx_Norm[y] = ", gxy.getVal(nset_y))
5757

5858
# Integrate normalized pdf over subrange

0 commit comments

Comments
 (0)