Belle II Software light-2406-ragdoll
B2A421-OrcaKinFit_1CFit.py
1#!/usr/bin/env python3
2
3
10
11
21
22import basf2 as b2
23from modularAnalysis import inputMdst
24from modularAnalysis import fillParticleList
25from modularAnalysis import reconstructDecay
26from modularAnalysis import matchMCTruth
27from kinfit import UnmeasuredfitKinematic1C
28from modularAnalysis import variablesToNtuple
29import variables.collections as vc
30import variables.utils as vu
31
32# create path
33mypath = b2.create_path()
34
35b2.set_log_level(b2.LogLevel.WARNING)
36
37# Input file(s).
38inputMdst(filename=b2.find_file('darkphotonmumu_mdst.root', 'examples', False),
39 path=mypath)
40
41# use standard final state particle lists for muons
42fillParticleList('mu-:z0', 'chiProb > 0.001 and p > 1.0', path=mypath)
43fillParticleList('mu-:z0fit', 'chiProb > 0.001 and p > 1.0', path=mypath)
44
45# reconstruct Z -> mu+ mu-
46reconstructDecay('Z0:mm_rec -> mu+:z0 mu-:z0', '9.0 < M < 11.0', path=mypath)
47reconstructDecay('Z0:mm_kinfit -> mu+:z0fit mu-:z0fit', '9.0 < M < 11.0', path=mypath)
48
49# MC truth matching
50matchMCTruth('Z0:mm_rec', path=mypath)
51matchMCTruth('Z0:mm_kinfit', path=mypath)
52
53# kinematic 1C hard fit
54UnmeasuredfitKinematic1C('Z0:mm_kinfit', path=mypath)
55
56# Select variables that we want to store to ntuple
57
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 + \
63 ['OrcaKinFitProb',
64 'OrcaKinFitChi2',
65 'OrcaKinFitErrorCode',
66 'OrcaKinFitUnmeasuredTheta',
67 'OrcaKinFitUnmeasuredPhi',
68 'OrcaKinFitUnmeasuredE'
69 ]
70
71# Saving variables to ntuple
72output_file = 'B2A421-Orcakinfit_1CFit.root'
73variablesToNtuple('Z0:mm_rec', z0vars,
74 filename=output_file, treename='Z0_mm_rec', path=mypath)
75variablesToNtuple('Z0:mm_kinfit', z0uvars,
76 filename=output_file, treename='Z0_mm_kinfit', path=mypath)
77
78
79# Process the events
80b2.process(mypath)
81
82# print out the summary
83print(b2.statistics)