5 Check that random numbers don't change and are consistent.
7 This steering file runs through a set of exp/run combinations and prints
8 the first few random numbers in initialize(), beginRun(), event() and endRun().
10 It also sets the framework to debugging output and shows the information used
11 to calculate the random generator state.
16 from ROOT
import gRandom
19 def double_to_hex(double):
20 """Convert a double to a hex string representation"""
23 return "%016X" % struct.unpack(
"<Q", struct.pack(
"<d", double))[0]
27 """Print some random numbers to check reproducibility"""
30 """Make sure we can run in multiple processes"""
31 super(RandomTestModule, self).
__init__()
32 self.set_property_flags(basf2.ModulePropFlags.PARALLELPROCESSINGCERTIFIED)
37 """Print the first 20 random numbers"""
38 numbers = [
"First 20 random values in %s::%s()" % (self.
name, name)]
40 numbers.append(
", ".join(double_to_hex(gRandom.Rndm())
for i
in range(4)))
41 basf2.B2INFO(
"\n ".join(numbers))
44 """Show random numbers in initialize"""
48 """Show random numbers in beginRun"""
52 """Show random numbers in event"""
56 """Show random numbers in endRun"""
63 main.add_module(
"EventInfoSetter", evtNumList=[3, 4, 5],
64 runList=[0x11121314, 0x21222324, 0x31323334],
65 expList=[0x123, 0x234, 0x345])
70 main.add_module(
"EventInfoPrinter")
72 main.add_module(
"RandomBarrier")
77 logging_framework = basf2.logging.package(
"framework")
78 logging_framework.set_log_level(basf2.LogLevel.DEBUG)
79 logging_framework.set_debug_level(200)
80 logging_framework.set_info(basf2.LogLevel.DEBUG, basf2.LogInfo.LEVEL | basf2.LogInfo.MESSAGE)
81 basf2.set_random_seed(
"this is the seed")