ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
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. More...
 
virtual ~DecisionUnpackerStandalone ()
 Destructor. More...
 
 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. More...
 
virtual StatusCode unpackNavigation (const EventContext &ctx, HLT::TrigNavStructure *nav) const override
 Function unpacking the payload of the trigger navigation. More...
 
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. More...
 
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. More...
 

Private Attributes

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

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  }

◆ ~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

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

33 { return msg() << lvl; }

◆ 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  }

◆ 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:
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  }

◆ 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  }

◆ 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" );
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  }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

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

◆ 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.

◆ 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.


The documentation for this class was generated from the following files:
xAOD::TrigDecision_v1::efPrescaled
const std::vector< uint32_t > & efPrescaled() const
Get the EF prescaled bits.
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
xAOD::TrigDecision_v1::efResurrected
const std::vector< uint32_t > & efResurrected() const
Get the EF resurrected bits.
HLT::TrigNavStructure::deserialize
virtual bool deserialize(const std::vector< uint32_t > &)=0
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
Trig::DecisionUnpackerStandalone::m_navikey
const SG::ReadHandleKey< xAOD::TrigNavigation > * m_navikey
Key of the trigger navigation object in the event.
Definition: DecisionUnpackerStandalone.h:87
xAOD::bgCode
bgCode
Definition: TrigDecision_v1.cxx:39
HLT::NavigationCore::deserialize
bool deserialize(const std::vector< uint32_t > &input)
Definition: NavigationCore.cxx:151
xAOD::TrigDecision_v1::tav
const std::vector< uint32_t > & tav() const
Get the Trigger After Veto bits.
HLT::TrigNavStructure::reset
virtual void reset(bool inFinalize=false)
resets all the navigation, goes to the factory and asks to withdraw all produced objects
Definition: TrigNavStructure.cxx:756
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
xAOD::TrigNavigation_v1::serialized
const std::vector< unsigned int > & serialized() const
expose the navigation information (in serialized form)
HLT::NavigationCore::reset
virtual void reset(bool inFinalize=false)
resets all the navigation, goes to the factory and asks to withdraw all produced objects
Definition: NavigationCore.cxx:281
xAOD::TrigDecision_v1::lvl2PassedThrough
const std::vector< uint32_t > & lvl2PassedThrough() const
Get the LVL2 pass-through bits.
PyPoolBrowser.item
item
Definition: PyPoolBrowser.py:129
HLT::NavigationCore
The NavigationCore class, adds on top of the TrigNavStructure the EDM read-only handling.
Definition: NavigationCore.h:96
LVL1CTP::Lvl1Item
Definition: Lvl1Item.h:37
Trig::DecisionUnpackerStandalone::unpackItems
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.
Definition: DecisionUnpackerStandalone.cxx:163
Trig::DecisionUnpackerStandalone::m_deckey
const SG::ReadHandleKey< xAOD::TrigDecision > * m_deckey
Key of the trigger decision object in the event.
Definition: DecisionUnpackerStandalone.h:85
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
xAOD::TrigDecision_v1::efPassedThrough
const std::vector< uint32_t > & efPassedThrough() const
Get the EF pass-through bits.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Trig::Logger::msg
MsgStream & msg() const
Definition: Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/Logger.h:29
xAOD::TrigDecision_v1::efPassedRaw
const std::vector< uint32_t > & efPassedRaw() const
Get the EF passed-raw bits.
merge.output
output
Definition: merge.py:17
get32BitDecision
bool get32BitDecision(unsigned int index, const std::vector< uint32_t > &vec)
Definition: DecisionUnpackerEventInfo.cxx:20
item
Definition: ItemListSvc.h:43
xAOD::TrigDecision_v1::tap
const std::vector< uint32_t > & tap() const
Get the Trigger After Prescale bits.
xAOD::TrigDecision_v1::bgCode
char bgCode() const
Get the bunch group code of the current event.
xAOD::TrigDecision_v1::lvl2Prescaled
const std::vector< uint32_t > & lvl2Prescaled() const
Get the LVL2 prescaled bits.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::TrigNavigation_v1
Interface to the raw trigger navigation information of the event.
Definition: TrigNavigation_v1.h:34
xAOD::TrigDecision_v1::tbp
const std::vector< uint32_t > & tbp() const
Get the Trigger Before Prescale bits.
xAOD::TrigDecision_v1::lvl2Resurrected
const std::vector< uint32_t > & lvl2Resurrected() const
Get the LVL2 resurrected bits.
xAOD::TrigDecision_v1
Interface to the raw trigger decision information of the event.
Definition: TrigDecision_v1.h:44
xAOD::TrigDecision_v1::lvl2PassedRaw
const std::vector< uint32_t > & lvl2PassedRaw() const
Get the LVL2 passed-raw bits.
Trig::DecisionUnpackerStandalone::unpackChains
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.
Definition: DecisionUnpackerStandalone.cxx:190