28 def checkAuxAttributes(self, itemList):
29 """
30 Checks dynamic Aux attribute selection in the ItemList for duplicates and conflicts
31
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.
41 """
42 newitemlist=[]
43 auxitems = defaultdict(set)
44 for item in itemList:
45 auxpos = item.find(self.__AUX_ext__)
46 if auxpos > 0:
47
48 itemname = item[ : auxpos+self.__AUX_len__]
49 selection = item[auxpos+self.__AUX_len__ : ]
50
51
52 auxitems[itemname].
add( selection )
53 else:
54 newitemlist.append(item)
55
56 newauxlist=[]
57 for k,sel in auxitems.items():
60 for line in sel:
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]=='-'}
65 if newneg:
66 if not negsel:
67 negsel = newneg
68 else:
69
70 if newneg != negsel:
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)}")
75 if len(sel) == 1:
76
77 newauxlist.append( k + next(iter(sel)) )
78 continue
79
80 if '' in sel or '*' in allsel:
81 if len(allsel) > 1:
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 + '*')
85 continue
86
87 newitem = k + ".".join(sorted(allsel))
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}")
91
92 return newitemlist + newauxlist
93
94
bool add(const std::string &hname, TKey *tobj)