Belle II Software development
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
38# Input file(s).
39inputMdst(filename=b2.find_file('darkphotonmumu_mdst.root', 'examples', False),
40 path=mypath)
41
42# Creates a list of photons
43stdPhotons('loose', path=mypath)
44
45# use standard final state particle lists for muons
46fillParticleList('mu-:A', 'chiProb > 0.001 and p > 1.0', path=mypath)
47
48# reconstruct A -> mu+ mu-
49pdg.add_particle('A', 9000008, 999., 999., 0, 0) # name, PDG, mass, width, charge, spin
50reconstructDecay('A:mm -> mu+:A mu-:A', '', path=mypath)
51
52pdg.add_particle('beam', 9000009, 999., 999., 0, 0) # name, PDG, mass, width, charge, spin
53reconstructDecay("beam:rec -> gamma:loose A:mm", "", path=mypath)
54reconstructDecay("beam:kinfit -> gamma:loose A:mm", "", path=mypath)
55
56# MC truth matching
57matchMCTruth('beam:rec', path=mypath)
58matchMCTruth('beam:kinfit', path=mypath)
59
60# kinematic 3C hard fit
61fitKinematic3C('beam:kinfit', path=mypath)
62
63# Select variables that we want to store to ntuple
64
65mugvars = vc.inv_mass + vc.kinematics + vc.mc_truth + vc.mc_kinematics + vc.momentum_uncertainty
66Avars = vc.inv_mass + vc.kinematics + vc.mc_kinematics + vc.mc_truth + \
67 vu.create_aliases_for_selected(mugvars, 'beam -> ^gamma [^A -> ^mu+ ^mu-]')
68
69Auvars = Avars + ['OrcaKinFitProb', 'OrcaKinFitChi2', 'OrcaKinFitErrorCode']
70
71# Saving variables to ntuple
72output_file = 'B2A422-Orcakinfit_3CFit.root'
73variablesToNtuple('beam:rec', Avars,
74 filename=output_file, treename='A_mm_rec', path=mypath)
75variablesToNtuple('beam:kinfit', Auvars,
76 filename=output_file, treename='A_mm_kinfit', path=mypath)
77
78# Process the events
79b2.process(mypath)
80
81# print out the summary
82print(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