Convert XGBoost BDT regression model to TMVA

yeah, 500 lines of barely understandable segmentation fault for not converting a double to float, if that can be improved would be great!
I could open an issue when I have some time to make a reproducer.
But now that we talk, for me to understand, this is the variable below that causes the issue:
.Define("EVT_Nominal_B_E", "float(91.1876 - EVT_ThrustEmin_E - EVT_ThrustEmax_E + sqrt(EVT_CandP*EVT_CandP + EVT_CandMass*EVT_CandMass))")

all variables EVT_* in the calculation are floats, so I assumed (wrongly) that putting the Z mass like it is, would also result in a float, but looks it converted it to a double.

Totally! RDF typically checks for type mismatches, so a reproducer for this particular case would be great.

C++ shenanigans: 91.1876 is of type double. 91.1876f is the corresponding float literal and should turn the full expression into a float (unless sqrt also does a conversion, but it really shouldn’t).

Cheers,
Enrico

Here is a reproducer

import ROOT
from array import array


ROOT.gInterpreter.ProcessLine('''
TMVA::Experimental::RBDT<> bdt("Bc2TauNu_BDT", "/afs/cern.ch/user/h/helsens/public/4ROOT/xgb_bdt_vtx.root");
computeModel = TMVA::Experimental::Compute<18, float>(bdt);
''')

df = ROOT.RDataFrame(10)
df2=df.Define("EVT_Float","1.f")\
      .Define("EVT_Double","1.")\
      .Define("MVAVec", ROOT.computeModel, ("EVT_Float", "EVT_Float", "EVT_Float", "EVT_Float", "EVT_Float", "EVT_Float","EVT_Float", "EVT_Float", "EVT_Float", "EVT_Float", "EVT_Float", "EVT_Float","EVT_Float", "EVT_Float", "EVT_Float", "EVT_Float", "EVT_Float", "EVT_Double"))\
      .Define("EVT_MVA1", "MVAVec.at(0)")

branchList = ROOT.vector('string')()
branchList.push_back("EVT_MVA1")
df2.Snapshot("events", "test.root", branchList)

but seems there is already a catch for such thing

    runtime_error: RDefineReader: column "EVT_Double" is being used as float but defined column has type double

in my setup it was even more convoluted given the number of threads and other stuff so I did not saw it.

so I guess no need to open an issue?
Clement

1 Like