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