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