ATLAS Offline Software
Loading...
Searching...
No Matches
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 EventContext &ctx, 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)
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
SG::ReadHandleKey< xAOD::CTPResultm_ctpResultKey
Gaudi::Property< bool > m_useTBPBit
Gaudi::Property< bool > m_useEDMxAOD
std::map< std::string, size_t > m_itemNametoCTPIDMap

Detailed Description

Definition at line 17 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.

19 : CTPUnpackingToolBase(type, name, parent) {}
CTPUnpackingToolBase(const std::string &type, const std::string &name, const IInterface *parent)

Member Function Documentation

◆ decode()

StatusCode CTPUnpackingTool::decode ( const EventContext & ctx,
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 94 of file CTPUnpackingTool.cxx.

94 {
95 auto nItems = Monitored::Scalar( "Items", 0 );
96 auto nChains = Monitored::Scalar( "Chains", 0 );
97
98 std::vector<uint32_t> ctpBits;
99 if (m_useEDMxAOD) { // Need to make sure you can pick up the correct CTPResult in StoreGate
100
101 // Retrieve xAOD::CTPResult object
102 SG::ReadHandle<xAOD::CTPResult> ctpRes{ m_ctpResultKey, ctx };
103 if (!ctpRes.isValid()) {
104 ATH_MSG_ERROR("Failed to retrieve CTPResult with key " << m_ctpResultKey.key());
105 return StatusCode::FAILURE;
106 };
107
108 // Get the appropriate trigger bits for L1A bunch
109 ctpBits = m_useTBPBit ? ctpRes->getTBPWords() : ctpRes->getTAVWords();
110
111 }
112 else {
113
114 // Get appropriate trigger bits from ROIB::CTPResult object in RoIBResult object
115 auto rois = m_useTBPBit ? roib.cTPResult().TBP() : roib.cTPResult().TAV();
116 ctpBits.reserve(rois.size());
117
118 // Trigger bits stored in vector of ROIB::CTPRoI objects (which are just uint32_t), need to convert to a vector of type uint32_t
119 std::transform(rois.begin(), rois.end(), std::back_inserter(ctpBits), [](const ROIB::CTPRoI& roi){ return roi.roIWord(); });
120
121 }
122 const size_t bitsSize = ctpBits.size();
123 constexpr static size_t wordSize{32};
124
125 for ( size_t wordCounter = 0; wordCounter < bitsSize; ++wordCounter ) {
126 for ( size_t bitCounter = 0; bitCounter < wordSize; ++bitCounter ) {
127 const size_t ctpIndex = wordSize*wordCounter + bitCounter;
128 const bool decision = ( ctpBits[wordCounter] & ((uint32_t)1 << bitCounter) ) > 0;
129
130 if ( decision or m_forceEnable ) {
131 if ( decision ) {
132 nItems = nItems + 1;
133 ATH_MSG_DEBUG("L1 item " << ctpIndex << " active, enabling chains "
134 << (m_forceEnable ? " due to the forceEnable flag" : " due to the seed"));
135 }
136
137 auto itr = m_ctpToChain.find( ctpIndex );
138 if ( itr != m_ctpToChain.end() ) {
139 enabledChains.insert( enabledChains.end(), itr->second.begin(), itr->second.end() );
140 }
141 }
142 }
143 }
144 // the unseeded chains are always enabled at this stage
145 const auto itr = m_ctpToChain.find( s_CTPIDForUnseededChains );
146 if ( itr != m_ctpToChain.cend() ) {
147 enabledChains.insert( enabledChains.end(), itr->second.begin(), itr->second.end());
148 }
149
150 nChains = enabledChains.size();
151 for ( auto chain: enabledChains ) {
152 ATH_MSG_DEBUG( "Enabling chain: " << chain );
153 }
154 if ( nItems == 0 ) {
155 ATH_MSG_ERROR( "All CTP bits were disabled, this event should not have shown here" );
156 return StatusCode::FAILURE;
157 }
158 Monitored::Group( m_monTool, nItems, nChains );
159 return StatusCode::SUCCESS;
160}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
ToolHandle< GenericMonitoringTool > m_monTool
std::unordered_map< int, HLT::IDVec > m_ctpToChain
static constexpr int s_CTPIDForUnseededChains
Gaudi::Property< bool > m_forceEnable
SG::ReadHandleKey< xAOD::CTPResult > m_ctpResultKey
Gaudi::Property< bool > m_useTBPBit
Gaudi::Property< bool > m_useEDMxAOD
const std::vector< CTPRoI > TBP() const
get trigger result before prescale
const std::vector< CTPRoI > TAV() const
get trigger result after veto
const CTPResult & cTPResult() const
Gets the CTP part of the L1 RDO.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
setEventNumber uint32_t

◆ initialize()

StatusCode CTPUnpackingTool::initialize ( )
overridevirtual

Reimplemented from CTPUnpackingToolBase.

Definition at line 22 of file CTPUnpackingTool.cxx.

22 {
23 ATH_CHECK( m_L1MenuKey.initialize() );
24 ATH_CHECK( m_HLTMenuKey.initialize() );
25 ATH_CHECK( m_ctpResultKey.initialize( m_useEDMxAOD ) );
26
27
29
30 return StatusCode::SUCCESS;
31}
#define ATH_CHECK
Evaluate an expression and check for errors.
virtual StatusCode initialize() override
SG::ReadHandleKey< TrigConf::HLTMenu > m_HLTMenuKey
SG::ReadHandleKey< TrigConf::L1Menu > m_L1MenuKey

◆ isEmulated()

virtual bool CTPUnpackingToolBase::isEmulated ( ) const
inlineoverridevirtualinherited

Reimplemented in CTPUnpackingEmulationTool.

Definition at line 41 of file CTPUnpackingToolBase.h.

41{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 163 of file CTPUnpackingTool.cxx.

165 {
166
167 pass = false;
168
169 const auto ctpBits = roib->cTPResult().TBP();
170
171 for (const std::string& l1name : l1ItemNames) {
172 try {
173 // Retrieve before prescale decision
174 const size_t ctpId = m_itemNametoCTPIDMap.at(l1name);
175 const size_t bitCounter = ctpId % 32;
176 const size_t wordCounter = ctpId / 32;
177
178 const bool decision = (ctpBits[wordCounter].roIWord() & ((uint32_t)1 << bitCounter)) > 0;
179
180 pass = (pass || decision);
181 }
182 catch (const std::exception& e) {
183 ATH_MSG_ERROR ( l1name << " is not part of L1Menu!" );
184 return StatusCode::FAILURE;
185 }
186 }
187
188 return StatusCode::SUCCESS;
189}
std::map< std::string, size_t > m_itemNametoCTPIDMap

◆ start()

StatusCode CTPUnpackingTool::start ( )
overridevirtual

Definition at line 34 of file CTPUnpackingTool.cxx.

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

Member Data Documentation

◆ m_ctpResultKey

SG::ReadHandleKey<xAOD::CTPResult> CTPUnpackingTool::m_ctpResultKey
private
Initial value:
{
this, "CTPResult", "StoreGateSvc+CTPResult", "CTP Result"}

Definition at line 44 of file CTPUnpackingTool.h.

44 {
45 this, "CTPResult", "StoreGateSvc+CTPResult", "CTP Result"};

◆ m_ctpToChain

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

Definition at line 46 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 48 of file CTPUnpackingToolBase.h.

48 {
49 this, "ForceEnableAllChains", false, "Enables all chains in each event, testing mode"};

◆ m_HLTMenuKey

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

Definition at line 39 of file CTPUnpackingTool.h.

39 {
40 this, "HLTTriggerMenu", "DetectorStore+HLTTriggerMenu", "HLT Menu"};

◆ m_itemNametoCTPIDMap

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

Definition at line 55 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 41 of file CTPUnpackingTool.h.

41 {
42 this, "L1TriggerMenu", "DetectorStore+L1TriggerMenu", "L1 Menu"};

◆ m_monTool

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

Definition at line 51 of file CTPUnpackingToolBase.h.

51{this, "MonTool", "", "Monitoring tool"};

◆ m_useEDMxAOD

Gaudi::Property<bool> CTPUnpackingTool::m_useEDMxAOD
private
Initial value:
{
this, "UseEDMxAOD", false,
"When true, use xAOD::CTPResult object when decoding instead of relying on ROIB::RoIBResult for CTP words"}

Definition at line 51 of file CTPUnpackingTool.h.

51 {
52 this, "UseEDMxAOD", false,
53 "When true, use xAOD::CTPResult object when decoding instead of relying on ROIB::RoIBResult for CTP words"};

◆ 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 47 of file CTPUnpackingTool.h.

47 {
48 this, "UseTBPBits", false,
49 "When true, use Trigger Before Prescale bits instead of Trigger After Veto (for testing only)"};

◆ s_CTPIDForUnseededChains

int CTPUnpackingToolBase::s_CTPIDForUnseededChains = -1
staticconstexprprotectedinherited

Definition at line 45 of file CTPUnpackingToolBase.h.


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