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