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

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

◆ initialize()

StatusCode CTPUnpackingTool::initialize ( )
overridevirtual

Reimplemented from CTPUnpackingToolBase.

Definition at line 22 of file CTPUnpackingTool.cxx.

22  {
25  ATH_CHECK( m_ctpResultKey.initialize( m_useEDMxAOD ) );
26 
27 
29 
30  return StatusCode::SUCCESS;
31 }

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

◆ 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
40  m_itemNametoCTPIDMap.clear();
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 
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 }

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.

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

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

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

◆ m_monTool

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

Definition at line 51 of file CTPUnpackingToolBase.h.

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

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

◆ s_CTPIDForUnseededChains

constexpr 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:
ROIB::CTPRoI
ROIB::CTPRoI contains a RoI delivered by the CTP.
Definition: CTPRoI.h:28
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:45
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:67
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:55
CTPUnpackingTool::m_L1MenuKey
SG::ReadHandleKey< TrigConf::L1Menu > m_L1MenuKey
Definition: CTPUnpackingTool.h:41
CTPUnpackingTool::m_HLTMenuKey
SG::ReadHandleKey< TrigConf::HLTMenu > m_HLTMenuKey
Definition: CTPUnpackingTool.h:39
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
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:274
PyPoolBrowser.item
item
Definition: PyPoolBrowser.py:129
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:46
calibdata.exception
exception
Definition: calibdata.py:495
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
CTPUnpackingToolBase::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: CTPUnpackingToolBase.h:51
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:19
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:47
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:239
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:71
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
TriggerTest.rois
rois
Definition: TriggerTest.py:23
python.XMLReader.l1menu
l1menu
Definition: XMLReader.py:73
CTPUnpackingToolBase::m_forceEnable
Gaudi::Property< bool > m_forceEnable
Definition: CTPUnpackingToolBase.h:48
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
CTPUnpackingTool::m_useEDMxAOD
Gaudi::Property< bool > m_useEDMxAOD
Definition: CTPUnpackingTool.h:51
python.compressB64.c
def c
Definition: compressB64.py:93
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
CTPUnpackingTool::m_ctpResultKey
SG::ReadHandleKey< xAOD::CTPResult > m_ctpResultKey
Definition: CTPUnpackingTool.h:44