Belle II Software  release-06-02-00
B2A407-KFit-FourCFit.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
26 
27 
28 #
29 # Import and mdst loading
30 #
31 
32 import basf2 as b2
33 from modularAnalysis import inputMdst
34 from modularAnalysis import fillParticleList
35 from modularAnalysis import reconstructDecay
36 from vertex import kFit
37 from modularAnalysis import matchMCTruth
38 from modularAnalysis import variablesToNtuple
39 from stdPhotons import stdPhotons
40 import variables.collections as vc
41 import variables.utils as vu
42 
43 # create path
44 my_path = b2.create_path()
45 
46 # load input ROOT file
47 inputMdst(environmentType='default',
48  filename=b2.find_file('Y4SEventToetaY1S-evtgen_100.root', 'examples', False),
49  path=my_path)
50 
51 
52 # Creates a list of good pions and kaons with some PID and IP cut
53 stdPhotons('loose', path=my_path)
54 fillParticleList('mu+:pid', 'muonID>0.1', path=my_path)
55 
56 
57 # Reconstructs eta -> gamma gamma
58 reconstructDecay("eta:gg -> gamma:loose gamma:loose", "", path=my_path)
59 # Reconstructs Upsilon -> u+ u-
60 reconstructDecay("Upsilon:uu -> mu+:pid mu-:pid", "M>2.", path=my_path)
61 
62 # Reconstructs Upsilon(4S) -> Upsilon eta
63 reconstructDecay("Upsilon(4S) -> eta:gg Upsilon:uu", "", path=my_path)
64 
65 # Associates the MC truth to the reconstructed particles
66 matchMCTruth('Upsilon(4S)', path=my_path)
67 
68 # Perform four momentum constraint fit using KFit.
69 # Reject the candidates with failed fit.
70 kFit("Upsilon(4S)", 0.0, 'fourC', path=my_path)
71 
72 # Perform four momentum constraint fit using KFit and update the Daughters
73 # Reject the candidates with failed fit.
74 # kFit("Upsilon(4S)", 0.0, 'fourC', daughtersUpdate=True, path=my_path)
75 
76 # Select variables that we want to store to ntuple
77 muvars = vc.mc_truth + vc.pid + vc.kinematics
78 gvars = vc.kinematics + vc.mc_truth
79 etaanduvars = vc.inv_mass + vc.kinematics + vc.mc_truth
80 u4svars = vc.inv_mass + vc.kinematics + vc.mc_truth + \
81  vu.create_aliases(['FourCFitProb', 'FourCFitChi2'], 'extraInfo({variable})', "") + \
82  vu.create_aliases_for_selected(etaanduvars, 'Upsilon(4S) -> ^eta ^Upsilon') + \
83  vu.create_aliases_for_selected(muvars, 'Upsilon(4S) -> eta [Upsilon -> ^mu+ ^mu-]') + \
84  vu.create_aliases_for_selected(gvars, 'Upsilon(4S) -> [eta -> ^gamma ^gamma] Upsilon')
85 
86 # Saving variables to ntuple
87 output_file = 'B2A407-KFit-FourCFit.root'
88 variablesToNtuple('Upsilon(4S)', u4svars,
89  filename=output_file, treename='Upsilon4s', path=my_path)
90 
91 #
92 # Process and print statistics
93 #
94 
95 # Process the events
96 b2.process(my_path)
97 # print out the summary
98 print(b2.statistics)