Belle II Software  release-06-01-15
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  B2WARNING("stdPi0s is loading \"May2020\" pi0 recommendations. Please check Neutrals Performance Confluence"
40  " page for most up-to-date pi0 recommendations.")
41 
42  if listtype == 'all':
43  stdPhotons('all', path, loadPhotonBeamBackgroundMVA)
44  ma.reconstructDecay('pi0:all -> gamma:all gamma:all', '', 1, True, path)
45  ma.matchMCTruth('pi0:all', path)
46  elif 'eff10_May2020' == listtype:
47  stdPhotons('pi0eff10_May2020', path, loadPhotonBeamBackgroundMVA)
48  ma.reconstructDecay('pi0:eff10_May2020 -> gamma:pi0eff10_May2020 gamma:pi0eff10_May2020',
49  '0.127<InvM<0.139 and -0.9<daughterDiffOf(0,1,phi)<0.9 and daughterAngle(0,1)<0.8',
50  1,
51  True,
52  path)
53  ma.matchMCTruth('pi0:eff10_May2020', path)
54  elif 'eff20_May2020' == listtype:
55  stdPhotons('pi0eff20_May2020', path, loadPhotonBeamBackgroundMVA)
56  ma.reconstructDecay('pi0:eff20_May2020 -> gamma:pi0eff20_May2020 gamma:pi0eff20_May2020',
57  '0.121<InvM<0.142 and -1.0<daughterDiffOf(0,1,phi)<1.0 and daughterAngle(0,1)<0.9',
58  1,
59  True,
60  path)
61  ma.matchMCTruth('pi0:eff20_May2020', path)
62  elif 'eff30_May2020' == listtype:
63  stdPhotons('pi0eff30_May2020', path, loadPhotonBeamBackgroundMVA)
64  ma.reconstructDecay('pi0:eff30_May2020 -> gamma:pi0eff30_May2020 gamma:pi0eff30_May2020',
65  '0.120<InvM<0.145 and -1.5<daughterDiffOf(0,1,phi)<1.5 and daughterAngle(0,1)<1.4',
66  1,
67  True,
68  path)
69  ma.matchMCTruth('pi0:eff30_May2020', path)
70  elif 'eff40_May2020' == listtype:
71  stdPhotons('pi0eff40_May2020', path, loadPhotonBeamBackgroundMVA)
72  ma.reconstructDecay('pi0:eff40_May2020 -> gamma:pi0eff40_May2020 gamma:pi0eff40_May2020', '0.120<InvM<0.145', 1, True, path)
73  ma.matchMCTruth('pi0:eff40_May2020', path)
74  elif 'eff50_May2020_nomcmatch' == listtype:
75  stdPhotons('pi0eff50_May2020', path, loadPhotonBeamBackgroundMVA)
76  ma.reconstructDecay(
77  'pi0:eff50_May2020_nomcmatch -> gamma:pi0eff50_May2020 gamma:pi0eff50_May2020',
78  '0.105<InvM<0.150',
79  1,
80  True,
81  path)
82  elif 'eff50_May2020' == listtype:
83  stdPi0s('eff50_May2020_nomcmatch', path, loadPhotonBeamBackgroundMVA)
84  ma.cutAndCopyList('pi0:eff50_May2020', 'pi0:eff50_May2020_nomcmatch', '', True, path)
85  ma.matchMCTruth('pi0:eff50_May2020', path)
86  elif 'eff60_May2020_nomcmatch' == listtype:
87  stdPhotons('pi0eff60_May2020', path, loadPhotonBeamBackgroundMVA)
88  ma.reconstructDecay(
89  'pi0:eff60_May2020_nomcmatch -> gamma:pi0eff60_May2020 gamma:pi0eff60_May2020',
90  '0.03<InvM',
91  1,
92  True,
93  path)
94  elif 'eff60_May2020' == listtype:
95  stdPi0s('eff60_May2020_nomcmatch', path, loadPhotonBeamBackgroundMVA)
96  ma.cutAndCopyList('pi0:eff60_May2020', 'pi0:eff60_May2020_nomcmatch', '', True, path)
97  ma.matchMCTruth('pi0:eff60_May2020', path)
98 
99  # skim list(s)
100  elif listtype == 'skim':
101  stdPi0s('eff50_May2020_nomcmatch', path, loadPhotonBeamBackgroundMVA)
102  ma.cutAndCopyList('pi0:skim', 'pi0:eff50_May2020_nomcmatch', '', True, path)
103  kFit('pi0:skim', 0.0, 'mass', path=path)
104  elif listtype == 'SkimHighEff':
105  stdPi0s('eff60_May2020_nomcmatch', path, loadPhotonBeamBackgroundMVA)
106  ma.cutAndCopyList('pi0:SkimHighEff', 'pi0:eff60_May2020_nomcmatch', '', True, path)
107  kFit('pi0:SkimHighEff', 0.0, 'mass', path=path)
108 
109  # same lists with, but with mass constraints fits
110  elif listtype == 'allFit':
111  stdPi0s('all', path, loadPhotonBeamBackgroundMVA)
112  ma.cutAndCopyList('pi0:allFit', 'pi0:all', '', True, path)
113  kFit('pi0:allFit', 0.0, 'mass', path=path)
114  elif listtype == 'eff10_May2020Fit':
115  stdPi0s('eff10_May2020', path, loadPhotonBeamBackgroundMVA)
116  ma.cutAndCopyList('pi0:eff10_May2020Fit', 'pi0:eff10_May2020', '', True, path)
117  kFit('pi0:eff10_May2020Fit', 0.0, 'mass', path=path)
118  elif listtype == 'eff20_May2020Fit':
119  stdPi0s('eff20_May2020', path, loadPhotonBeamBackgroundMVA)
120  ma.cutAndCopyList('pi0:eff20_May2020Fit', 'pi0:eff20_May2020', '', True, path)
121  kFit('pi0:eff20_May2020Fit', 0.0, 'mass', path=path)
122  elif listtype == 'eff30_May2020Fit':
123  stdPi0s('eff30_May2020', path, loadPhotonBeamBackgroundMVA)
124  ma.cutAndCopyList('pi0:eff30_May2020Fit', 'pi0:eff30_May2020', '', True, path)
125  kFit('pi0:eff30_May2020Fit', 0.0, 'mass', path=path)
126  elif listtype == 'eff40_May2020Fit':
127  stdPi0s('eff40_May2020', path, loadPhotonBeamBackgroundMVA)
128  ma.cutAndCopyList('pi0:eff40_May2020Fit', 'pi0:eff40_May2020', '', True, path)
129  kFit('pi0:eff40_May2020Fit', 0.0, 'mass', path=path)
130  elif listtype == 'eff50_May2020Fit':
131  stdPi0s('eff50_May2020', path, loadPhotonBeamBackgroundMVA)
132  ma.cutAndCopyList('pi0:eff50_May2020Fit', 'pi0:eff50_May2020', '', True, path)
133  kFit('pi0:eff50_May2020Fit', 0.0, 'mass', path=path)
134  elif listtype == 'eff60_May2020Fit':
135  stdPi0s('eff60_May2020', path, loadPhotonBeamBackgroundMVA)
136  ma.cutAndCopyList('pi0:eff60_May2020Fit', 'pi0:eff60_May2020', '', True, path)
137  kFit('pi0:eff60_May2020Fit', 0.0, 'mass', path=path)
138  else:
139  raise ValueError(f"\"{listtype}\" is none of the allowed standardized types of pi0 lists!")
140 
141 # pi0 list(s) for skims (and ONLY for skims)
142 
143 
144 def loadStdSkimPi0(path):
145  """
146  Function to prepare the skim pi0 lists.
147 
148  Warning:
149  Should only be used by skims.
150 
151  Parameters:
152  path (basf2.Path) modules are added to this path
153 
154  """
155  stdPi0s('skim', path, loadPhotonBeamBackgroundMVA=False)
156 
157 
158 def loadStdSkimHighEffPi0(path):
159  """
160  Function to prepare the high-efficiency skim pi0 lists based on eff60_May2020 list.
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('SkimHighEff', path, loadPhotonBeamBackgroundMVA=False)