22void CompileModelForRDF(
const std::string & headerModelFile,
unsigned int ninputs,
unsigned int nslots=0) {
24 std::string modelName = headerModelFile.substr(0,headerModelFile.find(
".hxx"));
25 std::string cmd = std::string(
"#include \"") + headerModelFile + std::string(
"\"");
28 throw std::runtime_error(
"Error compiling : " + cmd);
29 std::cout <<
"compiled : " << cmd << std::endl;
31 cmd =
"auto sofie_functor = TMVA::Experimental::SofieFunctor<" + std::to_string(ninputs) +
",TMVA_SOFIE_" +
32 modelName +
"::Session>(" + std::to_string(nslots) +
");";
35 throw std::runtime_error(
"Error compiling : " + cmd);
36 std::cout <<
"compiled : " << cmd << std::endl;
37 std::cout <<
"Model is ready to be evaluated" << std::endl;
41void TMVA_SOFIE_RDataFrame_JIT(std::string modelFile =
"Higgs_trained_model.h5"){
47 Info(
"TMVA_SOFIE_RDataFrame",
"You need to run TMVA_Higgs_Classification.C to generate the Keras trained model");
54 std::string modelName = modelFile.substr(0,modelFile.find(
".h5"));
55 std::string modelHeaderFile = modelName + std::string(
".hxx");
61 std::string modelWeightFile = modelName + std::string(
".dat");
63 Error(
"TMVA_SOFIE_RDataFrame",
"Generated weight file is missing");
68 CompileModelForRDF(modelHeaderFile,7);
70 std::string inputFileName =
"Higgs_data.root";
71 std::string inputFile =
"http://root.cern.ch/files/" + inputFileName;
74 auto h1 = df1.Define(
"DNN_Value",
"sofie_functor(rdfslot_,m_jj, m_jjj, m_lv, m_jlv, m_bb, m_wbb, m_wwbb)")
75 .Histo1D({
"h_sig",
"", 100, 0, 1},
"DNN_Value");
78 auto h2 = df2.Define(
"DNN_Value",
"sofie_functor(rdfslot_,m_jj, m_jjj, m_lv, m_jlv, m_bb, m_wbb, m_wwbb)")
79 .Histo1D({
"h_bkg",
"", 100, 0, 1},
"DNN_Value");
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
virtual void SetLineColor(Color_t lcolor)
Set the line color.
void OutputGenerated(std::string filename="", bool append=false)
void Generate(std::underlying_type_t< Options > options, int batchSize=-1, long pos=0, bool verbose=false)
static void PyInitialize()
Initialize Python interpreter.
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.