Belle II Software  release-06-02-00
zero_suppression.py
1 
8 
9 import basf2
10 from ROOT import Belle2
11 import 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 
22 class 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.thresholdSNthresholdSN = 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.thresholdSNthresholdSN * 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("Found digit under threshold: {0}".format(digit.to_string()))
49 
50 
51 if __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:56
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:213
def __init__(self, thresholdSN)
def clean_working_directory()
Definition: __init__.py:185
def show_only_errors()
Definition: __init__.py:94
def safe_process(*args, **kwargs)
Definition: __init__.py:233