ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
xAOD
xAODCore
Root
AuxCompression.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
// EDM include(s):
7
#include "
AthContainers/AuxTypeRegistry.h
"
8
9
// Local include(s):
10
#include "
xAODCore/AuxCompression.h
"
11
12
// System include(s).
13
#include <iostream>
14
15
namespace
xAOD
{
16
17
AuxCompression::AuxCompression
()
18
:
m_compression_map
{}
19
{
20
}
21
36
void
AuxCompression::setCompressedAuxIDs
(
const
std::map<
unsigned
int
, std::set< std::string > >& attributes ) {
37
38
m_compression_map
= attributes;
39
return
;
40
}
41
50
std::map< unsigned int, SG::auxid_set_t >
51
AuxCompression::getCompressedAuxIDs
(
const
SG::auxid_set_t
& fullset )
const
{
52
//these are unnecessary if using a transparent comparitor in the set type
53
static
const
std::string hyphenStr{
"-"
};
54
static
const
std::string asteriskStr{
"*"
};
55
//
56
// Create an empty result map
57
std::map< unsigned int, SG::auxid_set_t > result;
58
59
// Loop over the internal map set by setCompressedAuxIDs
60
for
(
const
auto
& val :
m_compression_map
) {
61
62
// Set helper variables
63
const
unsigned
int
nmantissa = val.first;
64
const
std::set< std::string> &
names
= val.second;
65
66
// Start from an empty list
67
SG::auxid_set_t
auxids;
68
69
// Check the simplest case, nothing to be compressed
70
if
(
names
.empty() || (
names
.find(hyphenStr) !=
names
.end() ) ) {
71
continue
;
72
}
73
74
// Check that the user only put positive or negative selections on the
75
// list. They can't be mixed.
76
bool
sub =
false
,
add
=
false
;
77
auto
name_itr =
names
.begin();
78
auto
name_end =
names
.end();
79
for
( ; name_itr != name_end; ++name_itr ) {
80
if
( ( *name_itr )[ 0 ] ==
'-'
) {
81
sub =
true
;
82
}
else
{
83
add
=
true
;
84
}
85
}
86
if
( sub &&
add
) {
87
// At this level we don't have a handle to the MsgStream,
88
// otherwise it'd be preferred!
89
std::cerr <<
"xAOD::AuxCompression ERROR Mixing + and - options for "
90
<<
"compression attributes"
<< std::endl;
91
continue
;
// Ill-defined input, not compressing anything just in case
92
}
93
94
// Loop over the full set, find all float and std::vector<float> variables, add to the list
95
// This is our starting point as we currently compress only floats.
96
// This way we don't mistakenly float compress a random type based on wrong user input.
97
SG::auxid_set_t
fauxids;
98
99
// not using reference, because our iterator doesn't return a reference
100
for
(
const
SG::auxid_t
auxid : fullset ) {
101
const
std::string cType =
SG::AuxTypeRegistry::instance
().
getTypeName
( auxid );
102
if
( cType ==
"float"
|| cType ==
"std::vector<float>"
) {
103
fauxids.insert( auxid );
104
}
105
}
106
107
// Check if all floats are to be compressed
108
if
(
names
.find(asteriskStr) !=
names
.end() ) {
109
auxids = std::move(fauxids);
110
}
111
// Here comes the parsing either + or - as in AuxSelection that we follow closely
112
else
if
(
add
) {
113
// Build the list of variables to be compressed starting from the empty list
114
name_itr =
names
.begin();
115
name_end =
names
.end();
116
for
( ; name_itr != name_end; ++name_itr ) {
117
// Get the ID of this name
118
const
SG::auxid_t
auxid =
SG::AuxTypeRegistry::instance
().
findAuxID
( *name_itr );
119
if
( auxid !=
SG::null_auxid
) {
120
// Add this variable if it exists
121
if
( fauxids.test( auxid ) ) {
122
auxids.insert( auxid );
123
}
124
}
125
}
126
}
else
{
127
// Build the list of variables to be compressed starting from the full float list
128
auxids = fauxids;
129
// Loop over all float variables and remove if matching
130
for
(
SG::auxid_t
auxid : fauxids ) {
131
// Construct the name of this ID
132
const
std::string attrname =
"-"
+
SG::AuxTypeRegistry::instance
().
getName
( auxid );
133
// Check if it is in the list to be removed
134
if
(
names
.find( attrname ) !=
names
.end() ) {
135
auxids.erase( auxid );
136
}
137
}
138
}
139
140
// Finally fill the result map
141
result[ nmantissa ] = std::move(auxids);
142
143
}
// End of loop over internal map
144
145
return
result;
// Return the result map
146
}
147
148
}
// namespace xAOD
AuxCompression.h
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
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::getTypeName
std::string getTypeName(SG::auxid_t auxid) const
Return the type name of an aux data item.
Definition
AuxTypeRegistry.cxx:924
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::AuxCompression::AuxCompression
AuxCompression()
Default constructor.
Definition
AuxCompression.cxx:17
xAOD::AuxCompression::getCompressedAuxIDs
virtual std::map< unsigned int, SG::auxid_set_t > getCompressedAuxIDs(const SG::auxid_set_t &fullset) const
Return those variables that are selected to be compressed per compression setting.
Definition
AuxCompression.cxx:51
xAOD::AuxCompression::setCompressedAuxIDs
virtual void setCompressedAuxIDs(const std::map< unsigned int, std::set< std::string > > &attributes)
Set which variables should be compressed per compression setting.
Definition
AuxCompression.cxx:36
xAOD::AuxCompression::m_compression_map
std::map< unsigned int, std::set< std::string > > m_compression_map
Properties following the variable selection convention.
Definition
AuxCompression.h:36
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
xAOD::names
static const EventInfo_v1::Accessor< std::vector< std::string > > names("streamTagNames")
Generated on
for ATLAS Offline Software by
1.17.0