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 // xAOD converter tool (for Run-1 data)
27 if ( !m_xAODTool.empty() ) ATH_CHECK( m_xAODTool.retrieve() );
28 else m_xAODTool.disable();
29
30 // Initialize handle keys
33
36
37 if ( m_dataScoutingKeysIn.size() != m_dataScoutingKeysOut.size() ) {
38 ATH_MSG_ERROR("Size of DSResultKeysIn/Out does not match: " << m_dataScoutingKeysIn <<
39 " vs " << m_dataScoutingKeysOut );
40 return StatusCode::FAILURE;
41 }
42 ATH_CHECK( m_dataScoutingKeysIn.initialize() );
43 ATH_CHECK( m_dataScoutingKeysOut.initialize() );
44
45 // Initialize the TrigSerializeConcHelper here so that all the additional streamerinfos are read in.
46 // In case of DataScouting this may give problems if the DS ROBs contain containers which
47 // were not compiled with navigation (the container type information is then not known
48 // for a given CLID).
49 ToolHandle<ITrigSerializeConvHelper> trigCnvHelper("TrigSerializeConvHelper",this);
50 ATH_CHECK( trigCnvHelper.retrieve() );
51
52 return StatusCode::SUCCESS;
53}
54
55
57
58 const EventContext& ctx = Gaudi::Hive::currentContext();
59 const bool isRun1 = m_navToolL2.isEnabled();
60 if ( isRun1 ) {
61 if ( repackFeaturesToSG(ctx, *m_navToolL2, m_l2ResultKeyIn, m_l2ResultKeyOut, false, false).isFailure() )
62 ATH_MSG_WARNING( "failed unpacking features from BS to SG for: " << m_l2ResultKeyIn );
63 }
64
65 if ( !m_hltResultKeyIn.empty() ) {
66 // unpack, merge with L2 result and do xAOD conversion
67 // xAOD conversion is only done for HLTResult_EF in Run-1
68 if ( repackFeaturesToSG(ctx, *m_navTool, m_hltResultKeyIn, m_hltResultKeyOut, isRun1, isRun1).isFailure() )
69 ATH_MSG_WARNING( "failed unpacking features from BS to SG for: " << m_hltResultKeyIn );
70 }
71
72 for (size_t i = 0; i<m_dataScoutingKeysIn.size(); i++ ) {
73 if ( repackFeaturesToSG(ctx, *m_navTool, m_dataScoutingKeysIn[i], m_dataScoutingKeysOut[i], false, false).isFailure() )
74 ATH_MSG_WARNING( "failed unpacking features from BS to SG for: " << m_dataScoutingKeysIn[i] );
75 }
76
77 if ( isRun1 ) m_navToolL2->reset();
78 m_navTool->reset();
79
80 return StatusCode::SUCCESS;
81}
82
83
84StatusCode TrigBSExtraction::repackFeaturesToSG (const EventContext& ctx,
85 HLT::Navigation& navTool,
88 bool equalize,
89 bool xAODCnv) {
90
91 ATH_MSG_DEBUG( "Trying to deserialize content of " << key );
92 auto cresult = SG::makeHandle(key, ctx);
93
94 if ( !cresult.get() ) {
95 ATH_MSG_WARNING( "No HLTResult found with key " << key );
96 return StatusCode::SUCCESS;
97 }
98
99 ATH_MSG_DEBUG("HLTResult is level=" << cresult->getHLTLevel() );
100
101 const std::vector<uint32_t>& navData = cresult->getNavigationResult();
102 if ( !navData.empty() ) {
103 ATH_MSG_DEBUG( "Navigation payload obtained from " << key << " has size " << navData.size() );
104 navTool.deserialize( navData );
105 } else {
106 ATH_MSG_WARNING( "Navigation payload obtained from " << key << " has size 0" );
107 }
108
109 if ( equalize && m_navToolL2.isEnabled() ) {
110 ATH_MSG_DEBUG( "Merging L2 and EF navigation structures for " << key );
111 navTool.merge(*m_navToolL2);
112 }
113
114 navTool.prepare();
115
116 // optional xAOD conversion for Run-1 AOD containers
117 if ( xAODCnv && m_xAODTool.isEnabled() ) {
118
119 ATH_CHECK( m_xAODTool->convert(ctx, &navTool) );
120
121 // after AOD TrigPassBitsCollection was converted to xAOD::TrigPassBitsContainer,
122 // let's fill new xAOD::TrigPassBits objects with the proper pointers to
123 // converted xAOD containers
124 ATH_CHECK( m_xAODTool->setTrigPassBits(&navTool) );
125
126 // this will redirect all Features to the xAOD converters
127 ATH_CHECK( m_xAODTool->rewireNavigation(&navTool) );
128 }
129
130 // Create a copy of HLTResult and pack navigation back into it
131 auto result = std::make_unique<HLT::HLTResult>(*cresult);
132
133 result->getNavigationResult().clear();
134 bool status = navTool.serialize(result->getNavigationResult(), result->getNavigationResultCuts());
135 ATH_MSG_DEBUG( "New serialized navigation for " << keyOut << " has size " << result->getNavigationResult().size() );
136
137 ATH_CHECK( SG::makeHandle(keyOut, ctx).record(std::move(result)) );
138
139 return StatusCode(status);
140}
141
#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 with parameters:
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.
virtual StatusCode execute() override
Execute method without EventContext (deprecated).
StatusCode repackFeaturesToSG(const EventContext &ctx, HLT::Navigation &navTool, const SG::ReadHandleKey< HLT::HLTResult > &key, SG::WriteHandleKey< HLT::HLTResult > &keyOut, bool equalize, bool xAODConv)
method which does loop over objects
SG::ReadHandleKey< HLT::HLTResult > m_hltResultKeyIn
ToolHandle< ITrigBStoxAODTool > m_xAODTool
SG::WriteHandleKey< HLT::HLTResult > m_hltResultKeyOut
ToolHandle< HLT::Navigation > m_navToolL2
TrigBSExtraction(const std::string &name, ISvcLocator *pSvcLocator)
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())