Belle II Software  release-08-01-10
clean_bg_file.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 # remove empty events from beam background data files.
13 
14 import basf2 as b2
15 from ROOT import Belle2
16 
17 
18 class SVDTrigger(b2.Module):
19 
20  """Returns 1 if current event contains at least one SVDSimHit or one
21  SVD-related BeamBackHit, 0 otherwise"""
22 
23  def initialize(self):
24  """reimplementation of Module::initialize()."""
25 
26  def event(self):
27  """reimplementation of Module::event()."""
28 
29  self.return_value(0)
30  simhits = Belle2.PyStoreArray('SVDSimHits')
31  bghits = Belle2.PyStoreArray('BeamBackHits')
32  if len(simhits) > 0 or len(bghits) > 0:
33  self.return_value(1)
34 
35 
36 main = b2.create_path()
37 
38 input = b2.register_module('RootInput')
39 main.add_module(input)
40 
41 
43 trigger = SVDTrigger()
44 main.add_module(trigger)
45 
46 # if SVDTrigger returns 0, we'll jump into an empty path
47 # (skipping output)
48 emptypath = b2.create_path()
49 trigger.if_false(emptypath)
50 
51 
52 output = b2.register_module('RootOutput')
53 main.add_module(output)
54 
55 main.add_module(b2.register_module('ProgressBar'))
56 
57 b2.process(main)
58 
59 print(b2.statistics)
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72