forked from UCATLAS/xAODAnaHelpers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xAH_config.py
34 lines (28 loc) · 843 Bytes
/
xAH_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import ROOT
class xAH_config(object):
def __init__(self):
self._algorithms = []
self._log = []
def setalg(self, name, val):
#
# Construct the given constructor
# (complicated b/c we have to deal nesting of namespaces)
#
alg = reduce(lambda x,y: getattr(x, y, None), name.split('.'), ROOT)
if alg is None:
raise AttributeError(name)
#
# Construct an instance of the alg and set its attributes
#
alg_obj = alg()
self._log.append((alg,))
for k,v in val.iteritems():
if not hasattr(alg_obj, k):
raise AttributeError(k)
self._log.append((alg, k, v))
setattr(alg_obj, k, v)
print
#
# Add the constructed algo to the list of algorithms to run
#
self._algorithms.append(alg_obj)