ATLAS Offline Software
Loading...
Searching...
No Matches
Trig::DecisionUnpackerStandalone Class Reference

Helper class for unpacking the xAOD trigger decision/navigation. More...

#include <DecisionUnpackerStandalone.h>

Inheritance diagram for Trig::DecisionUnpackerStandalone:
Collaboration diagram for Trig::DecisionUnpackerStandalone:

Public Types

typedef unsigned CTPID
typedef unsigned CHAIN_COUNTER

Public Member Functions

 DecisionUnpackerStandalone (const SG::ReadHandleKey< xAOD::TrigDecision > *, const SG::ReadHandleKey< xAOD::TrigNavigation > *navikey)
 Constructor with arguments.
virtual ~DecisionUnpackerStandalone ()
 Destructor.
 DecisionUnpackerStandalone (const DecisionUnpackerStandalone &)=delete
DecisionUnpackerStandaloneoperator= (const DecisionUnpackerStandalone &)=delete
virtual StatusCode unpackDecision (const EventContext &ctx, std::unordered_map< std::string, const LVL1CTP::Lvl1Item * > &itemsByName, std::map< CTPID, LVL1CTP::Lvl1Item > &itemsCache, std::unordered_map< std::string, const HLT::Chain * > &l2chainsByName, std::map< CHAIN_COUNTER, HLT::Chain > &l2chainsCache, std::unordered_map< std::string, const HLT::Chain * > &efchainsByName, std::map< CHAIN_COUNTER, HLT::Chain > &efchainsCache, char &bgCode, bool unpackHLT) const override
 Function unpacking the payload of the trigger decision.
virtual StatusCode unpackNavigation (const EventContext &ctx, HLT::TrigNavStructure *nav) const override
 Function unpacking the payload of the trigger navigation.
MsgStream & msg () const
MsgStream & msg (const MSG::Level lvl) const
bool msgLvl (const MSG::Level lvl) const

Private Member Functions

StatusCode unpackItems (const xAOD::TrigDecision &trigDec, std::map< CTPID, LVL1CTP::Lvl1Item > &itemsCache, std::unordered_map< std::string, const LVL1CTP::Lvl1Item * > &itemsByName) const
 Function unpacking the decision of the LVL1 items.
StatusCode unpackChains (std::map< unsigned, HLT::Chain > &cache, const std::vector< uint32_t > &raw, const std::vector< uint32_t > &passedThrough, const std::vector< uint32_t > &prescaled, const std::vector< uint32_t > &resurrected, std::unordered_map< std::string, const HLT::Chain * > &output) const
 Function unpacking the decision of the HLT chains.

Private Attributes

const SG::ReadHandleKey< xAOD::TrigDecision > * m_deckey {nullptr}
 Key of the trigger decision object in the event.
const SG::ReadHandleKey< xAOD::TrigNavigation > * m_navikey {nullptr}
 Key of the trigger navigation object in the event.

Static Private Attributes

static asg::AsgTool *s_logger ATLAS_THREAD_SAFE {nullptr}

Detailed Description

Helper class for unpacking the xAOD trigger decision/navigation.

Definition at line 41 of file DecisionUnpackerStandalone.h.

Member Typedef Documentation

◆ CHAIN_COUNTER

typedef unsigned Trig::IDecisionUnpacker::CHAIN_COUNTER
inherited

Definition at line 33 of file IDecisionUnpacker.h.

◆ CTPID

typedef unsigned Trig::IDecisionUnpacker::CTPID
inherited

Definition at line 32 of file IDecisionUnpacker.h.

Constructor & Destructor Documentation

◆ DecisionUnpackerStandalone() [1/2]

Trig::DecisionUnpackerStandalone::DecisionUnpackerStandalone ( const SG::ReadHandleKey< xAOD::TrigDecision > * deckey,
const SG::ReadHandleKey< xAOD::TrigNavigation > * navikey )

Constructor with arguments.

Definition at line 39 of file DecisionUnpackerStandalone.cxx.

41 : m_deckey(deckey), m_navikey(navikey)
42 {
43 }
const SG::ReadHandleKey< xAOD::TrigNavigation > * m_navikey
Key of the trigger navigation object in the event.
const SG::ReadHandleKey< xAOD::TrigDecision > * m_deckey
Key of the trigger decision object in the event.

