3 from AthenaCommon.Logging
import logging
6 from .ThresholdType
import ThrType
8 log = logging.getLogger(__name__)
48 raise RuntimeError(
"Variable parameter '%s' does not exist for algorithm %s of type %s,\navailable parameters are %r" % (name,self.
name, self.
classtype, self.
_availableVars))
55 raise RuntimeError(
"Generic parameter '%s' does not exist for algorithm %s of type %s,\navailable parameters are %r" % (name,self.
name, self.
classtype, self.
_availableVars))
65 tw = self.
menuThr.typeWideThresholdConfig(ThrType[
"EM"])
66 return 1000 // tw[
"resolutionMeV"]
77 from L1TopoHardware.L1TopoHardware
import HardwareConstrainedParameter
78 if isinstance(value,HardwareConstrainedParameter):
79 self.
value =
":%s:" % value.name
86 def __init__(self, classtype, name, inputs, outputs):
87 super(SortingAlgo, self).
__init__(classtype=classtype, name=name)
101 confObj = super(SortingAlgo, self).json()
103 confObj[
"output"] = self.
outputs
104 confObj[
"fixedParameters"] = {}
105 confObj[
"fixedParameters"][
"generics"] = {}
106 for (pos, genParm)
in enumerate(self.
generics):
107 confObj[
"fixedParameters"][
"generics"][genParm.name] = {
"value": genParm.value,
"position": pos}
109 confObj[
"variableParameters"] =
list()
112 if "MUCTP-" in self.
name:
114 for (pos, variable)
in enumerate(self.
variables):
115 if variable.name ==
"MinET" or variable.name ==
"MinEtTGC" or variable.name ==
"MinEtRPC":
119 variable.value *= _emscale_for_decision
121 variable.value = ((variable.value - _mu_for_decision )
if variable.value>0
else variable.value)
122 confObj[
"variableParameters"].
append({
"name": variable.name,
"value": variable.value})
124 if type(variable.value)
is float:
125 raise RuntimeError(
"In algorithm %s the variable %s with value %r is of type float but must be int" % (self.
name,variable.name,variable.value))
131 def __init__(self, classtype, name, inputs, outputs):
132 super(DecisionAlgo, self).
__init__(classtype=classtype, name=name)
140 confObj = super(DecisionAlgo, self).json()
141 confObj[
"input"] = self.
inputs
142 confObj[
"output"] = self.
outputs
144 confObj[
"fixedParameters"] = {}
145 confObj[
"fixedParameters"][
"generics"] = {}
146 for (pos, genParm)
in enumerate(self.
generics):
147 confObj[
"fixedParameters"][
"generics"][genParm.name] = {
"value": genParm.value,
"position": pos}
150 confObj[
"variableParameters"] =
list()
153 if "MUCTP-" in self.
name:
155 for (pos, variable)
in enumerate(self.
variables):
157 for _minet
in [
"MinET"]:
158 if variable.name==_minet+
"1" or variable.name==_minet+
"2" or variable.name==_minet+
"3" or variable.name==_minet:
159 for (tobid, _input)
in enumerate(self.
inputs):
160 if (_input.find(
"e")>=0
or _input.find(
"j")>=0
or _input.find(
"g")>=0):
162 elif (_input.find(
"TAU")>=0
or _input.find(
"EM")>=0):
163 if (len(self.
inputs)>1
and (variable.name==_minet+
str(tobid+1)
or (tobid==0
and variable.name==_minet)))
or (len(self.
inputs)==1
and (variable.name.find(_minet)>=0)):
164 variable.value *= _emscale_for_decision
166 if _input.find(
"MU")>=0:
167 if (len(self.
inputs)>1
and (variable.name==_minet+
str(tobid+1)
or (tobid==0
and variable.name==_minet)))
or (len(self.
inputs)==1
and (variable.name.find(_minet)>=0)):
168 variable.value = ((variable.value - _mu_for_decision )
if variable.value>0
else variable.value)
170 if type(variable.value)
is float:
171 raise RuntimeError(
"In algorithm %s the variable %s with value %r is of type float but must be int" % (self.
name,variable.name,variable.value))
173 if variable.selection >= 0:
174 confObj[
"variableParameters"].
append({
"name": variable.name,
"selection": variable.selection,
"value": variable.value})
176 confObj[
"variableParameters"].
append({
"name": variable.name,
"value": variable.value})
183 def __init__(self, classtype, name, threshold, input, output, nbits):
184 super(MultiplicityAlgo, self).
__init__(classtype=classtype, name=name)
197 confObj = super(MultiplicityAlgo, self).json()
198 confObj[
"threshold"] = self.threshold
199 confObj[
"input"] = self.input
200 confObj[
"output"] = self.outputs
201 confObj[
"nbits"] = self.nbits
206 def __init__(self, name, threshold, nbits, classtype ):
207 super(EMMultiplicityAlgo, self).
__init__(classtype=classtype, name=name,
208 threshold = threshold,
209 input=
None, output=
"%s" % threshold,
211 mres = re.match(
"(?P<type>[A-z]*)[0-9]*(?P<suffix>[VHILMT]*)",threshold).groupdict()
216 def __init__(self, name, threshold, nbits, classtype ):
217 super(TauMultiplicityAlgo, self).
__init__(classtype=classtype, name=name,
218 threshold = threshold,
219 input=
None, output=
"%s" % threshold,
221 mres = re.match(
"(?P<type>[A-z]*)[0-9]*(?P<suffix>[HLMT]*)",threshold).groupdict()
226 def __init__(self, name, threshold, nbits, classtype ):
227 super(JetMultiplicityAlgo, self).
__init__(classtype=classtype, name=name,
228 threshold = threshold,
229 input=
None, output=
"%s" % threshold,
231 mres = re.match(
"(?P<type>[A-z]*)[0-9]*(?P<suffix>[A-z]*)",threshold).groupdict()
236 def __init__(self, name, threshold, nbits, classtype = "EnergyThreshold"):
237 super(XEMultiplicityAlgo, self).
__init__( classtype = classtype, name=name,
238 threshold = threshold,
239 input=
None, output=
"%s" % threshold,
241 mres = re.match(
"(?P<type>[A-z]*)[0-9]*(?P<suffix>[A-z]*)",threshold).groupdict()
242 mres[
"type"] = mres[
"type"].
replace(
'SPARE',
'')
247 confObj = super(XEMultiplicityAlgo, self).json()
249 confObj[
"input"] = self.
input
250 confObj[
"output"] = self.
outputs
251 confObj[
"flavour"] = self.
flavour
252 confObj[
"nbits"] = self.
nbits
256 def __init__(self, classtype, name, input, output, nbits):
257 super(MuMultiplicityAlgo, self).
__init__(classtype=classtype, name=name, input=input, output=output, nbits=nbits)
262 class LArSaturationAlgo(MultiplicityAlgo):
264 name =
'LArSaturation'
265 super(LArSaturationAlgo, self).
__init__(name=name, classtype=name, input=
'jTE', output=name, threshold=name, nbits=1)
269 super(ZeroBiasAlgo, self).
__init__(name=name, classtype=
'ZeroBias', input=name, threshold=name, output=name, nbits=1)