3 from GaudiConfig2.semantics
import getSemanticsFor, SequenceSemantics
4 from collections
import defaultdict
6 from AthenaCommon.Logging
import logging
7 msg = logging.getLogger(
"OutputStreamItemListAuxCheck")
11 __handled_types__ = (
"OutputStreamItemList", )
13 __AUX_len__ = len(__AUX_ext__)
16 valueSem = getSemanticsFor(
"std::string")
if cpp_type
in self.
__handled_types__ else None
17 super(OutputStreamItemListSemantics, self).
__init__(cpp_type, valueSem=valueSem)
30 Checks dynamic Aux attribute selection in the ItemList for duplicates and conflicts
32 From Event/xAOD/xAODCore/Root/AuxSelection.cxx
33 The formalism for attribute selection is the following:
34 - An empty set, or a set containing "*" will select all the dynamic
35 attributes passed to the object.
36 - A single "-" attribute will not select any of the dynamic attributes.
37 - A set of variables (without "-" as the first character of the
38 variable names) will select just the variables listed.
39 - A set of variable names, each prefixed by "-", will select all
40 variables but the ones listed.
43 auxitems = defaultdict(set)
52 auxitems[itemname].
add( selection )
54 newitemlist.append(item)
57 for k,sel
in auxitems.items():
61 if ".." in line
or line.startswith(
".")
or line.endswith(
'.'):
62 raise ValueError(f
"ItemList AuxAttribute selection syntax error for {k} - extra dot in '{line}'")
63 newsel =
set(line.split(
'.'))
64 newneg = {s
for s
in newsel
if s[:1]==
'-'}
71 raise ValueError(f
"Multiple (different) negative selection are not supported: for {k} : {str(sel)}")
72 allsel.update( newsel )
73 if negsel
and len(negsel) != len(allsel):
74 raise ValueError(f
"Mixing up negative and positive Aux selections is not supported: {k} : {str(sel)}")
77 newauxlist.append( k +
next(iter(sel)) )
80 if '' in sel
or '*' in allsel:
82 msg.info(f
"Multiple Aux attribute selections for {k} - will write all attributes." +
83 f
" Original selection was: {str(sel)}")
84 newauxlist.append( k +
'*')
88 newauxlist.append(newitem)
89 msg.info(f
"Multiple attribute selections for {k} - will write combined selection. Found {len(sel)} selections: {str(sel)}")
90 msg.info(f
" New selection: {newitem}")
92 return newitemlist + newauxlist