Belle II Software  release-08-01-10
SADreader.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 from basf2 import set_log_level, LogLevel, register_module, create_path, process, statistics
13 
14 # Set the global log level
15 set_log_level(LogLevel.ERROR)
16 
17 # Register the event meta generator and set the number of events to a very
18 # high number which exceeds the number of events in the input file.
19 eventinfosetter = register_module('EventInfoSetter')
20 eventinfosetter.param({'evtNumList': [10000000], 'runList': [1]})
21 
22 # Register the SADInput module and specify the location of the SAD input file.
23 # The file can be downloaded from the TWiki.
24 sadinput = register_module('SADInput')
25 sadinput.param('Filename', 'SADreaderInput.root')
26 
27 # Set the ReadMode of the SAD input module. 0 = one SAD particle per event.
28 # This produces weighted events. 1 = one real particle per event. This produces
29 # unweighted events. 2 = all SAD particles in one event. Can be used for
30 # visualization.
31 sadinput.param('ReadMode', 1)
32 
33 # Set the accelerator ring with which the SAD input has been generated. 0 = LER
34 # 1 = HER.
35 sadinput.param('AccRing', 0)
36 
37 # Set the readout time for your subdetector in [ns]. Please note: The value
38 # given here corresponds to the readout time of the PXD ! This setting is only
39 # used if the 'ReadMode' is set to 1.
40 sadinput.param('ReadoutTime', 20000)
41 
42 # Set the range around the IP in which SAD particles are accepted into the
43 # simulation. The value given below is highly recommended.
44 sadinput.param('Range', 390)
45 
46 # If you would like to see some information about the created particles set the
47 # logging output of the Input module to DEBUG.
48 sadinput.set_log_level(LogLevel.DEBUG)
49 
50 # Register the standard chain of modules to the framework, which are required
51 # for the simulation.
52 gearbox = register_module('Gearbox')
53 
54 geometry = register_module('Geometry')
55 
56 fullsim = register_module('FullSim')
57 
58 # Add additional modules according to your own needs
59 # pxddigi = register_module('PXDDigitizer')
60 # progress = register_module('Progress')
61 
62 # Write the output to a file
63 rootoutput = register_module('RootOutput')
64 rootoutput.param('outputFileName', 'SADreaderOutput.root')
65 
66 progress = register_module('Progress')
67 
68 # Create the main path and add the required modules
69 main = create_path()
70 main.add_module(eventinfosetter)
71 main.add_module(gearbox)
72 main.add_module(sadinput)
73 main.add_module(geometry)
74 main.add_module(fullsim)
75 
76 # Add additional modules if you like main.add_module(pxddigi)
77 main.add_module(progress)
78 
79 # Add the output module
80 main.add_module(rootoutput)
81 
82 # Start the event processing
83 process(main)
84 
85 # Print some basic event statistics
86 print('Event Statistics:')
87 print(statistics)