Belle II Software  release-08-01-10
B2A410-TagVertex.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
30 
31 import basf2 as b2
32 from modularAnalysis import inputMdst
33 from modularAnalysis import reconstructDecay
34 from modularAnalysis import matchMCTruth
35 from vertex import raveFit
36 from modularAnalysis import buildRestOfEvent
37 from modularAnalysis import fillParticleList
38 from vertex import TagV
39 from stdCharged import stdMu
40 import variables.collections as vc
41 import variables.utils as vu
42 from 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
50 my_path = b2.create_path()
51 
52 # load input ROOT file
53 inputMdst(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.)
59 stdMu('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
63 fillParticleList('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
67 reconstructDecay('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
71 reconstructDecay('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
74 matchMCTruth('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)
78 raveFit('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
81 buildRestOfEvent('B0:jpsiks', path=my_path)
82 
83 # calculate the Tag Vertex and Delta t (in ps)
84 # breco: type of MC association.
85 TagV('B0:jpsiks', 'breco', path=my_path)
86 
87 # Select variables that we want to store to ntuple
88 
89 fshars = vc.pid + vc.track + vc.mc_truth
90 jpsiandk0svars = vc.inv_mass + vc.vertex + vc.mc_vertex + vc.mc_truth
91 bvars = 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
99 output_file = 'B2A410-TagVertex.root'
100 variablesToNtuple('B0:jpsiks', bvars,
101  filename=output_file, treename='B0tree', path=my_path)
102 
103 
104 # Process the events
105 b2.process(my_path)
106 
107 # print out the summary
108 print(b2.statistics)