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