Belle II Software development
B2A410-TagVertex.py
1#!/usr/bin/env python3
2
3
10
11
30
31import basf2 as b2
32from modularAnalysis import inputMdst
33from modularAnalysis import reconstructDecay
34from modularAnalysis import matchMCTruth
35from vertex import raveFit
36from modularAnalysis import buildRestOfEvent
37from modularAnalysis import fillParticleList
38from vertex import TagV
39from stdCharged import stdMu
40import variables.collections as vc
41import variables.utils as vu
42from modularAnalysis import variablesToNtuple
43
44# Add signal MC files for release 9.
45# 150000 events!
46# Consider using -n flag in command line to limit number of events, e.g.:
47# > basf2 B2A410-TagVertex.py -n 1000
48
49# create path
50my_path = b2.create_path()
51
52# load input ROOT file
53inputMdst(filename=b2.find_file('B02JpsiKs_Jpsi2mumu_Ks2pipi.root', 'examples', False),
54 path=my_path)
55
56# use standard final state particle lists
57#
58# creates "mu+:loose" ParticleList (and c.c.)
59stdMu('loose', path=my_path)
60
61# create Ks -> pi+ pi- list from V0
62# keep only candidates with 0.4 < M(pipi) < 0.6 GeV
63fillParticleList('K_S0:pipi -> pi+ pi-', '0.4 < M < 0.6', path=my_path)
64
65# reconstruct J/psi -> mu+ mu- decay
66# keep only candidates with 3.0 < M(mumu) < 3.2 GeV
67reconstructDecay('J/psi:mumu -> mu+:loose mu-:loose', '3.0 < M < 3.2', path=my_path)
68
69# reconstruct B0 -> J/psi Ks decay
70# keep only candidates with 5.2 < M(J/PsiKs) < 5.4 GeV
71reconstructDecay('B0:jpsiks -> J/psi:mumu K_S0:pipi', '5.2 < M < 5.4', path=my_path)
72
73# perform MC matching (MC truth association). Always before TagV
74matchMCTruth('B0:jpsiks', path=my_path)
75
76# perform B0 kinematic vertex fit using only the mu+ mu-
77# keep candidates only passing C.L. value of the fit > 0.0 (no cut)
78raveFit('B0:jpsiks', 0.0, decay_string='B0 -> [J/psi -> ^mu+ ^mu-] K_S0', path=my_path)
79
80# build the rest of the event associated to the B0
81buildRestOfEvent('B0:jpsiks', path=my_path)
82
83# calculate the Tag Vertex and Delta t (in ps)
84# breco: type of MC association.
85TagV('B0:jpsiks', 'breco', path=my_path)
86
87# Select variables that we want to store to ntuple
88
89fshars = vc.pid + vc.track + vc.mc_truth
90jpsiandk0svars = vc.inv_mass + vc.vertex + vc.mc_vertex + vc.mc_truth
91bvars = vc.inv_mass + vc.deltae_mbc + \
92 vc.vertex + vc.mc_vertex + vc.mc_truth + vc.tag_vertex + vc.tag_vertex + \
93 vc.mc_tag_vertex + \
94 vu.create_aliases_for_selected(fshars, 'B0 -> [J/psi -> ^mu+ ^mu-] [K_S0 -> ^pi+ ^pi-]') + \
95 vu.create_aliases_for_selected(jpsiandk0svars, 'B0 -> [^J/psi -> mu+ mu-] [^K_S0 -> pi+ pi-]')
96
97
98# Saving variables to ntuple
99output_file = 'B2A410-TagVertex.root'
100variablesToNtuple('B0:jpsiks', bvars,
101 filename=output_file, treename='B0tree', path=my_path)
102
103
104# Process the events
105b2.process(my_path)
106
107# print out the summary
108print(b2.statistics)