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