Assigning per-entry weight errors to a RooDataSet only works if it was constructed using RooFit::StoreError. If it was not constructed this way, the last wgtError argument passed is assigned as the weight error for the entire dataset. Demonstration below.

This is potentially confusing as there is no documentation explaining this in the RooDataSet class reference. I have created a pull request adding documentation, but I think a better solution would be either to enable storage of such errors by default or to raise an exception if the user attempts to set a variable error that cannot be stored.

input:

import ROOT
def FillData():
for i in xrange(100):
x.setVal(i)
w.setVal(float(i) / 100)
data.add(obs, w.getVal(), float(i) / 1000)
def CheckSame():
allsame = True
for i in xrange(100):
data.get(i)
if i == 0:
ref = data.weightError()
elif data.weightError() != ref:
allsame = False
if i == 1 or i == 90:
print 'Weight and error at entry {}:'.format(i), data.weight(), data.weightError()
print 'All entries have the same error?', allsame
x = ROOT.RooRealVar('x', 'x', 0, 100)
w = ROOT.RooRealVar('w', 'w', 0, 1)
obs = ROOT.RooArgSet(x, w)
data = ROOT.RooDataSet('data', 'data', obs, w.GetName())
print 'in-line constructor:'
FillData()
CheckSame()
erset = ROOT.RooArgSet(w)
data = ROOT.RooDataSet('data', 'data', obs, ROOT.RooFit.WeightVar(w), ROOT.RooFit.StoreError(erset))
print 'StoreError constructor:'
FillData()
CheckSame()

output:

in-line constructor:
Weight and error at entry 1: 0.01 0.099
Weight and error at entry 90: 0.9 0.099
All entries have the same error? True
StoreError constructor:
Weight and error at entry 1: 0.01 0.001
Weight and error at entry 90: 0.9 0.09
All entries have the same error? False

thanks for pointing this out. I agree this needs to be fixed.

Since not many people read documentation, I will fix this with run time checks. The current output of your reproducer is:

in-line constructor:
[#0] ERROR:DataHandling -- An event weight error was given, but the weight variable 'w' is not in the set of variables with `StoreError`. Check the RooDataSet constructor.
[#0] ERROR:DataHandling -- An event weight error was given, but the weight variable 'w' is not in the set of variables with `StoreError`. Check the RooDataSet constructor.
[#0] ERROR:DataHandling -- An event weight error was given, but the weight variable 'w' is not in the set of variables with `StoreError`. Check the RooDataSet constructor.
[#0] ERROR:DataHandling -- An event weight error was given, but the weight variable 'w' is not in the set of variables with `StoreError`. Check the RooDataSet constructor.
[#0] ERROR:DataHandling -- An event weight error was given, but the weight variable 'w' is not in the set of variables with `StoreError`. Check the RooDataSet constructor.
[#0] ERROR:DataHandling -- An event weight error was given, but the weight variable 'w' is not in the set of variables with `StoreError`. Check the RooDataSet constructor.
[#0] ERROR:DataHandling -- An event weight error was given, but the weight variable 'w' is not in the set of variables with `StoreError`. Check the RooDataSet constructor.
[#0] ERROR:DataHandling -- An event weight error was given, but the weight variable 'w' is not in the set of variables with `StoreError`. Check the RooDataSet constructor.
[#0] ERROR:DataHandling -- An event weight error was given, but the weight variable 'w' is not in the set of variables with `StoreError`. Check the RooDataSet constructor.
[#0] ERROR:DataHandling -- An event weight error was given, but the weight variable 'w' is not in the set of variables with `StoreError`. Check the RooDataSet constructor.
Weight and error at entry 1: 0.01 0.0
Weight and error at entry 90: 0.9 0.0
All entries have the same error? True
StoreError constructor:
Weight and error at entry 1: 0.01 0.001
Weight and error at entry 90: 0.9 0.09
All entries have the same error? False