19 from b2test_utils
import skip_test
21 variables = [
'p',
'pz',
'daughter(0, p)',
'daughter(0, pz)',
'daughter(1, p)',
'daughter(1, pz)',
22 'chiProb',
'dr',
'dz',
'daughter(0, dr)',
'daughter(1, dr)',
'daughter(0, chiProb)',
'daughter(1, chiProb)',
23 'daughter(0, kaonID)',
'daughter(0, pionID)',
'daughterAngle(0, 1)']
25 if __name__ ==
"__main__":
28 if not (os.path.isfile(
'train.root')
and os.path.isfile(
'test.root')):
29 skip_test(
'Necessary files "train.root" and "test.root" not available.')
31 general_options = basf2_mva.GeneralOptions()
32 general_options.m_datafiles = basf2_mva.vector(
"train.root")
33 general_options.m_treename =
"tree"
34 general_options.m_variables = basf2_mva.vector(*variables)
35 general_options.m_target_variable =
"isSignal"
38 (
'Trivial.xml', basf2_mva.TrivialOptions()),
39 (
'Python.xml', basf2_mva.PythonOptions()),
40 (
'FastBDT.xml', basf2_mva.FastBDTOptions()),
41 (
'TMVAClassification.xml', basf2_mva.TMVAOptionsClassification()),
42 (
'FANN.xml', basf2_mva.FANNOptions()),
46 with tempfile.TemporaryDirectory()
as tempdir:
47 os.symlink(os.path.abspath(
'train.root'), tempdir +
'/' + os.path.basename(
'train.root'))
48 os.symlink(os.path.abspath(
'test.root'), tempdir +
'/' + os.path.basename(
'test.root'))
51 for identifier, specific_options
in methods:
52 general_options.m_identifier = identifier
53 basf2_mva.teacher(general_options, specific_options)
55 basf2_mva.expert(basf2_mva.vector(*[i
for i, _
in methods]),
56 basf2_mva.vector(
'train.root'),
'tree',
'expert.root')
58 subprocess.call(
'basf2_mva_evaluate.py -c -o latex.pdf -train train.root -data test.root -i ' +
59 ' '.join([i
for i, _
in methods]), shell=
True)
62 shutil.copyfile(tempdir +
'/latex.pdf',
'latex.pdf')