ATLAS Offline Software
Loading...
Searching...
No Matches
xAOD::AuxSelection Class Reference

Class helping in dealing with dynamic branch selection. More...

#include <AuxSelection.h>

Collaboration diagram for xAOD::AuxSelection:

Public Member Functions

 AuxSelection ()
 Default constructor.
virtual void selectAux (const std::set< std::string > &attributes)
 Select which variables should be written out.
virtual SG::auxid_set_t getSelectedAuxIDs (const SG::auxid_set_t &fullset) const
 Return which variables were selected to be written out.

Protected Attributes

std::set< std::string > m_names
 Properties following the variable selection convention.

Detailed Description

Class helping in dealing with dynamic branch selection.

This class is used by the code internally to select which of the dynamic branches should be written out into an output file.

Author
Marcin Nowak Marci.nosp@m.n.No.nosp@m.wak@c.nosp@m.ern..nosp@m.ch
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h
Revision
583607
Date
2014-02-17 12:02:08 +0100 (Mon, 17 Feb 2014)

Definition at line 31 of file AuxSelection.h.

Constructor & Destructor Documentation

◆ AuxSelection()

xAOD::AuxSelection::AuxSelection ( )

Default constructor.

Definition at line 32 of file AuxSelection.cxx.

33 : m_names()
34 {
35 }
std::set< std::string > m_names
Properties following the variable selection convention.

Member Function Documentation

◆ getSelectedAuxIDs()

SG::auxid_set_t xAOD::AuxSelection::getSelectedAuxIDs ( const SG::auxid_set_t & fullset) const
virtual

Return which variables were selected to be written out.

This function takes care of interpreting the options passed to ItemList in Athena, and TEvent in ROOT.

It filters the list of variables passed to it, and returns the IDs of just the variables that should be written out.

Parameters
fullsetThe variables to be filtered based on the rules received
Returns
The list of variables to be written out

Definition at line 64 of file AuxSelection.cxx.

64 {
65 static const std::string asteriskStr{"*"}; //..or use a transparent comparitor
66 // Check for the simplest case... all variables selected:
67 if( m_names.empty() || ( m_names.find( asteriskStr ) != m_names.end() ) ) {
68 return fullset;
69 }
70
71 // Start from an empty list:
72 SG::auxid_set_t auxids;
73 static const std::string hyphenStr{"-"};
74 // Check if everything should be disregarded:
75 if( m_names.find( hyphenStr ) != m_names.end() ) {
76 return auxids;
77 }
78
79 // Check that the user only put positive or negative selections on the
80 // list. They can't be mixed.
81 bool sub = false, add = false;
82 std::set< std::string >::const_iterator name_itr = m_names.begin();
83 std::set< std::string >::const_iterator name_end = m_names.end();
84 for( ; name_itr != name_end; ++name_itr ) {
85 if( ( *name_itr )[ 0 ] == '-' ) {
86 sub = true;
87 } else {
88 add = true;
89 }
90 }
91 if( sub && add ) {
92 std::cerr << "xAOD::AuxSelection ERROR Mixing + and - options for "
93 << "dynamic attributes" << std::endl;
94 return fullset; //better safe than sorry
95 }
96
97 if( add ) {
98 // Start with an empty list, and loop over the selected names:
99 name_itr = m_names.begin();
100 name_end = m_names.end();
101 for( ; name_itr != name_end; ++name_itr ) {
102 // Get the ID of this name:
103 const SG::auxid_t auxid =
105 if( auxid != SG::null_auxid ) {
106 // Add this variable if it exists:
107 if( fullset.test( auxid ) ) {
108 auxids.insert( auxid );
109 }
110 } else {
111 // Check if a warning should be printed at this time or not:
112 std::lock_guard<std::mutex> lock (mentionedMutex);
113 if( ::mentionedVariableNames.insert( *name_itr ).second ) {
114 // Apparently we didn't complain about this name yet...
115 std::cerr << "xAOD::AuxSelection WARNING Selected dynamic "
116 << "Aux atribute \"" << *name_itr
117 << "\" not found in the registry" << std::endl;
118 }
119 }
120 }
121 } else {
122 // Start from the full list:
123 auxids = fullset;
124 // ...and check which variables should be removed:
125 for (SG::auxid_t id : fullset) {
126 // Construct the name that we need to look for:
127 const std::string attrname =
129 // Check if it is in the list to be removed:
130 if( m_names.find( attrname ) != m_names.end() ) {
131 auxids.erase( id );
132 }
133 }
134 }
135
136 // Return the list of variables to be written out:
137 return auxids;
138 }
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
SG::auxid_t findAuxID(const std::string &name, const std::string &clsname="") const
Look up a name -> auxid_t mapping.
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
bool add(const std::string &hname, TKey *tobj)
Definition fastadd.cxx:55
ConcurrentBitset & insert(bit_t bit, bit_t new_nbits=0)
Set a bit to 1.
static const auxid_t null_auxid
To signal no aux data item.
Definition AuxTypes.h:30
SG::auxid_t auxid() const
Return the aux id for this variable.
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27

◆ selectAux()

void xAOD::AuxSelection::selectAux ( const std::set< std::string > & attributes)
virtual

Select which variables should be written out.

Sets which variables should be selected from a store object.

The formalism is the following:

  • An empty set, or a set containing "*" will select all the dynamic attributes passed to the object.
  • A single "-" attribute will not select any of the dynamic attributes.
  • A set of variables (without "-" as the first character of the variable names) will select just the variables listed.
  • A set of variable names, each prefixed by "-", will select all variables but the ones listed.
Parameters
attributesThe attributes from ItemList or TEvent

Definition at line 49 of file AuxSelection.cxx.

49 {
50
52 return;
53 }

Member Data Documentation

◆ m_names

std::set< std::string > xAOD::AuxSelection::m_names
protected

Properties following the variable selection convention.

Definition at line 45 of file AuxSelection.h.


The documentation for this class was generated from the following files: