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

Functions

 _streamKey (dataType)
 guid2string (guid)
 token2string (tk, replace_empty_cntID=False)
 _resolveAncestorProvenance (dh, requestedKey)
 _resolveSelfReference (dh, requestedKey)
 resolveProvenanceGuid (store, dataType, inputDataType)

Variables

 _TOKEN_DB_RE
dict _STREAM_KEY
tuple _KNOWN_ANCESTOR_KEYS

Detailed Description

EventGUIDLookupLib.py

Provenance GUID resolution, adapted from the "Self reference and
Provenance" block of
  Database/EventIndex/EventIndexProducer/python/POOL2EI_Lib.py

- If the requested dataType IS the input file's own dataType, the GUID
  is in the *self reference* (the current file's own DataHeader entry).
- Otherwise, the GUID is in the *ancestor provenance* record for that
  stream, and only exists at all for the handful of streams POOL2EI_Lib
  recognizes there (RAW/ESD/AOD/RDO/HITS/EVGEN/Embedding) -- see
  _KNOWN_ANCESTOR_KEYS.

Function Documentation

◆ _resolveAncestorProvenance()

_resolveAncestorProvenance ( dh,
requestedKey )
protected

Definition at line 63 of file EventGUIDLookupLib.py.

63def _resolveAncestorProvenance(dh, requestedKey):
64 if dh.sizeProvenance() == 0:
65 return None
66 guid = None
67 prv = dh.beginProvenance()
68 for _ in range(dh.sizeProvenance()):
69 key = prv.getKey()
70 if key.startswith("Output"):
71 key = key[6:]
72 if key.startswith("Input"):
73 key = key[5:]
74 if key in _KNOWN_ANCESTOR_KEYS and key == requestedKey and guid is None:
75 tk = prv.getToken()
76 stk = token2string(tk, replace_empty_cntID=(key != 'StreamRAW'))
77 m = _TOKEN_DB_RE.search(stk)
78 if m:
79 guid = m.group(1)
80 del tk
81 del key
82 prv += 1
83 del prv
84 return guid
85
86

◆ _resolveSelfReference()

_resolveSelfReference ( dh,
requestedKey )
protected

Definition at line 87 of file EventGUIDLookupLib.py.

87def _resolveSelfReference(dh, requestedKey):
88 if dh.size() == 0:
89 return None
90 guid = None
91 dhe = dh.begin()
92 for _ in range(dh.size()):
93 key = dhe.getKey()
94 if key == requestedKey and guid is None:
95 tk = dhe.getToken()
96 stk = token2string(tk, replace_empty_cntID=True)
97 m = _TOKEN_DB_RE.search(stk)
98 if m:
99 guid = m.group(1)
100 del tk
101 del key
102 dhe += 1
103 dh.end()
104 return guid
105
106

◆ _streamKey()

_streamKey ( dataType)
protected
Map --dataType/--inputDataType onto the DataHeader key. Types with
no fixed internal name (DAOD_PHYS, DAOD_PHYSLITE) fall back to
'Stream<dataType>' -- only usable as a self-reference, never as a
recognized ancestor key (see _KNOWN_ANCESTOR_KEYS).

Definition at line 37 of file EventGUIDLookupLib.py.

37def _streamKey(dataType):
38 """Map --dataType/--inputDataType onto the DataHeader key. Types with
39 no fixed internal name (DAOD_PHYS, DAOD_PHYSLITE) fall back to
40 'Stream<dataType>' -- only usable as a self-reference, never as a
41 recognized ancestor key (see _KNOWN_ANCESTOR_KEYS)."""
42 return _STREAM_KEY.get(dataType, 'Stream' + dataType)
43
44

◆ guid2string()

guid2string ( guid)

Definition at line 45 of file EventGUIDLookupLib.py.

45def guid2string(guid):
46 return "{:08X}-{:04X}-{:04X}-{:02X}{:02X}-{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}".format(
47 guid.data1(), guid.data2(), guid.data3(),
48 ord(guid.data4(0)[0]), ord(guid.data4(1)[0]),
49 ord(guid.data4(2)[0]), ord(guid.data4(3)[0]),
50 ord(guid.data4(4)[0]), ord(guid.data4(5)[0]),
51 ord(guid.data4(6)[0]), ord(guid.data4(7)[0]))
52
53

◆ resolveProvenanceGuid()

resolveProvenanceGuid ( store,
dataType,
inputDataType )
Return the provenance GUID string for `dataType`, given the input
file is actually `inputDataType`, for the current event -- call from
inside an algorithm's execute(). Returns None if not found.

Definition at line 107 of file EventGUIDLookupLib.py.

107def resolveProvenanceGuid(store, dataType, inputDataType):
108 """Return the provenance GUID string for `dataType`, given the input
109 file is actually `inputDataType`, for the current event -- call from
110 inside an algorithm's execute(). Returns None if not found."""
111
112 dh = store.retrieve('DataHeader', 'EventSelector')
113 requestedKey = _streamKey(dataType)
114
115 if dataType == inputDataType:
116 return _resolveSelfReference(dh, requestedKey)
117 else:
118 return _resolveAncestorProvenance(dh, requestedKey)

◆ token2string()

token2string ( tk,
replace_empty_cntID = False )

Definition at line 54 of file EventGUIDLookupLib.py.

54def token2string(tk, replace_empty_cntID=False):
55 cntID = tk.contID()
56 if replace_empty_cntID and cntID == "":
57 cntID = "POOLContainer(DataHeader)"
58 return "[DB={}][CNT={}][CLID={}][TECH={:08X}][OID={:016X}-{:016X}]".format(
59 guid2string(tk.dbID()), cntID, guid2string(tk.classID()),
60 tk.technology(), tk.oid().first, tk.oid().second)
61
62

Variable Documentation

◆ _KNOWN_ANCESTOR_KEYS

tuple EventGUIDLookupLib._KNOWN_ANCESTOR_KEYS
protected
Initial value:
= ('StreamRAW', 'StreamAOD', 'StreamESD', 'StreamRDO',
'StreamHITS', 'StreamEVGEN', 'EmbeddingStream')

Definition at line 33 of file EventGUIDLookupLib.py.

◆ _STREAM_KEY

dict EventGUIDLookupLib._STREAM_KEY
protected
Initial value:
= {
'RAW': 'StreamRAW',
'ESD': 'StreamESD',
'AOD': 'StreamAOD',
'RDO': 'StreamRDO',
'HITS': 'StreamHITS',
'EVNT': 'StreamEVGEN',
}

Definition at line 24 of file EventGUIDLookupLib.py.

◆ _TOKEN_DB_RE

EventGUIDLookupLib._TOKEN_DB_RE
protected
Initial value:
= re.compile(r'\‍[DB=([0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-'
r'[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12})\‍]')

Definition at line 20 of file EventGUIDLookupLib.py.