ATLAS Offline Software
Loading...
Searching...
No Matches
xAODRootTest Namespace Reference

Classes

class  AllocTestRead
class  Analysis
class  xAODTestClearDecor
class  xAODTestCopy
class  xAODTestDecor
class  xAODTestPDecor
class  xAODTestRead

Functions

 CHECK (sc)
 _typename (t)
 xAODInit ()
 format_int (x)
 format_float (x)
 format_str (x)
 format_el (x)
 format_el_vec (v)
 format_float_vec (v)
 format_int_vec (v)
 format_str_vec (v)
 dump_auxitem (x, auxid, f=sys.stdout)
 dump_auxdata (x, exclude=[], f=sys.stdout)
 dump_c (c, f=sys.stdout)
 dump_xaodobj (h, f=sys.stdout)
 dump_plinks (p, f=sys.stdout)
 copy_obj (event, obj, key)
 copy_vec (event, obj, key)
 copy_view (event, obj, key)

Variables

 reg = ROOT.SG.AuxTypeRegistry.instance()
 cvec_cls = ROOT.DataVector(ROOT.DMTest.C_v1)
 cel_cls = ROOT.ElementLink(cvec_cls)
 CVec_type = ROOT.DataVector(ROOT.DMTest.C_v1)
dict accessors

Function Documentation

◆ _typename()

xAODRootTest._typename ( t)
protected

Definition at line 34 of file xAODRootTest.py.

34def _typename(t):
35 return getattr (t, '__cpp_name__', t.__name__)
36

◆ CHECK()

xAODRootTest.CHECK ( sc)

Definition at line 25 of file xAODRootTest.py.

25def CHECK(sc):
26 if not sc.isSuccess():
27 raise Exception ('bad StatusCode')
28 return
29
30
31
#define CHECK(...)
Evaluate an expression and check for errors.

◆ copy_obj()

xAODRootTest.copy_obj ( event,
obj,
key )

Definition at line 147 of file xAODRootTest.py.

147def copy_obj (event, obj, key):
148 copy = obj.__class__()
149 copy_aux = obj.getConstStore().__class__()
150 copy.setNonConstStore (copy_aux)
151 copy.__assign__ (obj)
152 CHECK (event.record (copy, key))
153 CHECK (event.record (copy_aux, key + 'Aux.'))
154 ROOT.SetOwnership (copy, False)
155 ROOT.SetOwnership (copy_aux, False)
156 return
157
158

◆ copy_vec()

xAODRootTest.copy_vec ( event,
obj,
key )

Definition at line 159 of file xAODRootTest.py.

159def copy_vec (event, obj, key):
160 copy = obj.__class__()
161 copy_aux = obj.getConstStore().__class__()
162 copy.setNonConstStore (copy_aux)
163 for i in range(obj.size()):
164 elt_orig = obj[i]
165 if _typename (elt_orig.__class__).startswith ('DataModel_detail::ElementProxy<'):
166 elt_orig = elt_orig.__follow__()
167 elt = elt_orig.__class__()
168 copy.push_back(elt)
169 ROOT.SetOwnership (elt, False)
170 elt.__assign__ (elt_orig)
171 CHECK (event.record (copy, key))
172 CHECK (event.record (copy_aux, key + 'Aux.'))
173 ROOT.SetOwnership (copy, False)
174 ROOT.SetOwnership (copy_aux, False)
175 return
176
177

◆ copy_view()

xAODRootTest.copy_view ( event,
obj,
key )

Definition at line 178 of file xAODRootTest.py.

178def copy_view (event, obj, key):
179 copy = obj.__class__(obj)
180 copy.toPersistent()
181 CHECK (event.record (copy, key))
182 ROOT.SetOwnership (copy, False)
183 return
184
185

◆ dump_auxdata()

xAODRootTest.dump_auxdata ( x,
exclude = [],
f = sys.stdout )

Definition at line 110 of file xAODRootTest.py.

110def dump_auxdata (x, exclude=[], f = sys.stdout):
111 auxids = list(x.getAuxIDs())
112 auxids = [(reg.getName(id), id) for id in auxids]
113 auxids.sort()
114 for name, auxid in auxids:
115 if name in exclude: continue
116 if reg.isLinked (auxid): continue
117 print (name + ': ', file=f, end='')
118 dump_auxitem (x, auxid, f)
119 return
120
121

◆ dump_auxitem()

xAODRootTest.dump_auxitem ( x,
auxid,
f = sys.stdout )

Definition at line 98 of file xAODRootTest.py.

98def dump_auxitem (x, auxid, f = sys.stdout):
99 tname = reg.getTypeName (auxid)
100 ac_p = accessors.get (tname)
101 if not ac_p:
102 print ('<unknown %s>'%tname, end='', file=f)
103 else:
104 (ac_cl, formatter) = ac_p
105 val = ac_cl(reg.getName(auxid))(x)
106 print (formatter(val) + '; ', end='', file=f)
107 return
108
109

◆ dump_c()

xAODRootTest.dump_c ( c,
f = sys.stdout )

Definition at line 122 of file xAODRootTest.py.

122def dump_c (c, f=sys.stdout):
123 if hasattr(c, '__deref__'):
124 c = c.__deref__()
125 print (' anInt1: %d; aFloat: %.1f; ' % (c.anInt(), c.aFloat()), end='')
126 dump_auxdata (c, exclude = ['anInt1', 'aFloat'])
127 print ('')
128 return
129
130

◆ dump_plinks()

xAODRootTest.dump_plinks ( p,
f = sys.stdout )

Definition at line 139 of file xAODRootTest.py.

