Belle II Software  light-2212-foldex
stdPi0s.py
1 #!/usr/bin/env python3
2 
3 
10 
11 import modularAnalysis as ma
12 from stdPhotons import stdPhotons
13 from vertex import kFit
14 from basf2 import B2WARNING
15 
16 
17 def stdPi0s(
18  listtype="eff60_May2020",
19  path=None,
20  loadPhotonBeamBackgroundMVA=False,
21  loadPhotonHadronicSplitOffMVA=False,
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  loadPhotonBeamBackgroundMVA (bool): If true, photon candidates will be assigned a beam background probability.
42  loadPhotonHadronicSplitOffMVA (bool): If true, photon candidates will be assigned a hadronic split-off probability.
43  biasCorrectionTable (str): correction table for the photon energy bias correction (should only be applied to data)
44 
45  .. tip::
46  Please refer to the
47  `Neutrals Performance Confluence page <https://confluence.desy.de/display/BI/Neutrals+Performance>`_
48  for information on the names of available correction tables..
49 
50  """
51 
52  if listtype != 'all':
53  B2WARNING("stdPi0s is loading \"May2020\" pi0 recommendations. Please check Neutrals Performance Confluence"
54  " page for most up-to-date pi0 recommendations.")
55 
56  if listtype == 'all':
57  stdPhotons('all', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA, biasCorrectionTable)
58  ma.reconstructDecay('pi0:all -> gamma:all gamma:all', '', 1, True, path)
59  ma.matchMCTruth('pi0:all', path)
60  elif 'eff10_May2020' == listtype:
61  stdPhotons('pi0eff10_May2020', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA, biasCorrectionTable)
62  ma.reconstructDecay('pi0:eff10_May2020 -> gamma:pi0eff10_May2020 gamma:pi0eff10_May2020',
63  '0.127<InvM<0.139 and -0.9<daughterDiffOf(0,1,phi)<0.9 and daughterAngle(0,1)<0.8',
64  1,
65  True,
66  path)
67  ma.matchMCTruth('pi0:eff10_May2020', path)
68  elif 'eff20_May2020' == listtype:
69  stdPhotons('pi0eff20_May2020', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA, biasCorrectionTable)
70  ma.reconstructDecay('pi0:eff20_May2020 -> gamma:pi0eff20_May2020 gamma:pi0eff20_May2020',
71  '0.121<InvM<0.142 and -1.0<daughterDiffOf(0,1,phi)<1.0 and daughterAngle(0,1)<0.9',
72  1,
73  True,
74  path)
75  ma.matchMCTruth('pi0:eff20_May2020', path)
76  elif 'eff30_May2020' == listtype:
77  stdPhotons('pi0eff30_May2020', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA, biasCorrectionTable)
78  ma.reconstructDecay('pi0:eff30_May2020 -> gamma:pi0eff30_May2020 gamma:pi0eff30_May2020',
79  '0.120<InvM<0.145 and -1.5<daughterDiffOf(0,1,phi)<1.5 and daughterAngle(0,1)<1.4',
80  1,
81  True,
82  path)
83  ma.matchMCTruth('pi0:eff30_May2020', path)
84  elif 'eff40_May2020' == listtype:
85  stdPhotons('pi0eff40_May2020', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA, biasCorrectionTable)
86  ma.reconstructDecay('pi0:eff40_May2020 -> gamma:pi0eff40_May2020 gamma:pi0eff40_May2020', '0.120<InvM<0.145', 1, True, path)
87  ma.matchMCTruth('pi0:eff40_May2020', path)
88  elif 'eff50_May2020_nomcmatch' == listtype:
89  stdPhotons('pi0eff50_May2020', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA, biasCorrectionTable)
90  ma.reconstructDecay(
91  'pi0:eff50_May2020_nomcmatch -> gamma:pi0eff50_May2020 gamma:pi0eff50_May2020',
92  '0.105<InvM<0.150',
93  1,
94  True,
95  path)
96  elif 'eff50_May2020' == listtype:
97  stdPi0s('eff50_May2020_nomcmatch', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA)
98  ma.cutAndCopyList('pi0:eff50_May2020', 'pi0:eff50_May2020_nomcmatch', '', True, path)
99  ma.matchMCTruth('pi0:eff50_May2020', path)
100  elif 'eff60_May2020_nomcmatch' == listtype:
101  stdPhotons('pi0eff60_May2020', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA, biasCorrectionTable)
102  ma.reconstructDecay(
103  'pi0:eff60_May2020_nomcmatch -> gamma:pi0eff60_May2020 gamma:pi0eff60_May2020',
104  '0.03<InvM',
105  1,
106  True,
107  path)
108  elif 'eff60_May2020' == listtype:
109  stdPi0s('eff60_May2020_nomcmatch', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA)
110  ma.cutAndCopyList('pi0:eff60_May2020', 'pi0:eff60_May2020_nomcmatch', '', True, path)
111  ma.matchMCTruth('pi0:eff60_May2020', path)
112 
113  # skim list(s)
114  elif listtype == 'skim':
115  stdPi0s('eff50_May2020_nomcmatch', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA)
116  ma.cutAndCopyList('pi0:skim', 'pi0:eff50_May2020_nomcmatch', '', True, path)
117  kFit('pi0:skim', 0.0, 'mass', path=path)
118  elif listtype == 'SkimHighEff':
119  stdPi0s('eff60_May2020_nomcmatch', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA)
120  ma.cutAndCopyList('pi0:SkimHighEff', 'pi0:eff60_May2020_nomcmatch', '', True, path)
121  kFit('pi0:SkimHighEff', 0.0, 'mass', path=path)
122 
123  # same lists with, but with mass constraints fits
124  elif listtype == 'allFit':
125  stdPi0s('all', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA)
126  ma.cutAndCopyList('pi0:allFit', 'pi0:all', '', True, path)
127  kFit('pi0:allFit', 0.0, 'mass', path=path)
128  elif listtype == 'eff10_May2020Fit':
129  stdPi0s('eff10_May2020', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA)
130  ma.cutAndCopyList('pi0:eff10_May2020Fit', 'pi0:eff10_May2020', '', True, path)
131  kFit('pi0:eff10_May2020Fit', 0.0, 'mass', path=path)
132  elif listtype == 'eff20_May2020Fit':
133  stdPi0s('eff20_May2020', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA)
134  ma.cutAndCopyList('pi0:eff20_May2020Fit', 'pi0:eff20_May2020', '', True, path)
135  kFit('pi0:eff20_May2020Fit', 0.0, 'mass', path=path)
136  elif listtype == 'eff30_May2020Fit':
137  stdPi0s('eff30_May2020', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA)
138  ma.cutAndCopyList('pi0:eff30_May2020Fit', 'pi0:eff30_May2020', '', True, path)
139  kFit('pi0:eff30_May2020Fit', 0.0, 'mass', path=path)
140  elif listtype == 'eff40_May2020Fit':
141  stdPi0s('eff40_May2020', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA)
142  ma.cutAndCopyList('pi0:eff40_May2020Fit', 'pi0:eff40_May2020', '', True, path)
143  kFit('pi0:eff40_May2020Fit', 0.0, 'mass', path=path)
144  elif listtype == 'eff50_May2020Fit':
145  stdPi0s('eff50_May2020', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA)
146  ma.cutAndCopyList('pi0:eff50_May2020Fit', 'pi0:eff50_May2020', '', True, path)
147  kFit('pi0:eff50_May2020Fit', 0.0, 'mass', path=path)
148  elif listtype == 'eff60_May2020Fit':
149  stdPi0s('eff60_May2020', path, loadPhotonBeamBackgroundMVA, loadPhotonHadronicSplitOffMVA)
150  ma.cutAndCopyList('pi0:eff60_May2020Fit', 'pi0:eff60_May2020', '', True, path)
151  kFit('pi0:eff60_May2020Fit', 0.0, 'mass', path=path)
152  else:
153  raise ValueError(f"\"{listtype}\" is none of the allowed standardized types of pi0 lists!")
154 
155 # pi0 list(s) for skims (and ONLY for skims)
156 
157 
158 def loadStdSkimPi0(path):
159  """
160  Function to prepare the skim pi0 lists.
161 
162  Warning:
163  Should only be used by skims.
164 
165  Parameters:
166  path (basf2.Path) modules are added to this path
167 
168  """
169  stdPi0s('skim', path)
170 
171 
172 def loadStdSkimHighEffPi0(path):
173  """
174  Function to prepare the high-efficiency skim pi0 lists based on eff60_May2020 list.
175 
176  Warning:
177  Should only be used by skims.
178 
179  Parameters:
180  path (basf2.Path) modules are added to this path
181 
182  """
183  stdPi0s('SkimHighEff', path)