Belle II Software  release-06-00-14
B2A203-LoadV0s.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
28 
29 import basf2 as b2
30 import modularAnalysis as ma
31 import variables.collections as vc
32 import variables.utils as vu
33 import stdV0s as stdv
34 
35 # create path
36 my_path = b2.create_path()
37 
38 # load input ROOT file
39 ma.inputMdst(environmentType='default',
40  filename=b2.find_file('B2pi0D_D2hh_D2hhh_B2munu.root', 'examples', False),
41  path=my_path)
42 
43 # print contents of the DataStore before loading Particles
44 ma.printDataStore(path=my_path)
45 
46 # The recommended way to create and fill Ks/Lambda0 ParticleLists is to use
47 # the default functions provided in analysis/scripts/stdV0s.py
48 # These functions load a combined list of V0 objects merged with
49 # a list of particles combined using the analysis ParticleCombiner module.
50 # See the script (analysis/scripts/stdV0s.py) for more details.
51 stdv.stdKshorts(prioritiseV0=True, path=my_path)
52 stdv.stdLambdas(prioritiseV0=True, path=my_path)
53 
54 # print contents of the DataStore after loading Particles
55 ma.printDataStore(path=my_path)
56 
57 # print out the contents of each ParticleList
58 ma.printList(list_name='K_S0:merged', full=False, path=my_path)
59 ma.printList(list_name='Lambda0:merged', full=False, path=my_path)
60 
61 # define variables
62 pi0_vars = vc.kinematics + \
63  vc.pid + \
64  vc.track + \
65  vc.track_hits + \
66  vc.mc_truth
67 
68 v0_vars = vc.kinematics + \
69  vc.inv_mass + \
70  vc.vertex + \
71  vc.mc_truth + \
72  ['chiProb'] + \
73  vu.create_daughter_aliases(pi0_vars, 0) +\
74  vu.create_daughter_aliases(pi0_vars, 1)
75 
76 
77 # saving variables to ntuple
78 rootOutputFile = 'B2A203-LoadV0s.root'
79 
80 # K_S0 from standard list (merged list, see stdV0s.py)
81 ma.variablesToNtuple(treename='kshort_std',
82  decayString='K_S0:merged',
83  variables=v0_vars,
84  filename=rootOutputFile,
85  path=my_path)
86 
87 # Lambda0 from standard list (merged list, see stdV0s.py)
88 ma.variablesToNtuple(treename='lambda_std',
89  decayString='Lambda0:merged',
90  variables=v0_vars,
91  filename=rootOutputFile,
92  path=my_path)
93 
94 
95 b2.process(my_path)
96 
97 # print out the summary
98 print(b2.statistics)