4 from basf2
import B2ERROR
5 from modularAnalysis
import fillParticleList
9 _chargednames = [
'pi',
'K',
'p',
'e',
'mu']
10 _pidnames = [
'pionID',
'kaonID',
'protonID',
'electronID',
'muonID']
11 _effnames = [
'95eff',
'90eff',
'85eff']
14 _mostLikelyList =
'mostlikely'
17 def _stdChargedEffCuts(particletype, listtype):
19 Provides the PID cut corresponding to a given efficiency percentile
21 @param particletype type of charged particle (pi, K, p, e, mu)
22 @param listtype efficiency percentile for the list (95eff, 90eff, 85eff)
25 particleindex = _chargednames.index(particletype)
26 effindex = _effnames.index(listtype)
29 effcuts = [[0.001, 0.019, 0.098],
31 [0.000, 0.043, 0.251],
32 [0.093, 0.301, 0.709],
33 [0.187, 0.418, 0.909]]
35 return effcuts[particleindex][effindex]
40 Function to prepare one of several standardized types of charged particle lists:
41 - 'all' with no cuts on track
42 - 'good' high purity lists for data studies
43 - 'loosepid' loose selections for skimming, PID cut only
44 - 'loose' loose selections for skimming
45 - 'higheff' high efficiency list with loose global ID cut for data studies
46 - 'mostlikely' list with the highest PID likelihood
47 Also the following lists, which may or may not be available depending on the release
48 - '99eff' with 99% selection efficiency (calculated for 1<p<4 GeV) and good track (MC only)
49 - '95eff' with 95% selection efficiency (calculated for 1<p<4 GeV) and good track (MC only)
50 - '90eff' with 90% selection efficiency (calculated for 1<p<4 GeV) and good track (MC only)
51 - '85eff' with 85% selection efficiency (calculated for 1<p<4 GeV) and good track (MC only)
53 @param particletype type of charged particle to make a list of
54 @param listtype name of standard list
55 @param path modules are added to this path
59 trackQuality =
'thetaInCDCAcceptance and nCDCHits>20'
60 ipCut =
'dr < 0.5 and abs(dz) < 2'
61 goodTrack = trackQuality +
' and ' + ipCut
63 if particletype
not in _chargednames:
64 B2ERROR(
"The requested list is not a standard charged particle. Use one of pi, K, e, mu, p.")
67 fillParticleList(particletype +
'+:all',
'',
True, path=path)
68 elif listtype ==
'good':
70 particletype +
'+:good',
71 _pidnames[_chargednames.index(particletype)] +
' > 0.5 and ' + goodTrack,
74 elif listtype ==
'loose':
76 particletype +
'+:loose',
77 _pidnames[_chargednames.index(particletype)] +
' > 0.1 and ' + goodTrack,
80 elif listtype ==
'loosepid':
82 particletype +
'+:loosepid',
83 _pidnames[_chargednames.index(particletype)] +
' > 0.1',
86 elif listtype ==
'higheff':
88 particletype +
'+:higheff',
89 _pidnames[_chargednames.index(particletype)] +
' > 0.002 and ' + goodTrack,
92 elif listtype
not in _effnames:
93 B2ERROR(
"The requested list is not defined. Please refer to the stdCharged documentation.")
95 pidcut = _stdChargedEffCuts(particletype, listtype)
96 if 0.0 < pidcut < 1.0:
101 _pidnames[_chargednames.index(particletype)] +
109 B2ERROR(
'The requested standard particle list ' + particletype +
110 '+:' + listtype +
' is not available in this release.')
115 def stdPi(listtype=_defaultlist, path=None):
117 Function to prepare standard pion lists, refer to stdCharged for details
119 @param listtype name of standard list
120 @param path modules are added to this path
125 def stdK(listtype=_defaultlist, path=None):
127 Function to prepare standard kaon lists, refer to stdCharged for details
129 @param listtype name of standard list
130 @param path modules are added to this path
135 def stdPr(listtype=_defaultlist, path=None):
137 Function to prepare standard proton lists, refer to stdCharged for details
139 @param listtype name of standard list
140 @param path modules are added to this path
145 def stdE(listtype=_defaultlist, path=None):
147 Function to prepare standard electron lists, refer to stdCharged for details
149 @param listtype name of standard list
150 @param path modules are added to this path
155 def stdMu(listtype=_defaultlist, path=None):
157 Function to prepare standard muon lists, refer to stdCharged for details
159 @param listtype name of standard list
160 @param path modules are added to this path
165 def stdMostLikely(pidPriors=None, suffix='', path=None):
167 Function to prepare most likely particle lists according to PID likelihood, refer to stdCharged for details
169 @param pidPriors list of 5 float numbers used to reweight PID likelihoods
170 @param suffix string added to the end of particle list names
171 @param path modules are added to this path
177 if pidPriors
is not None:
178 args = str(pidPriors)[1:-1]
179 trackQuality =
'thetaInCDCAcceptance and nCDCHits>20'
180 for name
in _chargednames:
181 fillParticleList(
'%s+:%s' % (name, _mostLikelyList+suffix),
182 'pidIsMostLikely(%s) > 0 and %s' % (args, trackQuality),
True, path=path)