Belle II Software development
stdPi0s.py
1#!/usr/bin/env python3
2
3
10
11import modularAnalysis as ma
12from stdPhotons import stdPhotons
13from vertex import kFit
14from basf2 import B2WARNING
15
16
17def stdPi0s(
18 listtype="eff60_May2020",
19 path=None,
20 beamBackgroundMVAWeight="",
21 fakePhotonMVAWeight="",
22 biasCorrectionTable="",
23 writeOut=True
24 ):
25 """
26 Function to prepare one of several standardized types of pi0 lists:
27
28 - 'all' using gamma:all
29 - 'eff10_May2020' gamma:pi0eff10_May2020, mass range selection, 10% pi0 efficiency list, optimized in May 2020
30 - 'eff20_May2020' gamma:pi0eff20_May2020, mass range selection, 20% pi0 efficiency list, optimized in May 2020
31 - 'eff30_May2020' gamma:pi0eff30_May2020, mass range selection, 30% pi0 efficiency list, optimized in May 2020
32 - 'eff40_May2020' gamma:pi0eff40_May2020, mass range selection, 40% pi0 efficiency list, optimized in May 2020
33 - 'eff50_May2020' gamma:pi0eff50_May2020, mass range selection, 50% pi0 efficiency list, optimized in May 2020
34 - 'eff60_May2020' gamma:pi0eff60_May2020, mass range selection, 60% pi0 efficiency list, optimized in May 2020
35
36 You can also append "Fit" to the listtype which will run a mass fit and
37 require that the fit did not fail. For example: "pi0:eff50_May2020Fit" is the 50%
38 efficiency list plus a not-failing mass fit.
39
40 Parameters:
41 listtype (str): name of standard list
42 path (basf2.Path): modules are added to this path
43 beamBackgroundMVAWeight (str): type of weight file for beam background MVA; if empty, beam background MVA will not be used
44
45 .. tip::
46 Please refer to the
47 `Performance Recommendations <https://belle2.pages.desy.de/performance/recommendations/>`_
48 for information on the beam background MVA.
49
50 fakePhotonMVAWeight (str): type of weight file for fake photon MVA; if empty, fake photon MVA will not be used
51
52 .. tip::
53 Please refer to the
54 `Performance Recommendations <https://belle2.pages.desy.de/performance/recommendations/>`_
55 for information on the fake photon MVA.
56
57 biasCorrectionTable (str): correction table for the photon energy bias correction (should only be applied to data)
58
59 .. tip::
60 Please refer to the
61 `Performance Recommendations <https://belle2.pages.desy.de/performance/recommendations/>`_
62 for information on the names of available correction tables.
63
64 writeOut (bool): whether RootOutput module should save the created ParticleList
65
66 """
67
68 if listtype != 'all':
69 B2WARNING("stdPi0s is loading \"May2020\" pi0 recommendations. Please check Neutrals Performance XWiki"
70 " page for most up-to-date pi0 recommendations.")
71
72 if listtype == 'all':
73 stdPhotons('all', path, beamBackgroundMVAWeight, fakePhotonMVAWeight, biasCorrectionTable)
74 ma.reconstructDecay('pi0:all -> gamma:all gamma:all', '', 1, writeOut=writeOut, path=path)
75 ma.matchMCTruth('pi0:all', path)
76 elif 'eff10_May2020' == listtype:
77 stdPhotons('pi0eff10_May2020', path, beamBackgroundMVAWeight, fakePhotonMVAWeight, biasCorrectionTable)
78 ma.reconstructDecay('pi0:eff10_May2020 -> gamma:pi0eff10_May2020 gamma:pi0eff10_May2020',
79 '0.127<InvM<0.139 and -0.9<daughterDiffOf(0,1,phi)<0.9 and daughterAngle(0,1)<0.8',
80 1,
81 writeOut=writeOut,
82 path=path)
83 ma.matchMCTruth('pi0:eff10_May2020', path)
84 elif 'eff20_May2020' == listtype:
85 stdPhotons('pi0eff20_May2020', path, beamBackgroundMVAWeight, fakePhotonMVAWeight, biasCorrectionTable)
86 ma.reconstructDecay('pi0:eff20_May2020 -> gamma:pi0eff20_May2020 gamma:pi0eff20_May2020',
87 '0.121<InvM<0.142 and -1.0<daughterDiffOf(0,1,phi)<1.0 and daughterAngle(0,1)<0.9',
88 1,
89 writeOut=writeOut,
90 path=path)
91 ma.matchMCTruth('pi0:eff20_May2020', path)
92 elif 'eff30_May2020' == listtype:
93 stdPhotons('pi0eff30_May2020', path, beamBackgroundMVAWeight, fakePhotonMVAWeight, biasCorrectionTable)
94 ma.reconstructDecay('pi0:eff30_May2020 -> gamma:pi0eff30_May2020 gamma:pi0eff30_May2020',
95 '0.120<InvM<0.145 and -1.5<daughterDiffOf(0,1,phi)<1.5 and daughterAngle(0,1)<1.4',
96 1,
97 writeOut=writeOut,
98 path=path)
99 ma.matchMCTruth('pi0:eff30_May2020', path)
100 elif 'eff40_May2020' == listtype:
101 stdPhotons('pi0eff40_May2020', path, beamBackgroundMVAWeight, fakePhotonMVAWeight, biasCorrectionTable)
102 ma.reconstructDecay('pi0:eff40_May2020 -> gamma:pi0eff40_May2020 gamma:pi0eff40_May2020',
103 '0.120<InvM<0.145', 1, writeOut=writeOut, path=path)
104 ma.matchMCTruth('pi0:eff40_May2020', path)
105 elif 'eff50_May2020_nomcmatch' == listtype:
106 stdPhotons('pi0eff50_May2020', path, beamBackgroundMVAWeight, fakePhotonMVAWeight, biasCorrectionTable)
107 ma.reconstructDecay(
108 'pi0:eff50_May2020_nomcmatch -> gamma:pi0eff50_May2020 gamma:pi0eff50_May2020',
109 '0.105<InvM<0.150',
110 1,
111 writeOut=writeOut,
112 path=path)
113 elif 'eff50_May2020' == listtype:
114 stdPi0s('eff50_May2020_nomcmatch', path, beamBackgroundMVAWeight, fakePhotonMVAWeight)
115 ma.cutAndCopyList('pi0:eff50_May2020', 'pi0:eff50_May2020_nomcmatch', '', writeOut=writeOut, path=path)
116 ma.matchMCTruth('pi0:eff50_May2020', path)
117 elif 'eff60_May2020_nomcmatch' == listtype:
118 stdPhotons('pi0eff60_May2020', path, beamBackgroundMVAWeight, fakePhotonMVAWeight, biasCorrectionTable)
119 ma.reconstructDecay(
120 'pi0:eff60_May2020_nomcmatch -> gamma:pi0eff60_May2020 gamma:pi0eff60_May2020',
121 '0.03<InvM',
122 1,
123 writeOut=writeOut,
124 path=path)
125 elif 'eff60_May2020' == listtype:
126 stdPi0s('eff60_May2020_nomcmatch', path, beamBackgroundMVAWeight, fakePhotonMVAWeight)
127 ma.cutAndCopyList('pi0:eff60_May2020', 'pi0:eff60_May2020_nomcmatch', '', writeOut=writeOut, path=path)
128 ma.matchMCTruth('pi0:eff60_May2020', path)
129
130 # skim list(s)
131 elif listtype == 'skim':
132 stdPi0s('eff50_May2020_nomcmatch', path, beamBackgroundMVAWeight, fakePhotonMVAWeight)
133 ma.cutAndCopyList('pi0:skim', 'pi0:eff50_May2020_nomcmatch', '', writeOut=writeOut, path=path)
134 kFit('pi0:skim', 0.0, 'mass', path=path)
135 elif listtype == 'SkimHighEff':
136 stdPi0s('eff60_May2020_nomcmatch', path, beamBackgroundMVAWeight, fakePhotonMVAWeight)
137 ma.cutAndCopyList('pi0:SkimHighEff', 'pi0:eff60_May2020_nomcmatch', '', writeOut=writeOut, path=path)
138 kFit('pi0:SkimHighEff', 0.0, 'mass', path=path)
139
140 # same lists with, but with mass constraints fits
141 elif listtype == 'allFit':
142 stdPi0s('all', path, beamBackgroundMVAWeight, fakePhotonMVAWeight)
143 ma.cutAndCopyList('pi0:allFit', 'pi0:all', '', writeOut=writeOut, path=path)
144 kFit('pi0:allFit', 0.0, 'mass', path=path)
145 elif listtype == 'eff10_May2020Fit':
146 stdPi0s('eff10_May2020', path, beamBackgroundMVAWeight, fakePhotonMVAWeight)
147 ma.cutAndCopyList('pi0:eff10_May2020Fit', 'pi0:eff10_May2020', '', writeOut=writeOut, path=path)
148 kFit('pi0:eff10_May2020Fit', 0.0, 'mass', path=path)
149 elif listtype == 'eff20_May2020Fit':
150 stdPi0s('eff20_May2020', path, beamBackgroundMVAWeight, fakePhotonMVAWeight)
151 ma.cutAndCopyList('pi0:eff20_May2020Fit', 'pi0:eff20_May2020', '', writeOut=writeOut, path=path)
152 kFit('pi0:eff20_May2020Fit', 0.0, 'mass', path=path)
153 elif listtype == 'eff30_May2020Fit':
154 stdPi0s('eff30_May2020', path, beamBackgroundMVAWeight, fakePhotonMVAWeight)
155 ma.cutAndCopyList('pi0:eff30_May2020Fit', 'pi0:eff30_May2020', '', writeOut=writeOut, path=path)
156 kFit('pi0:eff30_May2020Fit', 0.0, 'mass', path=path)
157 elif listtype == 'eff40_May2020Fit':
158 stdPi0s('eff40_May2020', path, beamBackgroundMVAWeight, fakePhotonMVAWeight)
159 ma.cutAndCopyList('pi0:eff40_May2020Fit', 'pi0:eff40_May2020', '', writeOut=writeOut, path=path)
160 kFit('pi0:eff40_May2020Fit', 0.0, 'mass', path=path)
161 elif listtype == 'eff50_May2020Fit':
162 stdPi0s('eff50_May2020', path, beamBackgroundMVAWeight, fakePhotonMVAWeight)
163 ma.cutAndCopyList('pi0:eff50_May2020Fit', 'pi0:eff50_May2020', '', writeOut=writeOut, path=path)
164 kFit('pi0:eff50_May2020Fit', 0.0, 'mass', path=path)
165 elif listtype == 'eff60_May2020Fit':
166 stdPi0s('eff60_May2020', path, beamBackgroundMVAWeight, fakePhotonMVAWeight)
167 ma.cutAndCopyList('pi0:eff60_May2020Fit', 'pi0:eff60_May2020', '', writeOut=writeOut, path=path)
168 kFit('pi0:eff60_May2020Fit', 0.0, 'mass', path=path)
169 else:
170 raise ValueError(f"\"{listtype}\" is none of the allowed standardized types of pi0 lists!")
171
172# pi0 list(s) for skims (and ONLY for skims)
173
174
175def loadStdSkimPi0(path):
176 """
177 Function to prepare the skim pi0 lists.
178
179 Warning:
180 Should only be used by skims.
181
182 Parameters:
183 path (basf2.Path) modules are added to this path
184
185 """
186 stdPi0s('skim', path)
187
188
189def loadStdSkimHighEffPi0(path):
190 """
191 Function to prepare the high-efficiency skim pi0 lists based on eff60_May2020 list.
192
193 Warning:
194 Should only be used by skims.
195
196 Parameters:
197 path (basf2.Path) modules are added to this path
198
199 """
200 stdPi0s('SkimHighEff', path)