RDataFrame Used in Python: can not resolve method template call for 'Define'

Hello experts,

I am newbie for RDataFrame.
When I used RDataFrame under ATLAS environment: asteup AnalysisBase,21.2.165,here, there is always an error showing

  ...__rdf_arg_HGamEventInfoAuxDyn_weightFJvt*36207.66/109.175384521
......
TypeError: can not resolve method template call for 'Define'

But I checked the MxAOD root file, and it exists, So I can’t understand this.
How could I fix the problem? I really appreciate any help you can provide.

Best regards
Qiuping


_ROOT Version: _ 6.20/06
Platform: Built for linuxx8664gcc on Jun 10 2020, 06:10:57
Compiler: From tags/v6-20-06@v6-20-06


Welcome to the ROOT Forum! I think there is some information missing here. But maybe @eguiraud can already give some hints?

Hello @Qiuping ,

sorry for the trouble! It’s hard to say what the problem is without knowing the schema of the input TTree and without seeing the source code that corresponds to the error :smiley:

It would be great if you could try to reduce this to just the lines of code that cause the issue and then shared that minimal reproducer together with the output of tree->Print() for the problematic TTree.

Also note that v6.20.06 is a fairly old ROOT version RDataFrame-wise, many improvements have been added since.

Cheers,
Enrico

Hello Enrico,

Here is my output:

xAOD::Init                INFO    Environment initialised for data access
input_line_197:4:141: error: **use of undeclared identifier '__rdf_arg_HGamEventInfoAuxDyn_weightFJvt'**
  ...__rdf_arg_HGamEventInfoAuxDyn_weightFJvt*36207.66/109.175384521
     ^
Traceback (most recent call last):
  File "tutorial/cutflow_rdataframe.py", line 85, in <module>
    result_list = [readMxAOD(filedict=val, cutflow=CutFlow) for val in list_files]
  File "tutorial/cutflow_rdataframe.py", line 66, in readMxAOD
    dataframe_new = dataframe_ori.Filter(select).Define('eventweight', temp_var)
TypeError: can not resolve method template call for 'Define'

It looks like RDataFrame cannot explain the variable. I will try the new version ROOT.

Thanks a lot,
Qiuping

Given the error message, I guess just this code would reproduce the problem:

ROOT.RDataFrame(tree_name, input_file).Define('x', temp_var)

where temp_var should be a string containing something like "HGamEventInfoAuxDyn_weightFJvt*36207.66/109.175384521". Can you confirm this is the case?

If it is, can you please share the input file, even just privately with me, together with the contents of temp_var? That should help us figure out what’s going wrong.

Cheers,
Enrico

I did the following tries as your suggestions:

>>> df1 = ROOT.RDataFrame('CollectionTree', '../../example.root').Define('x','crossSectionBRfilterEff*weight*weightFJvt')
input_line_210:4:141: error: use of undeclared identifier '__rdf_arg_HGamEventInfoAuxDyn_weightFJvt'
return __rdf_arg_HGamEventInfoAuxDyn_crossSectionBRfilterEff*__rdf_arg_HGamEventInfoAuxDyn_weight*__rdf_arg_HGamEventInfoAuxDyn_pro_weight*__rdf_arg_...
                                                                                                                                            ^
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can not resolve method template call for 'Define'
>>> df1 = ROOT.RDataFrame('CollectionTree', '../../example.root').Define('x','weightFJvt')
>>> df1 = ROOT.RDataFrame('CollectionTree', '../../example.root').Define('x','crossSectionBRfilterEff*weightFJvt')
>>> df2 = ROOT.RDataFrame('CollectionTree', '../../example.root').Define('x', 'weight')
  1. Only weightFJvt it works well
  2. If removed weight, it also works well
  3. Only weight, it works well

So it seems that there is a problem with the weight variable, I checked its type: float.
It looks normal, so I’m wondering where the problem is.

Cheers,
Enrico

Hello Enrico,

Thanks for your hints, and I tried the latest version of root which works very well.

Cheers,
Qiuping