3 from JetMonitoring.HistoDefinitionHelpers
import createHistoDefTool
as hdef
4 from JetMonitoring.HistoDefinitionHelpers
import mergeHistoDefinition
5 from JetMonitoring.JetMonitoringConf
import JetAttributeHisto, JetSelectorAttributeRunII
6 from JetMonitoring.JetHistoManager
import jetHistoManager
as jhm
14 for name, spec
in compactSpecification.items():
16 binning, attributeInfo = spec
19 binning, attributeInfo1, attributeInfo2 = spec
20 doTProfile = name.beginswith(
"Prof_")
21 self.
add2DHistoTool(name, binning, attributeInfo1, attributeInfo2, DoTProfile=doTProfile)
25 if self.
jhm.hasTool(name):
26 print (
"ERROR JetAttributeHisto with name ", name ,
" already exists. Can't add a new one")
30 return self.
jhm.addTool( tool)
34 def add2DHistoTool(self, name, binning=None, attributeInfo1=None, attributeInfo2=None,**otherArgs):
35 if self.
jhm.hasTool(name):
36 print (
"ERROR JetAttributeHisto with name ", name ,
" already exists. Can't add a new one")
39 tool =
create2DHistoTool(name, binning, attributeInfo1, attributeInfo2, **otherArgs)
40 return self.
jhm.addTool( tool )
44 tool = self.
jhm.
tool(name, build2Difmissing=
False)
45 if tool
is not None :
return tool
49 n1, n2 = name.split(
':')
54 missing = n1
if t1
is None else n2
55 print (
"ERROR : can't build 2D histo", name,
" : ",missing,
" is unknonw")
59 def rebuildSuffix(index):
60 if index==-1:
return ''
61 return '['+
str(index)+
']'
62 attInfo1 = (t1.AttributeNames[0]+rebuildSuffix(t1.SelectIndex), t1.AttributeTypes[0])
63 attInfo2 = (t2.AttributeNames[0]+rebuildSuffix(t2.SelectIndex), t2.AttributeTypes[0])
67 return self.
jhm.addTool( tool)
70 if name !=
"" and self.
jhm.hasTool(name) :
71 print (
"ERROR JetSelectorAttributeRunII with name ", name ,
" already exists. Can't add a new one")
73 if self.
jhm.hasTool(selectString) :
74 print (
"ERROR JetSelectorAttributeRunII ", selectString ,
" already exists. Can't add a new one")
78 from AthenaCommon.AppMgr
import ToolSvc
81 return self.
jhm.addTool( tool , alias=selectString)
88 attName, attType, attGeV =
unpackto3(attributeInfo)
94 return JetAttributeHisto( name, HistoDef = hdef(hname, *binning),
95 AttributeTypes = [ attType ],
96 AttributeNames = [ attName ],
97 AttributeInGeV = [
bool(attGeV) ],
98 SelectIndex = selectIndex , **otherArgs)
101 def create2DHistoTool( name, binning=None, attributeInfo1=None, attributeInfo2=None,**otherArgs):
102 attName1, attType1, attGeV1 =
unpackto3(attributeInfo1)
105 attName2, attType2, attGeV2 =
unpackto3(attributeInfo2)
109 selectIndex = max ( selectIndex1, selectIndex2)
114 return JetAttributeHisto( name, HistoDef = hdef(hname, *binning),
115 AttributeTypes = [ attType1, attType2 ],
116 AttributeNames = [ attName1, attName2 ],
117 AttributeInGeV = [
bool(attGeV1),
bool(attGeV2) ],
118 SelectIndex = selectIndex , **otherArgs)
122 """A short cut to create JetSelectorAttributeRunII out of a simple string """
125 if ind>-1
and 'vector' not in typ :
126 typ =
'vector<'+typ+
'>'
130 name = selectString.replace(
'<',
'_inf_')
131 name = name.replace(
'[',
'_')
132 name = name.replace(
']',
'_')
133 name = name.replace(
'.',
'_')
135 tool = JetSelectorAttributeRunII(name, Attribute=att, AttributeType=typ, VectorIndex=ind)
136 if cmin
is not None: tool.CutMin = cmin
137 if cmax
is not None: tool.CutMax = cmax
142 return name.replace(
'[',
'_').
replace(
']',
'_')
151 name, index = name.split(
'[')
153 name, index = name,
''
154 if not index.endswith(
']'):
156 index =
int(index[:-1])
161 """Interpret a selection string in the form '12.3<var<42.0'
163 '12.3<var<42.0' -> returns (12.3, 'var', 42.)
164 'var<42.0' -> returns (None, 'var', 42.)
165 '12.3<var' -> returns (12.3, 'var', None)
167 parts = selStr.split(
'<')
168 cmin, cmax =
None,
None
173 var, cut = parts[0] ,
float(parts[1])
175 cut, var =
float(parts[0]) ,parts[1]
177 if ismin : cmin = cut
180 cmin, var, cmax = parts
184 return cmin, var, cmax