TMath::Max in RDataframe using pyroot, error: call to 'Max' is ambiguous

Hello,

I am trying to create a series of filter on my RDataframe, I have a filter as a function of a variable dependent on the maximum value of other variable.

#WP definition 2016                                                                                                                                                                                 
        cutlister.define( dft , 'mini' , 'pfRelIso03_all_2' , '(el_neuIso + el_phoIso - (event_rho.rho)*({0}))'.format(Mini_effArea) )
        cutlister.define( dft , 'mini' , 'pfRelIso03_all' , '( el_chIso + TMath::Max( 0.0 , pfRelIso03_all_2 ) )/el_pt' )

the member function define() is defined as:

 def define(self, df , aod , branch , defs):
        df[aod] = df[aod].Define(branch,defs)
    pass

While I execute the python script i have met with error:

[shoh@lxplus7110 xAOD]$ ./cutFlow.sh
 --> mini : /eos/cms/store/group/phys_egamma/soffi/TnP/ntuples_04162018-Legacy2016/Legacy16_V1/data/TnPTree_07Aug17_Run2016BCDEFGH.root
 --> nano : /afs/cern.ch/work/s/shoh/analysis/TnP/NanoTnP/skim/results/latinov7_16/SingleElectron_Run2016.root
 --> process : Data_16

Warning in <TClass::Init>: no dictionary for class pair<edm::Hash<1>,edm::ParameterSetBlob> is available
 - Default --> mini : 32162953.00 ; nano : 23354344.00 ; diff : 27.39%
 - Tag cut pt>32 GeV --> mini : 30640837.00 ; nano : 23354344.00 ; diff : 23.78%
input_line_81:4:21: error: call to 'Max' is ambiguous
return ( el_chIso + TMath::Max( 0.0 , pfRelIso03_all_2 ) )/el_pt
                    ^~~~~~~~~~
/cvmfs/sft.cern.ch/lcg/views/LCG_95apython3/x86_64-centos7-gcc7-opt/include/TMathBase.h:236:23: note: candidate function
inline Float_t TMath::Max(Float_t a, Float_t b)
                      ^
/cvmfs/sft.cern.ch/lcg/views/LCG_95apython3/x86_64-centos7-gcc7-opt/include/TMathBase.h:239:24: note: candidate function
inline Double_t TMath::Max(Double_t a, Double_t b)
                       ^
/cvmfs/sft.cern.ch/lcg/views/LCG_95apython3/x86_64-centos7-gcc7-opt/include/TMathBase.h:212:23: note: candidate function
inline Short_t TMath::Max(Short_t a, Short_t b)
                      ^
/cvmfs/sft.cern.ch/lcg/views/LCG_95apython3/x86_64-centos7-gcc7-opt/include/TMathBase.h:215:24: note: candidate function
inline UShort_t TMath::Max(UShort_t a, UShort_t b)
                       ^
/cvmfs/sft.cern.ch/lcg/views/LCG_95apython3/x86_64-centos7-gcc7-opt/include/TMathBase.h:218:21: note: candidate function
inline Int_t TMath::Max(Int_t a, Int_t b)
                    ^
/cvmfs/sft.cern.ch/lcg/views/LCG_95apython3/x86_64-centos7-gcc7-opt/include/TMathBase.h:221:22: note: candidate function
inline UInt_t TMath::Max(UInt_t a, UInt_t b)
                     ^
/cvmfs/sft.cern.ch/lcg/views/LCG_95apython3/x86_64-centos7-gcc7-opt/include/TMathBase.h:224:22: note: candidate function
inline Long_t TMath::Max(Long_t a, Long_t b)
                     ^
/cvmfs/sft.cern.ch/lcg/views/LCG_95apython3/x86_64-centos7-gcc7-opt/include/TMathBase.h:227:23: note: candidate function
inline ULong_t TMath::Max(ULong_t a, ULong_t b)
                      ^
/cvmfs/sft.cern.ch/lcg/views/LCG_95apython3/x86_64-centos7-gcc7-opt/include/TMathBase.h:230:24: note: candidate function
inline Long64_t TMath::Max(Long64_t a, Long64_t b)
                       ^
/cvmfs/sft.cern.ch/lcg/views/LCG_95apython3/x86_64-centos7-gcc7-opt/include/TMathBase.h:233:25: note: candidate function
inline ULong64_t TMath::Max(ULong64_t a, ULong64_t b)

how do I resolve the ambiguity of calling Max.?

Thanks.
Cheers,
Siewyan

ROOT Version: 6.16/00
Platform: lxplus7110.cern.ch 3.10.0-1127.el7.x86_64 GNU/Linux
Compiler: gcc (GCC) 7.3.0 ; Python 3.6.5


Hi,
does using TMath::Max(0.0, double(pfRelIso03_all_2)) fix it? That should tell the compiler that what you want is the Max(Double_t, Double_t) overload.

Cheers,
Enrico

1 Like

Hi Enrico,

Thanks, its fixed by the suggested solution.

Cheers,
Siewyan

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