Belle II Software  release-06-02-00
event_kinematics_mc_compatibility.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 """
13 a test of the EventKinematics variables using the small test file for running quickly
14 """
15 
16 import b2test_utils
17 from basf2 import set_random_seed, create_path, process
18 
19 # make logging more reproducible by replacing some strings
21 set_random_seed("1337")
22 testinput = [b2test_utils.require_file('analysis/tests/mdst.root')]
23 
24 fsps = ['gamma', 'e+', 'mu+', 'pi+', 'K+', 'p+',
25  'K_S0', 'Lambda0']
26 
28 testpath = create_path()
29 testpath.add_module('RootInput', inputFileNames=testinput)
30 testpath.add_module('ParticleLoader', decayStrings=fsps,
31  addDaughters=True, skipNonPrimaryDaughters=True, useMCParticles=True)
32 for fsp in fsps:
33  testpath.add_module('ParticleListManipulator', outputListName=fsp,
34  inputListNames=[fsp + ':MC'], cut='mcPrimary > 0 and nDaughters == 0')
35 
36 # Variables filled by event kinematics module
37 event_kinematics = [
38  'genMissingMass2OfEvent',
39  'genMissingEnergyOfEventCMS',
40  'genMissingMomentumOfEventCMS',
41  'genTotalPhotonsEnergyOfEvent', # It is 0, because there is no primary photons in the event
42  'genVisibleEnergyOfEventCMS',
43 ]
44 
45 testpath.add_module('EventKinematics', particleLists=fsps, usingMC=True)
46 # Print the variables to log
47 testpath.add_module('ParticlePrinter', listName='', fullPrint=False,
48  variables=event_kinematics)
49 process(testpath, 1)
def configure_logging_for_tests(user_replacements=None)
Definition: __init__.py:106
def require_file(filename, data_type="", py_case=None)
Definition: __init__.py:54