16 from ROOT
import Belle2
20 from b2test_utils
import clean_working_directory, safe_process, skip_test_if_light
24 basf2.conditions.disable_globaltag_replay()
25 basf2.set_random_seed(
"something important")
27 basf2.logging.enable_summary(
False)
28 for level
in basf2.LogLevel.values.values():
29 basf2.logging.set_info(level, basf2.LogInfo.LEVEL | basf2.LogInfo.MESSAGE)
34 """Test to read relations in the input files."""
37 """reimplementation of Module::event().
39 prints PXD true and simhit indices, using relations
43 for truehit
in truehits:
44 relations = truehit.getRelationsTo(
"PXDSimHits")
45 print(
"truehit %d => hits " % truehit.getArrayIndex(), end=
"")
47 print(hit.getArrayIndex(), end=
", ")
54 filename = basf2.find_file(
'framework/tests/seqroot_input.sroot')
57 seqinput = main.add_module(
"SeqRootInput", logLevel=basf2.LogLevel.WARNING)
58 main.add_module(
"EventInfoPrinter")
59 main.add_module(
"PrintCollections", printForEvent=0)
62 with clean_working_directory():
63 content = open(filename,
"rb").read()
64 first_record = struct.unpack(
"@i", content[:4])[0]
65 second_record = struct.unpack(
"@i", content[first_record:first_record + 4])[0] + first_record
68 open(
"01-ok.sroot",
"wb").write(content)
69 open(
"01-ok.sroot-1",
"wb").write(content[first_record:])
72 open(
"02-1+1b.sroot",
"wb").write(content[:first_record + 1])
75 open(
"03-1+5b.sroot",
"wb").write(content[:first_record + 5])
78 open(
"04-2+1b.sroot",
"wb").write(content[:second_record + 1])
81 open(
"05-2+5b.sroot",
"wb").write(content[:second_record + 5])
82 gzip.open(
"05-ok.sroot.gz",
"wb").write(content)
83 gcontent = open(
"05-ok.sroot.gz",
"rb").read()
84 gzip.open(
"05-ok.sroot-1.gz",
"wb").write(content[first_record:])
85 gzip.open(
"06-1+1b.sroot.gz",
"wb").write(content[:first_record + 1])
86 gzip.open(
"07-1+5b.sroot.gz",
"wb").write(content[:first_record + 5])
89 open(
"08-nogz.sroot.gz",
"wb").write(content)
91 open(
"09-cut.sroot.gz",
"wb").write(gcontent[:len(gcontent) // 2])
93 open(
"10-max.sroot",
"wb").write(struct.pack(
"@i", 0x7fffffff))
100 files = sorted(glob.glob(
"*.sroot") + glob.glob(
"*.sroot.gz")) + \
101 [
"nosuchfile.sroot",
"/nosuchdir/file.sroot"]
103 for filename
in files:
104 print(
"Trying", filename,
"...")
105 seqinput.param(
"inputFileName", filename)
A (simplified) python wrapper for StoreArray.