12from ROOT
import TMVA, TFile, TString, gROOT
13from array
import array
14from subprocess
import call
15from os.path
import isfile
23data =
TFile.Open(str(gROOT.GetTutorialDir()) +
"/tmva/data/tmva_class_example.root")
24signal = data.Get(
'TreeS')
25background = data.Get(
'TreeB')
28for branch
in signal.GetListOfBranches():
29 branchName = branch.GetName()
30 branches[branchName] = array(
'f', [-999])
31 reader.AddVariable(branchName, branches[branchName])
32 signal.SetBranchAddress(branchName, branches[branchName])
33 background.SetBranchAddress(branchName, branches[branchName])
36reader.BookMVA(
'PyKeras',
TString(
'dataset/weights/TMVAClassification_PyKeras.weights.xml'))
39print(
'Some signal example classifications:')
42 print(reader.EvaluateMVA(
'PyKeras'))
45print(
'Some background example classifications:')
47 background.GetEntry(i)
48 print(reader.EvaluateMVA(
'PyKeras'))
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
static void PyInitialize()
Initialize Python interpreter.
The Reader class serves to use the MVAs in a specific analysis context.