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