Belle II Software  release-06-02-00
stdPhotons.py
1 #!/usr/bin/env python3
2 
3 
10 
11 from modularAnalysis import fillParticleList, cutAndCopyList
12 
13 
14 def stdPhotons(listtype='loose', path=None, loadPhotonBeamBackgroundMVA=False):
15  """
16  Function to prepare one of several standardized types of photon lists:
17 
18  - 'gamma:all' with no cuts this will be polluted by tracks from outside the acceptance
19  - 'gamma:cdc' all clusters inside the CDC tracking acceptance
20  - 'gamma:loose' (default) with some loose quality selections
21  - 'gamma:tight' like loose but with higher energy cuts depending on detector regions
22  - 'gamma:pi0eff60_May2020' gamma list for 60% pi0 efficiency list, optimized in May 2020
23  - 'gamma:pi0eff50_May2020' gamma list for 50% pi0 efficiency list, optimized in May 2020
24  - 'gamma:pi0eff40_May2020' gamma list for 40% pi0 efficiency list, optimized in May 2020
25  - 'gamma:pi0eff30_May2020' gamma list for 30% pi0 efficiency list, optimized in May 2020
26  - 'gamma:pi0eff20_May2020' gamma list for 20% pi0 efficiency list, optimized in May 2020
27  - 'gamma:pi0eff10_May2020' gamma list for 10% pi0 efficiency list, optimized in May 2020
28  - 'gamma:pi0' gamma list for pi0 list
29  - 'gamma:pi0highE' gamma list for pi0 list, high energy selection
30 
31  - For latest pi0 recommendations see https://confluence.desy.de/display/BI/Neutrals+Performance
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  # all photons (all neutral ECLClusters that have the c_nPhotons hypothesis)
40  if listtype == 'all':
41  fillParticleList('gamma:all', '', writeOut=True, path=path,
42  loadPhotonBeamBackgroundMVA=loadPhotonBeamBackgroundMVA)
43  # all photons within the cdc tracking acceptance: remove un track-matched
44  # electrons from outside the tracking acceptance
45  elif listtype == 'cdc':
46  fillParticleList(
47  'gamma:cdc',
48  'inCDCAcceptance',
49  writeOut=True,
50  path=path,
51  loadPhotonBeamBackgroundMVA=loadPhotonBeamBackgroundMVA
52  )
53  # clusterErrorTiming < 1e6 removes failed waveform fits, this is not an actual timing cut. A 99% efficiency cut
54  # is already applied on mdst level for photons with E < 50 MeV.
55  elif listtype == 'loose':
56  stdPhotons('cdc', path, loadPhotonBeamBackgroundMVA=loadPhotonBeamBackgroundMVA)
57  cutAndCopyList(
58  'gamma:loose',
59  'gamma:cdc',
60  'clusterErrorTiming < 1e6 and [clusterE1E9 > 0.4 or E > 0.075]',
61  True,
62  path)
63  # additional region dependent energy cuts
64  elif listtype == 'tight':
65  stdPhotons('loose', path, loadPhotonBeamBackgroundMVA=loadPhotonBeamBackgroundMVA)
66  cutAndCopyList(
67  'gamma:tight',
68  'gamma:loose',
69  '[clusterReg == 1 and E > 0.05] or [clusterReg == 2 and E > 0.05] or [clusterReg == 3 and E > 0.075]',
70  True,
71  path)
72  elif listtype == 'pi0eff10_May2020':
73  fillParticleList(
74  'gamma:pi0eff10_May2020',
75  '[clusterNHits>1.5] and [0.2967< clusterTheta<2.6180] and \
76  [[clusterReg==1 and E>0.200] or [clusterReg==2 and E>0.100] or [clusterReg==3 and E>0.180]] and [clusterE1E9>0.5]',
77  writeOut=True,
78  path=path,
79  loadPhotonBeamBackgroundMVA=loadPhotonBeamBackgroundMVA
80  )
81  elif listtype == 'pi0eff20_May2020':
82  fillParticleList(
83  'gamma:pi0eff20_May2020',
84  '[clusterNHits>1.5] and [0.2967< clusterTheta<2.6180] and \
85  [[clusterReg==1 and E>0.120] or [clusterReg==2 and E>0.030] or [clusterReg==3 and E>0.080]] and [clusterE1E9>0.4]',
86  writeOut=True,
87  path=path,
88  loadPhotonBeamBackgroundMVA=loadPhotonBeamBackgroundMVA
89  )
90  elif listtype == 'pi0eff30_May2020' or listtype == 'pi0eff40_May2020':
91  fillParticleList(
92  f'gamma:{listtype}',
93  '[clusterNHits>1.5] and [0.2967< clusterTheta<2.6180] and \
94  [[clusterReg==1 and E>0.080] or [clusterReg==2 and E>0.030] or [clusterReg==3 and E>0.060 ]]',
95  writeOut=True,
96  path=path,
97  loadPhotonBeamBackgroundMVA=loadPhotonBeamBackgroundMVA
98  )
99  elif listtype == 'pi0eff50_May2020':
100  fillParticleList(
101  'gamma:pi0eff50_May2020',
102  '[clusterNHits>1.5] and [0.2967< clusterTheta<2.6180] and \
103  [[clusterReg==1 and E>0.025] or [clusterReg==2 and E>0.025] or [clusterReg==3 and E>0.040]]',
104  writeOut=True,
105  path=path,
106  loadPhotonBeamBackgroundMVA=loadPhotonBeamBackgroundMVA
107  )
108  elif listtype == 'pi0eff60_May2020':
109  fillParticleList(
110  'gamma:pi0eff60_May2020',
111  '[clusterNHits>1.5] and [0.2967< clusterTheta<2.6180] and \
112  [[clusterReg==1 and E>0.0225] or [clusterReg==2 and E>0.020] or [clusterReg==3 and E>0.020]]',
113  writeOut=True,
114  path=path,
115  loadPhotonBeamBackgroundMVA=loadPhotonBeamBackgroundMVA
116  )
117  else:
118  raise ValueError(f"\"{listtype}\" is none of the allowed standardized types of photon lists!")
119 
120 # Used in skimming code
121 
122 
123 def loadStdSkimPhoton(path):
124  """
125  Function to prepare the skim photon lists.
126 
127  Warning:
128  Should only be used by skims.
129 
130  Parameters:
131  path (basf2.Path): modules are added to this path
132 
133  """
134  stdPhotons('loose', path, loadPhotonBeamBackgroundMVA=False)
135  cutAndCopyList(
136  'gamma:skim',
137  'gamma:loose',
138  '',
139  True,
140  path)
141 
142 
143 # Only used for Belle via b2bii
144 def loadStdGoodBellePhoton(path):
145  """
146  Load the Belle goodBelle list. Creates a ParticleList named
147  'gamma:goodBelle' with '0.5 < :b2:var:`goodBelleGamma` < 1.5'
148 
149  Warning:
150  Should only be used for Belle analyses using `b2bii`.
151 
152  Parameters:
153  path (basf2.Path): the path to load the modules
154  """
155  fillParticleList('gamma:goodBelle', '0.5 < goodBelleGamma < 1.5', True, path, loadPhotonBeamBackgroundMVA=False)