Belle II Software development
B2A409-KFit-SmearedIPtube.py
1#!/usr/bin/env python3
2
3
10
11
29
30import basf2 as b2
31from modularAnalysis import inputMdst
32from modularAnalysis import reconstructDecay
33from modularAnalysis import matchMCTruth
34from vertex import kFit
35from stdCharged import stdMu
36from stdV0s import stdKshorts
37from modularAnalysis import variablesToNtuple
38import variables.collections as vc
39
40# create path
41my_path = b2.create_path()
42
43# load input ROOT file
44inputMdst(filename=b2.find_file('B02JpsiKs_Jpsi2mumu_Ks2pipi.root', 'examples', False),
45 path=my_path)
46
47# creates "mu+:all" ParticleList (and c.c.)
48stdMu('all', path=my_path)
49# creates "K_S0:merged" ParticleList
50stdKshorts(path=my_path)
51
52# reconstruct J/psi -> mu- mu+ decay
53reconstructDecay('J/psi:mm -> mu-:all mu+:all', cut='3.05<M<3.15', path=my_path)
54
55# reconstruct B0 -> J/psi K_S0 decay
56# create two lists for comparison
57reconstructDecay('B0:iptube -> J/psi:mm K_S0:merged', cut='5.27<Mbc<5.29 and abs(deltaE)<0.1', path=my_path)
58reconstructDecay('B0:iptube20um -> J/psi:mm K_S0:merged', cut='5.27<Mbc<5.29 and abs(deltaE)<0.1', path=my_path)
59
60# perform B0 vertex fit using only muons from J/psi
61# fit one list with iptube constraint, the other with smeared iptube constraint.
62kFit('B0:iptube', 0.0, 'vertex', constraint='iptube', decay_string='B0 -> [J/psi -> ^mu- ^mu+] K_S0', smearing=0.0, path=my_path)
63kFit(
64 'B0:iptube20um',
65 0.0,
66 'vertex',
67 constraint='iptube',
68 decay_string='B0 -> [J/psi -> ^mu- ^mu+] K_S0',
69 smearing=0.002,
70 path=my_path)
71
72# perform MC matching (MC truth association)
73matchMCTruth('B0:iptube', path=my_path)
74matchMCTruth('B0:iptube20um', path=my_path)
75
76# Select variables that we want to store to ntuple
77B0_vars = vc.mc_truth + vc.vertex + vc.mc_vertex
78
79# Saving variables to ntuple
80output_file = 'B2A409-KFit-SmearedIPtube.root'
81variablesToNtuple('B0:iptube', B0_vars,
82 filename=output_file, treename='B0tree_noSmear', path=my_path)
83variablesToNtuple('B0:iptube20um', B0_vars,
84 filename=output_file, treename='B0tree_smear20um', path=my_path)
85
86# Process the events
87b2.process(my_path)
88
89# print out the summary
90print(b2.statistics)