ATLAS Offline Software
Loading...
Searching...
No Matches
JetAttributeHistoManager Namespace Reference

Classes

class  AttributeHistoManager

Functions

 create1DHistoTool (name, binning, attributeInfo, **otherArgs)
 create2DHistoTool (name, binning=None, attributeInfo1=None, attributeInfo2=None, **otherArgs)
 createAttSelector (selectString, name="", typ="float")
 sanitizeName (name)
 unpackto3 (t)
 findSelectIndex (name)
 interpretSelStr (selStr)

Variables

 attributeHistoManager = AttributeHistoManager(jhm)

Function Documentation

◆ create1DHistoTool()

JetAttributeHistoManager.create1DHistoTool ( name,
binning,
attributeInfo,
** otherArgs )

Definition at line 86 of file JetAttributeHistoManager.py.

86def create1DHistoTool( name, binning, attributeInfo,**otherArgs):
87
88 attName, attType, attGeV = unpackto3(attributeInfo)
89 attName, selectIndex = findSelectIndex(attName) # 'JVF[1]' --> 'JVF', 1
90
91 #hname = name if selectIndex==-1 else (name+'_'+str(selectIndex))
92 hname = sanitizeName(name) # remove [ and ] which can be problematic in histo names
93
94 return JetAttributeHisto( name, HistoDef = hdef(hname, *binning),
95 AttributeTypes = [ attType ],
96 AttributeNames = [ attName ],
97 AttributeInGeV = [ bool(attGeV) ],
98 SelectIndex = selectIndex , **otherArgs)
99
100
A histo building tool (JetHistoBase) using attributes to fill histograms.

◆ create2DHistoTool()

JetAttributeHistoManager.create2DHistoTool ( name,
binning = None,
attributeInfo1 = None,
attributeInfo2 = None,
** otherArgs )

Definition at line 101 of file JetAttributeHistoManager.py.

101def create2DHistoTool( name, binning=None, attributeInfo1=None, attributeInfo2=None,**otherArgs):
102 attName1, attType1, attGeV1 = unpackto3(attributeInfo1)
103 attName1, selectIndex1 = findSelectIndex(attName1)
104
105 attName2, attType2, attGeV2 = unpackto3(attributeInfo2)
106 attName2, selectIndex2 = findSelectIndex(attName2)
107
108 # currently support only vector<float> vs float, so there can be only one selected index.
109 selectIndex = max ( selectIndex1, selectIndex2)
110
111 #hname = name if selectIndex==-1 else (name+'_'+str(selectIndex))
112 hname = sanitizeName(name) # remove [ and ] which can be problematic in histo names
113
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)
119
120

◆ createAttSelector()

JetAttributeHistoManager.createAttSelector ( selectString,
name = "",
typ = "float" )
A short cut to create JetSelectorAttributeRunII out of a simple string 

Definition at line 121 of file JetAttributeHistoManager.py.

121def createAttSelector(selectString, name="", typ="float"):
122 """A short cut to create JetSelectorAttributeRunII out of a simple string """
123 cmin, att, cmax = interpretSelStr(selectString)
124 att, ind = findSelectIndex(att)
125 if ind>-1 and 'vector' not in typ :
126 typ = 'vector<'+typ+'>'
127
128 if name == "":
129 # try to build a unique name
130 name = selectString.replace('<','_inf_')
131 name = name.replace('[','_')
132 name = name.replace(']','_')
133 name = name.replace('.','_')
134 name = 'sel_'+name
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
138 return tool
139
140

◆ findSelectIndex()

JetAttributeHistoManager.findSelectIndex ( name)

Definition at line 149 of file JetAttributeHistoManager.py.

149def findSelectIndex( name):
150 try:
151 name, index = name.split('[')
152 except Exception:
153 name, index = name, ''
154 if not index.endswith(']'):
155 return name, -1
156 index = int(index[:-1])
157 return name, index
158
159

◆ interpretSelStr()

JetAttributeHistoManager.interpretSelStr ( selStr)
Interpret a selection string in the form '12.3<var<42.0'
and returns a tuple.
 '12.3<var<42.0' -> returns (12.3, 'var', 42.)
 'var<42.0' -> returns (None, 'var', 42.)
 '12.3<var' -> returns (12.3, 'var', None)

Definition at line 160 of file JetAttributeHistoManager.py.

160def interpretSelStr(selStr):
161 """Interpret a selection string in the form '12.3<var<42.0'
162 and returns a tuple.
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)
166 """
167 parts = selStr.split('<')
168 cmin, cmax = None, None
169 var = selStr
170 if len(parts)==2:
171 ismin = False
172 try :
173 var, cut = parts[0] , float(parts[1])
174 except Exception:
175 cut, var = float(parts[0]) ,parts[1]
176 ismin=True
177 if ismin : cmin = cut
178 else: cmax = cut
179 elif len(parts)==3:
180 cmin, var, cmax = parts
181 cmin = float(cmin)
182 cmax = float(cmax)
183
184 return cmin, var, cmax
185
186

◆ sanitizeName()

JetAttributeHistoManager.sanitizeName ( name)

Definition at line 141 of file JetAttributeHistoManager.py.

141def sanitizeName(name):
142 return name.replace('[','_').replace(']','_')
143
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310

◆ unpackto3()

JetAttributeHistoManager.unpackto3 ( t)

Definition at line 144 of file JetAttributeHistoManager.py.

144def unpackto3(t):
145 if len(t)==2:
146 return t+(False,)
147 return t
148

Variable Documentation

◆ attributeHistoManager

JetAttributeHistoManager.attributeHistoManager = AttributeHistoManager(jhm)

Definition at line 187 of file JetAttributeHistoManager.py.