Belle II Software development
B2A401-KFit-MassFit.py
1#!/usr/bin/env python3
2
3
10
11
27
28import basf2 as b2
29from modularAnalysis import inputMdst
30from modularAnalysis import reconstructDecay
31from modularAnalysis import matchMCTruth
32from vertex import kFit
33from modularAnalysis import variablesToNtuple
34from stdPi0s import stdPi0s
35import variables.collections as vc
36import variables.utils as vu
37
38# create path
39my_path = b2.create_path()
40
41# load input ROOT file
42inputMdst(filename=b2.find_file('B02pi0D0_D2kpi_B2Dstarpi_Dstar2Dpi_D2kpi.root', 'examples', False),
43 path=my_path)
44
45# use standard final state particle lists
46#
47# creates "pi0:eff40_May2020Fit" ParticleList
48stdPi0s('eff40_May2020Fit', path=my_path)
49
50# reconstruct D0 -> pi0 pi0 decay
51# keep only candidates with 1.7 < M(pi0pi0) < 2.0 GeV
52reconstructDecay('D0:pi0pi0 -> pi0:eff40_May2020Fit pi0:eff40_May2020Fit', '1.7 < M < 2.0', path=my_path)
53
54# perform mass fit using KFit
55# Reject the candidates with failed fit.
56kFit('D0:pi0pi0', 0.0, 'mass', path=my_path)
57
58# reconstruct B0 -> D0 pi0 decay
59# keep only candidates with Mbc > 5.24 GeV
60# and -1 < Delta E < 1 GeV
61reconstructDecay('B0:all -> D0:pi0pi0 pi0:eff40_May2020Fit', '5.24 < Mbc < 5.29 and abs(deltaE) < 1.0', path=my_path)
62
63# perform MC matching (MC truth association)
64matchMCTruth('B0:all', path=my_path)
65
66# Select variables that we want to store to ntuple
67B0_vars = vc.inv_mass + vc.mc_truth + \
68 vu.create_aliases_for_selected(
69 vc.inv_mass + vc.mc_truth,
70 'B0 -> ^D0 ^pi0') + \
71 vu.create_aliases_for_selected(
72 vc.cluster, 'B0 -> D0 [pi0 -> ^gamma ^gamma]')
73
74pi0_vars = vc.mc_truth + vc.kinematics + \
75 ['extraInfo(BDT)', 'decayAngle(0)'] + \
76 vu.create_aliases_for_selected(
77 vc.cluster + vc.kinematics, 'pi0 -> ^gamma ^gamma')
78
79# Saving variables to ntuple
80output_file = 'B2A401-KFit-MassFit.root'
81variablesToNtuple('B0:all', B0_vars,
82 filename=output_file, treename='b0', path=my_path)
83variablesToNtuple('pi0:eff40_May2020Fit', pi0_vars,
84 filename=output_file, treename='pi0', path=my_path)
85
86# Process the events
87b2.process(my_path)
88
89# print out the summary
90print(b2.statistics)