Belle II Software development
AafhGenerationWithPreselection.py
1#!/usr/bin/env python3
2
3
10
11
17
18from basf2 import set_log_level, LogLevel, create_path, process, register_module, statistics
19
20# suppress messages and during processing:
21set_log_level(LogLevel.INFO)
22
23main = create_path()
24
25# event info setter
26main.add_module("EventInfoSetter", expList=0, runList=1, evtNumList=100)
27
28# generator
29aafh = register_module('AafhInput')
30aafh.param({
31 # decay mode to generate.
32 # 1: e+e- -> mu+mu-L+L- where L is a user defined particle (default: tau)
33 # 2: e+e- -> mu+mu-mu+mu-
34 # 3: e+e- -> e+e-mu+mu-
35 # 4: e+e- -> e+e-L+L- where L is a user defined particle (default: tau)
36 # 5: e+e- -> e+e-e+e-
37 'mode': 5,
38 # to set the particle for modes 1 and 4 use set parameter "particle"
39 # rejection scheme to generate unweighted events
40 # 1: use rejection once for the final event weight
41 # 2: use rejection per sub generator and then for the final event
42 'rejection': 2,
43 # max subgenerator event weight, only used if rejection is set to 2
44 # (default). If this value is to low the generation will produce errors. If
45 # it is to high generation runs slower.
46 'maxSubgeneratorWeight': 1.0,
47 # max final event weight which is always used. If this value is to low the
48 # generation will produce errors. If it is to high generation runs slower.
49 # ==> should be around 2-4
50 'maxFinalWeight': 3.0,
51 # adjust subgenerator weights so that each sub generator has same
52 # probability to be called and the maximum weight is equal as well. These
53 # values are printed at the end of generation when output level is set to
54 # INFO. These weights strongly depend on the mode
55 'subgeneratorWeights': [
56 1.0,
57 7.986e+01,
58 5.798e+04,
59 3.898e+05,
60 1.0,
61 1.664e+00,
62 2.812e+00,
63 7.321e-01,
64 ],
65 # set to awfully precise
66 'suppressionLimits': [1e100] * 4,
67 # minimum invariant mass of the secondary pair
68 'minMass': 0.50,
69})
70aafh.logging.log_level = LogLevel.INFO
71
72# preselection to reject no tag events
73generatorpreselection = register_module('GeneratorPreselection')
74generatorpreselection.param('nChargedMin', 1)
75# generatorpreselection.param('nChargedMax', 999)
76generatorpreselection.param('MinChargedP', 0.25)
77generatorpreselection.param('MinChargedPt', 0.1)
78generatorpreselection.param('MinChargedTheta', 17.)
79generatorpreselection.param('MaxChargedTheta', 150.)
80generatorpreselection.param('nPhotonMin', 1)
81# generatorpreselection.param('nPhotonMax', 999)
82generatorpreselection.param('MinPhotonEnergy', 0.50)
83generatorpreselection.param('MinPhotonTheta', 15.)
84generatorpreselection.param('MaxPhotonTheta', 170.)
85
86# print generated particles
87mcparticleprinter = register_module('PrintMCParticles')
88mcparticleprinter.logging.log_level = LogLevel.INFO
89
90output = register_module('RootOutput')
91output.param('outputFileName', './aafh_out.root')
92
93# creating the path for the processing
94main.add_module(aafh)
95main.add_module(generatorpreselection)
96# create an empty path and check the return value of the the preselection
97emptypath = create_path()
98generatorpreselection.if_value('<1', emptypath)
99# continue the main path otherwise (e.g. call detector simulation)
100main.add_module(mcparticleprinter)
101main.add_module(output)
102
103# process the events
104process(main)
105
106# show call statistics
107print(statistics)