ATLAS Offline Software
Loading...
Searching...
No Matches
L1jFexJetThresholdsDecoratorAlg.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
10
11#include <cstdint>
12#include <exception>
13#include <string>
14#include <vector>
15
16#include "TrigConfData/L1Menu.h"
18
19namespace CP
20{
21
23 const std::string& name, ISvcLocator* svcLoc)
24 : EL::AnaAlgorithm(name, svcLoc) {}
25
26
28 {
29 ANA_CHECK(m_l1JetsKey.initialize());
30 ANA_CHECK(m_trigConfigTool.retrieve());
31
33 ANA_CHECK(m_thresholdsDecorKey.initialize());
34 return StatusCode::SUCCESS;
35 }
36
38 const EventContext& ctx) {
39 const TrigConf::L1Menu* l1menu = nullptr;
40 try {
41 l1menu = &m_trigConfigTool->l1Menu(ctx);
42 } catch (const std::exception& e) {
43 ANA_MSG_ERROR("Could not read the L1 menu in execute(): "
44 << e.what()
45 << ". The Phase-I jFEX threshold table "
46 "cannot be built. Ensure TrigConf::xAODConfigSvc has "
47 "loaded the L1 menu for this input file.");
48 return StatusCode::FAILURE;
49 }
50
51 if (m_thresholdNamesLoaded && l1menu->name() == m_cachedL1MenuName) {
52 return StatusCode::SUCCESS;
53 }
55 ANA_MSG_INFO("L1 menu changed from '"
56 << m_cachedL1MenuName << "' to '" << l1menu->name()
57 << "' - rebuilding jFEX threshold table");
58 }
59 const auto& thresholds = l1menu->thresholds(m_l1ThresholdType.value());
60 if (thresholds.empty()) {
61 ANA_MSG_ERROR("L1 menu '" << l1menu->name()
62 << "' has no thresholds of type '"
63 << m_l1ThresholdType.value() << "'");
64 return StatusCode::FAILURE;
65 }
67 for (const auto& thr : thresholds) {
68 const unsigned int bit = thr->mapping();
69 if (bit >= m_jfexThresholdNames.size())
70 m_jfexThresholdNames.resize(bit + 1);
71 m_jfexThresholdNames[bit] = thr->name();
72 }
73 ANA_MSG_INFO("Loaded " << m_jfexThresholdNames.size()
74 << " jFEX threshold names from L1 menu '"
75 << l1menu->name() << "'");
76 m_cachedL1MenuName = l1menu->name();
78 return StatusCode::SUCCESS;
79 }
80
81 StatusCode L1jFexJetThresholdsDecoratorAlg::execute(const EventContext& ctx) {
83
85 if (!l1Jets.isValid()) {
86 ANA_MSG_ERROR("Failed to retrieve " << m_l1JetsKey.key());
87 return StatusCode::FAILURE;
88 }
89
90 static const SG::AuxElement::ConstAccessor<uint64_t>
91 thrPatternsAcc("thresholdPatterns");
93 thresholdsDec(m_thresholdsDecorKey, ctx);
94
95 for (const xAOD::jFexSRJetRoI* roi : *l1Jets) {
96 std::vector<std::string> passed;
97 if (thrPatternsAcc.isAvailable(*roi)) {
98 const uint64_t pat = thrPatternsAcc(*roi);
99 passed.reserve(m_jfexThresholdNames.size());
100 for (size_t b = 0; b < m_jfexThresholdNames.size(); ++b) {
101 if (((pat >> b) & 1ULL) && !m_jfexThresholdNames[b].empty()) {
102 passed.push_back(m_jfexThresholdNames[b]);
103 }
104 }
105 }
106 thresholdsDec(*roi) = std::move(passed);
107 }
108
109 return StatusCode::SUCCESS;
110 }
111}
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
Helper class to provide constant type-safe access to aux data.
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
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
StatusCode rebuildJfexThresholdTable(const EventContext &ctx)
SG::WriteDecorHandleKey< xAOD::jFexSRJetRoIContainer > m_thresholdsDecorKey
SG::ReadHandleKey< xAOD::jFexSRJetRoIContainer > m_l1JetsKey
L1jFexJetThresholdsDecoratorAlg(const std::string &name, ISvcLocator *svcLoc=nullptr)
ToolHandle< TrigConf::ITrigConfigTool > m_trigConfigTool
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
virtual::StatusCode execute()
execute this algorithm
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
L1 menu configuration.
Definition L1Menu.h:29
Select isolated Photons, Electrons and Muons.
This module defines the arguments passed from the BATCH driver to the BATCH worker.
jFexSRJetRoI_v1 jFexSRJetRoI
Define the latest version of the jFexSRJetRoI class.