ATLAS Offline Software
Loading...
Searching...
No Matches
GlobalJet1AlgTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "GlobalJet1AlgTool.h"
6
7#include "../IO/CommonTOB.h"
8
9#include <bitset>
10
11
12namespace GlobalSim {
13
14 // Main constructor
15 GlobalJet1AlgTool::GlobalJet1AlgTool(const std::string& type, const std::string& name, const IInterface* parent) :
16 base_class(type, name, parent) {
17 }
18
19
20 // Initialize function running before first event
22
23 CHECK(m_gblCellTowers.initialize());
24 CHECK(m_gblJet1JetsContainerKey.initialize());
25
26 return StatusCode::SUCCESS;
27 }
28
29
30 // Main functional block running for each event
31 StatusCode GlobalJet1AlgTool::run(const EventContext& ctx) const {
32
33 ATH_MSG_DEBUG("Building WTAConeJets");
34
35 // Read the GlobalCellTowers
36 auto h_towerTOBs = SG::makeHandle(m_gblCellTowers, ctx);
37 CHECK(h_towerTOBs.isValid());
38 const auto & towers = *h_towerTOBs;
39 const unsigned int inTopoTowersN = towers.size();
40 ATH_MSG_DEBUG("Reading " << inTopoTowersN << " cell towers as GenericTobs");
41
42 // Create bitwise towers
43 std::vector<WTATrigObj> input_towers;
44 for(unsigned int i = 0; i < inTopoTowersN; i++){
45 // Has constituent tracking feature
46 const IOBitwise::CommonTOB* tower = towers[i];
47 WTATrigObj this_tower(tower->et_bits().to_ulong(), tower->eta_bits().to_ulong(), tower->phi_bits().to_ulong(), 0, i);
48 input_towers.push_back(this_tower);
49 }
50
51 // Do the usual
52 std::unique_ptr<WTAConeMaker> MyWTAConeMaker = std::make_unique<WTACone2PassMaker>();
53 WTAParameters MyWTAParameters = WTAParameters(
54 8, // const_et_cut = 2 GeV
55 20, // seed_et_cut = 5 GeV
56 4 // jet_dR = 4
57 );
58 MyWTAConeMaker->m_WTAConeMakerParameter = MyWTAParameters; // Pass the WTAConeParameters
59 WTAConeParallelHelper wta_parallel_helper;
60 wta_parallel_helper.SetBlockN(4);
61 wta_parallel_helper.CreateBlocks(input_towers);
62 wta_parallel_helper.RunParallelWTA(MyWTAConeMaker);
63 wta_parallel_helper.CheckJetInCore();
64 std::vector<WTAJet> WTAJetList = wta_parallel_helper.GetAllJets(); // Bitwise Jets
65
66 auto h_Jet1TOBs = SG::makeHandle(m_gblJet1JetsContainerKey, ctx);
67 auto jets = std::make_unique<IOBitwise::CommonTOBContainer>();
68
69 for(const auto& WTAJet: WTAJetList){
70 int energyBits = std::clamp(static_cast<int>(WTAJet.pt()), 0, (1 << IOBitwise::CommonTOB::s_et_width) - 1);
71 int etaBits = std::clamp(static_cast<int>(WTAJet.eta()), 0, (1 << IOBitwise::CommonTOB::s_eta_width) - 1);
72 int phiBits = std::clamp(static_cast<int>(WTAJet.phi()), 0, (1 << IOBitwise::CommonTOB::s_phi_width) - 1);
73 jets->emplace_back(new IOBitwise::CommonTOB(std::bitset<IOBitwise::CommonTOB::s_et_width>(energyBits),
74 std::bitset<IOBitwise::CommonTOB::s_eta_width>(etaBits),
75 std::bitset<IOBitwise::CommonTOB::s_phi_width>(phiBits)));
76 // Print jet TOB
77 ATH_MSG_DEBUG("Returning Jet: " << jets->back()->to_string());
78 }
79
80 ATH_MSG_DEBUG("Built " << jets->size() << " WTAConeJets and stored them as GenericTobs");
81
82 CHECK(h_Jet1TOBs.record(std::move(jets)));
83
84
85 return StatusCode::SUCCESS;
86 }
87
88 // Overrides toString() function from base class, unused here
89 std::string GlobalJet1AlgTool::toString() const {
90 return {};
91 }
92
93} //namespace GlobalSim
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
SG::ReadHandleKey< IOBitwise::CommonTOBContainer > m_gblCellTowers
Read key for the output cell towers as a GenericTobContainer.
SG::WriteHandleKey< IOBitwise::CommonTOBContainer > m_gblJet1JetsContainerKey
Write key for the output Jet1Jets as a GenericTobContainer.
virtual StatusCode run(const EventContext &ctx) const override
Main functional block running for each event.
virtual std::string toString() const override
Overriding toString function from base class.
virtual StatusCode initialize() override
Initialize function running before first event.
GlobalJet1AlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Main constructor.
static constexpr std::size_t s_eta_width
Size of the eta bitset.
Definition CommonTOB.h:30
virtual std::bitset< s_et_width > et_bits() const
Definition CommonTOB.cxx:27
static constexpr std::size_t s_et_width
Size of the eT bitset.
Definition CommonTOB.h:28
virtual std::bitset< s_eta_width > eta_bits() const
Definition CommonTOB.cxx:31
virtual std::bitset< s_phi_width > phi_bits() const
Definition CommonTOB.cxx:35
static constexpr std::size_t s_phi_width
Size of the phi bitset.
Definition CommonTOB.h:32
std::vector< WTAJet > GetAllJets()
void RunParallelWTA(std::unique_ptr< WTAClassType > &AnyWTAClass)
void CreateBlocks(const std::vector< WTATrigObj > &all_towers)
void SetBlockN(unsigned int block_n)
eta_t eta() const
Definition WTAObject.h:33
phi_t phi() const
Definition WTAObject.h:35
pt_t pt() const
Definition WTAObject.h:31
AlgTool to read in LArStripNeighborhoods, and run the eRatio Algorithm.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())