Belle II Software light-2406-ragdoll
test_prototype_module.py
1#!/usr/bin/env python3
2
3
10
11from b2test_utils import skip_test_if_light
12skip_test_if_light() # light builds don't contain generators; skip before trying to import # noqa
13
14import basf2 as b2
15
16import modularAnalysis as ma
17from generators import add_evtgen_generator
18
19import tempfile
20import os
21
22from ROOT import Belle2
23
24if __name__ == "__main__":
25
26 path = b2.create_path()
27 ma.setupEventInfo(100, path)
28 add_evtgen_generator(path, 'signal', Belle2.FileSystem.findFile('analysis/examples/simulations/B2A101-Y4SEventGeneration.dec'))
29 path.add_module('MVAPrototype', identifier='fake.xml')
30
31 with tempfile.TemporaryDirectory() as tempdir:
32 os.chdir(tempdir)
33
34 # Create a fake weightfile
35 content = """
36 <?xml version="1.0" encoding="utf-8"?>
37 <method>Trivial</method>
38 <weightfile>fake.xml</weightfile>
39 <treename>tree</treename>
40 <target_variable>isSignal</target_variable>
41 <weight_variable>__weight__</weight_variable>
42 <signal_class>1</signal_class>
43 <max_events>0</max_events>
44 <number_feature_variables>1</number_feature_variables>
45 <variable0>M</variable0>
46 <number_spectator_variables>0</number_spectator_variables>
47 <number_data_files>1</number_data_files>
48 <datafile0>train.root</datafile0>
49 <Trivial_version>1</Trivial_version>
50 <Trivial_output>0</Trivial_output>
51 <signal_fraction>0.066082567</signal_fraction>
52 """
53 with open("fake.xml", "w") as f:
54 f.write(content)
55
56 b2.process(path)
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:151