3 from collections
import OrderedDict
as odict
5 from AthenaCommon.Logging
import logging
8 from .ThresholdType
import ThrType
10 log = logging.getLogger(__name__)
50 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))
57 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))
66 tw = self.
menuThr.typeWideThresholdConfig(ThrType[
"EM"])
67 return 1000 // tw[
"resolutionMeV"]
78 from L1TopoHardware.L1TopoHardware
import HardwareConstrainedParameter
79 if isinstance(value,HardwareConstrainedParameter):
80 self.
value =
":%s:" % value.name
87 def __init__(self, classtype, name, inputs, outputs):
88 super(SortingAlgo, self).
__init__(classtype=classtype, name=name)
102 confObj = super(SortingAlgo, self).json()
104 confObj[
"output"] = self.
outputs
105 confObj[
"fixedParameters"] = odict()
106 confObj[
"fixedParameters"][
"generics"] = odict()
107 for (pos, genParm)
in enumerate(self.
generics):
108 confObj[
"fixedParameters"][
"generics"][genParm.name] = odict([(
"value", genParm.value), (
"position", pos)])
110 confObj[
"variableParameters"] =
list()
113 if "MUCTP-" in self.
name:
115 for (pos, variable)
in enumerate(self.
variables):
116 if variable.name ==
"MinET" or variable.name ==
"MinEtTGC" or variable.name ==
"MinEtRPC":
120 variable.value *= _emscale_for_decision
122 variable.value = ((variable.value - _mu_for_decision )
if variable.value>0
else variable.value)
123 confObj[
"variableParameters"].
append(odict([(
"name", variable.name),(
"value", variable.value)]))
125 if type(variable.value)
is float:
126 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))
132 def __init__(self, classtype, name, inputs, outputs):
133 super(DecisionAlgo, self).
__init__(classtype=classtype, name=name)
141 confObj = super(DecisionAlgo, self).json()
142 confObj[
"input"] = self.
inputs
143 confObj[
"output"] = self.
outputs
145 confObj[
"fixedParameters"] = odict()
146 confObj[
"fixedParameters"][
"generics"] = odict()
147 for (pos, genParm)
in enumerate(self.
generics):
148 confObj[
"fixedParameters"][
"generics"][genParm.name] = odict([(
"value", genParm.value), (
"position", pos)])
151 confObj[
"variableParameters"] =
list()
154 if "MUCTP-" in self.
name:
156 for (pos, variable)
in enumerate(self.
variables):
158 for _minet
in [
"MinET"]:
159 if variable.name==_minet+
"1" or variable.name==_minet+
"2" or variable.name==_minet+
"3" or variable.name==_minet:
160 for (tobid, _input)
in enumerate(self.
inputs):
161 if (_input.find(
"e")>=0
or _input.find(
"j")>=0
or _input.find(
"g")>=0):
163 elif (_input.find(
"TAU")>=0
or _input.find(
"EM")>=0):
164 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)):
165 variable.value *= _emscale_for_decision
167 if _input.find(
"MU")>=0:
168 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)):
169 variable.value = ((variable.value - _mu_for_decision )
if variable.value>0
else variable.value)
171 if type(variable.value)
is float:
172 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))
174 if variable.selection >= 0:
175 confObj[
"variableParameters"].
append(odict([(
"name", variable.name), (
"selection",variable.selection), (
"value", variable.value)]))
177 confObj[
"variableParameters"].
append(odict([(
"name", variable.name), (
"value", variable.value)]))
184 def __init__(self, classtype, name, threshold, input, output, nbits):
185 super(MultiplicityAlgo, self).
__init__(classtype=classtype, name=name)
198 confObj = super(MultiplicityAlgo, self).json()
199 confObj[
"threshold"] = self.threshold
200 confObj[
"input"] = self.input
201 confObj[
"output"] = self.outputs
202 confObj[
"nbits"] = self.nbits
207 def __init__(self, name, threshold, nbits, classtype ):
208 super(EMMultiplicityAlgo, self).
__init__(classtype=classtype, name=name,
209 threshold = threshold,
210 input=
None, output=
"%s" % threshold,
212 mres = re.match(
"(?P<type>[A-z]*)[0-9]*(?P<suffix>[VHILMT]*)",threshold).groupdict()
217 def __init__(self, name, threshold, nbits, classtype ):
218 super(TauMultiplicityAlgo, self).
__init__(classtype=classtype, name=name,
219 threshold = threshold,
220 input=
None, output=
"%s" % threshold,
222 mres = re.match(
"(?P<type>[A-z]*)[0-9]*(?P<suffix>[HLMT]*)",threshold).groupdict()
227 def __init__(self, name, threshold, nbits, classtype ):
228 super(JetMultiplicityAlgo, self).
__init__(classtype=classtype, name=name,
229 threshold = threshold,
230 input=
None, output=
"%s" % threshold,
232 mres = re.match(
"(?P<type>[A-z]*)[0-9]*(?P<suffix>[A-z]*)",threshold).groupdict()
237 def __init__(self, name, threshold, nbits, classtype = "EnergyThreshold"):
238 super(XEMultiplicityAlgo, self).
__init__( classtype = classtype, name=name,
239 threshold = threshold,
240 input=
None, output=
"%s" % threshold,
242 mres = re.match(
"(?P<type>[A-z]*)[0-9]*(?P<suffix>[A-z]*)",threshold).groupdict()
243 mres[
"type"] = mres[
"type"].
replace(
'SPARE',
'')
248 confObj = super(XEMultiplicityAlgo, self).json()
250 confObj[
"input"] = self.
input
251 confObj[
"output"] = self.
outputs
252 confObj[
"flavour"] = self.
flavour
253 confObj[
"nbits"] = self.
nbits
257 def __init__(self, classtype, name, input, output, nbits):
258 super(MuMultiplicityAlgo, self).
__init__(classtype=classtype, name=name, input=input, output=output, nbits=nbits)
263 class LArSaturationAlgo(MultiplicityAlgo):
265 name =
'LArSaturation'
266 super(LArSaturationAlgo, self).
__init__(name=name, classtype=name, input=
'jTE', output=name, threshold=name, nbits=1)
270 super(ZeroBiasAlgo, self).
__init__(name=name, classtype=
'ZeroBias', input=name, threshold=name, output=name, nbits=1)