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