Belle II Software development
B2A420-OrcaKinFit.py
1#!/usr/bin/env python3
2
3
10
11
22
23import basf2 as b2
24from modularAnalysis import inputMdst
25from modularAnalysis import fillParticleList
26from modularAnalysis import reconstructDecay
27from modularAnalysis import matchMCTruth
28from kinfit import fitKinematic4C
29from modularAnalysis import variablesToNtuple
30import variables.collections as vc
31import variables.utils as vu
32
33# create path
34mypath = b2.create_path()
35
36b2.set_log_level(b2.LogLevel.WARNING)
37
38# Input file(s).
39inputMdst(filename=b2.find_file('B2A424-SimulateMuonPairs.root', 'examples', False),
40 path=mypath)
41
42# use standard final state particle lists for muons
43fillParticleList('mu-:z0', 'chiProb > 0.001 and p > 1.0', path=mypath)
44fillParticleList('mu-:z0fit', 'chiProb > 0.001 and p > 1.0', path=mypath)
45
46# reconstruct Z -> mu+ mu-
47reconstructDecay('Z0:mm_rec -> mu+:z0 mu-:z0', '9.0 < M < 11.0', path=mypath)
48reconstructDecay('Z0:mm_kinfit -> mu+:z0fit mu-:z0fit', '9.0 < M < 11.0', path=mypath)
49
50# MC truth matching
51matchMCTruth('Z0:mm_rec', path=mypath)
52matchMCTruth('Z0:mm_kinfit', path=mypath)
53
54# kinematic 4C hard fit
55fitKinematic4C('Z0:mm_kinfit', path=mypath)
56
57# Select variables that we want to store to ntuple
58muvars = vc.kinematics + vc.mc_truth + vc.mc_kinematics + vc.momentum_uncertainty
59z0vars = vc.inv_mass + vc.kinematics + vc.mc_kinematics + vc.mc_truth + \
60 vu.create_aliases_for_selected(muvars, 'Z0 -> ^mu+ ^mu-')
61
62z0uvars = z0vars + ['OrcaKinFitProb', 'OrcaKinFitChi2', 'OrcaKinFitErrorCode']
63
64
65# Saving variables to ntuple
66output_file = 'B2A420-OrcaKinFit.root'
67variablesToNtuple('Z0:mm_rec', z0vars,
68 filename=output_file, treename='Z0_mm_rec', path=mypath)
69variablesToNtuple('Z0:mm_kinfit', z0uvars,
70 filename=output_file, treename='Z0_mm_kinfit', path=mypath)
71
72
73# Process the events
74b2.process(mypath)
75
76# print out the summary
77print(b2.statistics)