The Gaudi Framework  v32r2 (46d42edc)
GaudiProfiling.GenerateGaudiOpts Namespace Reference

Classes

class  XmlDictObject
 

Functions

def generateOptions (counter, cmask, invmask, sampling_period, startatevent, storeresultsat, family)
 
def _ConvertDictToXmlRecurse (parent, dictitem)
 
def ConvertDictToXml (xmldict)
 
def _ConvertXmlToDictRecurse (node, dictclass)
 
def ConvertXmlToDict (root, dictclass=XmlDictObject)
 

Function Documentation

◆ _ConvertDictToXmlRecurse()

def GaudiProfiling.GenerateGaudiOpts._ConvertDictToXmlRecurse (   parent,
  dictitem 
)
private

Definition at line 103 of file GenerateGaudiOpts.py.

103 def _ConvertDictToXmlRecurse(parent, dictitem):
104  assert type(dictitem) is not type([])
105 
106  if isinstance(dictitem, dict):
107  for (tag, child) in dictitem.iteritems():
108  if str(tag) == '_text':
109  parent.text = str(child)
110  elif type(child) is type([]):
111  # iterate through the array and convert
112  for listchild in child:
113  elem = ElementTree.Element(tag)
114  parent.append(elem)
115  _ConvertDictToXmlRecurse(elem, listchild)
116  else:
117  elem = ElementTree.Element(tag)
118  parent.append(elem)
119  _ConvertDictToXmlRecurse(elem, child)
120  else:
121  parent.text = str(dictitem)
122 
123 
def _ConvertDictToXmlRecurse(parent, dictitem)

◆ _ConvertXmlToDictRecurse()

def GaudiProfiling.GenerateGaudiOpts._ConvertXmlToDictRecurse (   node,
  dictclass 
)
private

Definition at line 135 of file GenerateGaudiOpts.py.

135 def _ConvertXmlToDictRecurse(node, dictclass):
136  nodedict = dictclass()
137 
138  if len(node.items()) > 0:
139  # if we have attributes, set them
140  nodedict.update(dict(node.items()))
141 
142  for child in node:
143  # recursively add the element's children
144  newitem = _ConvertXmlToDictRecurse(child, dictclass)
145  if child.tag in nodedict:
146  # found duplicate tag, force a list
147  if type(nodedict[child.tag]) is type([]):
148  # append to existing list
149  nodedict[child.tag].append(newitem)
150  else:
151  # convert to list
152  nodedict[child.tag] = [nodedict[child.tag], newitem]
153  else:
154  # only one, directly set the dictionary
155  nodedict[child.tag] = newitem
156 
157  if node.text is None:
158  text = ''
159  else:
160  text = node.text.strip()
161 
162  if len(nodedict) > 0:
163  # if we have a dictionary add the text as a dictionary value (if there is any)
164  if len(text) > 0:
165  nodedict['_text'] = text
166  else:
167  # if we don't have child nodes or attributes, just set the text
168  nodedict = text
169 
170  return nodedict
171 
172 
def _ConvertXmlToDictRecurse(node, dictclass)

◆ ConvertDictToXml()

def GaudiProfiling.GenerateGaudiOpts.ConvertDictToXml (   xmldict)
Converts a dictionary to an XML ElementTree Element

Definition at line 124 of file GenerateGaudiOpts.py.

124 def ConvertDictToXml(xmldict):
125  """
126  Converts a dictionary to an XML ElementTree Element
127  """
128 
129  roottag = xmldict.keys()[0]
130  root = ElementTree.Element(roottag)
131  _ConvertDictToXmlRecurse(root, xmldict[roottag])
132  return root
133 
134 
def _ConvertDictToXmlRecurse(parent, dictitem)

◆ ConvertXmlToDict()

def GaudiProfiling.GenerateGaudiOpts.ConvertXmlToDict (   root,
  dictclass = XmlDictObject 
)
Converts an XML file or ElementTree Element to a dictionary

Definition at line 173 of file GenerateGaudiOpts.py.

173 def ConvertXmlToDict(root, dictclass=XmlDictObject):
174  """
175  Converts an XML file or ElementTree Element to a dictionary
176  """
177 
178  # If a string is passed in, try to open it as a file
179  if type(root) == type(''):
180  root = ElementTree.parse(root).getroot()
181  elif not isinstance(root, ElementTree.Element):
182  raise TypeError('Expected ElementTree.Element or file path string')
183 
184  return dictclass({root.tag: _ConvertXmlToDictRecurse(root, dictclass)})
def _ConvertXmlToDictRecurse(node, dictclass)
def ConvertXmlToDict(root, dictclass=XmlDictObject)

◆ generateOptions()

def GaudiProfiling.GenerateGaudiOpts.generateOptions (   counter,
  cmask,
  invmask,
  sampling_period,
  startatevent,
  storeresultsat,
  family 
)

Definition at line 8 of file GenerateGaudiOpts.py.

8 def generateOptions(counter, cmask, invmask, sampling_period, startatevent,
9  storeresultsat, family):
10  cmask = map(int, cmask)
11  invmask = map(int, invmask)
12  sampling_period = map(int, sampling_period)
13  startatevent = int(startatevent)
14 
15  from Configurables import ApplicationMgr, AuditorSvc, PerfMonAuditor
16  app = ApplicationMgr()
17  app.AuditAlgorithms = 1
18  pfaud = PerfMonAuditor()
19  try:
20  pfaud.EVENT0 = counter[0]
21  pfaud.SP0 = sampling_period[0]
22  pfaud.INV0 = int(invmask[0])
23  pfaud.CMASK0 = int(cmask[0])
24  pfaud.EVENT1 = counter[1]
25  pfaud.SP1 = sampling_period[1]
26  pfaud.INV1 = int(invmask[1])
27  pfaud.CMASK1 = int(cmask[1])
28  pfaud.EVENT2 = counter[2]
29  pfaud.SP2 = sampling_period[2]
30  pfaud.INV2 = int(invmask[2])
31  pfaud.CMASK2 = int(cmask[2])
32  pfaud.EVENT3 = counter[3]
33  pfaud.SP3 = sampling_period[3]
34  pfaud.INV3 = int(invmask[3])
35  pfaud.CMASK3 = int(cmask[3])
36  except IndexError:
37  pass
38  pfaud.FAMILY = family
39  # for <2.5 Python use: test and true_value or false_value
40  pfaud.PREFIX = "%s_%s" % (storeresultsat,
41  "S" if sampling_period[0] > 0 else "C")
42  pfaud.SAMPLE = int(sampling_period[0] > 0)
43  pfaud.START_AT_EVENT = startatevent
44  #pfaud.LEVEL = 5
45  AuditorSvc().Auditors.append(pfaud)
46  print(pfaud)
47 
48 
def generateOptions(counter, cmask, invmask, sampling_period, startatevent, storeresultsat, family)
Performance Monitoring Auditor that uses Perfmon2 library to monitor algorithms.
struct GAUDI_API map
Parametrisation class for map-like implementation.
The Application Manager class.