Belle II Software development
evtgen_sim.py
1#!/usr/bin/env python3
2
3
10
11import basf2 as b2
12from optparse import OptionParser
13from tracking import add_tracking_reconstruction
14from modularAnalysis import inputMdst
15import os
16# --------------------------------------------------------------------
17# Performs Geant4 simulation of events generated with evtgen_gen.py
18# PXD, SVD, CDC and ARICH detectors are used. Reconstruction of tracks
19# is also included and objects needed for ARICH reconstruction are stored
20# in output root file.
21# --------------------------------------------------------------------
22
23parser = OptionParser()
24parser.add_option('-f', '--file', dest='filename',
25 default='ARICHEvents.root')
26(options, args) = parser.parse_args()
27
28home = os.environ['BELLE2_LOCAL_DIR']
29
30mypath = b2.create_path()
31
32# Suppress messages and warnings during processing:
33b2.set_log_level(b2.LogLevel.ERROR)
34
35# load input ROOT file
36inputMdst(home + '/B2Kpi_events.root', path=mypath)
37
38# Gearbox: access to database (xml files)
39mypath.add_module('Gearbox')
40
41# Geometry
42geometry = b2.register_module('Geometry')
43geometry.param('components', [
44 'MagneticField',
45 'BeamPipe',
46 'PXD',
47 'SVD',
48 'CDC',
49 'ARICH'])
50mypath.add_module(geometry)
51
52# Simulation
53mypath.add_module('FullSim')
54
55# PXD digitization & clustering
56mypath.add_module('PXDDigitizer')
57mypath.add_module('PXDClusterizer')
58
59# SVD digitization & clustering
60mypath.add_module('SVDEventInfoSetter')
61mypath.add_module('SVDDigitizer')
62mypath.add_module('SVDClusterizer')
63
64# CDC digitization
65mypath.add_module('CDCDigitizer')
66
67# tracking reconstruction
68add_tracking_reconstruction(mypath)
69
70# Track extrapolation
71mypath.add_module('Ext')
72
73# This creates relations between ExtHits (track points on aerogel plane, from
74# extrapolated CDC tracks) and ARICHAeroHits (MC hits on aerogel plane).
75# It allows to have relevant MC information
76# without storing full MCParticles (which are LARGE) into output root file.
77mypath.add_module('ARICHRelate')
78
79# store branches needed for ARICH reconstruction in root file
80output = b2.register_module('RootOutput')
81output.param('outputFileName', options.filename)
82output.param('branchNames', ['ARICHAeroHits', 'ARICHSimHits', 'ExtHits',
83 'ARICHAeroHitsToExtHits', 'Tracks', 'TrackFitResults'])
84mypath.add_module(output)
85
86# Show progress of processing
87mypath.add_module('Progress')
88
89# Process events
90b2.process(mypath)
91
92# Print call statistics
93print(b2.statistics)