| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

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

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

Definition at line 99 of file GenerateGaudiOpts.py.

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

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

Definition at line 131 of file GenerateGaudiOpts.py.

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

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

    Converts a dictionary to an XML ElementTree Element

Definition at line 120 of file GenerateGaudiOpts.py.

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

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

    Converts an XML file or ElementTree Element to a dictionary

Definition at line 169 of file GenerateGaudiOpts.py.

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

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