From 9668852cd689967ae3f3fd8d6b98d8cca2fd1c6e Mon Sep 17 00:00:00 2001 From: Tomasz Bold <tomasz.bold@gmail.com> Date: Thu, 8 Nov 2018 16:29:33 +0100 Subject: [PATCH] added serialisation/deserialisation testing Former-commit-id: 9db3aa082d37815a80bf57aad06db02ff2e56612 --- .../src/TriggerEDMSerialiserTool.cxx | 22 ++++++---- .../src/TriggerEDMSerialiserTool.h | 3 +- .../components/TrigOutputHandling_entries.cxx | 7 ++-- .../TrigUpgradeTest/share/egamma.withViews.py | 41 +++++++++++-------- 4 files changed, 43 insertions(+), 30 deletions(-) diff --git a/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMSerialiserTool.cxx b/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMSerialiserTool.cxx index b4d7ed18fb6..a238c0ec8a9 100644 --- a/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMSerialiserTool.cxx +++ b/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMSerialiserTool.cxx @@ -24,7 +24,7 @@ TriggerEDMSerialiserTool::~TriggerEDMSerialiserTool() {} StatusCode TriggerEDMSerialiserTool::initialize() { ATH_CHECK( m_serializerSvc.retrieve() ); - + ATH_CHECK( m_clidSvc.retrieve() ); for ( std::string typeAndKey: m_collectionsToSerialize ) { const std::string type = typeAndKey.substr( 0, typeAndKey.find('#') ); if ( type.find('_') == std::string::npos ) { @@ -65,16 +65,16 @@ StatusCode TriggerEDMSerialiserTool::makeHeader(const Address& address, std::vec return StatusCode::SUCCESS; } -StatusCode TriggerEDMSerialiserTool::fillPayload( void* data, size_t sz, std::vector<uint32_t>& buffer ) const { +StatusCode TriggerEDMSerialiserTool::fillPayload( const void* data, size_t sz, std::vector<uint32_t>& buffer ) const { ATH_CHECK( sz != 0 ); ATH_CHECK( data != nullptr ); buffer.push_back( sz ); // size in bytes - const size_t neededSize = sz/sizeof(uint32_t) + (sz%sizeof(uint32_t) ? 1 : 0); + const size_t neededSize = std::ceil( double(sz)/sizeof(uint32_t) ); // ideally we could use the vector<uint32_t> right away auto intTempBuffer = std::make_unique<uint32_t[]>( neededSize ); intTempBuffer[ neededSize-1 ] = 0; // empty last bytes - std::memcpy(data, intTempBuffer.get(), sz); + std::memcpy( intTempBuffer.get(), data, sz); // copy to buffer buffer.insert( buffer.end(), intTempBuffer.get(), intTempBuffer.get()+neededSize ); @@ -84,7 +84,9 @@ StatusCode TriggerEDMSerialiserTool::fillPayload( void* data, size_t sz, std::ve StatusCode TriggerEDMSerialiserTool::fill( HLT::HLTResultMT& resultToFill ) const { - + ATH_CHECK ( resultToFill.getSerialisedData().find(m_moduleID) == resultToFill.getSerialisedData().end() ); // do not want overwrite + + std::vector<uint32_t> payload; for ( const Address& address: m_toSerialize ) { ATH_MSG_DEBUG( "Streaming " << address.type << "#" << address.key ); // obtain object @@ -119,12 +121,14 @@ StatusCode TriggerEDMSerialiserTool::fill( HLT::HLTResultMT& resultToFill ) cons ATH_CHECK( makeHeader( address, fragment ) ); ATH_CHECK( fillPayload( mem, sz, fragment ) ); fragment[0] = fragment.size(); - - resultToFill.addSerialisedData( m_moduleID, fragment ); - + ATH_MSG_DEBUG("Fragment size " << fragment.size() ); + payload.insert( payload.end(), fragment.begin(), fragment.end() ); + if ( mem ) delete [] static_cast<const char*>( mem ); - ATH_MSG_DEBUG( "Navigation size after inserting " << address.type << "#" << address.key << " " << resultToFill.getSerialisedData( m_moduleID ).size()*sizeof(uint32_t) << " bytes" ); + ATH_MSG_DEBUG( "Payload size after inserting " << address.type << "#" << address.key << " " << payload.size()*sizeof(uint32_t) << " bytes" ); } + + resultToFill.addSerialisedData( m_moduleID, payload ); return StatusCode::SUCCESS; } diff --git a/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMSerialiserTool.h b/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMSerialiserTool.h index f1ce285a638..ee2b38d8006 100644 --- a/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMSerialiserTool.h +++ b/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMSerialiserTool.h @@ -13,7 +13,6 @@ // OutputHandling includes #include "TrigOutputHandling/HLTResultMTMakerTool.h" -#include "TrigSteeringEvent/HLTResult.h" #include "AthenaKernel/IClassIDSvc.h" #include "AthenaKernel/IAthenaSerializeSvc.h" #include "AthenaKernel/IDictLoaderSvc.h" @@ -66,7 +65,7 @@ class TriggerEDMSerialiserTool: public extends<AthAlgTool, HLTResultMTMakerTool> * This function is candidate to be made global function at some point * and we will need also readPayload function */ - StatusCode fillPayload( void* data, size_t sz, std::vector<uint32_t>& buffer ) const ; + StatusCode fillPayload( const void* data, size_t sz, std::vector<uint32_t>& buffer ) const ; }; diff --git a/Trigger/TrigSteer/TrigOutputHandling/src/components/TrigOutputHandling_entries.cxx b/Trigger/TrigSteer/TrigOutputHandling/src/components/TrigOutputHandling_entries.cxx index 19bdde80c86..81a554dac93 100644 --- a/Trigger/TrigSteer/TrigOutputHandling/src/components/TrigOutputHandling_entries.cxx +++ b/Trigger/TrigSteer/TrigOutputHandling/src/components/TrigOutputHandling_entries.cxx @@ -1,16 +1,17 @@ #include "../HLTEDMCreator.h" #include "../StreamTagMakerTool.h" -#include "TrigOutputHandling/HLTResultMTMaker.h" #include "../HLTResultMTMakerAlg.h" +#include "TrigOutputHandling/HLTResultMTMaker.h" #include "../DecisionSummaryMakerAlg.h" #include "TrigOutputHandling/TriggerBitsMakerTool.h" #include "../TriggerEDMSerialiserTool.h" - +#include "../TriggerEDMDeserialiserAlg.h" DECLARE_COMPONENT( HLTEDMCreator ) -DECLARE_COMPONENT( HLTResultMTMaker ) DECLARE_COMPONENT( HLTResultMTMakerAlg ) +DECLARE_COMPONENT( HLTResultMTMaker ) DECLARE_COMPONENT( StreamTagMakerTool ) DECLARE_COMPONENT( DecisionSummaryMakerAlg ) DECLARE_COMPONENT( TriggerBitsMakerTool ) DECLARE_COMPONENT( TriggerEDMSerialiserTool ) +DECLARE_COMPONENT( TriggerEDMDeserialiserAlg ) diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py b/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py index a74807ac111..c12da439cbd 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py @@ -361,32 +361,41 @@ bitsmaker.ChainDecisions = "HLTFinalDecisions" bitsmaker.ChainToBit = dict( [ (chain, 10*num) for num,chain in enumerate(testChains) ] ) bitsmaker.OutputLevel = DEBUG -hltResultMaker = HLTResultMTMaker() -hltResultMaker.MakerTools = [ stmaker, bitsmaker, serialiser ] -hltResultMaker.OutputLevel = DEBUG +hltResultMakerTool = HLTResultMTMaker() +hltResultMakerTool.MakerTools = [ stmaker, bitsmaker, serialiser ] +hltResultMakerTool.OutputLevel = DEBUG + +hltResultMakerAlg = HLTResultMTMakerAlg() + from AthenaMonitoring.GenericMonitoringTool import GenericMonitoringTool, defineHistogram -hltResultMaker.MonTool = GenericMonitoringTool("MonOfHLTResultMTtest") -hltResultMaker.MonTool.HistPath = "OutputMonitoring" -hltResultMaker.MonTool.Histograms = [ defineHistogram( 'TIME_build', path='EXPERT', type='TH1F', title='Time of result construction in;[micro seccond]', - xbins=100, xmin=0, xmax=1000 ), - defineHistogram( 'nstreams', path='EXPERT', type='TH1F', title='number of streams', - xbins=60, xmin=0, xmax=60 ), - defineHistogram( 'nfrags', path='EXPERT', type='TH1F', title='number of HLT results', - xbins=10, xmin=0, xmax=10 ), - defineHistogram( 'sizeMain', path='EXPERT', type='TH1F', title='Main (physics) HLT Result size;4B words', - xbins=100, xmin=-1, xmax=999 ) ] # 1000 k span +hltResultMakerTool.MonTool = GenericMonitoringTool("MonOfHLTResultMTtest") +hltResultMakerTool.MonTool.HistPath = "OutputMonitoring" +hltResultMakerTool.MonTool.Histograms = [ defineHistogram( 'TIME_build', path='EXPERT', type='TH1F', title='Time of result construction in;[micro seccond]', + xbins=100, xmin=0, xmax=1000 ), + defineHistogram( 'nstreams', path='EXPERT', type='TH1F', title='number of streams', + xbins=60, xmin=0, xmax=60 ), + defineHistogram( 'nfrags', path='EXPERT', type='TH1F', title='number of HLT results', + xbins=10, xmin=0, xmax=10 ), + defineHistogram( 'sizeMain', path='EXPERT', type='TH1F', title='Main (physics) HLT Result size;4B words', + xbins=100, xmin=-1, xmax=999 ) ] # 1000 k span -hltResultMakerAlg = HLTResultMTMakerAlg() -hltResultMakerAlg.ResultMaker = hltResultMaker +hltResultMakerAlg.ResultMaker = hltResultMakerTool +from TrigOutputHandling.TrigOutputHandlingConf import TriggerEDMDeserialiserAlg +deserialiser = TriggerEDMDeserialiserAlg() +deserialiser.Prefix="SERIALISED_" +deserialiser.OutputLevel=DEBUG ################################################################################ # assemble top list of algorithms -hltTop = seqOR( "hltTop", [ steps, summMaker, mon, hltResultMakerAlg, summary, StreamESD ] ) +hltTop = seqOR( "hltTop", [ steps, mon, summary, summMaker, hltResultMakerAlg, deserialiser, StreamESD ] ) + + + topSequence += hltTop ###### Begin Cost Monitoring block -- GitLab