Skip to content
Snippets Groups Projects
Commit 202a1c73 authored by Tomasz Bold's avatar Tomasz Bold
Browse files

Added serialisation of the dynamic variables

Former-commit-id: 544f0ba1
parent 08ea4423
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@ HLTResultMTMaker::~HLTResultMTMaker() {}
// =============================================================================
StatusCode HLTResultMTMaker::initialize() {
ATH_CHECK(m_hltResultWHKey.initialize());
ATH_CHECK(m_makerTools.retrieve());
ATH_CHECK(m_monTool.retrieve());
return StatusCode::SUCCESS;
}
......
......@@ -10,6 +10,10 @@
#include "GaudiKernel/IToolSvc.h"
#include "GaudiKernel/System.h"
#include "AthenaKernel/StorableConversions.h"
#include "AthContainersInterfaces/IAuxStoreIO.h"
#include "AthContainers/AuxTypeRegistry.h"
#include "xAODCore/AuxContainerBase.h"
#include "TrigSerializeResult/StringSerializer.h"
#include "TriggerEDMSerialiserTool.h"
......@@ -34,7 +38,7 @@ StatusCode TriggerEDMSerialiserTool::initialize() {
}
const std::string transientType = typeKeyAux.substr( 0, typeKeyAux.find('_') );
const std::string key = typeKeyAux.substr( typeKeyAux.find('#')+1, typeKeyAux.find('.') );
const std::string key = typeKeyAux.substr( typeKeyAux.find('#')+1, typeKeyAux.find('.')-typeKeyAux.find('#') );
CLID clid;
if ( m_clidSvc->getIDOfTypeName(transientType, clid).isFailure() ) {
ATH_MSG_ERROR( "Can not find CLID for " << transientType << " that is needed to stream " << key );
......@@ -60,9 +64,10 @@ StatusCode TriggerEDMSerialiserTool::initialize() {
sel.selectAux( variableNames );
}
const bool isAux = key.find("Aux") != std::string::npos;
m_toSerialize.push_back( Address{ type, clid, classDesc, key, sel } );
m_toSerialize.push_back( Address{ type, clid, key, isAux, sel } );
}
return StatusCode::SUCCESS;
}
......@@ -96,6 +101,69 @@ StatusCode TriggerEDMSerialiserTool::fillPayload( const void* data, size_t sz, s
return StatusCode::SUCCESS;
}
StatusCode TriggerEDMSerialiserTool::fillDynAux( const Address& address, DataObject* dObj, std::vector<uint32_t>& buffer ) const {
// TODO, check if we can cache this informion after it is filled once
DataBucketBase* dObjAux = dynamic_cast<DataBucketBase*>(dObj);
ATH_CHECK( dObjAux != nullptr );
const xAOD::AuxContainerBase* auxStore = dObjAux->template cast<xAOD::AuxContainerBase> (nullptr, true);
if ( auxStore == nullptr ) {
ATH_MSG_DEBUG( "Can't obtain AuxStoreIO of " << address.key << " no dynamic variables presumably" );
return StatusCode::SUCCESS;
}
const SG::auxid_set_t& selected = address.sel.getSelectedAuxIDs( auxStore->getDynamicAuxIDs() );
if ( selected.empty() ) {
ATH_MSG_VERBOSE( "Empty set of dynamic variables to store, do nothing" );
return StatusCode::SUCCESS;
}
ATH_MSG_DEBUG("Ready for serialisation of " << selected.size() << " dynamic variables");
for (SG::auxid_t auxVarID : selected ) {
const std::string typeName = SG::AuxTypeRegistry::instance().getVecTypeName(auxVarID);
const std::string name = SG::AuxTypeRegistry::instance().getName(auxVarID);
ATH_MSG_DEBUG("Streaming " << name << " of type " << typeName );
CLID clid;
if ( m_clidSvc->getIDOfTypeName(typeName, clid).isFailure() ) {
ATH_MSG_ERROR( "Can not obtain CLID of: " << typeName );
return StatusCode::FAILURE;
}
RootType classDesc = RootType::ByName( typeName );
size_t sz=0;
const void* rawptr = auxStore->getData( auxVarID );
ATH_CHECK( rawptr != nullptr );
void* mem = m_serializerSvc->serialize( rawptr, classDesc, sz );
if ( mem == nullptr or sz == 0 ) {
ATH_MSG_ERROR( "Serialisation of " << address.type <<"#" << address.key << "."<< name << " unsuccessful" );
return StatusCode::FAILURE;
}
std::vector<uint32_t> fragment;
Address auxAddress = { typeName, clid, address.key+"."+name, false };
ATH_CHECK( makeHeader( auxAddress, fragment ) );
ATH_CHECK( fillPayload( mem, sz, fragment ) );
fragment[0] = fragment.size();
if ( mem ) delete [] static_cast<const char*>( mem );
ATH_MSG_DEBUG("Fragment size " << fragment.size() );
buffer.insert( buffer.end(), fragment.begin(), fragment.end() );
}
return StatusCode::SUCCESS;
}
StatusCode TriggerEDMSerialiserTool::fill( HLT::HLTResultMT& resultToFill ) const {
......@@ -122,6 +190,7 @@ StatusCode TriggerEDMSerialiserTool::fill( HLT::HLTResultMT& resultToFill ) cons
RootType classDesc = RootType::ByName( address.type );
size_t sz=0;
void* mem = m_serializerSvc->serialize( rawptr, classDesc, sz );
ATH_MSG_DEBUG( "Streamed to buffer at address " << mem << " of " << sz << " bytes" );
if ( mem == nullptr or sz == 0 ) {
......@@ -133,17 +202,23 @@ StatusCode TriggerEDMSerialiserTool::fill( HLT::HLTResultMT& resultToFill ) cons
std::vector<uint32_t> fragment;
ATH_CHECK( makeHeader( address, fragment ) );
ATH_CHECK( fillPayload( mem, sz, fragment ) );
fragment[0] = fragment.size();
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("Fragment size " << fragment.size() );
if ( address.isAux ) {
ATH_CHECK( fillDynAux( address, dObj, fragment ) );
ATH_MSG_DEBUG("Fragment size with Aux data " << fragment.size() );
}
fragment[0] = fragment.size();
if ( mem ) delete [] static_cast<const char*>( mem );
payload.insert( payload.end(), fragment.begin(), fragment.end() );
ATH_MSG_DEBUG( "Payload size after inserting " << address.type << "#" << address.key << " " << payload.size()*sizeof(uint32_t) << " bytes" );
}
ATH_CHECK( resultToFill.addSerialisedDataWithCheck( m_moduleID, payload ) );
return StatusCode::SUCCESS;
......
......@@ -18,6 +18,8 @@
* @class TriggerEDMSerialiserTool is tool responsible for creation of HLT Result filled with streamed EDM collections
**/
class DataObject;
class TriggerEDMSerialiserTool: public extends<AthAlgTool, HLTResultMTMakerTool>
{
......@@ -42,9 +44,9 @@ class TriggerEDMSerialiserTool: public extends<AthAlgTool, HLTResultMTMakerTool>
struct Address {
std::string type;
CLID clid;
RootType rt;
std::string key;
xAOD::AuxSelection sel;
bool isAux = false;
xAOD::AuxSelection sel = {}; // xAOD dynamic varaibles selection
};
std::vector< Address > m_toSerialize; // postprocessed configuration info
......@@ -63,9 +65,13 @@ 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( const 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;
/**
* Adds dynamic variables to the payload
*/
StatusCode fillDynAux( const Address& address, DataObject* dObject, std::vector<uint32_t>& buffer ) const;
};
......
......@@ -346,12 +346,12 @@ print summMaker
################################################################################
# test online HLT Result maker
serialiser = TriggerEDMSerialiserTool(OutputLevel=VERBOSE)
serialiser = TriggerEDMSerialiserTool(name="Serialiser", OutputLevel=VERBOSE)
serialiser.CollectionsToSerialize = [ "xAOD::TrigCompositeContainer_v1#EgammaCaloDecisions_remap",
"xAOD::TrigCompositeAuxContainer_v1#EgammaCaloDecisionsAux.name.seed",
"xAOD::TrigElectronContainer_v1#HLT_xAOD__TrigElectronContainer_L2ElectronFex_remap",
"xAOD::TrigElectronAuxContainer_v1#HLT_xAOD__TrigElectronContainer_L2ElectronFexAux." ]
serialiser.CollectionsToSerialize = [ "xAOD::TrigCompositeContainer_v1#remap_EgammaCaloDecisions",
"xAOD::TrigCompositeAuxContainer_v1#remap_EgammaCaloDecisionsAux.*",
"xAOD::TrigElectronContainer_v1#HLT_xAOD__TrigElectronContainer_L2ElectronFex",
"xAOD::TrigElectronAuxContainer_v1#HLT_xAOD__TrigElectronContainer_L2ElectronFexAux.eta.phi.rawEnergy.rawEt.rawEta.rawPhi.nCells.clusterQuality.energy.et.e237.e277.fracs1.weta2.ehad1.e232.wstot" ]
stmaker = StreamTagMakerTool()
stmaker.OutputLevel = DEBUG
......@@ -363,11 +363,11 @@ bitsmaker.ChainDecisions = "HLTFinalDecisions"
bitsmaker.ChainToBit = dict( [ (chain, 10*num) for num,chain in enumerate(testChains) ] )
bitsmaker.OutputLevel = DEBUG
hltResultMakerTool = HLTResultMTMaker()
hltResultMakerTool = HLTResultMTMaker("MKTool")
hltResultMakerTool.MakerTools = [ stmaker, bitsmaker, serialiser ]
hltResultMakerTool.OutputLevel = DEBUG
hltResultMakerAlg = HLTResultMTMakerAlg()
hltResultMakerAlg = HLTResultMTMakerAlg("HLTRMakerAlg")
from AthenaMonitoring.GenericMonitoringTool import GenericMonitoringTool, defineHistogram
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment