ATLAS Offline Software
Loading...
Searching...
No Matches
xAOD::AuxCompression Class Reference

#include <AuxCompression.h>

Collaboration diagram for xAOD::AuxCompression:

Public Member Functions

 AuxCompression ()
 Default constructor.
virtual void setCompressedAuxIDs (const std::map< unsigned int, std::set< std::string > > &attributes)
 Set which variables should be compressed per compression setting.
virtual std::map< unsigned int, SG::auxid_set_tgetCompressedAuxIDs (const SG::auxid_set_t &fullset) const
 Return those variables that are selected to be compressed per compression setting.

Protected Attributes

std::map< unsigned int, std::set< std::string > > m_compression_map
 Properties following the variable selection convention.

Detailed Description

Definition at line 20 of file AuxCompression.h.

Constructor & Destructor Documentation

◆ AuxCompression()

xAOD::AuxCompression::AuxCompression ( )

Default constructor.

Definition at line 17 of file AuxCompression.cxx.

19 {
20 }
std::map< unsigned int, std::set< std::string > > m_compression_map
Properties following the variable selection convention.

Member Function Documentation

◆ getCompressedAuxIDs()

std::map< unsigned int, SG::auxid_set_t > xAOD::AuxCompression::getCompressedAuxIDs ( const SG::auxid_set_t & fullset) const
virtual

Return those variables that are selected to be compressed per compression setting.

This function takes care of interpreting the options passed to CompressionList in Athena.

It filters the list of variables passed to it, and returns the IDs of just the variables that should be compressed.

Parameters
fullsetThe variables to be compressed based on the rules received
Returns
The list of variables to be compressed per compression level

Definition at line 51 of file AuxCompression.cxx.

51 {
52
53 // Create an empty result map
54 std::map< unsigned int, SG::auxid_set_t > result;
55
56 // Loop over the internal map set by setCompressedAuxIDs
57 for(const auto& val : m_compression_map) {
58
59 // Set helper variables
60 const unsigned int nmantissa = val.first;
61 const std::set< std::string > &names = val.second;
62
63 // Start from an empty list
64 SG::auxid_set_t auxids;
65
66 // Check the simplest case, nothing to be compressed
67 if( names.empty() || ( names.find("-") != names.end() ) ) {
68 continue;
69 }
70
71 // Check that the user only put positive or negative selections on the
72 // list. They can't be mixed.
73 bool sub = false, add = false;
74 std::set< std::string >::const_iterator name_itr = names.begin();
75 std::set< std::string >::const_iterator name_end = names.end();
76 for( ; name_itr != name_end; ++name_itr ) {
77 if( ( *name_itr )[ 0 ] == '-' ) {
78 sub = true;
79 } else {
80 add = true;
81 }
82 }
83 if( sub && add ) {
84 // At this level we don't have a handle to the MsgStream,
85 // otherwise it'd be preferred!
86 std::cerr << "xAOD::AuxCompression ERROR Mixing + and - options for "
87 << "compression attributes" << std::endl;
88 continue; // Ill-defined input, not compressing anything just in case
89 }
90
91 // Loop over the full set, find all float and std::vector<float> variables, add to the list
92 // This is our starting point as we currently compress only floats.
93 // This way we don't mistakenly float compress a random type based on wrong user input.
94 SG::auxid_set_t fauxids;
95
96 // not using reference, because our iterator doesn't return a reference
97 for ( const SG::auxid_t auxid : fullset ) {
98 const std::string cType = SG::AuxTypeRegistry::instance().getTypeName( auxid );
99 if( cType == "float" || cType == "std::vector<float>" ) {
100 fauxids.insert( auxid );
101 }
102 }
103
104 // Check if all floats are to be compressed
105 if( names.find("*") != names.end() ) {
106 auxids = std::move(fauxids);
107 }
108 // Here comes the parsing either + or - as in AuxSelection that we follow closely
109 else if( add ) {
110 // Build the list of variables to be compressed starting from the empty list
111 name_itr = names.begin();
112 name_end = names.end();
113 for( ; name_itr != name_end; ++name_itr ) {
114 // Get the ID of this name
115 const SG::auxid_t auxid = SG::AuxTypeRegistry::instance().findAuxID( *name_itr );
116 if( auxid != SG::null_auxid ) {
117 // Add this variable if it exists
118 if( fauxids.test( auxid ) ) {
119 auxids.insert( auxid );
120 }
121 }
122 }
123 } else {
124 // Build the list of variables to be compressed starting from the full float list
125 auxids = fauxids;
126 // Loop over all float variables and remove if matching
127 for ( SG::auxid_t auxid : fauxids ) {
128 // Construct the name of this ID
129 const std::string attrname = "-" + SG::AuxTypeRegistry::instance().getName( auxid );
130 // Check if it is in the list to be removed
131 if( names.find( attrname ) != names.end() ) {
132 auxids.erase( auxid );
133 }
134 }
135 }
136
137 // Finally fill the result map
138 result[ nmantissa ] = std::move(auxids);
139
140 } // End of loop over internal map
141
142 return result; // Return the result map
143 }
bool test(bit_t bit) const
Test to see if a bit is set.
ConcurrentBitset & erase(bit_t bit)
Turn off one bit.
ConcurrentBitset & insert(bit_t bit, bit_t new_nbits=0)
Set a bit to 1.
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.
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
static const SG::AuxElement::Accessor< std::vector< std::string > > names("thrNames")
Accessor for the names of the passed thresholds.

◆ setCompressedAuxIDs()

void xAOD::AuxCompression::setCompressedAuxIDs ( const std::map< unsigned int, std::set< std::string > > & attributes)
virtual

Set which variables should be compressed per compression setting.

Set which variables should be compressed The formalism is the following:

  • A set containing "*" will compress all float attributes passed to the object.
  • An empty set, or a single "-" attribute will not compress any of the float attributes.
  • A set of variables (without "-" as the first character of the variable names) will compress just the variables listed.
  • A set of variable names, each prefixed by "-", will compress all variables but the ones listed.
Parameters
attributesThe attributes from CompressionList. By convention the key is the nmantissa and the value is the set of variables that should be compressed at that level.

Definition at line 36 of file AuxCompression.cxx.

36 {
37
39 return;
40 }

Member Data Documentation

◆ m_compression_map

std::map< unsigned int, std::set< std::string > > xAOD::AuxCompression::m_compression_map
protected

Properties following the variable selection convention.

Definition at line 36 of file AuxCompression.h.


The documentation for this class was generated from the following files: