Belle II Software development
zero_suppression.py
1
8
9import basf2
10from ROOT import Belle2
11import b2test_utils
12
13# ====================================================================
14# This test does the following:
15# 1. Simulate a few hundred ParticleGun events to produce a sample of
16# SVD simhits.
17# 2. Use SVDDigitizer with varius zero-suppression cut settings and check
18# that the settings work.
19# ====================================================================
20
21
22class CheckZS(basf2.Module):
23 """Check that SVVDShaperDigits are correctly zero-suppressed."""
24
25 def __init__(self, thresholdSN):
26 '''initialize python module'''
27 super().__init__()
28
29
30 self.thresholdSN = thresholdSN
31
32 def event(self):
33 '''event'''
34 storedigits = Belle2.PyStoreArray("SVDShaperDigits")
36 for digit in storedigits:
37 info = gc.get(digit.getSensorID())
38 isU = digit.isUStrip()
39 noise_in_e = info.getElectronicNoiseU() if isU else info.getElectronicNoiseV()
40 adu_equivalent = info.getAduEquivalentU() if isU else info.getAduEquivalentV()
41 noise_in_adu = noise_in_e / adu_equivalent
42 threshold_in_adu = self.thresholdSN * noise_in_adu
43 samples = digit.getSamples()
44 for s in samples:
45 if s > threshold_in_adu:
46 break
47 else:
48 basf2.B2FATAL(f"Found digit under threshold: {digit.to_string()}")
49
50
51if __name__ == "__main__":
52
54
55 basf2.B2INFO('Creating simhits...')
56 # We create data separately, so that we can use them in other tests.
57
58 create_simhits = basf2.create_path()
59 create_simhits.add_module('EventInfoSetter', evtNumList=[50])
60 create_simhits.add_module('Gearbox')
61 create_simhits.add_module('Geometry', components=['MagneticField', 'SVD'], useDB=False)
62 create_simhits.add_module('ParticleGun')
63 create_simhits.add_module('FullSim')
64 create_simhits.add_module('RootOutput', outputFileName='SimulationForThresholdTest.root',
65 branchNames=['EventMetaData', 'SVDSimHits', 'SVDTrueHits'])
67 b2test_utils.safe_process(create_simhits)
68
69 basf2.B2INFO('Threshold testing...')
70
71 threshold = 3
72
73 test_threshold = basf2.create_path()
74 # Read generated Simhits and Truehits
75 test_threshold.add_module('RootInput', inputFileName='SimulationForThresholdTest.root')
76 test_threshold.add_module('Gearbox')
77 test_threshold.add_module('Geometry', components=['MagneticField', 'SVD'], useDB=False)
78 # Set the threshold.
79 test_threshold.add_module('SVDDigitizer', ZeroSuppressionCut=threshold)
80 threshold_checker = CheckZS(threshold)
81 test_threshold.add_module(threshold_checker)
83 b2test_utils.safe_process(test_threshold)
84
85 basf2.B2INFO('Test done.')
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
def __init__(self, thresholdSN)
def clean_working_directory()
Definition: __init__.py:189
def show_only_errors()
Definition: __init__.py:94
def safe_process(*args, **kwargs)
Definition: __init__.py:236