From aa933909035b0ff495a3c84f1d38b89611d7290e Mon Sep 17 00:00:00 2001
From: Alaettin Serhan Mete <alaettin.serhan.mete@cern.ch>
Date: Thu, 3 Sep 2020 14:32:24 +0000
Subject: [PATCH] AthenaServices : Fill the float compression map if and only
 if something is setup to be compressed

---
 .../AthenaServices/src/AthenaOutputStream.cxx | 20 +++++++++----------
 .../test/AthenaOutputStream_test.cxx          |  3 ++-
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/Control/AthenaServices/src/AthenaOutputStream.cxx b/Control/AthenaServices/src/AthenaOutputStream.cxx
index 8701fa4c6513..6d521d15da2f 100644
--- a/Control/AthenaServices/src/AthenaOutputStream.cxx
+++ b/Control/AthenaServices/src/AthenaOutputStream.cxx
@@ -874,7 +874,6 @@ void AthenaOutputStream::addItemObjects(const SG::FolderItem& item,
                     // Get a handle on the compression information for this store
                     std::string key = item_key;
                     key.erase (key.size()-4, 4);
-                    SG::ThinningInfo::compression_map_t& compMap = compInfo[key];
 
                     // Build the compression list, retrieve the relevant AuxIDs and
                     // store it in the relevant map that is going to be inserted into
@@ -882,16 +881,15 @@ void AthenaOutputStream::addItemObjects(const SG::FolderItem& item,
                     xAOD::AuxCompression compression;
                     compression.setCompressedAuxIDs( comp_attr_map );
                     for( const auto& it : compression.getCompressedAuxIDs( allVars ) ) {
-                      if( it.second.size() > 0 ) // insert only if the set is non-empty
-                        compMap[ it.first ] = it.second;
-                    }
-
-                    for( const auto& it : compMap ) {
-                      ATH_MSG_DEBUG( "Lossy float compression level " << it.first <<
-                                     " contains " << it.second.size() <<  " elements"
-                                     " for container " << key );
-                    }
-                  }
+                      if( it.second.size() > 0 ) { // insert only if the set is non-empty
+                        compInfo[ key ][ it.first ] = it.second;
+                        ATH_MSG_DEBUG( "Container " << key << " has " << it.second.size() <<
+                                       " variables that'll be lossy float compressed"
+                                       " with " << it.first << " mantissa bits" );
+                      }
+                    } // End of loop over variables to be lossy float compressed
+                  } // End of lossy float compression logic
+
                }
 
                added = true;
diff --git a/Control/AthenaServices/test/AthenaOutputStream_test.cxx b/Control/AthenaServices/test/AthenaOutputStream_test.cxx
index 8425a140a038..953bfe01db91 100644
--- a/Control/AthenaServices/test/AthenaOutputStream_test.cxx
+++ b/Control/AthenaServices/test/AthenaOutputStream_test.cxx
@@ -131,9 +131,10 @@ int main() {
 
   const SG::CompressionInfo* compInfo = nullptr;
   assert (pStore->retrieve (compInfo, "CompressionInfo_AthenaOutputStream").isSuccess());
-  assert (compInfo->size() == 2); // 2 levels of compression as high/low
+  assert (compInfo->size() == 1); // A single container has variables to be compressed
   auto val = compInfo->find("comp");
   assert (val != compInfo->end());
+  assert (val->second.size() == 2); // 2 levels of compression as high/low
   assert (val->second.at(10).test(foo.auxid()));  // compress foo high
   assert (!val->second.at(10).test(bar.auxid())); // don't compress bar since it's double
   assert (val->second.at(16).test(zzz.auxid()));  // compress zzz low
-- 
GitLab