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