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