| The Gaudi Framework v32r1 (f65d50dc)

Classes | Functions
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 102 of file GenerateGaudiOpts.py.

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

## ◆ _ConvertXmlToDictRecurse()

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

Definition at line 134 of file GenerateGaudiOpts.py.

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

## ◆ ConvertDictToXml()

def GaudiProfiling.GenerateGaudiOpts.ConvertDictToXml | ( |  | xmldict | ) |

    Converts a dictionary to an XML ElementTree Element

Definition at line 123 of file GenerateGaudiOpts.py.

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

## ◆ ConvertXmlToDict()

def GaudiProfiling.GenerateGaudiOpts.ConvertXmlToDict | ( |  | root,
|  |  | dictclass = `XmlDictObject`
| ) |  |

    Converts an XML file or ElementTree Element to a dictionary

Definition at line 172 of file GenerateGaudiOpts.py.

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

## ◆ generateOptions()

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

Definition at line 7 of file GenerateGaudiOpts.py.

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