4 from basf2
import create_path, LogLevel, LogInfo, logging, set_random_seed, B2INFO, Module
6 from ROOT
import Belle2, gRandom
10 """Small test module to print something in Path.doWhile"""
13 """Remember how many iterations we want"""
19 """Print the current iteration for this event as well as the first five random numbers"""
20 weight = self.
eventInfo.getGeneratedWeight()
21 B2INFO(f
"Current Iteration: {weight}")
22 rndm = [
"%.4f" % gRandom.Rndm()
for i
in range(5)]
23 B2INFO(f
"First 5 random numbers: {rndm}")
31 set_random_seed(
"something important")
33 for level
in LogLevel.values.values():
34 logging.set_info(level, LogInfo.LEVEL | LogInfo.MESSAGE)
37 logging.enable_summary(
False)
40 path.add_module(
'EventInfoSetter', evtNumList=[2, 2, 1], runList=[0, 3, 5], expList=[0, 1, 3])
41 path.add_module(
'EventInfoPrinter')
42 subpath = create_path()
44 path.do_while(subpath, max_iterations=3)
48 test_module.if_true(create_path())
55 path.add_module(
'EventInfoSetter')
56 subpath = create_path()
57 subpath.add_module(
"EventInfoPrinter")
58 path.do_while(subpath)
64 path.add_module(
"EventInfoSetter", evtNumList=5)
65 subpath = create_path()
66 subpath.add_module(
"EventInfoPrinter")
67 p1 = subpath.add_module(
"Prescale", prescale=0.9)
68 p1.if_true(create_path())
69 subpath.add_module(
"Prescale", prescale=0.2)
74 path.add_module(
'EventInfoSetter', evtNumList=5)
75 subpath = create_path()
76 subpath.add_module(
"EventInfoPrinter")
77 subpath.add_module(
"Prescale", prescale=0.2)
78 path.do_while(subpath)
86 env.setPicklePath(
"testpath.pkl")
90 path.add_module(
"EventInfoPrinter")