Belle II Software light-2406-ragdoll
chain_input.py
1#!/usr/bin/env python3
2
3
10
11import basf2
12from b2test_utils import configure_logging_for_tests, skip_test_if_light
13from ROOT import Belle2
14
15skip_test_if_light() # light builds don't know about PXD hits
16configure_logging_for_tests()
17basf2.set_random_seed("something important")
18
19
20class NoopModule(basf2.Module):
21 """Doesn't do anything."""
22
23
24class TestModule(basf2.Module):
25 """Test to read relations in the input files."""
26
27
28 iEvent = 0
29
30 def event(self):
31 """reimplementation of Module::event().
32
33 prints PXD true and simhit indices, using relations
34 """
35 filemetadata = Belle2.PyStoreObj('FileMetaData', 1)
36 nevents = filemetadata.obj().getNEvents()
37 if self.iEvent < 12 and not nevents == 12:
38 basf2.B2FATAL("FileMetaData from file 1 not loaded!")
39 elif self.iEvent >= 12 and not nevents == 15:
40 basf2.B2FATAL("FileMetaData from file 2 not loaded!")
41
42 simhits = Belle2.PyStoreArray('PXDSimHits')
43 for hit in simhits:
44 relations = hit.getRelationsFrom("PXDTrueHits")
45 for truehit in relations:
46 print(f'truehit {truehit.getArrayIndex()} => hit {hit.getArrayIndex()}')
47
48 self.iEvent += 1
49
50
51inputfiles = [
52 basf2.find_file('framework/tests/chaintest_1.root'),
53 basf2.find_file('framework/tests/chaintest_2.root')
54]
55
56basf2.conditions.disable_globaltag_replay()
57main = basf2.Path()
58
59# not used for anything, just checking wether the master module
60# can be found if it's not the first module in the path.
61main.add_module(NoopModule())
62
63main.add_module('RootInput', logLevel=basf2.LogLevel.WARNING, inputFileNames=inputfiles)
64main.add_module('EventInfoPrinter')
65main.add_module('PrintCollections', printForEvent=0)
66
67main.add_module(TestModule())
68
69# Process events
70basf2.process(main)
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:67
int iEvent
event counter
Definition: chain_input.py:28