Belle II Software  release-05-01-25
B2A400-TreeFit.py
1 #!/usr/bin/env python3
2 
3 
28 
29 import basf2 as b2
30 import modularAnalysis as ma
31 import vertex as vx
32 from stdPi0s import stdPi0s
33 
34 # create path
35 my_path = b2.create_path()
36 
37 # load input ROOT file
38 ma.inputMdst(environmentType='default',
39  filename=b2.find_file('B02D0pi0_D02pi0pi0.root', 'examples', False),
40  path=my_path)
41 
42 
43 # use standard final state particle lists
44 #
45 # creates "pi0:eff40_Jan2020Fit" ParticleList
46 # see Standard Particles section at https://software.belle2.org/
47 stdPi0s(listtype='eff40_Jan2020Fit', path=my_path)
48 
49 # reconstruct D0 -> pi0 pi0 decay
50 # keep only candidates with 1.7 < M(pi0pi0) < 2.0 GeV
51 ma.reconstructDecay(decayString='D0:pi0pi0 -> pi0:eff40_Jan2020Fit pi0:eff40_Jan2020Fit',
52  cut='1.7 < M < 2.0',
53  path=my_path)
54 
55 # reconstruct B0 -> D0 pi0 decay
56 # keep only candidates with Mbc > 5.24 GeV
57 # and -1 < Delta E < 1 GeV
58 ma.reconstructDecay(decayString='B0:all -> D0:pi0pi0 pi0:eff40_Jan2020Fit',
59  cut='5.24 < Mbc < 5.29 and abs(deltaE) < 1.0',
60  path=my_path)
61 
62 # perform MC matching (MC truth association)
63 ma.matchMCTruth(list_name='B0:all', path=my_path)
64 
65 vx.treeFit(list_name='B0:all',
66  conf_level=0, # 0:keep only fit survivors, -1: keep all candidates; optimise this cut for your need
67  ipConstraint=True,
68  # pins the B0 PRODUCTION vertex to the IP (increases SIG and BKG rejection) use for better vertex resolution
69  updateAllDaughters=True, # update momenta of ALL particles
70  massConstraint=['pi0'], # mass constrain ALL pi0
71  path=my_path)
72 
73 # whatever you are interested in
74 #
75 # see analysis/VariableManager/ for implementation of the vars
76 variables = [
77  'isSignal', # MC truth
78  'chiProb', # pValue of the fit use this in your analysis to reject background
79  "p", # momentum (of the B0)
80  "mcP", # generated momentum
81  "pErr", # momentum uncertainty taking the full px, py, pz covariance into account
82 ]
83 
84 # safe the output
85 output_name = "B2A400-TreeFit.root"
86 my_path.add_module('VariablesToNtuple',
87  treeName='B0',
88  particleList='B0:all',
89  variables=variables,
90  fileName=output_name)
91 
92 # Process the events
93 b2.process(my_path)
94 
95 # print out the summary
96 print(b2.statistics)
stdPi0s
Definition: stdPi0s.py:1