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
// EDM include(s):
6
#include "
AthContainers/AuxTypeRegistry.h
"
7
8
// Local include(s):
9
#include "
xAODCore/AuxSelection.h
"
10
#include "
CxxUtils/checker_macros.h
"
11
#include <mutex>
12
13
// System include(s):
14
#include <iostream>
15
#include <map>
16
#include <print>
17
18
namespace
{
19
22
std::set< std::string > mentionedVariableNames
ATLAS_THREAD_SAFE
;
23
std::mutex mentionedMutex;
24
25
}
// private namespace
26
27
namespace
xAOD
{
28
29
AuxSelection::AuxSelection
()
30
:
m_names
()
31
{
32
}
33
46
void
AuxSelection::selectAux
(
const
std::set< std::string >& attributes ) {
47
48
m_names
= attributes;
49
return
;
50
}
51
60
SG::auxid_set_t
61
AuxSelection::getSelectedAuxIDs
(
const
SG::auxid_set_t
& fullset )
const
{
62
static
const
std::string asteriskStr{
"*"
};
//..or use a transparent comparitor
63
// Check for the simplest case... all variables selected:
64
if
(
m_names
.empty() || (
m_names
.find( asteriskStr ) !=
m_names
.end() ) ) {
65
return
fullset;
66
}
67
68
// Start from an empty list:
69
SG::auxid_set_t
auxids;
70
static
const
std::string hyphenStr{
"-"
};
71
// Check if everything should be disregarded:
72
if
(
m_names
.find( hyphenStr ) !=
m_names
.end() ) {
73
return
auxids;
74
}
75
76
// Check that the user only put positive or negative selections on the
77
// list. They can't be mixed.
78
bool
sub =
false
,
add
=
false
;
79
std::set< std::string >::const_iterator name_itr =
m_names
.begin();
80
std::set< std::string >::const_iterator name_end =
m_names
.end();
81
for
( ; name_itr != name_end; ++name_itr ) {
82
if
( ( *name_itr )[ 0 ] ==
'-'
) {
83
sub =
true
;
84
}
else
{
85
add
=
true
;
86
}
87
}
88
if
( sub &&
add
) {
89
std::println( std::cerr,
"xAOD::AuxSelection ERROR Mixing + and - options for "
90
"dynamic attributes"
);
91
return
fullset;
//better safe than sorry
92
}
93
94
if
(
add
) {
95
// Start with an empty list, and loop over the selected names:
96
name_itr =
m_names
.begin();
97
name_end =
m_names
.end();
98
for
( ; name_itr != name_end; ++name_itr ) {
99
// Get the ID of this name:
100
const
SG::auxid_t
auxid =
101
SG::AuxTypeRegistry::instance
().
findAuxID
( *name_itr );
102
if
( auxid !=
SG::null_auxid
) {
103
// Add this variable if it exists:
104
if
( fullset.test( auxid ) ) {
105
auxids.insert( auxid );
106
}
107
}
else
{
108
// Check if a warning should be printed at this time or not:
109
std::lock_guard<std::mutex>
lock
(mentionedMutex);
110
if
( ::mentionedVariableNames.insert( *name_itr ).second ) {
111
// Apparently we didn't complain about this name yet...
112
std::println( std::cerr,
"xAOD::AuxSelection WARNING Selected dynamic "
113
"Aux atribute \"{}\" not found in the registry"
,
114
*name_itr );
115
}
116
}
117
}
118
}
else
{
119
// Start from the full list:
120
auxids = fullset;
121
// ...and check which variables should be removed:
122
for
(
SG::auxid_t
id
: fullset) {
123
// Construct the name that we need to look for:
124
const
std::string attrname =
125
"-"
+
SG::AuxTypeRegistry::instance
().
getName
(
id
);
126
// Check if it is in the list to be removed:
127
if
(
m_names
.find( attrname ) !=
m_names
.end() ) {
128
auxids.erase(
id
);
129
}
130
}
131
}
132
133
// Return the list of variables to be written out:
134
return
auxids;
135
}
136
137
}
// 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:46
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:61
xAOD::AuxSelection::AuxSelection
AuxSelection()
Default constructor.
Definition
AuxSelection.cxx:29
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