Belle II Software  release-08-01-10
evtgen_sim.py
1 #!/usr/bin/env python3
2 
3 
10 
11 import basf2 as b2
12 from optparse import OptionParser
13 from tracking import add_tracking_reconstruction
14 from modularAnalysis import inputMdst
15 import 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 
23 parser = OptionParser()
24 parser.add_option('-f', '--file', dest='filename',
25  default='ARICHEvents.root')
26 (options, args) = parser.parse_args()
27 
28 home = os.environ['BELLE2_LOCAL_DIR']
29 
30 mypath = b2.create_path()
31 
32 # Suppress messages and warnings during processing:
33 b2.set_log_level(b2.LogLevel.ERROR)
34 
35 # load input ROOT file
36 inputMdst(home + '/B2Kpi_events.root', path=mypath)
37 
38 # Gearbox: access to database (xml files)
39 mypath.add_module('Gearbox')
40 
41 # Geometry
42 geometry = b2.register_module('Geometry')
43 geometry.param('components', [
44  'MagneticField',
45  'BeamPipe',
46  'PXD',
47  'SVD',
48  'CDC',
49  'ARICH'])
50 mypath.add_module(geometry)
51 
52 # Simulation
53 mypath.add_module('FullSim')
54 
55 # PXD digitization & clustering
56 mypath.add_module('PXDDigitizer')
57 mypath.add_module('PXDClusterizer')
58 
59 # SVD digitization & clustering
60 mypath.add_module('SVDEventInfoSetter')
61 mypath.add_module('SVDDigitizer')
62 mypath.add_module('SVDClusterizer')
63 
64 # CDC digitization
65 mypath.add_module('CDCDigitizer')
66 
67 # tracking reconstruction
68 add_tracking_reconstruction(mypath)
69 
70 # Track extrapolation
71 mypath.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.
77 mypath.add_module('ARICHRelate')
78 
79 # store branches needed for ARICH reconstruction in root file
80 output = b2.register_module('RootOutput')
81 output.param('outputFileName', options.filename)
82 output.param('branchNames', ['ARICHAeroHits', 'ARICHSimHits', 'ExtHits',
83  'ARICHAeroHitsToExtHits', 'Tracks', 'TrackFitResults'])
84 mypath.add_module(output)
85 
86 # Show progress of processing
87 mypath.add_module('Progress')
88 
89 # Process events
90 b2.process(mypath)
91 
92 # Print call statistics
93 print(b2.statistics)