Belle II Software  release-05-02-19
test_prototype_module.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 # Thomas Keck 2016
4 
5 from b2test_utils import skip_test_if_light
6 skip_test_if_light() # light builds don't contain generators; skip before trying to import
7 
8 from basf2 import *
9 
10 from modularAnalysis import *
11 from generators import add_evtgen_generator
12 
13 import tempfile
14 import os
15 
16 from ROOT import Belle2
17 
18 if __name__ == "__main__":
19 
20  path = create_path()
21  setupEventInfo(100, path)
22  add_evtgen_generator(path, 'signal', Belle2.FileSystem.findFile('analysis/examples/simulations/B2A101-Y4SEventGeneration.dec'))
23  path.add_module('MVAPrototype', identifier='fake.xml')
24 
25  with tempfile.TemporaryDirectory() as tempdir:
26  os.chdir(tempdir)
27 
28  # Create a fake weightfile
29  content = """
30  <?xml version="1.0" encoding="utf-8"?>
31  <method>Trivial</method>
32  <weightfile>fake.xml</weightfile>
33  <treename>tree</treename>
34  <target_variable>isSignal</target_variable>
35  <weight_variable>__weight__</weight_variable>
36  <signal_class>1</signal_class>
37  <max_events>0</max_events>
38  <number_feature_variables>1</number_feature_variables>
39  <variable0>M</variable0>
40  <number_spectator_variables>0</number_spectator_variables>
41  <number_data_files>1</number_data_files>
42  <datafile0>train.root</datafile0>
43  <Trivial_version>1</Trivial_version>
44  <Trivial_output>0</Trivial_output>
45  <signal_fraction>0.066082567</signal_fraction>
46  """
47  with open("fake.xml", "w") as f:
48  f.write(content)
49 
50  process(path)
Belle2::FileSystem::findFile
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...
Definition: FileSystem.cc:147