ATLAS Offline Software
AuxSelection.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id: AuxSelection.cxx 653257 2015-03-11 11:26:15Z krasznaa $
6 
7 // System include(s):
8 #include <iostream>
9 #include <map>
10 
11 // EDM include(s):
13 
14 // Local include(s):
15 #include "xAODCore/AuxSelection.h"
17 #include <mutex>
18 
19 namespace {
20 
23  std::set< std::string > mentionedVariableNames ATLAS_THREAD_SAFE;
24  std::mutex mentionedMutex;
25 
26 } // private namespace
27 
28 namespace xAOD {
29 
31  : m_names()
32  {
33  }
34 
47  void AuxSelection::selectAux( const std::set< std::string >& attributes ) {
48 
50  return;
51  }
52 
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  }
137 
138 } // namespace xAOD
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:49
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:159
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
SG::AuxTypeRegistry::getName
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
Definition: AuxTypeRegistry.cxx:277
xAOD::AuxSelection::m_names
std::set< std::string > m_names
Properties following the variable selection convention.
Definition: AuxSelection.h:45
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
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
AuxSelection.h
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
collListGuids.attributes
attributes
Definition: collListGuids.py:46
SG::auxid_set_t
A set of aux data identifiers.
Definition: AuxTypes.h:47
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
xAOD::AuxSelection::selectAux
virtual void selectAux(const std::set< std::string > &attributes)
Select which variables should be written out.
Definition: AuxSelection.cxx:47
CxxUtils::ConcurrentBitset::erase
ConcurrentBitset & erase(bit_t bit)
Turn off one bit.
xAOD::AuxSelection::getSelectedAuxIDs
virtual SG::auxid_set_t getSelectedAuxIDs(const SG::auxid_set_t &fullset) const
Return which variables were selected to be written out.
Definition: AuxSelection.cxx:62
checker_macros.h
Define macros for attributes used to control the static checker.
xAOD::AuxSelection::AuxSelection
AuxSelection()
Default constructor.
Definition: AuxSelection.cxx:30
CxxUtils::ConcurrentBitset::test
bool test(bit_t bit) const
Test to see if a bit is set.