Belle II Software light-2406-ragdoll
loadNonStandardV0s.py
1#!/usr/bin/env python3
2
3
10
11
34
35import basf2 as b2
36import modularAnalysis as ma
37import variables.collections as vc
38import variables.utils as vu
39import vertex as vtx
40
41# create path
42my_path = b2.create_path()
43
44# load input ROOT file
45ma.inputMdst(filename=b2.find_file('B2pi0D_D2hh_D2hhh_B2munu.root', 'examples', False),
46 path=my_path)
47
48# print contents of the DataStore before loading Particles
49ma.printDataStore(path=my_path)
50
51# this is an example of how create and fill Ks/Lambda0 ParticleLists, using V0s as source
52# second argument are the selection criteria: '' means no cut, take all
53# the decay chain has to be specified (i.e. the two daughters, as well)
54# A vertex fit should also be performed
55# In this example a cut on the candidates' mass is applied
56ma.fillParticleList(decayString='K_S0:v0 -> pi+ pi-', cut='0.3 < M < 0.7', path=my_path)
57vtx.treeFit(list_name='K_S0:v0', conf_level=0.0, path=my_path)
58ma.fillParticleList(decayString='Lambda0:v0 -> p+ pi-', cut='0.9 < M < 1.3', path=my_path)
59vtx.treeFit(list_name='Lambda0:v0', conf_level=0.0, path=my_path)
60
61# alternatively, we can create a list of particles combined
62# using the analysis ParticleCombiner module
63# Before doing it we need to create and fill ParticleLists
64# of the V0s' daughters (anti-particle lists are automatically
65# created, too)
66# A vertex fit should also be performed
67# In this example a cut on the candidates' mass is applied
68ma.fillParticleList(decayString='pi-:all', cut='', path=my_path)
69ma.fillParticleList(decayString='p+:all', cut='', path=my_path)
70
71ma.reconstructDecay(decayString='K_S0:RD -> pi+:all pi-:all', cut='0.3 < M < 0.7', path=my_path)
72vtx.treeFit(list_name='K_S0:RD', conf_level=0.0, path=my_path)
73ma.reconstructDecay(decayString='Lambda0:RD -> p+:all pi-:all', cut='0.9 < M < 1.3', path=my_path)
74vtx.treeFit(list_name='Lambda0:RD', conf_level=0.0, path=my_path)
75
76# print contents of the DataStore after loading Particles
77ma.printDataStore(path=my_path)
78
79# print out the contents of each ParticleList
80ma.printList(list_name='K_S0:v0', full=False, path=my_path)
81ma.printList(list_name='Lambda0:v0', full=False, path=my_path)
82
83ma.printList(list_name='K_S0:RD', full=False, path=my_path)
84ma.printList(list_name='Lambda0:RD', full=False, path=my_path)
85
86# define variables
87pi0_vars = vc.kinematics + \
88 vc.pid + \
89 vc.track + \
90 vc.track_hits + \
91 vc.mc_truth
92
93v0_vars = vc.kinematics + \
94 vc.inv_mass + \
95 vc.vertex +\
96 vc.mc_truth + \
97 ['chiProb'] +\
98 vu.create_daughter_aliases(pi0_vars, 0) +\
99 vu.create_daughter_aliases(pi0_vars, 1)
100
101
102# saving variables to ntuple
103rootOutputFile = 'B2A205-LoadV0s_expert.root'
104
105# K_S0 from V0s
106ma.variablesToNtuple(treename='kshort_v0',
107 decayString='K_S0:v0',
108 variables=v0_vars,
109 filename=rootOutputFile,
110 path=my_path)
111
112# K_S0 from reconstructDecay
113ma.variablesToNtuple(treename='kshort_rd',
114 decayString='K_S0:RD',
115 variables=v0_vars,
116 filename=rootOutputFile,
117 path=my_path)
118
119# Lambda0 from V0s
120ma.variablesToNtuple(treename='lambda_v0',
121 decayString='Lambda0:v0',
122 variables=v0_vars,
123 filename=rootOutputFile,
124 path=my_path)
125
126# Lambda0 from reconstructDecay
127ma.variablesToNtuple(treename='lambda_rd',
128 decayString='Lambda0:RD',
129 variables=v0_vars,
130 filename=rootOutputFile,
131 path=my_path)
132
133b2.process(my_path)
134
135# print out the summary
136print(b2.statistics)