◆ ~DecisionUnpackerStandalone()

Trig::DecisionUnpackerStandalone::~DecisionUnpackerStandalone ( )
virtual

Destructor.

Definition at line 45 of file DecisionUnpackerStandalone.cxx.

45 {
46 }

◆ DecisionUnpackerStandalone() [2/2]

Trig::DecisionUnpackerStandalone::DecisionUnpackerStandalone ( const DecisionUnpackerStandalone & )
delete

Member Function Documentation

◆ msg() [1/2]

MsgStream & Trig::Logger::msg ( ) const
inlineinherited

Definition at line 29 of file Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/Logger.h.

29 {
30 if (s_logger) return s_logger->msg();
31 else throw std::runtime_error("TrigDecisionTool Logger not initialized.");
32 }

◆ msg() [2/2]

MsgStream & Trig::Logger::msg ( const MSG::Level lvl) const
inlineinherited

◆ msgLvl()

bool Trig::Logger::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 34 of file Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/Logger.h.

34{ return s_logger && s_logger->msgLvl(lvl); }

◆ operator=()

DecisionUnpackerStandalone & Trig::DecisionUnpackerStandalone::operator= ( const DecisionUnpackerStandalone & )
delete

◆ unpackChains()

StatusCode Trig::DecisionUnpackerStandalone::unpackChains ( std::map< unsigned, HLT::Chain > & cache,
const std::vector< uint32_t > & raw,
const std::vector< uint32_t > & passedThrough,
const std::vector< uint32_t > & prescaled,
const std::vector< uint32_t > & resurrected,
std::unordered_map< std::string, const HLT::Chain * > & output ) const
private

Function unpacking the decision of the HLT chains.

Definition at line 189 of file DecisionUnpackerStandalone.cxx.

195 {
196 output.reserve( output.size() + cache.size() );
197
198 for( auto& [cntr, chain] : cache ) {
199
200 chain.reset();
201 ATH_MSG_VERBOSE( "raw dec for " << cntr << " is "
202 << get32BitDecision( cntr, raw ) );
203 chain.setDecisions( get32BitDecision( cntr, raw ),
204 get32BitDecision( cntr,
205 passedthrough ),
206 get32BitDecision( cntr, prescaled),
207 get32BitDecision( cntr, resurrected ) );
208 output[ chain.getChainName() ] = &chain;
209 ATH_MSG_VERBOSE( "Updated chain in this event : " << chain );
210 }
211
212 return StatusCode::SUCCESS;
213 }
#define ATH_MSG_VERBOSE(x)
bool get32BitDecision(unsigned int index, const std::vector< uint32_t > &vec)
output
Definition merge.py:16

◆ unpackDecision()

StatusCode Trig::DecisionUnpackerStandalone::unpackDecision ( const EventContext & ctx,
std::unordered_map< std::string, const LVL1CTP::Lvl1Item * > & itemsByName,
std::map< CTPID, LVL1CTP::Lvl1Item > & itemsCache,
std::unordered_map< std::string, const HLT::Chain * > & l2chainsByName,
std::map< CHAIN_COUNTER, HLT::Chain > & l2chainsCache,
std::unordered_map< std::string, const HLT::Chain * > & efchainsByName,
std::map< CHAIN_COUNTER, HLT::Chain > & efchainsCache,
char & bgCode,
bool unpackHLT ) const
overridevirtual

Function unpacking the payload of the trigger decision.

Implements Trig::IDecisionUnpacker.

Definition at line 49 of file DecisionUnpackerStandalone.cxx.