139def dump_plinks (p, f=sys.stdout):
140 if hasattr(p, '__deref__'):
141 p = p.__deref__()
142 dump_auxdata (p)
143 print ('')
144 return
145
146

◆ dump_xaodobj()

xAODRootTest.dump_xaodobj ( h,
f = sys.stdout )

Definition at line 131 of file xAODRootTest.py.

131def dump_xaodobj (h, f=sys.stdout):
132 if hasattr(h, '__deref__'):
133 h = h.__deref__()
134 dump_auxdata (h)
135 print ('')
136 return
137
138

◆ format_el()

xAODRootTest.format_el ( x)

Definition at line 55 of file xAODRootTest.py.

55def format_el(x): return '%s[%s]' % (x.dataID(), ('inv' if x.isDefaultIndex() else x.index()))

◆ format_el_vec()

xAODRootTest.format_el_vec ( v)

Definition at line 56 of file xAODRootTest.py.

56def format_el_vec(v): return '[' + ', '.join([format_el(el) for el in v.asVector()]) + ']'

◆ format_float()

xAODRootTest.format_float ( x)

Definition at line 53 of file xAODRootTest.py.

53def format_float(x): return '%.1f'%x

◆ format_float_vec()

xAODRootTest.format_float_vec ( v)

Definition at line 57 of file xAODRootTest.py.

57def format_float_vec(v):
58 l = [format_float(x) for x in v]
59 return '[' + ','.join(l) + ']'

◆ format_int()

xAODRootTest.format_int ( x)

Definition at line 52 of file xAODRootTest.py.

52def format_int(x): return '%d'%x

◆ format_int_vec()

xAODRootTest.format_int_vec ( v)

Definition at line 60 of file xAODRootTest.py.

60def format_int_vec(v):
61 l = [format_int(x) for x in v]
62 return '[' + ','.join(l) + ']'

◆ format_str()

xAODRootTest.format_str ( x)

Definition at line 54 of file xAODRootTest.py.

54def format_str(x): return f"'{x}'"

◆ format_str_vec()

xAODRootTest.format_str_vec ( v)

Definition at line 63 of file xAODRootTest.py.

63def format_str_vec(v):
64 l = [format_str(x) for x in v]
65 return '[' + ','.join(l) + ']'

◆ xAODInit()

xAODRootTest.xAODInit ( )

Definition at line 37 of file xAODRootTest.py.

37def xAODInit():
38 ROOT.xAOD.TEvent
39 CHECK(ROOT.xAOD.Init())
40 import sys
41 if len(sys.argv) >= 2 and sys.argv[1] == '--rntuple':
42 return True
43 return False
44
45
46

Variable Documentation

◆ accessors

dict xAODRootTest.accessors
Initial value:
1= {
2 'int' : (ROOT.SG.ConstAccessor(int), format_int),
3 'unsigned int' : (getattr (ROOT, 'SG::ConstAccessor<unsigned int>'), format_int),
4 'float' : (ROOT.SG.ConstAccessor(float), format_float),
5 'std::vector<float>' : (getattr (ROOT, 'SG::ConstAccessor<std::vector<float> >'), format_float_vec),
6 'std::vector<int>' : (getattr (ROOT, 'SG::ConstAccessor<std::vector<int> >'), format_int_vec),
7 'ElementLink<DataVector<DMTest::C_v1> >' :
8 (ROOT.SG.ConstAccessor(cel_cls), format_el),
9 'SG::JaggedVecElt<int>' :
10 (ROOT.SG.ConstAccessor(ROOT.SG.JaggedVecElt(ROOT.int)),
11 format_int_vec),
12 'SG::JaggedVecElt<float>' :
13 (ROOT.SG.ConstAccessor(ROOT.SG.JaggedVecElt(ROOT.float)),
14 format_float_vec),
15 'SG::JaggedVecElt<double>' :
16 (ROOT.SG.ConstAccessor(ROOT.SG.JaggedVecElt(ROOT.double)),
17 format_float_vec),
18 'SG::JaggedVecElt<std::string>' :
19 (ROOT.SG.ConstAccessor(ROOT.SG.JaggedVecElt(ROOT.std.string)),
20 format_str_vec),
21 'SG::JaggedVecElt<ElementLink<DataVector<DMTest::C_v1> > >' :
22 (ROOT.SG.ConstAccessor(ROOT.SG.JaggedVecElt(ROOT.ElementLink(CVec_type))),
23 format_el_vec),
24 'SG::PackedLink<DataVector<DMTest::C_v1> >' :
25 (ROOT.SG.ConstAccessor(ROOT.SG.PackedLink(ROOT.DataVector(ROOT.DMTest.C_v1))),
26 format_el),
27 'std::vector<SG::PackedLink<DataVector<DMTest::C_v1> > >' :
28 (ROOT.SG.ConstAccessor(ROOT.std.vector(ROOT.SG.PackedLink(ROOT.DataVector(ROOT.DMTest.C_v1)))),
29 format_el_vec),
30 }

Definition at line 67 of file xAODRootTest.py.

◆ cel_cls

xAODRootTest.cel_cls = ROOT.ElementLink(cvec_cls)

Definition at line 48 of file xAODRootTest.py.

◆ cvec_cls

xAODRootTest.cvec_cls = ROOT.DataVector(ROOT.DMTest.C_v1)

Definition at line 47 of file xAODRootTest.py.

◆ CVec_type

xAODRootTest.CVec_type = ROOT.DataVector(ROOT.DMTest.C_v1)

Definition at line 66 of file xAODRootTest.py.

◆ reg

xAODRootTest.reg = ROOT.SG.AuxTypeRegistry.instance()

Definition at line 32 of file xAODRootTest.py.