Belle II Software  release-08-01-10
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(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
48 stdPi0s('eff40_May2020Fit', path=my_path)
49 
50 # reconstruct D0 -> pi0 pi0 decay
51 # keep only candidates with 1.7 < M(pi0pi0) < 2.0 GeV
52 reconstructDecay('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.
56 kFit('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
61 reconstructDecay('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)
64 matchMCTruth('B0:all', path=my_path)
65 
66 # Select variables that we want to store to ntuple
67 B0_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 
74 pi0_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
80 output_file = 'B2A401-KFit-MassFit.root'
81 variablesToNtuple('B0:all', B0_vars,
82  filename=output_file, treename='b0', path=my_path)
83 variablesToNtuple('pi0:eff40_May2020Fit', pi0_vars,
84  filename=output_file, treename='pi0', path=my_path)
85 
86 # Process the events
87 b2.process(my_path)
88 
89 # print out the summary
90 print(b2.statistics)