Commit c149e050 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

Merge branch 'master-relocate-floatcompressor' into 'master'

CaloUtils + CxxUtils + xAODCore + xAODTrackingCnv: Relocate FloatCompressor from xAODCore to CxxUtils

See merge request !35392
parents bb8ba973 d7a50ed2
......@@ -13,9 +13,9 @@
#include "AthenaBaseComps/AthService.h"
#include "CaloInterface/IxAODClusterCompressor.h"
#include "xAODCaloEvent/CaloClusterContainer.h"
#include "xAODCore/tools/FloatCompressor.h"
#include "CxxUtils/checker_macros.h"
#include "CxxUtils/FloatCompressor.h"
class ATLAS_CHECK_THREAD_SAFETY xAODClusterCompressor :
virtual public IxAODClusterCompressor, public AthService {
......@@ -45,8 +45,8 @@ class ATLAS_CHECK_THREAD_SAFETY xAODClusterCompressor :
typedef std::array< xAOD::CaloCluster::MomentType,60> momentList_t;
momentList_t m_allMoments;
//Use Float compressor from xAODCore
xAOD::FloatCompressor m_compressor;
//Use Float compressor from CxxUtils
CxxUtils::FloatCompressor m_compressor;
//JobO-driven flag to turn compression on/off
bool m_isEnabled;
......
......@@ -72,6 +72,10 @@ atlas_add_test( bitscan_test_portable
SOURCES test/bitscan_test.cxx
LINK_LIBRARIES CxxUtils )
atlas_add_test( ut_cxxutils_floatcompression_test
SOURCES test/ut_cxxutils_floatcompression_test.cxx
LINK_LIBRARIES CxxUtils )
if( TARGET CxxUtils_bitscan_test_portable )
target_compile_definitions(CxxUtils_bitscan_test_portable
PRIVATE "-DTEST_PORTABLE" )
......
......@@ -5,15 +5,15 @@
*/
// $Id: FloatCompressor.h 789425 2016-12-13 10:50:12Z krasznaa $
#ifndef XAODCORE_TOOLS_FLOATCOMPRESSOR_H
#define XAODCORE_TOOLS_FLOATCOMPRESSOR_H
#ifndef CXXUTILS_FLOATCOMPRESSOR_H
#define CXXUTILS_FLOATCOMPRESSOR_H
// System include(s):
extern "C" {
# include <stdint.h>
}
namespace xAOD {
namespace CxxUtils {
/// Class implementing a lossy float compression
///
......@@ -60,6 +60,6 @@ namespace xAOD {
}; // class FloatCompressor
} // namespace xAOD
} // namespace CxxUtils
#endif // XAODCORE_TOOLS_FLOATCOMPRESSOR_H
#endif // CXXUTILS_FLOATCOMPRESSOR_H
......@@ -8,9 +8,9 @@
#include <cmath>
// Local include(s):
#include "xAODCore/tools/FloatCompressor.h"
#include "CxxUtils/FloatCompressor.h"
namespace xAOD {
namespace CxxUtils {
/// Total number of total mantissa bits
static const unsigned int NMANTISSA = 23;
......@@ -122,4 +122,4 @@ namespace xAOD {
return fi.fvalue;
}
} // namespace xAOD
} // namespace CxxUtils
......@@ -4,7 +4,7 @@
// $Id: ut_xaodcore_floatcompression_test.cxx 789425 2016-12-13 10:50:12Z krasznaa $
//
// Unit test for the xAOD::FloatCompressor class.
// Unit test for the CxxUtils::FloatCompressor class.
//
// System include(s):
......@@ -12,13 +12,13 @@
#include <iomanip>
// Local include(s):
#include "xAODCore/tools/FloatCompressor.h"
#include "CxxUtils/FloatCompressor.h"
/// Helper function printing the results of some compressions
void testCompression( const xAOD::FloatCompressor& fc, float value ) {
void testCompression( const CxxUtils::FloatCompressor& fc, float value ) {
std::cout << "Original value: " << std::dec << value << std::endl;
xAOD::FloatCompressor::floatint_t compressed;
CxxUtils::FloatCompressor::floatint_t compressed;
compressed.fvalue = fc.reduceFloatPrecision( value );
std::cout << "Compressed value: " << compressed.fvalue
<< " (hex: " << std::hex << std::setw( 8 ) << std::setfill( '0' )
......@@ -29,14 +29,14 @@ void testCompression( const xAOD::FloatCompressor& fc, float value ) {
int main() {
// Create a compressor leaving only 7 mantissa bits:
const xAOD::FloatCompressor fc1( 7 );
const CxxUtils::FloatCompressor fc1( 7 );
// Try to compress some numbers, and see what we get:
testCompression( fc1, 1.2345 );
testCompression( fc1, 3.1415 );
// Now test a compressor leaving 16 mantissa bits:
const xAOD::FloatCompressor fc2( 16 );
const CxxUtils::FloatCompressor fc2( 16 );
// Try some numbers with this as well:
testCompression( fc2, 2.7182 );
......@@ -44,7 +44,7 @@ int main() {
// Finally, test that when we use the maximal number of mantissa bits for
// a float, the number doesn't get changed.
const xAOD::FloatCompressor fc3( 23 );
const CxxUtils::FloatCompressor fc3( 23 );
// Look at some numbers with this as well:
testCompression( fc3, 2.3456 );
......
......@@ -55,10 +55,6 @@ atlas_add_test( ut_xaodcore_clearDecorations_test
SOURCES test/ut_xaodcore_clearDecorations_test.cxx
LINK_LIBRARIES AthContainers xAODCore )
atlas_add_test( ut_xaodcore_floatcompression_test
SOURCES test/ut_xaodcore_floatcompression_test.cxx
LINK_LIBRARIES xAODCore )
atlas_add_test( ut_xaodcore_printhelpers_test
SOURCES test/ut_xaodcore_printhelpers_test.cxx
LINK_LIBRARIES AthContainers xAODCore )
......
......@@ -16,9 +16,9 @@
#include "xAODCore/AuxContainerBase.h"
#include "xAODCore/tools/IOStats.h"
#include "xAODCore/tools/ReadStats.h"
#include "xAODCore/tools/FloatCompressor.h"
#include "CxxUtils/checker_macros.h"
#include "CxxUtils/FloatCompressor.h"
using namespace std;
......@@ -682,13 +682,13 @@ namespace xAOD {
// Two main modes are supported: High and Low Compression
const unsigned int idx = highComp ? AuxCompression::High : AuxCompression::Low;
// This part could be nicer if we were to rewrite xAOD::FloatCompressor
// This part could be nicer if we were to rewrite CxxUtils::FloatCompressor
// to accept the number of bits in the call to reduceFloatPrecision instead
// of the constructor
static const unsigned int high_bits = m_compression.getCompressionBits(true);
static const unsigned int low_bits = m_compression.getCompressionBits(false);
static const std::vector< xAOD::FloatCompressor >
myFloatCompressors { xAOD::FloatCompressor(high_bits), xAOD::FloatCompressor(low_bits) };
static const std::vector< CxxUtils::FloatCompressor >
myFloatCompressors { CxxUtils::FloatCompressor(high_bits), CxxUtils::FloatCompressor(low_bits) };
return myFloatCompressors[ idx ].reduceFloatPrecision( value );
}
......
......@@ -40,4 +40,5 @@ atlas_add_component( xAODTrackingCnv
LINK_LIBRARIES xAODTracking TrkTrack AthenaBaseComps AthenaKernel
EventPrimitives GaudiKernel GeneratorObjects MCTruthClassifierLib Particle
ParticleTruth TrkLinks TrkParticleBase TrkTruthData VxVertex
TrkToolInterfaces xAODCore xAODTrackingCnvLib )
TrkToolInterfaces xAODCore xAODTrackingCnvLib
PRIVATE_LINK_LIBRARIES CxxUtils )
......@@ -41,7 +41,7 @@ namespace xAODMaker {
// Create the helper objects:
m_diagCovMatrixCompressor.reset(
new xAOD::FloatCompressor( m_diagCovMatrixBits ) );
new CxxUtils::FloatCompressor( m_diagCovMatrixBits ) );
// Return gracefully:
return StatusCode::SUCCESS;
......@@ -69,7 +69,7 @@ namespace xAODMaker {
tp.setDefiningParametersCovMatrixDiagVec( diagVecCompr );
auto compressOffDiag = []( const std::vector< float >& offDiagVec, int bits ) -> std::vector< float > {
xAOD::FloatCompressor fc( bits );
CxxUtils::FloatCompressor fc( bits );
std::vector< float > offDiagVecCompr;
offDiagVecCompr.reserve( offDiagVec.size() );
for( float element : offDiagVec ) {
......
......@@ -14,8 +14,8 @@
// Gaudi/Athena include(s):
#include "AthenaBaseComps/AthAlgTool.h"
// xAOD include(s):
#include "xAODCore/tools/FloatCompressor.h"
// CxxUtils include(s):
#include "CxxUtils/FloatCompressor.h"
// Local include(s):
#include "xAODTrackingCnv/ITrackParticleCompressorTool.h"
......@@ -60,7 +60,7 @@ namespace xAODMaker {
/// Helper object for compressing the on-diagonal covariance matrix
/// elements
std::unique_ptr< xAOD::FloatCompressor > m_diagCovMatrixCompressor;
std::unique_ptr< CxxUtils::FloatCompressor > m_diagCovMatrixCompressor;
}; // class TrackParticleCompressorTool
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment