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