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