Belle II Software  release-08-01-10
B2A409-KFit-SmearedIPtube.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
29 
30 import basf2 as b2
31 from modularAnalysis import inputMdst
32 from modularAnalysis import reconstructDecay
33 from modularAnalysis import matchMCTruth
34 from vertex import kFit
35 from stdCharged import stdMu
36 from stdV0s import stdKshorts
37 from modularAnalysis import variablesToNtuple
38 import variables.collections as vc
39 
40 # create path
41 my_path = b2.create_path()
42 
43 # load input ROOT file
44 inputMdst(filename=b2.find_file('B02JpsiKs_Jpsi2mumu_Ks2pipi.root', 'examples', False),
45  path=my_path)
46 
47 # creates "mu+:all" ParticleList (and c.c.)
48 stdMu('all', path=my_path)
49 # creates "K_S0:merged" ParticleList
50 stdKshorts(path=my_path)
51 
52 # reconstruct J/psi -> mu- mu+ decay
53 reconstructDecay('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
57 reconstructDecay('B0:iptube -> J/psi:mm K_S0:merged', cut='5.27<Mbc<5.29 and abs(deltaE)<0.1', path=my_path)
58 reconstructDecay('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.
62 kFit('B0:iptube', 0.0, 'vertex', constraint='iptube', decay_string='B0 -> [J/psi -> ^mu- ^mu+] K_S0', smearing=0.0, path=my_path)
63 kFit(
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 asociation)
73 matchMCTruth('B0:iptube', path=my_path)
74 matchMCTruth('B0:iptube20um', path=my_path)
75 
76 # Select variables that we want to store to ntuple
77 B0_vars = vc.mc_truth + vc.vertex + vc.mc_vertex
78 
79 # Saving variables to ntuple
80 output_file = 'B2A409-KFit-SmearedIPtube.root'
81 variablesToNtuple('B0:iptube', B0_vars,
82  filename=output_file, treename='B0tree_noSmear', path=my_path)
83 variablesToNtuple('B0:iptube20um', B0_vars,
84  filename=output_file, treename='B0tree_smear20um', path=my_path)
85 
86 # Process the events
87 b2.process(my_path)
88 
89 # print out the summary
90 print(b2.statistics)