PyROOT6.16 & RDataFrame: Filter-function does not return bool


ROOT Version: tags/v6-16-00@v6-16-00
Platform: macosx64
Compiler: gcc 4.2.1


Dear experts,

I meat similar issue as it was described here. It was mentioned that starting from ROOT 6.16 it will be able to handle collections as RVec automagically. In my case for some reason, it doesn’t work.

Input file: CERNBOX

A simple code to reproduce the problem:

	ROOT.ROOT.EnableImplicitMT()

	RDF = ROOT.ROOT.RDataFrame

	df = RDF('treeAnaWZ','data17_13TeV.00341294_el.root')
	filterCut = df.Filter('el_pt>0')
	model = ROOT.RDF.TH1DModel("el_pt", ";p_{T} (el_{0}) MeV;", 100, 0., 100000.)
	myHisto = filterCut.Define("myP4", "el_pt").Histo1D(model, "myP4")

	myHisto = myHisto.Clone("unicName")
	myHisto.SetDirectory(0)
	myHisto.Draw("")

	ROOT.ROOT.DisableImplicitMT()

Log files: failed.txt (63.5 KB)

Hi Daniil,
Filter must decide whether to keep processing a given event or not, and to take that decision it requires the filtering expression to return a single boolean.
However, if el_pt is an array, the expression el_pt>0 is an array of values (result of the inequality for each of the members of the array).

Maybe what you want is something like

df.Define("myP4", "el_pt[el_pt>0]").Histo1D("myP4");

?

That fills an histogram with the pt of electrons that have pt > 0.

Cheers,
Enrico

Hi @eguiraud,

Thanks! But for some reason it is also crashes with the same error

       ROOT.ROOT.EnableImplicitMT()
	RDF = ROOT.ROOT.RDataFrame
	df = RDF(treeName, file)
	filterCut = df.Filter("el_pt[el_pt>0]")
	model = ROOT.RDF.TH1DModel("myP4", ";p_{T} (el_{0}) MeV;", 100, 0., 100000.)
	myHisto = filterCut.Define("myP4", "el_pt[el_pt>0]").Histo1D(model, "myP4")

	myHisto.SetDirectory(0)
	myHisto.Draw("")

	ROOT.ROOT.DisableImplicitMT()

Yes, because you still have a Filter that returns an array :smile: I’m using Define in my example above.

Right :grin:. Thanks! Now it works.

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