Belle II Software  release-08-01-10
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(filename=b2.find_file('Y4SEventToetaY1S-evtgen_100.root', 'examples', False),
48  path=my_path)
49 
50 
51 # Creates a list of good pions and kaons with some PID and IP cut
52 stdPhotons('loose', path=my_path)
53 fillParticleList('mu+:pid', 'muonID>0.1', path=my_path)
54 
55 
56 # Reconstructs eta -> gamma gamma
57 reconstructDecay("eta:gg -> gamma:loose gamma:loose", "", path=my_path)
58 # Reconstructs Upsilon -> u+ u-
59 reconstructDecay("Upsilon:uu -> mu+:pid mu-:pid", "M>2.", path=my_path)
60 
61 # Reconstructs Upsilon(4S) -> Upsilon eta
62 reconstructDecay("Upsilon(4S) -> eta:gg Upsilon:uu", "", path=my_path)
63 
64 # Associates the MC truth to the reconstructed particles
65 matchMCTruth('Upsilon(4S)', path=my_path)
66 
67 # Perform four momentum constraint fit using KFit.
68 # Reject the candidates with failed fit.
69 kFit("Upsilon(4S)", 0.0, 'fourC', path=my_path)
70 
71 # Perform four momentum constraint fit using KFit and update the Daughters
72 # Reject the candidates with failed fit.
73 # kFit("Upsilon(4S)", 0.0, 'fourC', daughtersUpdate=True, path=my_path)
74 
75 # Select variables that we want to store to ntuple
76 muvars = vc.mc_truth + vc.pid + vc.kinematics
77 gvars = vc.kinematics + vc.mc_truth
78 etaanduvars = vc.inv_mass + vc.kinematics + vc.mc_truth
79 u4svars = vc.inv_mass + vc.kinematics + vc.mc_truth + \
80  vu.create_aliases(['FourCFitProb', 'FourCFitChi2'], 'extraInfo({variable})', "") + \
81  vu.create_aliases_for_selected(etaanduvars, 'Upsilon(4S) -> ^eta ^Upsilon') + \
82  vu.create_aliases_for_selected(muvars, 'Upsilon(4S) -> eta [Upsilon -> ^mu+ ^mu-]') + \
83  vu.create_aliases_for_selected(gvars, 'Upsilon(4S) -> [eta -> ^gamma ^gamma] Upsilon')
84 
85 # Saving variables to ntuple
86 output_file = 'B2A407-KFit-FourCFit.root'
87 variablesToNtuple('Upsilon(4S)', u4svars,
88  filename=output_file, treename='Upsilon4s', path=my_path)
89 
90 #
91 # Process and print statistics
92 #
93 
94 # Process the events
95 b2.process(my_path)
96 # print out the summary
97 print(b2.statistics)