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