ATLAS Offline Software
Loading...
Searching...
No Matches
TrigBSExtraction.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 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 bool isRun1 = m_navToolL2.isEnabled();
59 if ( isRun1 ) {
60 if ( repackFeaturesToSG(*m_navToolL2, m_l2ResultKeyIn, m_l2ResultKeyOut, false, false).isFailure() )
61 ATH_MSG_WARNING( "failed unpacking features from BS to SG for: " << m_l2ResultKeyIn );
62 }
63
64 if ( !m_hltResultKeyIn.empty() ) {
65 // unpack, merge with L2 result and do xAOD conversion
66 // xAOD conversion is only done for HLTResult_EF in Run-1
67 if ( repackFeaturesToSG(*m_navTool, m_hltResultKeyIn, m_hltResultKeyOut, isRun1, isRun1).isFailure() )
68 ATH_MSG_WARNING( "failed unpacking features from BS to SG for: " << m_hltResultKeyIn );
69 }
70
71 for (size_t i = 0; i<m_dataScoutingKeysIn.size(); i++ ) {
72 if ( repackFeaturesToSG(*m_navTool, m_dataScoutingKeysIn[i], m_dataScoutingKeysOut[i], false, false).isFailure() )
73 ATH_MSG_WARNING( "failed unpacking features from BS to SG for: " << m_dataScoutingKeysIn[i] );
74 }
75
76 if ( isRun1 ) m_navToolL2->reset();
77 m_navTool->reset();
78
79 return StatusCode::SUCCESS;
80}
81
82
86 bool equalize,
87 bool xAODCnv) {
88
89 ATH_MSG_DEBUG( "Trying to deserialize content of " << key );
90 auto cresult = SG::makeHandle(key);
91
92 if ( !cresult.get() ) {
93 ATH_MSG_WARNING( "No HLTResult found with key " << key );
94 return StatusCode::SUCCESS;
95 }
96
97 ATH_MSG_DEBUG("HLTResult is level=" << cresult->getHLTLevel() );
98
99 const std::vector<uint32_t>& navData = cresult->getNavigationResult();
100 if ( !navData.empty() ) {
101 ATH_MSG_DEBUG( "Navigation payload obtained from " << key << " has size " << navData.size() );
102 navTool.deserialize( navData );
103 } else {
104 ATH_MSG_WARNING( "Navigation payload obtained from " << key << " has size 0" );
105 }
106
107 if ( equalize && m_navToolL2.isEnabled() ) {
108 ATH_MSG_DEBUG( "Merging L2 and EF navigation structures for " << key );
109 navTool.merge(*m_navToolL2);
110 }
111
112 navTool.prepare();
113
114 // optional xAOD conversion for Run-1 AOD containers
115 if ( xAODCnv && m_xAODTool.isEnabled() ) {
116
117 ATH_CHECK( m_xAODTool->convert(&navTool) );
118
119 // after AOD TrigPassBitsCollection was converted to xAOD::TrigPassBitsContainer,
120 // let's fill new xAOD::TrigPassBits objects with the proper pointers to
121 // converted xAOD containers
122 ATH_CHECK( m_xAODTool->setTrigPassBits(&navTool) );
123
124 // this will redirect all Features to the xAOD converters
125 ATH_CHECK( m_xAODTool->rewireNavigation(&navTool) );
126 }
127
128 // Create a copy of HLTResult and pack navigation back into it
129 auto result = std::make_unique<HLT::HLTResult>(*cresult);
130
131 result->getNavigationResult().clear();
132 bool status = navTool.serialize(result->getNavigationResult(), result->getNavigationResultCuts());
133 ATH_MSG_DEBUG( "New serialized navigation for " << keyOut << " has size " << result->getNavigationResult().size() );
134
135 ATH_CHECK( SG::makeHandle(keyOut).record(std::move(result)) );
136
137 return StatusCode(status);
138}
139
#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
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
StatusCode repackFeaturesToSG(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::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())