Belle II Software light-2406-ragdoll
KlongDecayReconstructionExample.py
1#!/usr/bin/env python3
2
3
10
11
18
19import basf2
20import modularAnalysis as ma
21from stdCharged import stdMu
22from stdKlongs import stdKlongs
23import variables.collections as vc
24import variables.utils as vu
25from variables import variables
26from vertex import TagV, kFit
27
28
29main = basf2.create_path()
30
31ma.inputMdstList([basf2.find_file('B02JpsiKL_Jpsi2mumu.root', 'examples', False)], path=main)
32
33# Show progress of processing
34main.add_module('ProgressBar')
35
36stdMu('loose', path=main)
37stdKlongs('allklm', path=main)
38
39ma.reconstructDecay('J/psi:mumu -> mu-:loose mu+:loose', cut='3.08 < M < 3.12 and 1.45 < useCMSFrame(p) < 1.95', path=main)
40
41pcalc = basf2.register_module('KlongMomentumCalculatorExpert')
42pcalc.set_name('KlongMomentumCalculatorExpert_' + 'B0 -> J/psi:mumu K_L0:allklm')
43pcalc.param('decayString', 'B0 -> J/psi:mumu K_L0:allklm')
44pcalc.param('writeOut', False)
45pcalc.param('recoList', "_reco")
46main.add_module(pcalc)
47
48rmake = basf2.register_module('KlongDecayReconstructorExpert')
49rmake.set_name('KlongDecayReconstructorExpert_' + 'B0 -> J/psi:mumu K_L0:allklm')
50rmake.param('decayString', 'B0 -> J/psi:mumu K_L0:allklm')
51rmake.param('cut', 'M > 0')
52rmake.param('decayMode', 0)
53rmake.param('writeOut', False)
54rmake.param('recoList', "_reco")
55main.add_module(rmake)
56
57ma.buildRestOfEvent('B0', path=main)
58ma.matchMCTruth('B0', path=main)
59
60kFit(list_name='B0', conf_level=-1, fit_type='vertex', constraint='iptube',
61 decay_string='B0 -> [J/psi -> ^mu- ^mu+] K_L0',
62 daughtersUpdate=False, # if true, kinematics of J/psi -> mu- mu+ will be updated
63 path=main)
64
65# The vertex fit changes the kinematics of the B-meson.
66# Re-calculate the kinematics with the same method
67ma.updateKlongKinematicsExpert('B0', path=main)
68
69TagV('B0', constraintType='tube', confidenceLevel=0.0001, path=main)
70
71commonVariables = vc.inv_mass + vc.mc_truth
72commonVariables += vc.kinematics + vc.mc_kinematics
73commonVariables += vc.vertex + vc.mc_vertex
74
75variableList = [var for var in commonVariables]
76variableList += vc.deltae_mbc + vc.tag_vertex + vc.mc_tag_vertex + vc.reco_stats
77variableList += vu.create_aliases(commonVariables, 'daughter(0, {variable})', 'Jpsi')
78variableList += vu.create_aliases(commonVariables, 'daughter(1, {variable})', 'KL0')
79variableList += vu.create_aliases(vc.kinematics, 'useCMSFrame({variable})', 'CMS')
80variableList += vu.create_aliases(vc.kinematics, 'daughter(0, useCMSFrame({variable}))', 'Jpsi_CMS')
81variableList += vu.create_aliases(vc.kinematics, 'daughter(1, useCMSFrame({variable}))', 'KL0_CMS')
82variables.addAlias('dmID', 'extraInfo(decayModeID)')
83variableList += ['dmID']
84
85ma.variablesToNtuple('B0', variables=variableList, filename="Reconstruct_jpsi_kl_example.root", treename='tree', path=main)
86
87# Process all modules added to the main path
88basf2.process(main)
89
90# Print out the summary
91print(basf2.statistics)