Commit 8bd173af authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

HLTResultByteStreamTool: make result names and ROBs configurable

Make the HLT result name and ROB IDs configurable in the Run-1&2
`HLTResultByteStreamTool` rather than hard-coding them in the code.
This will make it possible to decode results under non-standard
names (e.g. after remapping them with `AddressRemappingSvc`).
parent 220503b7
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
/**********************************************************************************
......@@ -8,10 +8,6 @@
* @class : HLTResultByteStreamTool
*
* @brief Gaudi bytestream Converter tool for the HLTResult class
*
*
* File and Version Information:
* $Id: HLTResultByteStreamTool.h,v 1.4 2007-07-05 13:40:31 eifert Exp $
**********************************************************************************/
#ifndef TrigHLTResultByteStreamTool_h
......@@ -19,6 +15,8 @@
/* general stuff */
#include <stdint.h>
#include <map>
#include <string>
#include "AthenaBaseComps/AthAlgTool.h"
/* To be able to use OFFLINE_FRAGMENTS_NAMESPACE */
......@@ -38,21 +36,15 @@ namespace HLT {
/**
@class HLTResultByteStreamCnv
@brief An AlgTool class to provide conversion from HLTResult to ByteStream, and fill it in RawEvent
@brief An AlgTool to provide conversion of Run-1&2 HLTResult from/to ByteStream
This tool is used by the Gaudi converter class: HLTResultByteStreamCnv.
*/
class HLTResultByteStreamTool: public AthAlgTool {
public:
HLTResultByteStreamTool( const std::string& type, const std::string& name,
const IInterface* parent ) ; //!< std Gaudi tool constructor
virtual ~HLTResultByteStreamTool() ; //!< virtual destructor
const IInterface* parent ) ; //!< std Gaudi tool constructor
static const InterfaceID& interfaceID( ) ; //!< std Gaudi interface
......@@ -68,13 +60,16 @@ namespace HLT {
StatusCode convert(HLTResult* result, RawEventWrite* re,
std::string objName);
eformat::SubDetector byteStreamLocation(std::string objName); //!< helper method
FullEventAssembler<HLTSrcIdMap>* eventAssembler(std::string objName); //!< helper method
private:
static const std::string s_l2ResultName, s_efResultName, s_hltResultName, s_dataScoutingResultName; //!< LVL2 and EF StoreGate keys
FullEventAssembler<HLTSrcIdMap> m_feaL2, m_feaEF; //!< helper for reading
Gaudi::Property<std::map<std::string, uint32_t>> m_robIDMap{
this, "HLTResultRobIdMap", {
{"HLTResult_L2", eformat::helper::SourceIdentifier(eformat::TDAQ_LVL2, 0).code()},
{"HLTResult_EF", eformat::helper::SourceIdentifier(eformat::TDAQ_EVENT_FILTER, 0).code()},
{"HLTResult_HLT", eformat::helper::SourceIdentifier(eformat::TDAQ_HLT, 0).code()}
}, "Map of HLTResult names to ROB IDs"};
FullEventAssembler<HLTSrcIdMap> m_fea;
};
}
......
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
......@@ -10,46 +10,15 @@
#include <iostream>
#include <stdlib.h>
const std::string HLT::HLTResultByteStreamTool::s_l2ResultName = "HLTResult_L2";
const std::string HLT::HLTResultByteStreamTool::s_efResultName = "HLTResult_EF";
const std::string HLT::HLTResultByteStreamTool::s_hltResultName = "HLTResult_HLT";
const std::string HLT::HLTResultByteStreamTool::s_dataScoutingResultName = "DataScouting_";
HLT::HLTResultByteStreamTool::HLTResultByteStreamTool( const std::string& type,
const std::string& name,
const IInterface* parent )
: AthAlgTool(type,name,parent)
{
declareInterface< HLT::HLTResultByteStreamTool >( this );
m_feaL2.idMap().setDetId(eformat::TDAQ_LVL2);
m_feaEF.idMap().setDetId(eformat::TDAQ_EVENT_FILTER);
}
HLT::HLTResultByteStreamTool::~HLTResultByteStreamTool()
{
}
eformat::SubDetector HLT::HLTResultByteStreamTool::byteStreamLocation(std::string objName)
: AthAlgTool(type,name,parent)
{
if (objName == s_l2ResultName) return eformat::TDAQ_LVL2;
if (objName == s_efResultName || objName == s_hltResultName) return eformat::TDAQ_EVENT_FILTER;
if (objName.substr(0,s_dataScoutingResultName.length()) == s_dataScoutingResultName) return eformat::TDAQ_EVENT_FILTER;
return eformat::OTHER;
declareInterface<HLT::HLTResultByteStreamTool>( this );
}
FullEventAssembler<HLT::HLTSrcIdMap>*
HLT::HLTResultByteStreamTool::eventAssembler(std::string objName)
{
if (objName == s_l2ResultName) return &m_feaL2;
if (objName == s_efResultName || objName == s_hltResultName) return &m_feaEF;
if (objName.substr(0,s_dataScoutingResultName.length()) == s_dataScoutingResultName) return &m_feaEF;
return 0;
}
/**
Conversion from RDO to eformat::ROBFragment.
this is called from the createRep method.
......@@ -57,32 +26,26 @@ HLT::HLTResultByteStreamTool::eventAssembler(std::string objName)
StatusCode HLT::HLTResultByteStreamTool::convert( HLTResult* result, RawEventWrite* re,
std::string objName)
{
FullEventAssembler<HLTSrcIdMap>* fea = eventAssembler(objName);
eformat::SubDetector subDet = byteStreamLocation(objName);
if (!fea || subDet == eformat::OTHER) {
ATH_MSG_ERROR("Cannot store object with name " << objName
<< " in BS: we are expecting only HLTResult_(L2,EF,HLT)");
// find the ROB ID for the given HLTResult name
const auto itr = m_robIDMap.find(objName);
if ( itr==m_robIDMap.end() ) {
ATH_MSG_ERROR("No ROB ID configured for " << objName);
return StatusCode::FAILURE;
}
eformat::helper::SourceIdentifier rob(itr->second);
fea->clear() ;
// configure the EventAssembler and serialize into bytestream
m_fea.clear();
m_fea.idMap().setDetId(rob.subdetector_id());
uint32_t module_id(0);
if (objName.substr(0,s_dataScoutingResultName.length()) == s_dataScoutingResultName) {
module_id = atoi( (objName.substr(s_dataScoutingResultName.length(),2)).c_str() ) ;
}
eformat::helper::SourceIdentifier helpID(subDet, module_id);
uint32_t rodIdHLTResult = helpID.code();
std::vector<uint32_t>* rod = fea->getRodData( rodIdHLTResult );
std::vector<uint32_t>* rod = m_fea.getRodData( rob.code() );
if (!rod) return StatusCode::FAILURE;
result->serialize( *rod );
fea->fill(re, msg());
m_fea.fill(re, msg());
ATH_MSG_DEBUG(std::dec << "Serialized HLT Result " << objName << " (" << rod->size()
<< " words) to location " << subDet);
ATH_MSG_DEBUG("Serialized HLT Result " << objName << " (" << rod->size()
<< " words) to location " << rob.human());
return StatusCode::SUCCESS;
}
......@@ -95,50 +58,32 @@ StatusCode HLT::HLTResultByteStreamTool::convert( HLTResult* result, RawEventWri
StatusCode HLT::HLTResultByteStreamTool::convert(IROBDataProviderSvc& dataProvider,
HLT::HLTResult*& result, std::string objName)
{
eformat::SubDetector subDet = byteStreamLocation(objName);
if (subDet == eformat::OTHER) {
ATH_MSG_ERROR("Cannot store object with name " << objName
<< " in BS: we are expecting only HLTResult_(L2,EF,HLT)");
// find the ROB ID for the given HLTResult name
const auto itr = m_robIDMap.find(objName);
if ( itr==m_robIDMap.end() ) {
ATH_MSG_ERROR("No ROB ID configured for " << objName);
return StatusCode::FAILURE;
}
eformat::helper::SourceIdentifier rob(itr->second);
// unsigned int vector where to store HLT payload
std::vector<uint32_t> hltContent;
uint32_t module_id(0);
if (objName.substr(0,s_dataScoutingResultName.length()) == s_dataScoutingResultName) {
module_id = atoi( (objName.substr(s_dataScoutingResultName.length(),2)).c_str() ) ;
}
eformat::helper::SourceIdentifier helpID(byteStreamLocation(objName), module_id);
uint32_t robId = helpID.code();
std::vector<uint32_t> vID;
vID.push_back(robId);
// request the ROB and deserialize into HLTResult
IROBDataProviderSvc::VROBFRAG robFrags;
dataProvider.getROBData(vID, robFrags);
// (*log) << MSG::DEBUG << "Got ROB fragments: "<< robFrags.size() << endmsg;
for (IROBDataProviderSvc::VROBFRAG::const_iterator rob = robFrags.begin();
rob != robFrags.end(); ++rob) {
dataProvider.getROBData({rob.code()}, robFrags);
uint32_t nData = (*rob)->rod_ndata();
// size_t sourceID = (*rob)->rod_source_id();
// (*log) << MSG::DEBUG << "Reading fragment of size " << nData << " from source "
// << sourceID << endmsg;
// unsigned int vector where to store HLT payload
std::vector<uint32_t> hltContent;
for (const IROBDataProviderSvc::ROBF* rob : robFrags ) {
OFFLINE_FRAGMENTS_NAMESPACE::PointerType rodData = 0;
(*rob)->rod_data(rodData);
OFFLINE_FRAGMENTS_NAMESPACE::PointerType rodData = nullptr;
rob->rod_data(rodData);
const uint32_t nData = rob->rod_ndata();
hltContent.reserve(nData);
for (size_t i = 0; i < nData; i++) hltContent.push_back(rodData[i]);
}
result->deserialize(hltContent);
ATH_MSG_DEBUG("Deserialized HLT Result " << objName << " (" << hltContent.size()
<< " words) from location " << subDet);
ATH_MSG_DEBUG("Deserialized HLT Result " << objName << " (" << hltContent.size() << " words)");
return StatusCode::SUCCESS;
}
......@@ -108,28 +108,27 @@ class ByteStreamUnpackGetterRun1or2(Configured):
from TrigEDMConfig.TriggerEDM import getPreregistrationList
extr.Navigation.ClassesToPreregister = getPreregistrationList(ConfigFlags.Trigger.EDMVersion)
from eformat import helper as efh
robIDMap = {} # map of result keys and their ROB ID
if ConfigFlags.Trigger.EDMVersion == 1: # Run-1 has L2 and EF result
ServiceMgr.ByteStreamAddressProviderSvc.TypeNames += [
"HLT::HLTResult/HLTResult_L2",
"HLT::HLTResult/HLTResult_EF" ]
robIDMap["HLTResult_L2"] = efh.SourceIdentifier(efh.SubDetector.TDAQ_LVL2, 0).code()
robIDMap["HLTResult_EF"] = efh.SourceIdentifier(efh.SubDetector.TDAQ_EVENT_FILTER, 0).code()
extr.L2ResultKey = "HLTResult_L2"
extr.HLTResultKey = "HLTResult_EF"
else:
ServiceMgr.ByteStreamAddressProviderSvc.TypeNames += [
"HLT::HLTResult/HLTResult_HLT" ]
robIDMap["HLTResult_HLT"] = efh.SourceIdentifier(efh.SubDetector.TDAQ_HLT, 0).code()
extr.L2ResultKey = ""
extr.HLTResultKey = "HLTResult_HLT"
#
# Configure DataScouting
#
from PyUtils.MetaReaderPeeker import metadata
if 'stream' in metadata:
stream_local = metadata['stream'] # e.g. calibration_DataScouting_05_Jets
if stream_local.startswith('calibration_DataScouting_'):
ds_tag = '_'.join(stream_local.split('_')[1:3]) # e.g. DataScouting_05
ServiceMgr.ByteStreamAddressProviderSvc.TypeNames += [ "HLT::HLTResult/"+ds_tag ]
extr.DSResultKeys += [ ds_tag ]
ds_id = int(stream_local.split('_')[2]) # e.g. 05
robIDMap[ds_tag] = efh.SourceIdentifier(efh.SubDetector.TDAQ_HLT, ds_id).code()
extr.DSResultKeys += [ds_tag]
else:
# if data doesn't have HLT info set HLTResult keys as empty strings to avoid warnings
......@@ -139,18 +138,22 @@ class ByteStreamUnpackGetterRun1or2(Configured):
extr.DSResultKeys = []
topSequence += extr
from TrigSerializeTP.TrigSerializeTPConf import TrigSerTPTool
TrigSerToolTP = TrigSerTPTool('TrigSerTPTool')
# Add all HLTResult keys to AddressProvider
for k in robIDMap.keys():
ServiceMgr.ByteStreamAddressProviderSvc.TypeNames += [ f"HLT::HLTResult/{k}" ]
# Create necessary public tools
from AthenaCommon.AppMgr import ToolSvc
ToolSvc += TrigSerToolTP
from TrigSerializeTP.TrigSerializeTPConf import TrigSerTPTool
from TrigEDMConfig.TriggerEDM import getTPList
TrigSerToolTP.TPMap = getTPList((ConfigFlags.Trigger.EDMVersion))
ToolSvc += TrigSerTPTool(TPMap = getTPList((ConfigFlags.Trigger.EDMVersion)))
from TrigSerializeCnvSvc.TrigSerializeCnvSvcConf import TrigSerializeConvHelper
TrigSerializeConvHelper = TrigSerializeConvHelper(doTP = True)
ToolSvc += TrigSerializeConvHelper
ToolSvc += TrigSerializeConvHelper(doTP = True)
from TrigHLTResultByteStream.TrigHLTResultByteStreamConf import HLT__HLTResultByteStreamTool
ToolSvc += HLT__HLTResultByteStreamTool(HLTResultRobIdMap = robIDMap)
return True
......
Supports Markdown
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