Skip to content
Snippets Groups Projects
Commit e406d50f authored by Edward Moyse's avatar Edward Moyse
Browse files

Merge branch 'updateTestsToV2ofTrigComp' into 'master'

Follow up !20600 - Update tests to TrigCompositeAux to V2

See merge request atlas/athena!21276
parents 98ea86a2 2b9f5713
No related branches found
No related tags found
No related merge requests found
......@@ -56,16 +56,19 @@ StatusCode TriggerEDMSerialiserTool::initialize() {
xAOD::AuxSelection sel;
if ( typeKeyAux.find('.') != std::string::npos ) {
ATH_MSG_DEBUG( "with aux content: " );
std::string allVars = typeKeyAux.substr( typeKeyAux.find('.')+1 );
std::set<std::string> variableNames;
boost::split( variableNames, allVars, [](const char c){ return c == '.'; } );
for ( auto el: variableNames )
ATH_MSG_DEBUG( " " << el );
sel.selectAux( variableNames );
if (allVars != "") {
ATH_MSG_DEBUG( "with aux content: " );
std::set<std::string> variableNames;
boost::split( variableNames, allVars, [](const char c){ return c == '.'; } );
for ( auto el: variableNames ) {
ATH_MSG_DEBUG( " \"" << el << "\"" );
}
sel.selectAux( variableNames );
}
}
const bool isAux = key.find("Aux") != std::string::npos;
const bool isAux = (key.find("Aux") != std::string::npos);
if (moduleIdVec.empty()) {
ATH_MSG_ERROR( "No HLT result module IDs given for " << typeKeyAux );
......@@ -85,7 +88,6 @@ StatusCode TriggerEDMSerialiserTool::initialize() {
return StatusCode::SUCCESS;
}
StatusCode TriggerEDMSerialiserTool::makeHeader(const Address& address, std::vector<uint32_t>& buffer ) const {
buffer.push_back(0); // fragment size placeholder
buffer.push_back( address.clid ); // type info via CLID
......@@ -114,7 +116,7 @@ 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 {
StatusCode TriggerEDMSerialiserTool::fillDynAux( const Address& address, DataObject* dObj, std::vector<uint32_t>& buffer, size_t& nDynWritten) const {
// TODO, check if we can cache this informion after it is filled once
ATH_MSG_DEBUG("About to start streaming aux data of " << address.key );
DataBucketBase* dObjAux = dynamic_cast<DataBucketBase*>(dObj);
......@@ -125,6 +127,7 @@ StatusCode TriggerEDMSerialiserTool::fillDynAux( const Address& address, DataObj
ATH_MSG_DEBUG( "Can't obtain AuxContainerBase of " << address.key << " no dynamic variables presumably" );
return StatusCode::SUCCESS;
}
// ATH_MSG_DEBUG( "dump aux store" );
// SGdebug::dump_aux_vars( *auxStore );
......@@ -142,7 +145,6 @@ StatusCode TriggerEDMSerialiserTool::fillDynAux( const Address& address, DataObj
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 );
......@@ -170,18 +172,16 @@ StatusCode TriggerEDMSerialiserTool::fillDynAux( const Address& address, DataObj
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() );
buffer.insert( buffer.end(), fragment.begin(), fragment.end() );
++nDynWritten;
}
return StatusCode::SUCCESS;
}
StatusCode TriggerEDMSerialiserTool::fill( HLT::HLTResultMT& resultToFill ) const {
// Leave this check until there is a justified case for appending data to an existing result
......@@ -200,7 +200,6 @@ StatusCode TriggerEDMSerialiserTool::fill( HLT::HLTResultMT& resultToFill ) cons
continue;
}
const void* rawptr = SG::fromStorable( dObj, address.clid, nullptr, msgLvl(MSG::DEBUG) );
if ( rawptr == nullptr ) {
ATH_MSG_DEBUG( "Data Object with key " << address.key <<
......@@ -209,7 +208,6 @@ StatusCode TriggerEDMSerialiserTool::fill( HLT::HLTResultMT& resultToFill ) cons
}
ATH_MSG_DEBUG("Obtained raw pointer " << rawptr );
RootType classDesc = RootType::ByName( address.type );
size_t sz=0;
void* mem = m_serializerSvc->serialize( rawptr, classDesc, sz );
......@@ -228,11 +226,17 @@ StatusCode TriggerEDMSerialiserTool::fill( HLT::HLTResultMT& resultToFill ) cons
if ( mem ) delete [] static_cast<const char*>( mem );
ATH_MSG_DEBUG("Fragment size " << fragment.size() );
const size_t baseSize = fragment.size()*sizeof(uint32_t);
ATH_MSG_DEBUG(address.typeKey << " Fragment size :" << baseSize << " bytes" );
if ( address.isAux ) {
ATH_CHECK( fillDynAux( address, dObj, fragment ) );
ATH_MSG_DEBUG("Fragment size with Aux data " << fragment.size() );
size_t nDynWritten = 0;
ATH_CHECK( fillDynAux( address, dObj, fragment, nDynWritten ) );
if (nDynWritten > 0) {
const size_t decoratedSize = fragment.size()*sizeof(uint32_t);
ATH_MSG_DEBUG(" Fragment size including " << decoratedSize - baseSize <<
" bytes from " << nDynWritten << "x DynAux: " << decoratedSize << " bytes" );
}
}
fragment[0] = fragment.size();
......
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TRIGOUTPUTHANDLING_TriggerEDMSerialiserTool_H
#define TRIGOUTPUTHANDLING_TriggerEDMSerialiserTool_H
#ifndef TRIGOUTPUTHANDLING_TRIGGEREDMSERIALISERTOOL_H
#define TRIGOUTPUTHANDLING_TRIGGEREDMSERIALISERTOOL_H
#include <string>
#include "AthenaBaseComps/AthAlgTool.h"
......@@ -19,7 +18,7 @@
* @class TriggerEDMSerialiserTool is tool responsible for creation of HLT Result filled with streamed EDM collections
**/
class DataObject;
class DataObject; //!< Forward declaration
class TriggerEDMSerialiserTool: public extends<AthAlgTool, HLTResultMTMakerTool>
{
......@@ -44,7 +43,9 @@ class TriggerEDMSerialiserTool: public extends<AthAlgTool, HLTResultMTMakerTool>
"the main result, other IDs are used for data scouting."
};
// internal structure to keep configuration organised conveniently
/// @class Address
/// Internal structure to keep configuration organised conveniently
///
struct Address {
std::string typeKey;
std::string type;
......@@ -52,14 +53,16 @@ class TriggerEDMSerialiserTool: public extends<AthAlgTool, HLTResultMTMakerTool>
std::string key;
std::vector<uint16_t> moduleIdVec;
bool isAux = false;
xAOD::AuxSelection sel = {}; // xAOD dynamic varaibles selection
xAOD::AuxSelection sel = {}; //!< xAOD dynamic varaibles selection
};
std::vector< Address > m_toSerialize; //!< Postprocessed configuration info
std::vector< Address > m_toSerialize; // postprocessed configuration info
ServiceHandle<IClassIDSvc> m_clidSvc{ this, "ClassIDSvc", "ClassIDSvc", "Service to translate class name to CLID" };
ServiceHandle<IAthenaSerializeSvc> m_serializerSvc{ this, "Serializer", "AthenaRootSerializeSvc", "Service that translates transient to persistent respresenation" };
ServiceHandle<IClassIDSvc> m_clidSvc{ this, "ClassIDSvc", "ClassIDSvc",
"Service to translate class name to CLID" };
ServiceHandle<IAthenaSerializeSvc> m_serializerSvc{ this, "Serializer", "AthenaRootSerializeSvc",
"Service that translates transient to persistent respresenation" };
/**
* Given the ID if the collection (in address arg) insert basic streaming info into the buffer.
......@@ -73,12 +76,11 @@ class TriggerEDMSerialiserTool: public extends<AthAlgTool, HLTResultMTMakerTool>
*/
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;
StatusCode fillDynAux( const Address& address, DataObject* dObject, std::vector<uint32_t>& buffer, size_t& nDynWritten ) const;
};
#endif //> !TRIGOUTPUTHANDLING_TriggerEDMSerialiserTool_H
#endif //> !TRIGOUTPUTHANDLING_TRIGGEREDMSERIALISERTOOL_H
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#include <iostream>
#include "TestTools/expect.h"
......@@ -15,6 +15,8 @@
int main() {
using namespace std;
using TrigCompositeUtils::DecisionID;
ISvcLocator* pSvcLoc;
if (!Athena_test::initGaudi("test.txt", pSvcLoc)) {
cerr << "ERROR This test can not be run" << endl;
......@@ -31,14 +33,27 @@ int main() {
return -1;
}
std::vector<DecisionID> decisions = {2, 4, 6};
xAOD::TrigCompositeContainer* testContainer = new xAOD::TrigCompositeContainer();
xAOD::TrigCompositeAuxContainer* aux = new xAOD::TrigCompositeAuxContainer();
testContainer->setStore( aux );
// Note: idetail and fdetail are dynamic decorations.
// The decoration must be set on all objects within the container
testContainer->push_back( new xAOD::TrigComposite() );
testContainer->back()->setDetail( "idetail", 7 );
testContainer->back()->setDetail( "fdetail", 2.5f );
testContainer->back()->setDetail( "decisions", decisions );
testContainer->push_back( new xAOD::TrigComposite() );
testContainer->at(0)->setDetail( "idetail", 7 );
testContainer->at(1)->setDetail( "fdetail", 2.5f );
testContainer->back()->setDetail( "idetail", 8 );
testContainer->back()->setDetail( "fdetail", 3.5f );
testContainer->back()->setDetail( "decisions", decisions );
testContainer->back()->setObjectLink( "link", ElementLink<xAOD::TrigCompositeContainer>( 123, 456, testContainer->at(0) ) );
// Note the SG part of this link is junk data, but the third parameter is real. Meaning it will pass a isValid sanity check
void * rawContainerPtr = static_cast<void*>( testContainer );
void * rawStorePtr = static_cast<void*>( aux );
......@@ -48,28 +63,44 @@ int main() {
log << MSG::INFO << containerRT.Name() << endmsg;
BareDataBucket containerDataBucket( rawContainerPtr, ClassID_traits<xAOD::TrigCompositeContainer>::ID(), containerRT );
RootType storeRT = RootType::ByName( "xAOD::TrigCompositeAuxContainer_v1" );
RootType storeRT = RootType::ByName( "xAOD::TrigCompositeAuxContainer_v2" );
log << MSG::INFO << storeRT.Name() << endmsg;
BareDataBucket storeDataBucket( rawStorePtr, ClassID_traits<xAOD::TrigCompositeAuxContainer>::ID(), storeRT );
log << MSG::INFO << "recordObject done" << endmsg;
pStore->recordObject( SG::DataObjectSharedPtr<BareDataBucket>( &containerDataBucket ), "test", false, false );
pStore->recordObject( SG::DataObjectSharedPtr<BareDataBucket>( &storeDataBucket ), "testAux.", false, false );
log << MSG::INFO << "recordObject done" << endmsg;
VALUE( pStore->accessData( ClassID_traits<xAOD::TrigCompositeContainer>::ID(), "test" ) ) NOT_EXPECTED ( nullptr );
VALUE( pStore->accessData( ClassID_traits<xAOD::TrigCompositeAuxContainer>::ID(), "testAux." ) ) NOT_EXPECTED ( nullptr );
log << MSG::INFO << "objects in store, trying to read them back via rertieve" << endmsg;
log << MSG::INFO << "objects in store, trying to read them back via retrieve" << endmsg;
const xAOD::TrigCompositeContainer* containerBack = 0;
pStore->retrieve( containerBack, "test" );
log << MSG::INFO << "Check retrieve" << endmsg;
VALUE ( containerBack ) NOT_EXPECTED ( nullptr );
log << MSG::INFO << "Check size" << endmsg;
VALUE( containerBack->size() ) EXPECTED ( 2 );
log << MSG::INFO << "Check [0] int32_t" << endmsg;
VALUE( containerBack->at(0)->getDetail<int32_t>( "idetail" ) ) EXPECTED ( 7 );
VALUE( containerBack->at(1)->getDetail<float>( "fdetail" ) ) EXPECTED ( 2.5f );
log << MSG::INFO << "Check [0] float" << endmsg;
VALUE( containerBack->at(0)->getDetail<float>( "fdetail" ) ) EXPECTED ( 2.5f );
log << MSG::INFO << "Check [0] std::vector<DecisionID>" << endmsg;
VALUE( containerBack->at(0)->getDetail<std::vector<DecisionID>>( "decisions" )[0] ) EXPECTED ( decisions[0] );
VALUE( containerBack->at(0)->getDetail<std::vector<DecisionID>>( "decisions" )[1] ) EXPECTED ( decisions[1] );
VALUE( containerBack->at(0)->getDetail<std::vector<DecisionID>>( "decisions" )[2] ) EXPECTED ( decisions[2] );
log << MSG::INFO << "Check [1] int32_t" << endmsg;
VALUE( containerBack->at(1)->getDetail<int32_t>( "idetail" ) ) EXPECTED ( 8 );
log << MSG::INFO << "Check [1] float" << endmsg;
VALUE( containerBack->at(1)->getDetail<float>( "fdetail" ) ) EXPECTED ( 3.5f );
log << MSG::INFO << "Check [1] link" << endmsg;
ElementLink<xAOD::TrigCompositeContainer> link = containerBack->at(1)->objectLink<xAOD::TrigCompositeContainer>("link");
VALUE( link.key() ) EXPECTED ( 123 );
VALUE( link.index() ) EXPECTED ( 456 );
log << MSG::INFO << "Container read back is identical" << endmsg;
return 0;
......
......@@ -68,7 +68,7 @@ file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unitTestRun_egammaRunData )
atlas_add_test( egammaRunData
SCRIPT test/test_egamma_run_data.sh
PROPERTIES TIMEOUT 1000
EXTRA_PATTERNS "-s TrigSignatureMoniMT.*HLT_.*|payload after inserting"
EXTRA_PATTERNS "-s TrigSignatureMoniMT.*HLT_.*|Fragment size"
PROPERTIES WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unitTestRun_egammaRunData
)
......
......@@ -119,7 +119,7 @@ decisionObjectsToRecord = []
for d in decisionObjects:
decisionObjectsToRecord.extend([
"xAOD::TrigCompositeContainer_v1#%s" % d,
"xAOD::TrigCompositeAuxContainer_v1#%s" % d
"xAOD::TrigCompositeAuxContainer_v2#%s.decisions" % d
])
##########################################
......@@ -147,7 +147,7 @@ from TrigUpgradeTest.pebMenuDefs import dataScoutingResultIDFromName
electronDSModuleIDs = [serialiser.fullResultID(), dataScoutingResultIDFromName('dataScoutingElectronTest')] # 0 is main (full) result; we get the other ID from the EDM configuration
serialiser.addCollectionListToResults([
"xAOD::TrigElectronContainer_v1#Electrons",
"xAOD::TrigElectronAuxContainer_v1#ElectronsAux.pt.eta.phi.rawEnergy.rawEt.rawEta.nCells.energy.et.e237.e277.fracs1.weta2.ehad1.e232.wstot",
"xAOD::TrigElectronAuxContainer_v1#ElectronsAux.pt.eta.phi.rawEnergy.rawEt.rawEta.nCells.energy.et.e237.e277.fracs1.weta2.ehad1.wstot",
], electronDSModuleIDs)
##### Result maker part 2 - stream tags #####
......
......@@ -349,12 +349,11 @@ serialiser = TriggerEDMSerialiserToolCfg("Serialiser")
serialiser.OutputLevel=VERBOSE
serialiser.addCollectionListToMainResult([
"xAOD::TrigCompositeContainer_v1#remap_EgammaCaloDecisions",
"xAOD::TrigCompositeContainer_v1#remap_EgammaCaloDecisions",
"xAOD::TrigCompositeAuxContainer_v1#remap_EgammaCaloDecisionsAux.",
"xAOD::TrigCompositeAuxContainer_v2#remap_EgammaCaloDecisionsAux.decisions",
"xAOD::TrigEMClusterContainer_v1#HLT_xAOD__TrigEMClusterContainer_L2CaloClusters",
"xAOD::TrigEMClusterAuxContainer_v2#HLT_xAOD__TrigEMClusterContainer_L2CaloClustersAux.RoIword.clusterQuality.e233.e237.e277.e2tsts1.ehad1.emaxs1.energy.energySample.et.eta.eta1.fracs1.nCells.phi.rawEnergy.rawEnergySample.rawEt.rawEta.rawPhi.viewIndex.weta2.wstot",
"xAOD::TrigElectronContainer_v1#HLT_xAOD__TrigElectronContainer_L2ElectronFex",
"xAOD::TrigElectronAuxContainer_v1#HLT_xAOD__TrigElectronContainer_L2ElectronFexAux.pt.eta.phi.rawEnergy.rawEt.rawEta.nCells.energy.et.e237.e277.fracs1.weta2.ehad1.e232.wstot",
"xAOD::TrigElectronAuxContainer_v1#HLT_xAOD__TrigElectronContainer_L2ElectronFexAux.pt.eta.phi.rawEnergy.rawEt.rawEta.nCells.energy.et.e237.e277.fracs1.weta2.ehad1.wstot",
])
streamPhysicsMain = ['Main', 'physics', "True", "True"]
......
......@@ -120,7 +120,7 @@ decisionObjectsToRecord = []
for d in decisionObjects:
decisionObjectsToRecord.extend([
"xAOD::TrigCompositeContainer_v1#%s" % d,
"xAOD::TrigCompositeAuxContainer_v1#%s" % d
"xAOD::TrigCompositeAuxContainer_v2#%s.decisions" % d
])
##########################################
......@@ -142,7 +142,7 @@ serialiser.addCollectionListToMainResult([
"xAOD::TrigEMClusterContainer_v1#L2CaloEMClusters",
"xAOD::TrigEMClusterAuxContainer_v2#L2CaloEMClustersAux.RoIword.clusterQuality.e233.e237.e277.e2tsts1.ehad1.emaxs1.energy.energySample.et.eta.eta1.fracs1.nCells.phi.rawEnergy.rawEnergySample.rawEt.rawEta.rawPhi.viewIndex.weta2.wstot",
"xAOD::TrigElectronContainer_v1#Electrons",
"xAOD::TrigElectronAuxContainer_v1#ElectronsAux.pt.eta.phi.rawEnergy.rawEt.rawEta.nCells.energy.et.e237.e277.fracs1.weta2.ehad1.e232.wstot",
"xAOD::TrigElectronAuxContainer_v1#ElectronsAux.pt.eta.phi.rawEnergy.rawEt.rawEta.nCells.energy.et.e237.e277.fracs1.weta2.ehad1.wstot",
])
##### Result maker part 2 - stream tags #####
......
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