ATLAS Offline Software
Loading...
Searching...
No Matches
TrigBSExtraction.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
7
11
12TrigBSExtraction::TrigBSExtraction(const std::string& name, ISvcLocator* pSvcLocator)
13 : AthAlgorithm(name, pSvcLocator)
14{
15}
16
17
19
20 // L2 navigation tool is optional
21 if ( !m_l2ResultKeyIn.empty() ) ATH_CHECK( m_navToolL2.retrieve() );
22 else m_navToolL2.disable();
23
24 ATH_CHECK( m_navTool.retrieve() );
25
26 // Initialize handle keys
29
32
33 if ( m_dataScoutingKeysIn.size() != m_dataScoutingKeysOut.size() ) {
34 ATH_MSG_ERROR("Size of DSResultKeysIn/Out does not match: " << m_dataScoutingKeysIn <<
35 " vs " << m_dataScoutingKeysOut );
36 return StatusCode::FAILURE;
37 }
38 ATH_CHECK( m_dataScoutingKeysIn.initialize() );
39 ATH_CHECK( m_dataScoutingKeysOut.initialize() );
40
41 // Initialize the TrigSerializeConcHelper here so that all the additional streamerinfos are read in.
42 // In case of DataScouting this may give problems if the DS ROBs contain containers which
43 // were not compiled with navigation (the container type information is then not known
44 // for a given CLID).
45 ToolHandle<ITrigSerializeConvHelper> trigCnvHelper("TrigSerializeConvHelper",this);
46 ATH_CHECK( trigCnvHelper.retrieve() );
47
48 return StatusCode::SUCCESS;
49}
50
51
52StatusCode TrigBSExtraction::execute(const EventContext& ctx) {
53
54 const bool isRun1 = m_navToolL2.isEnabled();
55 if ( isRun1 ) {
56 ATH_MSG_ERROR("Unpacking of Run-1 bytestream is no longer supported");
57 return StatusCode::FAILURE;
58 }
59
60 if ( !m_hltResultKeyIn.empty() ) {
61 // unpack, merge with L2 result and do xAOD conversion
62 // xAOD conversion is only done for HLTResult_EF in Run-1
63 if ( repackFeaturesToSG(ctx, *m_navTool, m_hltResultKeyIn, m_hltResultKeyOut, isRun1).isFailure() )
64 ATH_MSG_WARNING( "failed unpacking features from BS to SG for: " << m_hltResultKeyIn );
65 }
66
67 for (size_t i = 0; i<m_dataScoutingKeysIn.size(); i++ ) {
68 if ( repackFeaturesToSG(ctx, *m_navTool, m_dataScoutingKeysIn[i], m_dataScoutingKeysOut[i], false).isFailure() )
69 ATH_MSG_WARNING( "failed unpacking features from BS to SG for: " << m_dataScoutingKeysIn[i] );
70 }
71 m_navTool->reset();
72
73 return StatusCode::SUCCESS;
74}
75
76
77StatusCode TrigBSExtraction::repackFeaturesToSG (const EventContext& ctx,
78 HLT::Navigation& navTool,
81 bool equalize) {
82
83 ATH_MSG_DEBUG( "Trying to deserialize content of " << key );
84 auto cresult = SG::makeHandle(key, ctx);
85
86 if ( !cresult.get() ) {
87 ATH_MSG_WARNING( "No HLTResult found with key " << key );
88 return StatusCode::SUCCESS;
89 }
90
91 ATH_MSG_DEBUG("HLTResult is level=" << cresult->getHLTLevel() );
92
93 const std::vector<uint32_t>& navData = cresult->getNavigationResult();
94 if ( !navData.empty() ) {
95 ATH_MSG_DEBUG( "Navigation payload obtained from " << key << " has size " << navData.size() );
96 navTool.deserialize( navData );
97 } else {
98 ATH_MSG_WARNING( "Navigation payload obtained from " << key << " has size 0" );
99 }
100
101 if ( equalize && m_navToolL2.isEnabled() ) {
102 ATH_MSG_DEBUG( "Merging L2 and EF navigation structures for " << key );
103 navTool.merge(*m_navToolL2);
104 }
105
106 navTool.prepare();
107
108 // Create a copy of HLTResult and pack navigation back into it
109 auto result = std::make_unique<HLT::HLTResult>(*cresult);
110
111 result->getNavigationResult().clear();
112 bool status = navTool.serialize(result->getNavigationResult(), result->getNavigationResultCuts());
113 ATH_MSG_DEBUG( "New serialized navigation for " << keyOut << " has size " << result->getNavigationResult().size() );
114
115 ATH_CHECK( SG::makeHandle(keyOut, ctx).record(std::move(result)) );
116
117 return StatusCode(status);
118}
119
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
virtual bool serialize(std::vector< uint32_t > &output) const
method serizlizes the navigation structure The structure is serrizlized in following order ....
bool merge(const NavigationCore &l2)
attemtps to merge two trees
virtual void prepare()
prepapres the navigation for next event
bool deserialize(const std::vector< uint32_t > &input)
The Navigation class, organizes TriggerElements into the tree structure.
Definition Navigation.h:100
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
SG::ReadHandleKey< HLT::HLTResult > m_hltResultKeyIn
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
SG::WriteHandleKey< HLT::HLTResult > m_hltResultKeyOut
ToolHandle< HLT::Navigation > m_navToolL2
TrigBSExtraction(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode repackFeaturesToSG(const EventContext &ctx, HLT::Navigation &navTool, const SG::ReadHandleKey< HLT::HLTResult > &key, SG::WriteHandleKey< HLT::HLTResult > &keyOut, bool equalize)
method which does loop over objects
SG::WriteHandleKeyArray< HLT::HLTResult > m_dataScoutingKeysOut
SG::ReadHandleKey< HLT::HLTResult > m_l2ResultKeyIn
virtual StatusCode initialize() override
SG::ReadHandleKeyArray< HLT::HLTResult > m_dataScoutingKeysIn
SG::WriteHandleKey< HLT::HLTResult > m_l2ResultKeyOut
ToolHandle< HLT::Navigation > m_navTool
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())