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