58 {
59
60 // Grab the trigger decision:
61 SG::ReadHandle<xAOD::TrigDecision> trigDec(*m_deckey, ctx);
62 const xAOD::TrigDecision* xaoddec = trigDec.cptr();
63 if( ! xaoddec ){
64 ATH_MSG_ERROR( "xAOD decision is null" );
65 return StatusCode::FAILURE;
66 }
67
68 // Read the bunch group code:
69 bgCode = xaoddec->bgCode();
70
71 // L1 items
72 itemsByName.clear();
73 ATH_MSG_DEBUG( "Unpacking of L1 items" );
74
75 if( unpackItems( *xaoddec, itemsCache,itemsByName ).isFailure() ) {
76 ATH_MSG_WARNING( "Unpacking of L1 items failed" );
77 }
78
79 // Protect from unpacking in case HLT was not run
80 // (i.e. configuration chains are 0)
81 if( ! unpackHLT ) {
82 return StatusCode::SUCCESS;
83 }
84
85 // L2 chains
86 l2chainsByName.clear();
87 ATH_MSG_DEBUG( "Unpacking of L2 chains" );
88
89 if( unpackChains( l2chainsCache, xaoddec->lvl2PassedRaw(),
90 xaoddec->lvl2PassedThrough(), xaoddec->lvl2Prescaled(),
91 xaoddec->lvl2Resurrected(),
92 l2chainsByName ).isFailure() ) {
93 ATH_MSG_WARNING( "Unpacking of L2 chains failed" );
94 }
95
96 // EF chains
97 efchainsByName.clear();
98 ATH_MSG_DEBUG( "Unpacking of EF/HLT chains" );
99
100 if ( unpackChains( efchainsCache, xaoddec->efPassedRaw(),
101 xaoddec->efPassedThrough(), xaoddec->efPrescaled(),
102 xaoddec->efResurrected(),
103 efchainsByName ).isFailure() ) {
104 ATH_MSG_WARNING( "Unpacking of EF/HLT chains failed" );
105 }
106
107 return StatusCode::SUCCESS;
108 }
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
StatusCode unpackChains(std::map< unsigned, HLT::Chain > &cache, const std::vector< uint32_t > &raw, const std::vector< uint32_t > &passedThrough, const std::vector< uint32_t > &prescaled, const std::vector< uint32_t > &resurrected, std::unordered_map< std::string, const HLT::Chain * > &output) const
Function unpacking the decision of the HLT chains.
StatusCode unpackItems(const xAOD::TrigDecision &trigDec, std::map< CTPID, LVL1CTP::Lvl1Item > &itemsCache, std::unordered_map< std::string, const LVL1CTP::Lvl1Item * > &itemsByName) const
Function unpacking the decision of the LVL1 items.
const std::vector< uint32_t > & efPrescaled() const
Get the EF prescaled bits.
const std::vector< uint32_t > & lvl2PassedRaw() const
Get the LVL2 passed-raw bits.
const std::vector< uint32_t > & efPassedThrough() const
Get the EF pass-through bits.
const std::vector< uint32_t > & lvl2PassedThrough() const
Get the LVL2 pass-through bits.
const std::vector< uint32_t > & lvl2Resurrected() const
Get the LVL2 resurrected bits.
const std::vector< uint32_t > & lvl2Prescaled() const
Get the LVL2 prescaled bits.
const std::vector< uint32_t > & efPassedRaw() const
Get the EF passed-raw bits.
char bgCode() const
Get the bunch group code of the current event.
const std::vector< uint32_t > & efResurrected() const
Get the EF resurrected bits.
TrigDecision_v1 TrigDecision
Define the latest version of the trigger decision class.

◆ unpackItems()

StatusCode Trig::DecisionUnpackerStandalone::unpackItems ( const xAOD::TrigDecision & trigDec,
std::map< CTPID, LVL1CTP::Lvl1Item > & itemsCache,
std::unordered_map< std::string, const LVL1CTP::Lvl1Item * > & itemsByName ) const
private

Function unpacking the decision of the LVL1 items.

Definition at line 162 of file DecisionUnpackerStandalone.cxx.

165 {
166 itemsByName.reserve( itemsByName.size() + itemsCache.size() );
167 for( auto& [ctpid, item] : itemsCache ) {
168 ATH_MSG_VERBOSE( "Unpacking bits for item: " << ctpid << " "
169 << item.name() );
170 bool passBP = get32BitDecision( ctpid, trigDec.tbp() );
171 bool passAP = get32BitDecision( ctpid, trigDec.tap() );
172 bool passAV = get32BitDecision( ctpid, trigDec.tav() );
173 ATH_MSG_VERBOSE( " --- bits are: bp: " << passBP
174 << " ap: " << passAP << " av: "
175 << passAV );
176
177 LVL1CTP::Lvl1Item itemNew (item.name(), item.hashId(),
178 passBP, passAP, passAV,
179 item.prescaleFactor());
180 item = std::move (itemNew);
181 itemsByName[ item.name() ] = &item;
182 }
183
184 return StatusCode::SUCCESS;
185 }
const std::vector< uint32_t > & tav() const
Get the Trigger After Veto bits.
const std::vector< uint32_t > & tap() const
Get the Trigger After Prescale bits.
const std::vector< uint32_t > & tbp() const
Get the Trigger Before Prescale bits.

