ATLAS Offline Software
Public Member Functions | Protected Attributes | Static Protected Attributes | Private Attributes | List of all members
CTPUnpackingTool Class Reference

#include <CTPUnpackingTool.h>

Inheritance diagram for CTPUnpackingTool:
Collaboration diagram for CTPUnpackingTool:

Public Member Functions

 CTPUnpackingTool (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual StatusCode decode (const ROIB::RoIBResult &roib, HLT::IDVec &enabledChains) const override
 Fills the list of chains that should be activated in a given event (note HLT prescaling happens at a later stage) More...
 
virtual StatusCode initialize () override
 
virtual StatusCode start () override
 
virtual StatusCode passBeforePrescaleSelection (const ROIB::RoIBResult *roib, const std::vector< std::string > &l1ItemNames, bool &pass) const override
 
virtual bool isEmulated () const override
 

Protected Attributes

std::unordered_map< int, HLT::IDVecm_ctpToChain
 
Gaudi::Property< bool > m_forceEnable
 
ToolHandle< GenericMonitoringToolm_monTool {this, "MonTool", "", "Monitoring tool"}
 

Static Protected Attributes

static constexpr int s_CTPIDForUnseededChains = -1
 

Private Attributes

SG::ReadHandleKey< TrigConf::HLTMenum_HLTMenuKey
 
SG::ReadHandleKey< TrigConf::L1Menum_L1MenuKey
 
Gaudi::Property< bool > m_useTBPBit
 
std::map< std::string, size_t > m_itemNametoCTPIDMap
 

Detailed Description

Definition at line 16 of file CTPUnpackingTool.h.

Constructor & Destructor Documentation

◆ CTPUnpackingTool()

CTPUnpackingTool::CTPUnpackingTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 16 of file CTPUnpackingTool.cxx.

Member Function Documentation

◆ decode()

StatusCode CTPUnpackingTool::decode ( const ROIB::RoIBResult roib,
HLT::IDVec enabledChains 
) const
overridevirtual

Fills the list of chains that should be activated in a given event (note HLT prescaling happens at a later stage)

Reimplemented from CTPUnpackingToolBase.

Definition at line 93 of file CTPUnpackingTool.cxx.

93  {
94  auto nItems = Monitored::Scalar( "Items", 0 );
95  auto nChains = Monitored::Scalar( "Chains", 0 );
96 
97  auto ctpBits = m_useTBPBit ? roib.cTPResult().TBP() : roib.cTPResult().TAV();
98  const size_t bitsSize = ctpBits.size();
99  constexpr static size_t wordSize{32};
100 
101  for ( size_t wordCounter = 0; wordCounter < bitsSize; ++wordCounter ) {
102  for ( size_t bitCounter = 0; bitCounter < wordSize; ++bitCounter ) {
103  const size_t ctpIndex = wordSize*wordCounter + bitCounter;
104  const bool decision = ( ctpBits[wordCounter].roIWord() & ((uint32_t)1 << bitCounter) ) > 0;
105 
106  if ( decision or m_forceEnable ) {
107  if ( decision ) {
108  nItems = nItems + 1;
109  ATH_MSG_DEBUG("L1 item " << ctpIndex << " active, enabling chains "
110  << (m_forceEnable ? " due to the forceEnable flag" : " due to the seed"));
111  }
112 
113  auto itr = m_ctpToChain.find( ctpIndex );
114  if ( itr != m_ctpToChain.end() ) {
115  enabledChains.insert( enabledChains.end(), itr->second.begin(), itr->second.end() );
116  }
117  }
118  }
119  }
120  // the unseeded chains are always enabled at this stage
121  const auto itr = m_ctpToChain.find( s_CTPIDForUnseededChains );
122  if ( itr != m_ctpToChain.cend() ) {
123  enabledChains.insert( enabledChains.end(), itr->second.begin(), itr->second.end());
124  }
125 
126  nChains = enabledChains.size();
127  for ( auto chain: enabledChains ) {
128  ATH_MSG_DEBUG( "Enabling chain: " << chain );
129  }
130  if ( nItems == 0 ) {
131  ATH_MSG_ERROR( "All CTP bits were disabled, this event should not have shown here" );
132  return StatusCode::FAILURE;
133  }
134  Monitored::Group( m_monTool, nItems, nChains );
135  return StatusCode::SUCCESS;
136 }

◆ initialize()

StatusCode CTPUnpackingTool::initialize ( )
overridevirtual

Reimplemented from CTPUnpackingToolBase.

Definition at line 22 of file CTPUnpackingTool.cxx.

22  {
25 
26 
28 
29  return StatusCode::SUCCESS;
30 }

◆ isEmulated()

virtual bool CTPUnpackingToolBase::isEmulated ( ) const
inlineoverridevirtualinherited

Reimplemented in CTPUnpackingEmulationTool.

Definition at line 40 of file CTPUnpackingToolBase.h.

40 {return false;}

◆ passBeforePrescaleSelection()

StatusCode CTPUnpackingTool::passBeforePrescaleSelection ( const ROIB::RoIBResult roib,
const std::vector< std::string > &  l1ItemNames,
bool &  pass 
) const
overridevirtual

Reimplemented from CTPUnpackingToolBase.

Definition at line 139 of file CTPUnpackingTool.cxx.

141  {
142 
143  pass = false;
144 
145  const auto ctpBits = roib->cTPResult().TBP();
146 
147  for (const std::string& l1name : l1ItemNames) {
148  try {
149  // Retrieve before prescale decision
150  const size_t ctpId = m_itemNametoCTPIDMap.at(l1name);
151  const size_t bitCounter = ctpId % 32;
152  const size_t wordCounter = ctpId / 32;
153 
154  const bool decision = (ctpBits[wordCounter].roIWord() & ((uint32_t)1 << bitCounter)) > 0;
155 
156  pass = (pass || decision);
157  }
158  catch (const std::exception& e) {
159  ATH_MSG_ERROR ( l1name << " is not part of L1Menu!" );
160  return StatusCode::FAILURE;
161  }
162  }
163 
164  return StatusCode::SUCCESS;
165 }

◆ start()

StatusCode CTPUnpackingTool::start ( )
overridevirtual

Definition at line 33 of file CTPUnpackingTool.cxx.

33  {
34  ATH_MSG_INFO( "Updating CTP bits decoding configuration");
35 
36  // iterate over all items and obtain the CPT ID for each item. Then, package that in the map: name -> CTP ID
37  ATH_MSG_INFO( "start(): use new L1 trigger menu" );
38  // Cleanup in case there was a stop/start transition
39  m_itemNametoCTPIDMap.clear();
40  m_ctpToChain.clear();
41 
43  if( l1menu.isValid() ) {
44  for ( const TrigConf::L1Item & item: *l1menu ) {
45  m_itemNametoCTPIDMap[item.name()] = item.ctpId();
46  }
47  } else {
48  ATH_MSG_ERROR( "TrigConf::L1Menu does not exist" );
49  }
50 
51  auto addIfItemExists = [&]( const std::string& itemName, HLT::Identifier id, bool warningOnly = false ) -> StatusCode {
52  if ( m_itemNametoCTPIDMap.find( itemName ) != m_itemNametoCTPIDMap.end() ) {
53  m_ctpToChain[ m_itemNametoCTPIDMap[itemName] ].push_back( id );
54  return StatusCode::SUCCESS;
55  }
56  if( warningOnly ) {
57  // this code should be removed after the L1 menu is migrated to the new json version
58  ATH_MSG_WARNING(itemName << " used to seed the chain " << id <<" not in the configuration ");
59  return StatusCode::SUCCESS;
60  }
61  ATH_MSG_ERROR(itemName << " used to seed the chain " << id <<" not in the configuration ");
62  return StatusCode::FAILURE;
63  };
64 
66  ATH_CHECK( hltMenuHandle.isValid() );
67  for ( const TrigConf::Chain& chain: *hltMenuHandle ) {
68  HLT::Identifier chainID{ chain.name() };
69  if ( chain.l1item().empty() ) { // unseeded chain
70  m_ctpToChain[ s_CTPIDForUnseededChains ].push_back( chainID );
71  } else if ( chain.l1item().find(',') != std::string::npos ) { // OR seeds
72 
73  std::vector<std::string> items;
74  boost::split(items, chain.l1item(), [](char c){return c == ',';});
75  for ( const std::string& i: items ) {
76  ATH_CHECK( addIfItemExists( i, chainID, true ) );
77  }
78  } else { // regular chain
79  ATH_CHECK( addIfItemExists( chain.l1item(), chainID ) );
80  }
81  }
82 
83  for ( const auto& ctpIDtoChain: m_ctpToChain ) {
84  for ( auto chain: ctpIDtoChain.second ) {
85  ATH_MSG_DEBUG( "CTP seed of " << ctpIDtoChain.first << " enables chains " << chain );
86  }
87  }
88 
89  return StatusCode::SUCCESS;
90 }

Member Data Documentation

◆ m_ctpToChain

std::unordered_map<int, HLT::IDVec> CTPUnpackingToolBase::m_ctpToChain
protectedinherited

Definition at line 45 of file CTPUnpackingToolBase.h.

◆ m_forceEnable

Gaudi::Property<bool> CTPUnpackingToolBase::m_forceEnable
protectedinherited
Initial value:
{
this, "ForceEnableAllChains", false, "Enables all chains in each event, testing mode"}

Definition at line 47 of file CTPUnpackingToolBase.h.

◆ m_HLTMenuKey

SG::ReadHandleKey<TrigConf::HLTMenu> CTPUnpackingTool::m_HLTMenuKey
private
Initial value:
{
this, "HLTTriggerMenu", "DetectorStore+HLTTriggerMenu", "HLT Menu"}

Definition at line 38 of file CTPUnpackingTool.h.

◆ m_itemNametoCTPIDMap

std::map<std::string, size_t> CTPUnpackingTool::m_itemNametoCTPIDMap
private

Definition at line 47 of file CTPUnpackingTool.h.

◆ m_L1MenuKey

SG::ReadHandleKey<TrigConf::L1Menu> CTPUnpackingTool::m_L1MenuKey
private
Initial value:
{
this, "L1TriggerMenu", "DetectorStore+L1TriggerMenu", "L1 Menu"}

Definition at line 40 of file CTPUnpackingTool.h.

◆ m_monTool

ToolHandle<GenericMonitoringTool> CTPUnpackingToolBase::m_monTool {this, "MonTool", "", "Monitoring tool"}
protectedinherited

Definition at line 50 of file CTPUnpackingToolBase.h.

◆ m_useTBPBit

Gaudi::Property<bool> CTPUnpackingTool::m_useTBPBit
private
Initial value:
{
this, "UseTBPBits", false,
"When true, use Trigger Before Prescale bits instead of Trigger After Veto (for testing only)"}

Definition at line 43 of file CTPUnpackingTool.h.

◆ s_CTPIDForUnseededChains

constexpr int CTPUnpackingToolBase::s_CTPIDForUnseededChains = -1
staticconstexprprotectedinherited

Definition at line 44 of file CTPUnpackingToolBase.h.


The documentation for this class was generated from the following files:
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
CTPUnpackingToolBase::s_CTPIDForUnseededChains
static constexpr int s_CTPIDForUnseededChains
Definition: CTPUnpackingToolBase.h:44
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
ROIB::CTPResult::TBP
const std::vector< CTPRoI > TBP() const
get trigger result before prescale
CTPUnpackingTool::m_itemNametoCTPIDMap
std::map< std::string, size_t > m_itemNametoCTPIDMap
Definition: CTPUnpackingTool.h:47
CTPUnpackingTool::m_L1MenuKey
SG::ReadHandleKey< TrigConf::L1Menu > m_L1MenuKey
Definition: CTPUnpackingTool.h:40
CTPUnpackingTool::m_HLTMenuKey
SG::ReadHandleKey< TrigConf::HLTMenu > m_HLTMenuKey
Definition: CTPUnpackingTool.h:38
CTPUnpackingToolBase::CTPUnpackingToolBase
CTPUnpackingToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Definition: CTPUnpackingToolBase.cxx:8
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CTPUnpackingToolBase::m_ctpToChain
std::unordered_map< int, HLT::IDVec > m_ctpToChain
Definition: CTPUnpackingToolBase.h:45
calibdata.exception
exception
Definition: calibdata.py:496
CTPUnpackingToolBase::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: CTPUnpackingToolBase.h:50
test_pyathena.parent
parent
Definition: test_pyathena.py:15
TrigConf::L1Item
L1 threshold configuration.
Definition: L1Item.h:18
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
HLT::Identifier
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:20
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
CTPUnpackingTool::m_useTBPBit
Gaudi::Property< bool > m_useTBPBit
Definition: CTPUnpackingTool.h:43
ROIB::RoIBResult::cTPResult
const CTPResult & cTPResult() const
Gets the CTP part of the L1 RDO.
Definition: RoIBResult.cxx:60
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:79
item
Definition: ItemListSvc.h:43
ROIB::CTPResult::TAV
const std::vector< CTPRoI > TAV() const
get trigger result after veto
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.XMLReader.l1menu
l1menu
Definition: XMLReader.py:73
CTPUnpackingToolBase::m_forceEnable
Gaudi::Property< bool > m_forceEnable
Definition: CTPUnpackingToolBase.h:47
CTPUnpackingToolBase::initialize
virtual StatusCode initialize() override
Definition: CTPUnpackingToolBase.cxx:14
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
TrigConf::Chain
HLT chain configuration.
Definition: TrigConfData/TrigConfData/HLTChain.h:18
python.compressB64.c
def c
Definition: compressB64.py:93
Trk::split
@ split
Definition: LayerMaterialProperties.h:38