Belle II Software  release-05-01-25
SADreader.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 # This steering file
5 # shows all options for the simulation of background events fed from SAD input
6 # files.
7 #
8 # Please note: The SAD input file contains weighted particles, in the following
9 # called 'SAD particles'. Thus, one particle in the input file doesn't
10 # correspond to one 'real' particle in an event. In order to simulate the
11 # background for your subdetector, you have two possibilities:
12 #
13 # a) Create unweighted events by setting the 'ReadMode' to 1 and 'ReadoutTime'
14 # to the correct readout time of your subdetector. Then run over ALL events in
15 # the input file. The result will be a ROOT file containing all particles which
16 # hit your subdetector during one readout frame/cycle of your subdetector.
17 #
18 # b) Create weighted events by setting the 'ReadMode' to 0. Run over ALL events
19 # in the input file. Each event will contain one MonteCarlo track, carrying the
20 # weight information. Using this information you can then scale the result to
21 # your subdetector readout time.
22 #
23 # Which one you choose depends on the background studies you would like to
24 # perform. For example, if you are interested in the details of your
25 # subdetector occupancy, it is recommended to choose a). On the other hand, if
26 # you are interested in the flux or rate of the background hitting your
27 # subdetector, you can choose b).
28 #
29 # Example steering file - 2012 Belle II Collaboration
30 
31 
32 from basf2 import set_log_level, LogLevel, register_module, create_path, process, statistics
33 
34 # Set the global log level
35 set_log_level(LogLevel.ERROR)
36 
37 # Register the event meta generator and set the number of events to a very
38 # high number which exceeds the number of events in the input file.
39 eventinfosetter = register_module('EventInfoSetter')
40 eventinfosetter.param({'evtNumList': [10000000], 'runList': [1]})
41 
42 # Register the SADInput module and specify the location of the SAD input file.
43 # The file can be downloaded from the TWiki.
44 sadinput = register_module('SADInput')
45 sadinput.param('Filename', 'SADreaderInput.root')
46 
47 # Set the ReadMode of the SAD input module. 0 = one SAD particle per event.
48 # This produces weighted events. 1 = one real particle per event. This produces
49 # unweighted events. 2 = all SAD particles in one event. Can be used for
50 # visualization.
51 sadinput.param('ReadMode', 1)
52 
53 # Set the accelerator ring with which the SAD input has been generated. 0 = LER
54 # 1 = HER.
55 sadinput.param('AccRing', 0)
56 
57 # Set the readout time for your subdetector in [ns]. Please note: The value
58 # given here corresponds to the readout time of the PXD ! This setting is only
59 # used if the 'ReadMode' is set to 1.
60 sadinput.param('ReadoutTime', 20000)
61 
62 # Set the range around the IP in which SAD particles are accepted into the
63 # simulation. The value given below is highly recommended.
64 sadinput.param('Range', 390)
65 
66 # If you would like to see some information about the created particles set the
67 # logging output of the Input module to DEBUG.
68 sadinput.set_log_level(LogLevel.DEBUG)
69 
70 # Register the standard chain of modules to the framework, which are required
71 # for the simulation.
72 gearbox = register_module('Gearbox')
73 
74 geometry = register_module('Geometry')
75 
76 fullsim = register_module('FullSim')
77 
78 # Add additional modules according to your own needs
79 # pxddigi = register_module('PXDDigitizer')
80 # progress = register_module('Progress')
81 
82 # Write the output to a file
83 rootoutput = register_module('RootOutput')
84 rootoutput.param('outputFileName', 'SADreaderOutput.root')
85 
86 progress = register_module('Progress')
87 
88 # Create the main path and add the required modules
89 main = create_path()
90 main.add_module(eventinfosetter)
91 main.add_module(gearbox)
92 main.add_module(sadinput)
93 main.add_module(geometry)
94 main.add_module(fullsim)
95 
96 # Add additional modules if you like main.add_module(pxddigi)
97 main.add_module(progress)
98 
99 # Add the output module
100 main.add_module(rootoutput)
101 
102 # Start the event processing
103 process(main)
104 
105 # Print some basic event statistics
106 print('Event Statistics:')
107 print(statistics)