◆ unpackNavigation()

StatusCode Trig::DecisionUnpackerStandalone::unpackNavigation ( const EventContext & ctx,
HLT::TrigNavStructure * nav ) const
overridevirtual

Function unpacking the payload of the trigger navigation.

Implements Trig::IDecisionUnpacker.

Definition at line 111 of file DecisionUnpackerStandalone.cxx.

112 {
113 // A security check:
114 if( ! nav ) {
115 ATH_MSG_VERBOSE( "Null HLT::TrigNavStructure pointer received" );
116 return StatusCode::SUCCESS;
117 }
118
119 ATH_MSG_DEBUG( "Unpacking Navigation" );
120 SG::ReadHandle<xAOD::TrigNavigation> trigNav(*m_navikey, ctx);
121 const xAOD::TrigNavigation* serializedNav = trigNav.cptr();
122 if( ! serializedNav ) {
123 [[maybe_unused]] static std::atomic<bool> warningPrinted =
124 [&]() { ATH_MSG_WARNING( "Serialized navigation not available" );
125 return true; }();
126 return StatusCode::FAILURE;
127 }
128
129 // try to get navigation from EF/HLT
130 ATH_MSG_DEBUG( "Trying to unpack Navigation of size: "
131 << serializedNav->serialized().size() );
132
133
134 bool navi_nonempty = !(serializedNav->serialized().empty());
135
136#if !defined(XAOD_STANDALONE) && !defined(XAOD_ANALYSIS)
137 HLT::NavigationCore* fullNav = dynamic_cast<HLT::NavigationCore*>(nav);
138
139 if(!fullNav){
140 ATH_MSG_ERROR("downcast failed");
141 return StatusCode::FAILURE;
142 }
143
144 fullNav->reset();
145 bool unpacking_status = navi_nonempty && fullNav->deserialize( serializedNav->serialized() ) ;
146#else
147 nav->reset();
148 bool unpacking_status = navi_nonempty && nav->deserialize( serializedNav->serialized() ) ;
149#endif
150
151 if ( ! unpacking_status ) {
152 ATH_MSG_WARNING( "Navigation unpacking failed" );
153 } else {
154 ATH_MSG_DEBUG( "Unpacked Navigation" );
155 }
156
157 // Return gracefully:
158 return StatusCode::SUCCESS;
159 }
static const Attributes_t empty
virtual void reset(bool inFinalize=false)
resets all the navigation, goes to the factory and asks to withdraw all produced objects
bool deserialize(const std::vector< uint32_t > &input)
virtual void reset(bool inFinalize=false)
resets all the navigation, goes to the factory and asks to withdraw all produced objects
virtual bool deserialize(const std::vector< uint32_t > &)=0
const std::vector< unsigned int > & serialized() const
expose the navigation information (in serialized form)
TrigNavigation_v1 TrigNavigation
Define the latest version of the trigger navigation class.

Member Data Documentation

◆ ATLAS_THREAD_SAFE

asg::AsgTool* s_logger Trig::Logger::ATLAS_THREAD_SAFE {nullptr}
inlinestaticprivateinherited

Definition at line 38 of file Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/Logger.h.

38{nullptr};

◆ m_deckey

const SG::ReadHandleKey<xAOD::TrigDecision>* Trig::DecisionUnpackerStandalone::m_deckey {nullptr}
private

Key of the trigger decision object in the event.

Definition at line 85 of file DecisionUnpackerStandalone.h.

85{nullptr};

◆ m_navikey

const SG::ReadHandleKey<xAOD::TrigNavigation>* Trig::DecisionUnpackerStandalone::m_navikey {nullptr}
private

Key of the trigger navigation object in the event.

Definition at line 87 of file DecisionUnpackerStandalone.h.

87{nullptr};

The documentation for this class was generated from the following files: