ATLAS Offline Software
Classes | Functions | Variables
JetAttributeHistoManager Namespace Reference

Classes

class  AttributeHistoManager
 

Functions

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

Variables

 attributeHistoManager = AttributeHistoManager(jhm)
 

Function Documentation

◆ create1DHistoTool()

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

Definition at line 86 of file JetAttributeHistoManager.py.

86 def 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 

◆ create2DHistoTool()

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

Definition at line 101 of file JetAttributeHistoManager.py.

101 def 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()

def 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.

121 def 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()

def JetAttributeHistoManager.findSelectIndex (   name)

Definition at line 149 of file JetAttributeHistoManager.py.

149 def 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()

def 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.

160 def 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()

def JetAttributeHistoManager.sanitizeName (   name)

Definition at line 141 of file JetAttributeHistoManager.py.

141 def sanitizeName(name):
142  return name.replace('[','_').replace(']','_')
143 

◆ unpackto3()

def JetAttributeHistoManager.unpackto3 (   t)

Definition at line 144 of file JetAttributeHistoManager.py.

144 def 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.

replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
JetAttributeHistoManager.create1DHistoTool
def create1DHistoTool(name, binning, attributeInfo, **otherArgs)
Definition: JetAttributeHistoManager.py:86
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
JetAttributeHistoManager.interpretSelStr
def interpretSelStr(selStr)
Definition: JetAttributeHistoManager.py:160
JetAttributeHistoManager.create2DHistoTool
def create2DHistoTool(name, binning=None, attributeInfo1=None, attributeInfo2=None, **otherArgs)
Definition: JetAttributeHistoManager.py:101
JetAttributeHistoManager.findSelectIndex
def findSelectIndex(name)
Definition: JetAttributeHistoManager.py:149
JetAttributeHistoManager.unpackto3
def unpackto3(t)
Definition: JetAttributeHistoManager.py:144
JetAttributeHistoManager.sanitizeName
def sanitizeName(name)
Definition: JetAttributeHistoManager.py:141
JetAttributeHisto
A histo building tool (JetHistoBase) using attributes to fill histograms.
Definition: JetAttributeHisto.h:35
JetAttributeHistoManager.createAttSelector
def createAttSelector(selectString, name="", typ="float")
Definition: JetAttributeHistoManager.py:121
JetSelectorAttributeRunII
Definition: JetSelectorAttributeRunII.h:21
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
readCCLHist.float
float
Definition: readCCLHist.py:83