12from ROOT 
import TMVA, TFile, TString
 
   13from array 
import array
 
   14from subprocess 
import call
 
   15from os.path 
import isfile
 
   24data = 
TFile.Open(
"http://root.cern.ch/files/tmva_class_example.root", 
"CACHEREAD");
 
   26    raise FileNotFoundError(
"Input file cannot be downloaded - exit")
 
   28signal = data.Get(
'TreeS')
 
   29background = data.Get(
'TreeB')
 
   32for branch 
in signal.GetListOfBranches():
 
   33    branchName = branch.GetName()
 
   34    branches[branchName] = array(
'f', [-999])
 
   35    reader.AddVariable(branchName, branches[branchName])
 
   36    signal.SetBranchAddress(branchName, branches[branchName])
 
   37    background.SetBranchAddress(branchName, branches[branchName])
 
   40reader.BookMVA(
'PyKeras', 
TString(
'dataset/weights/TMVAClassification_PyKeras.weights.xml'))
 
   43print(
'Some signal example classifications:')
 
   46    print(reader.EvaluateMVA(
'PyKeras'))
 
   49print(
'Some background example classifications:')
 
   51    background.GetEntry(i)
 
   52    print(reader.EvaluateMVA(
'PyKeras'))
 
static Bool_t SetCacheFileDir(ROOT::Internal::TStringView cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
 
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.