diff --git a/Control/AthViews/AthViews/ViewHelper.h b/Control/AthViews/AthViews/ViewHelper.h index 0db05af03d4858e7930d5a68ef3c4733109de155..53a6bbd7558bc4cd34201ef018669efbc7a0edc1 100644 --- a/Control/AthViews/AthViews/ViewHelper.h +++ b/Control/AthViews/AthViews/ViewHelper.h @@ -178,6 +178,7 @@ namespace ViewHelper //Make accessor for bookkeeping SG::AuxElement::Accessor< int > viewBookkeeper( "viewIndex" ); + //Loop over all views unsigned int offset = 0; for ( unsigned int viewIndex = 0; viewIndex < ViewVector.size(); ++viewIndex ) diff --git a/Trigger/TrigSteer/TrigOutputHandling/src/HLTResultMTMaker.cxx b/Trigger/TrigSteer/TrigOutputHandling/src/HLTResultMTMaker.cxx index 2c0811fd0905ee60cf086753f391172a7db072ca..341ecf6c1495a8dfbabd0d3e885e6e07dfdc94e3 100644 --- a/Trigger/TrigSteer/TrigOutputHandling/src/HLTResultMTMaker.cxx +++ b/Trigger/TrigSteer/TrigOutputHandling/src/HLTResultMTMaker.cxx @@ -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; } diff --git a/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMDeserialiserAlg.cxx b/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMDeserialiserAlg.cxx index ffa7506e9973c22abd9f7d70dbbf492d03eae9b0..e7e9fb0ab0e3849d274398ad45620862ec4e79e1 100644 --- a/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMDeserialiserAlg.cxx +++ b/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMDeserialiserAlg.cxx @@ -67,8 +67,9 @@ StatusCode TriggerEDMDeserialiserAlg::execute(const EventContext& context) const resize( bsize ); toBuffer( start, buff.get() ); - - RootType classDesc = RootType::ByName( transientType+"_v1" ); // TODO remove this dirty hack, needsdiscussion how to find the real type + /* TODO find out how to read the type informatin that is encoded in the payload, we will need to have less configuration, and thus more robust decoding + // this code is commented but will be used once this one bit is understood + RootType classDesc = RootType::ByName( transientType+"_v1" ); size_t usedBytes{ bsize }; void* obj = m_serializerSvc->deserialize( buff.get(), usedBytes, classDesc ); ATH_MSG_DEBUG( "Obtained object " << obj << " which used " << usedBytes << " bytes from available " << bsize ); @@ -84,7 +85,7 @@ StatusCode TriggerEDMDeserialiserAlg::execute(const EventContext& context) const } else { ATH_MSG_WARNING( "Deserialisation of object of CLID " << clid << " and name " << name << " failed" ); } - + */ start = toNextFragment( start ); } diff --git a/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMSerialiserTool.cxx b/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMSerialiserTool.cxx index 20c637d47dd83613f5e9a7d5272f47a0aa9793c9..97768fbb3678bee14f8444de8ecf6c6f790320cc 100644 --- a/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMSerialiserTool.cxx +++ b/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMSerialiserTool.cxx @@ -10,6 +10,11 @@ #include "GaudiKernel/IToolSvc.h" #include "GaudiKernel/System.h" #include "AthenaKernel/StorableConversions.h" +#include "AthContainersInterfaces/IAuxStoreIO.h" +#include "AthContainers/AuxTypeRegistry.h" +#include "AthContainers/debug.h" +#include "xAODCore/AuxContainerBase.h" + #include "TrigSerializeResult/StringSerializer.h" #include "TriggerEDMSerialiserTool.h" @@ -34,7 +39,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 +65,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 +102,73 @@ 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 + ATH_MSG_DEBUG("About to start streaming aux data of " << address.key ); + DataBucketBase* dObjAux = dynamic_cast<DataBucketBase*>(dObj); + ATH_CHECK( dObjAux != nullptr ); + + const SG::IAuxStoreIO* auxStoreIO = dObjAux->template cast<SG::IAuxStoreIO> (nullptr, true); + if ( auxStoreIO == nullptr ) { + 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 ); + + const SG::auxid_set_t& selected = address.sel.getSelectedAuxIDs( auxStoreIO->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; + } + ATH_MSG_DEBUG( "CLID " << clid ); + + RootType classDesc = RootType::ByName( typeName ); + + const void* rawptr = auxStoreIO->getIOData( auxVarID ); + ATH_CHECK( rawptr != nullptr ); + + size_t sz=0; + 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 +195,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 +207,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; diff --git a/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMSerialiserTool.h b/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMSerialiserTool.h index 43261c2879a2063bb55934a18f3959337f19e141..9d1eda9c391ff9ab7ad866ac7a0da7a4996f0499 100644 --- a/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMSerialiserTool.h +++ b/Trigger/TrigSteer/TrigOutputHandling/src/TriggerEDMSerialiserTool.h @@ -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> { @@ -35,16 +37,15 @@ class TriggerEDMSerialiserTool: public extends<AthAlgTool, HLTResultMTMakerTool> private: Gaudi::Property<std::vector<std::string>> m_collectionsToSerialize { this, "CollectionsToSerialize", {}, "TYPE#SG.aux1.aux2..etc key of collections to be streamed (like in StreamAOD), the type has to be an exact type i.e. with _vN not the alias type" }; - Gaudi::Property<int> m_moduleID { this, "ModuleID", 0, "The HLT result fragment to which the output should be added"}; // internal structure to keep configuration organised conveniently 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 +64,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; }; diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py b/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py index db3a6687d23ba27b298addfafb7288dd7b0171aa..60e46f4f64b02cf1500ba260ad7d976d3ecf7868 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py @@ -1,4 +1,5 @@ + # # Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration # @@ -58,7 +59,7 @@ clustersKey = "HLT_xAOD__TrigEMClusterContainer_L2CaloClusters" #"L2CaloClusters def createFastCaloSequence(rerun=False): __prefix = "Rerurn_" if rerun else "" - __l1RoIDecisions = "RerunEMRoIDecisions" if rerun else "EMRoIDecisions" + __l1RoIDecisions = "RerunL1EM" if rerun else "L1EM" __forViewDecsions = "RerunEMRoIDecisions" if rerun else "Filtered"+__l1RoIDecisions from TrigT2CaloEgamma.TrigT2CaloEgammaConfig import T2CaloEgamma_FastAlgo @@ -346,12 +347,15 @@ 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::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." ] stmaker = StreamTagMakerTool() stmaker.OutputLevel = DEBUG @@ -363,11 +367,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