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