So basically what I want to do is load a TTree into a RooDataSet with weighed events,
produce a 2d histogram using the createHistogram function and create a RooNDKeysPdf which
I can then compare to the histogram:
The code looks like this (using PyROOT):
#Create a RooDataSet from tree where 'requirement' has been applied x_var = ROOT.RooRealVar( invar_x, invar_x, minrange, maxrange ) y_var = ROOT.RooRealVar( invar_y, invar_y, minrange, maxrange ) weight = ROOT.RooRealVar( "weight", "weight", 0.0, 1.0 ) ds = ROOT.RooDataSet("dataset", "dataset", intree, ROOT.RooArgSet( x_var, y_var, weight ), "", "weight" ) #Using the Print() function for RooDataSet indicates that the events are weighed correct #Create 2d histogram from parameters hist = ds.createHistogram( x_var, y_var, nbins, nbins ) hist.Sumw2() hist.Scale(1.0/hist.Integral()) mvakde = ROOT.RooNDKeysPdf( "mvakde", "mvakde", ROOT.RooArgList( x_var, y_var ), ds, "a", 1.0 ) kdehist = mvakde.createHistogram( "%s,%s"%( invar_x, invar_y), nbins, nbins )
My questions are:
When I produce the histogram using the createHistogram function, the resulting bin errors are extremely large. If I look in the source code, it seems like Sumw2() is not called for the histogram that is returned, is this correct? Or are there any way I can change that?
The “kdehist” that I create does not in any way resemble the histogram I have produced. How does RooNDKeysPdf handle event weights?
If I change the code to ignore the event weights, i.e change:
ds = ROOT.RooDataSet("dataset", "dataset", intree, ROOT.RooArgSet( x_var, y_var, weight ), "", "weight" )
ds = ROOT.RooDataSet("dataset", "dataset", intree, ROOT.RooArgSet( x_var, y_var ) )
Everything works as it should.
Any comment would be highly appreciated.
Thanks a lot, cheers, Lars