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