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