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