Belle II Software development
digitize.py
1#!/usr/bin/env python3
2
3
10
11import basf2 as b2
12from optparse import OptionParser
13
14# --------------------------------------------------------------------
15# Example steering script for digitization and analysis of existing
16# background files containing only SimHits
17# Analysis output histograms are stored into a root file
18# In addition you can store the collection of hits in your detector
19# by uncommenting root output module lines
20#
21# run as: basf2 beast/examples/digitize.py -- -f inputfile -o outputfile
22# --------------------------------------------------------------------
23
24parser = OptionParser()
25parser.add_option('-f', '--file', dest='filename',
26 default='input.root')
27parser.add_option('-o', '--output', dest='output_filename',
28 default='output.root')
29
30(options, args) = parser.parse_args()
31
32# Suppress messages and warnings during processing:
33b2.set_log_level(b2.LogLevel.ERROR)
34
35# Create path
36main = b2.create_path()
37
38# input root file
39input_module = b2.register_module('RootInput')
40input_module.param('inputFileName', options.filename)
41main.add_module(input_module)
42
43histo = b2.register_module('HistoManager')
44histo.param('histoFileName', options.output_filename) # File to save histograms
45main.add_module(histo)
46
47# Gearbox: access to database (xml files)
48gearbox = b2.register_module('Gearbox')
49main.add_module(gearbox)
50
51# digitizers (for example He3Digitizer)
52he3digi = b2.register_module('He3Digitizer')
53main.add_module(he3digi)
54
55# make histograms (for example for He3)
56he3study = b2.register_module('He3tubeStudy')
57main.add_module(he3study)
58
59# root output module
60# now the root output file contains digitized He3 hits (He3tubeHits)!
61# output = register_module('RootOutput')
62# output.param('outputFileName', options.output_filename)
63# if you want to store only branches of interest (hits in your detector, etc.) use
64# output.param('branchNames', ['He3tubeHits'])
65# main.add_module(output)
66
67# Show progress of processing
68progress = b2.register_module('Progress')
69main.add_module(progress)
70
71# Process events
72b2.process(main)
73
74# Print call statistics
75print(b2.statistics)