Belle II Software  release-06-00-14
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(environmentType='default',
54  filename=b2.find_file('B02JpsiKs_Jpsi2mumu_Ks2pipi.root', 'examples', False),
55  path=my_path)
56 
57 # use standard final state particle lists
58 #
59 # creates "mu+:loose" ParticleList (and c.c.)
60 stdMu('loose', path=my_path)
61 
62 # create Ks -> pi+ pi- list from V0
63 # keep only candidates with 0.4 < M(pipi) < 0.6 GeV
64 fillParticleList('K_S0:pipi -> pi+ pi-', '0.4 < M < 0.6', path=my_path)
65 
66 # reconstruct J/psi -> mu+ mu- decay
67 # keep only candidates with 3.0 < M(mumu) < 3.2 GeV
68 reconstructDecay('J/psi:mumu -> mu+:loose mu-:loose', '3.0 < M < 3.2', path=my_path)
69 
70 # reconstruct B0 -> J/psi Ks decay
71 # keep only candidates with 5.2 < M(J/PsiKs) < 5.4 GeV
72 reconstructDecay('B0:jpsiks -> J/psi:mumu K_S0:pipi', '5.2 < M < 5.4', path=my_path)
73 
74 # perform MC matching (MC truth association). Always before TagV
75 matchMCTruth('B0:jpsiks', path=my_path)
76 
77 # perform B0 kinematic vertex fit using only the mu+ mu-
78 # keep candidates only passing C.L. value of the fit > 0.0 (no cut)
79 raveFit('B0:jpsiks', 0.0, decay_string='B0 -> [J/psi -> ^mu+ ^mu-] K_S0', path=my_path)
80 
81 # build the rest of the event associated to the B0
82 buildRestOfEvent('B0:jpsiks', path=my_path)
83 
84 # calculate the Tag Vertex and Delta t (in ps)
85 # breco: type of MC association.
86 TagV('B0:jpsiks', 'breco', path=my_path)
87 
88 # Select variables that we want to store to ntuple
89 
90 fshars = vc.pid + vc.track + vc.mc_truth
91 jpsiandk0svars = vc.inv_mass + vc.vertex + vc.mc_vertex + vc.mc_truth
92 bvars = vc.inv_mass + vc.deltae_mbc + \
93  vc.vertex + vc.mc_vertex + vc.mc_truth + vc.tag_vertex + vc.tag_vertex + \
94  vc.mc_tag_vertex + \
95  vu.create_aliases_for_selected(fshars, 'B0 -> [J/psi -> ^mu+ ^mu-] [K_S0 -> ^pi+ ^pi-]') + \
96  vu.create_aliases_for_selected(jpsiandk0svars, 'B0 -> [^J/psi -> mu+ mu-] [^K_S0 -> pi+ pi-]')
97 
98 
99 # Saving variables to ntuple
100 output_file = 'B2A410-TagVertex.root'
101 variablesToNtuple('B0:jpsiks', bvars,
102  filename=output_file, treename='B0tree', path=my_path)
103 
104 
105 # Process the events
106 b2.process(my_path)
107 
108 # print out the summary
109 print(b2.statistics)