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