ATLAS Offline Software
Public Member Functions | Protected Attributes | List of all members
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. More...
 
virtual void selectAux (const std::set< std::string > &attributes)
 Select which variables should be written out. More...
 
virtual SG::auxid_set_t getSelectedAuxIDs (const SG::auxid_set_t &fullset) const
 Return which variables were selected to be written out. More...
 

Protected Attributes

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

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 30 of file AuxSelection.cxx.

31  : m_names()
32  {
33  }

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 62 of file AuxSelection.cxx.

62  {
63 
64  // Check for the simplest case... all variables selected:
65  if( m_names.empty() || ( m_names.find( "*" ) != m_names.end() ) ) {
66  return fullset;
67  }
68 
69  // Start from an empty list:
70  SG::auxid_set_t auxids;
71 
72  // Check if everything should be disregarded:
73  if( m_names.find( "-" ) != m_names.end() ) {
74  return auxids;
75  }
76 
77  // Check that the user only put positive or negative selections on the
78  // list. They can't be mixed.
79  bool sub = false, add = false;
80  std::set< std::string >::const_iterator name_itr = m_names.begin();
81  std::set< std::string >::const_iterator name_end = m_names.end();
82  for( ; name_itr != name_end; ++name_itr ) {
83  if( ( *name_itr )[ 0 ] == '-' ) {
84  sub = true;
85  } else {
86  add = true;
87  }
88  }
89  if( sub && add ) {
90  std::cerr << "xAOD::AuxSelection ERROR Mixing + and - options for "
91  << "dynamic attributes" << std::endl;
92  return fullset; //better safe than sorry
93  }
94 
95  if( add ) {
96  // Start with an empty list, and loop over the selected names:
97  name_itr = m_names.begin();
98  name_end = m_names.end();
99  for( ; name_itr != name_end; ++name_itr ) {
100  // Get the ID of this name:
101  const SG::auxid_t auxid =
103  if( auxid != SG::null_auxid ) {
104  // Add this variable if it exists:
105  if( fullset.test( auxid ) ) {
106  auxids.insert( auxid );
107  }
108  } else {
109  // Check if a warning should be printed at this time or not:
110  std::lock_guard<std::mutex> lock (mentionedMutex);
111  if( ::mentionedVariableNames.insert( *name_itr ).second ) {
112  // Apparently we didn't complain about this name yet...
113  std::cerr << "xAOD::AuxSelection WARNING Selected dynamic "
114  << "Aux atribute \"" << *name_itr
115  << "\" not found in the registry" << std::endl;
116  }
117  }
118  }
119  } else {
120  // Start from the full list:
121  auxids = fullset;
122  // ...and check which variables should be removed:
123  for (SG::auxid_t id : fullset) {
124  // Construct the name that we need to look for:
125  const std::string attrname =
127  // Check if it is in the list to be removed:
128  if( m_names.find( attrname ) != m_names.end() ) {
129  auxids.erase( id );
130  }
131  }
132  }
133 
134  // Return the list of variables to be written out:
135  return auxids;
136  }

◆ 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 47 of file AuxSelection.cxx.

47  {
48 
50  return;
51  }

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:
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:639
SG::AuxTypeRegistry::findAuxID
SG::auxid_t findAuxID(const std::string &name, const std::string &clsname="") const
Look up a name -> auxid_t mapping.
Definition: AuxTypeRegistry.cxx:756
SG::AuxTypeRegistry::getName
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
Definition: AuxTypeRegistry.cxx:881
xAOD::AuxSelection::m_names
std::set< std::string > m_names
Properties following the variable selection convention.
Definition: AuxSelection.h:45
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
CxxUtils::ConcurrentBitset::insert
ConcurrentBitset & insert(bit_t bit, bit_t new_nbits=0)
Set a bit to 1.
add
bool add(const std::string &hname, TKey *tobj)
Definition: fastadd.cxx:55
collListGuids.attributes
attributes
Definition: collListGuids.py:46
SG::auxid_set_t
A set of aux data identifiers.
Definition: AuxTypes.h:47
CxxUtils::ConcurrentBitset::erase
ConcurrentBitset & erase(bit_t bit)
Turn off one bit.
CxxUtils::ConcurrentBitset::test
bool test(bit_t bit) const
Test to see if a bit is set.