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