Belle II Software  release-05-01-25
HepEvtReaderFull.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
18 
19 import basf2
20 from beamparameters import add_beamparameters
21 
22 # suppress messages and warnings during processing:
23 basf2.set_log_level(basf2.LogLevel.ERROR)
24 # set_log_level(LogLevel.DEBUG)
25 
26 # creating the path for the processing
27 main = basf2.create_path()
28 
29 # beam parameters
30 beamparameters = add_beamparameters(main, "SuperKEKB")
31 
32 # to run the framework the used modules need to be registered
33 hepevtreader = basf2.register_module('HepevtInput')
34 
35 # setting the options for the HEPEVT reader:
36 #
37 # indicate the list of filenames where the hepevtreader should read events from
38 hepevtreader.param('inputFileList', ['BhWide_10events.txt'])
39 
40 # this file is in the same directory. For more and different hepevt files look
41 # and download from the Twiki. On the Twiki you will also find which options
42 # are needed for which hepevt file.
43 #
44 # in case you don't want to process the first events but only all events after
45 # event 1000 uncomment the following line hepevtreader.param("skipEvents",
46 # 1000) default is skipEvents = 0 (This is useful, if you want to process the
47 # data from the same HepEvtFile in more than 1 job)
48 #
49 # if the events in the HepEvt file are weighted and you want to use the event
50 # weights use this line hepevtreader.param("useWeights", True) default is
51 # useWeight = False, all events have the same weight
52 #
53 # if some of the particles in the event of the HEPEVT file should not be put to
54 # the simulation (incoming particles, virtual particles etc.) you can specify
55 # the number of virtual particles in each event. The BhWide generator from the
56 # input file used in this example gives first the two beam particles. So the
57 # first two particles should be treated as virtual particles.
58 hepevtreader.param('nVirtualParticles', 2)
59 # The default for this option is nVirtualParticles=0 NOTE: this option always
60 # assumes that the virtual particles are the first ones in the event and that
61 # there is a fixed number of them. For more complexe cases, this information
62 # should be provided by the generator inside the HEPEVT file. They will then
63 # require a specific input module taking account the peculiarities of this
64 # particular generator.
65 #
66 # if the generator calculated the interaction in the center of mass system, you
67 # can ask basf2 to boost automatically all particles to the LAB frame of
68 # BELLE2. This option is switched on with this line
69 hepevtreader.param('boost2Lab', True)
70 # For BhWide this option is needed. default is boost2LAB = false.
71 #
72 # if the generator uses a wrong convention for the directions of the positron
73 # and electron beams (wrong sign of Pz) and you want to use the boost to the
74 # LAB frame you should set the option wrongSignPz to true. Otherwise the boost
75 # goes wrong. This option is switched on with this line
76 hepevtreader.param('wrongSignPz', True)
77 # For BhWide this option is needed. default is wrongSignPz = false.
78 #
79 # for a simple simulation job with output to a root file these additional
80 # modules are needed
81 eventinfosetter = basf2.register_module('EventInfoSetter')
82 progress = basf2.register_module('Progress')
83 simpleoutput = basf2.register_module('RootOutput')
84 
85 # Setting the option for all non-hepevt reader modules:
86 eventinfosetter.param('evtNumList', [100]) # we want to process 100 events
87 eventinfosetter.param('runList', [1]) # from run number 1
88 eventinfosetter.param('expList', [0]) # and experiment number 1
89 
90 simpleoutput.param('outputFileName', 'HepEvtReaderOutput.root')
91 
92 # creating the path for the processing
93 main.add_module(eventinfosetter)
94 main.add_module(progress)
95 
96 # Add hepevtreader module to path:
97 main.add_module(hepevtreader)
98 # and print parameters for hepevtreader on startup of process
99 basf2.print_params(hepevtreader)
100 
101 # Add all other modules for simple processing to path
102 main.add_module(simpleoutput)
103 
104 # Process the events
105 basf2.process(main)
106 # if there are less events in the input file the processing will be stopped at
107 # EOF.
basf2.process
def process(path, max_event=0)
Definition: __init__.py:25