ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
xAOD
xAODCore
Root
AuxSelection.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// $Id: AuxSelection.cxx 653257 2015-03-11 11:26:15Z krasznaa $
6
7
8
9
// EDM include(s):
10
#include "
AthContainers/AuxTypeRegistry.h
"
11
12
// Local include(s):
13
#include "
xAODCore/AuxSelection.h
"
14
#include "
CxxUtils/checker_macros.h
"
15
#include <mutex>
16
17
// System include(s):
18
#include <iostream>
19
#include <map>
20
21
namespace
{
22
25
std::set< std::string > mentionedVariableNames
ATLAS_THREAD_SAFE
;
26
std::mutex mentionedMutex;
27
28
}
// private namespace
29
30
namespace
xAOD
{
31
32
AuxSelection::AuxSelection
()
33
:
m_names
()
34
{
35
}
36
49
void
AuxSelection::selectAux
(
const
std::set< std::string >& attributes ) {
50
51
m_names
= attributes;
52
return
;
53
}
54
63
SG::auxid_set_t
64
AuxSelection::getSelectedAuxIDs
(
const
SG::auxid_set_t
& fullset )
const
{
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 =
104
SG::AuxTypeRegistry::instance
().
findAuxID
( *name_itr );
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 =
128
"-"
+
SG::AuxTypeRegistry::instance
().
getName
(
id
);
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
}
139
140
}
// namespace xAOD
AuxSelection.h
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
lock
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
checker_macros.h
Define macros for attributes used to control the static checker.
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition
checker_macros.h:211
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:757
SG::AuxTypeRegistry::getName
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
Definition
AuxTypeRegistry.cxx:882
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition
AuxTypeRegistry.cxx:640
SG::auxid_set_t
A set of aux data identifiers.
Definition
AuxTypes.h:47
xAOD::AuxSelection::m_names
std::set< std::string > m_names
Properties following the variable selection convention.
Definition
AuxSelection.h:45
xAOD::AuxSelection::selectAux
virtual void selectAux(const std::set< std::string > &attributes)
Select which variables should be written out.
Definition
AuxSelection.cxx:49
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:64
xAOD::AuxSelection::AuxSelection
AuxSelection()
Default constructor.
Definition
AuxSelection.cxx:32
add
bool add(const std::string &hname, TKey *tobj)
Definition
fastadd.cxx:55
SG::null_auxid
static const auxid_t null_auxid
To signal no aux data item.
Definition
AuxTypes.h:30
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition
AuxTypes.h:27
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition
ICaloAffectedTool.h:24
Generated on
for ATLAS Offline Software by
1.17.0