Belle II Software light-2406-ragdoll
B2A422-OrcaKinFit_3CFit.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 fitKinematic3C
29from modularAnalysis import variablesToNtuple
30import variables.collections as vc
31import variables.utils as vu
32from stdPhotons import stdPhotons
33import pdg
34
35# create path
36mypath = b2.create_path()
37
38b2.set_log_level(b2.LogLevel.WARNING)
39
40# Input file(s).
41inputMdst(filename=b2.find_file('darkphotonmumu_mdst.root', 'examples', False),
42 path=mypath)
43
44# Creates a list of photons
45stdPhotons('loose', path=mypath)
46
47# use standard final state particle lists for muons
48fillParticleList('mu-:z0', 'chiProb > 0.001 and p > 1.0', path=mypath)
49
50# reconstruct Z -> mu+ mu-
51reconstructDecay('Z0:mm -> mu+:z0 mu-:z0', '', path=mypath)
52
53
54pdg.add_particle('beam', 9000009, 999., 999., 0, 0) # name, PDG, mass, width, charge, spin
55reconstructDecay("beam:rec -> gamma:loose Z0:mm", "", path=mypath)
56reconstructDecay("beam:kinfit -> gamma:loose Z0:mm", "", path=mypath)
57
58
59# MC truth matching
60matchMCTruth('beam:rec', path=mypath)
61matchMCTruth('beam:kinfit', path=mypath)
62
63# kinematic 3C hard fit
64fitKinematic3C('beam:kinfit', path=mypath)
65
66# Select variables that we want to store to ntuple
67
68mugvars = vc.inv_mass + vc.kinematics + vc.mc_truth + vc.mc_kinematics + vc.momentum_uncertainty
69z0vars = vc.inv_mass + vc.kinematics + vc.mc_kinematics + vc.mc_truth + \
70 vu.create_aliases_for_selected(mugvars, 'beam -> ^gamma [^Z0 -> ^mu+ ^mu-]')
71
72z0uvars = z0vars + ['OrcaKinFitProb', 'OrcaKinFitChi2', 'OrcaKinFitErrorCode']
73
74# Saving variables to ntuple
75output_file = 'B2A422-Orcakinfit_3CFit.root'
76variablesToNtuple('beam:rec', z0vars,
77 filename=output_file, treename='Z0_mm_rec', path=mypath)
78variablesToNtuple('beam:kinfit', z0uvars,
79 filename=output_file, treename='Z0_mm_kinfit', path=mypath)
80
81# Process the events
82b2.process(mypath)
83
84# print out the summary
85print(b2.statistics)
def add_particle(name, pdgCode, mass, width, charge, spin, max_width=None, lifetime=0, pythiaID=0, define_anti_particle=False)
Definition: pdg.py:135