RDataFrame Histo1D crashes when weights are added

Dear experts,

I get this error when I try adding weights to Histo1D:

TypeError: takes at most 2 arguments (3 given)
Failed to instantiate “Histo1D(ROOT::RDF::TH1DModel*,std::string,std::string)”

my script is very simple similar to what I posted bellow

import ROOT
ch=ROOT.TChain("ch","ch")
ch->Add(path+"DecayTree") 
dtf=RDataFrame(ch)
h= dtf.Filter(cuts).Histo1D(ROOT.RDF.TH1DModel("h","",100,200,8000),"ple_PT","w")

The script works perfectly when I remove the weights.

please do u have any idea what I should do in this case?

Thanks in Advance

Sara

Hi @sara_sellam ,
that’s unexpected, but on the other hand the code you posted is not valid Python so I can’t really verify what is going wrong. Please share a reproducer for your actual error, I will take a look as soon as possible.

Cheers,
Enrico

P.S.
what is your ROOT version? see the Histo1D calls here, they use weights: ROOT: tutorials/dataframe/df103_NanoAODHiggsAnalysis.py File Reference

Thanks for your reply

my code Is working know I edited it as you suggested:

import ROOT
ch=ROOT.TChain("ch","ch")
ch->Add(path+"DecayTree") 
dtf=RDataFrame(ch)
h= dtf.Filter(cuts).Define("weights","w").Histo1D(ROOT.RDF.TH1DModel("h","",100,200,8000),"ple_PT","weights")

Thanks

Sara

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.