ATLAS Offline Software
Loading...
Searching...
No Matches
JfexThresholdTable.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8
9#include <cstdint>
10#include <exception>
11
12#include "TrigConfData/L1Menu.h"
14
15namespace CP
16{
18 ToolHandle<TrigConf::ITrigConfigTool>& trigConfigTool,
19 const std::string& thresholdType, const EventContext& ctx,
20 MsgStream& msg) {
21 const TrigConf::L1Menu* l1menu = nullptr;
22 try {
23 l1menu = &trigConfigTool->l1Menu(ctx);
24 } catch (const std::exception& e) {
25 msg << MSG::ERROR << "Could not read the L1 menu in execute(): "
26 << e.what()
27 << ". The Phase-I jFEX threshold table "
28 "cannot be built. Ensure TrigConf::xAODConfigSvc has "
29 "loaded the L1 menu for this input file." << endmsg;
30 return StatusCode::FAILURE;
31 }
32
33 if (m_loaded && l1menu->name() == m_menuName) {
34 return StatusCode::SUCCESS;
35 }
36 if (m_loaded) {
37 msg << MSG::INFO << "L1 menu changed from '"
38 << m_menuName << "' to '" << l1menu->name()
39 << "' - rebuilding jFEX threshold table" << endmsg;
40 }
41 const auto& thresholds = l1menu->thresholds(thresholdType);
42 if (thresholds.empty()) {
43 msg << MSG::ERROR << "L1 menu '" << l1menu->name()
44 << "' has no thresholds of type '" << thresholdType << "'"
45 << endmsg;
46 return StatusCode::FAILURE;
47 }
48 m_names.clear();
49 for (const auto& thr : thresholds) {
50 const unsigned int bit = thr->mapping();
51 if (bit >= m_names.size())
52 m_names.resize(bit + 1);
53 m_names[bit] = thr->name();
54 }
55 msg << MSG::INFO << "Loaded " << m_names.size()
56 << " jFEX threshold names from L1 menu '"
57 << l1menu->name() << "'" << endmsg;
58 m_menuName = l1menu->name();
59 m_loaded = true;
60 return StatusCode::SUCCESS;
61 }
62
63 std::vector<std::string> JfexThresholdTable::decode(
64 const xAOD::jFexSRJetRoI& roi) const {
65 std::vector<std::string> passed;
66 static const SG::ConstAccessor<uint64_t> thrPatternsAcc("thresholdPatterns");
67 if (!thrPatternsAcc.isAvailable(roi)) return passed;
68 const uint64_t pat = thrPatternsAcc(roi);
69 passed.reserve(m_names.size());
70 for (size_t b = 0; b < m_names.size(); ++b) {
71 if (((pat >> b) & 1ULL) && !m_names[b].empty()) {
72 passed.push_back(m_names[b]);
73 }
74 }
75 return passed;
76 }
77}
#define endmsg
Helper class to provide constant type-safe access to aux data.
bool passed(DecisionID id, const DecisionIDContainer &)
checks if required decision ID is in the set of IDs in the container
static const Attributes_t empty
std::vector< std::string > m_names
std::vector< std::string > decode(const xAOD::jFexSRJetRoI &roi) const
the names of the menu thresholds whose bits are set in the RoI's thresholdPatterns (empty if the patt...
StatusCode update(ToolHandle< TrigConf::ITrigConfigTool > &trigConfigTool, const std::string &thresholdType, const EventContext &ctx, MsgStream &msg)
build the table from the current L1 menu, unless it is already built for a menu of the same name
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
L1 menu configuration.
Definition L1Menu.h:29
Select isolated Photons, Electrons and Muons.
jFexSRJetRoI_v1 jFexSRJetRoI
Define the latest version of the jFexSRJetRoI class.
MsgStream & msg
Definition testRead.cxx:32