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