15from ROOT
import Belle2
19from b2test_utils
import clean_working_directory, safe_process, skip_test_if_light
23basf2.conditions.disable_globaltag_replay()
24basf2.set_random_seed(
"something important")
26basf2.logging.enable_summary(
False)
27for level
in basf2.LogLevel.values.values():
28 basf2.logging.set_info(level, basf2.LogInfo.LEVEL | basf2.LogInfo.MESSAGE)
33 """Test to read relations in the input files."""
36 """reimplementation of Module::event().
38 prints PXD true and simhit indices, using relations
42 for truehit
in truehits:
43 relations = truehit.getRelationsTo(
"PXDSimHits")
44 print(f
"truehit {truehit.getArrayIndex()} => hits ", end=
"")
46 print(hit.getArrayIndex(), end=
", ")
53filename = basf2.find_file(
'framework/tests/seqroot_input.sroot')
56seqinput = main.add_module(
"SeqRootInput", logLevel=basf2.LogLevel.WARNING)
57main.add_module(
"EventInfoPrinter")
58main.add_module(
"PrintCollections", printForEvent=0)
61with clean_working_directory():
62 content = open(filename,
"rb").read()
63 first_record = struct.unpack(
"@i", content[:4])[0]
64 second_record = struct.unpack(
"@i", content[first_record:first_record + 4])[0] + first_record
67 open(
"01-ok.sroot",
"wb").write(content)
68 open(
"01-ok.sroot-1",
"wb").write(content[first_record:])
71 open(
"02-1+1b.sroot",
"wb").write(content[:first_record + 1])
74 open(
"03-1+5b.sroot",
"wb").write(content[:first_record + 5])
77 open(
"04-2+1b.sroot",
"wb").write(content[:second_record + 1])
80 open(
"05-2+5b.sroot",
"wb").write(content[:second_record + 5])
81 gzip.open(
"05-ok.sroot.gz",
"wb").write(content)
82 gcontent = open(
"05-ok.sroot.gz",
"rb").read()
83 gzip.open(
"05-ok.sroot-1.gz",
"wb").write(content[first_record:])
84 gzip.open(
"06-1+1b.sroot.gz",
"wb").write(content[:first_record + 1])
85 gzip.open(
"07-1+5b.sroot.gz",
"wb").write(content[:first_record + 5])
88 open(
"08-nogz.sroot.gz",
"wb").write(content)
90 open(
"09-cut.sroot.gz",
"wb").write(gcontent[:len(gcontent) // 2])
92 open(
"10-max.sroot",
"wb").write(struct.pack(
"@i", 0x7fffffff))
99 files = sorted(glob.glob(
"*.sroot") + glob.glob(
"*.sroot.gz")) + \
100 [
"nosuchfile.sroot",
"/nosuchdir/file.sroot"]
102 for filename
in files:
103 print(
"Trying", filename,
"...")
104 seqinput.param(
"inputFileName", filename)
A (simplified) python wrapper for StoreArray.