ATLAS Offline Software
Loading...
Searching...
No Matches
JET1Alg.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3 */
4
5#include "JET1Alg.h"
9
10namespace GlobalSim {
11
12 StatusCode JET1Alg::initialize() {
13
14 CHECK( m_inputTowersKey.initialize() );
15 CHECK( m_outputKey.initialize() );
16
17 return StatusCode::SUCCESS;
18 }
19
20 StatusCode JET1Alg::execute(const EventContext& ctx) const {
21
22 ATH_MSG_DEBUG("Building WTAConeJets");
23 // Read the GlobalCellTowers
24 auto towers = SG::makeHandle(m_inputTowersKey, ctx);
25 CHECK(towers.isValid());
26 auto nTowers = towers->size();
27 ATH_MSG_DEBUG("Reading " << nTowers << " cell towers from xAOD::BaseContainer");
28
29 std::vector<WTATrigObj> input_towers;
30 for(size_t i = 0; i < nTowers; i++){
31 Object<topoc_pu_type> tower( *towers->at(i) );
32 WTATrigObj this_tower(tower.ptt.bits().to_ulong(), tower.eta.bits().to_ulong(), tower.phi.bits().to_ulong(), 0, i);
33 input_towers.push_back(this_tower);
34 }
35
36 // Do the usual
37 std::unique_ptr<WTAConeMaker> MyWTAConeMaker = std::make_unique<WTACone2PassMaker>();
38 WTAParameters MyWTAParameters = WTAParameters(
39 8, // const_et_cut = 2 GeV
40 20, // seed_et_cut = 5 GeV
41 4 // jet_dR = 4
42 );
43
44 MyWTAConeMaker->m_WTAConeMakerParameter = MyWTAParameters; // Pass the WTAConeParameters
45 WTAConeParallelHelper wta_parallel_helper;
46 wta_parallel_helper.SetBlockN(4);
47 wta_parallel_helper.CreateBlocks(input_towers);
48 wta_parallel_helper.RunParallelWTA(MyWTAConeMaker);
49 wta_parallel_helper.CheckJetInCore();
50 std::vector<WTAJet> WTAJetList = wta_parallel_helper.GetAllJets(); // Bitwise Jets
51
52 //Write out as an xAOD::BaseContainer of SG::AuxElements
53 auto jets = SG::makeHandle(m_outputKey, ctx);
54 CHECK( jets.record( std::make_unique<xAOD::BaseContainer>(), std::make_unique<xAOD::AuxContainerBase>()) );
55
56 for(const auto& WTAJet: WTAJetList){
57 jets->push_back( std::make_unique<SG::AuxElement>() );
58 auto jet = Object<main_output_type>( *jets->back());
59
60 jet.ptt = std::clamp(static_cast<int>(WTAJet.pt()), 0, (1 << jet.ptt.width) - 1);
61 jet.eta = std::clamp(static_cast<int>(WTAJet.eta()), 0, (1 << jet.eta.width) - 1);
62 jet.phi = std::clamp(static_cast<int>(WTAJet.phi()), 0, (1 << jet.phi.width) - 1);
63 //AM: The widths are not encoded anywhere here? This would be needed/nice
65 jet.ring_zero_ptt = std::clamp(static_cast<int>(ering_info.ring0_Et), 0, (1 << jet.ring_zero_ptt.width) - 1);
66 jet.ring_one_ptt = std::clamp(static_cast<int>(ering_info.ring1_Et), 0, (1 << jet.ring_one_ptt.width) - 1);
67 jet.ring_two_ptt = std::clamp(static_cast<int>(ering_info.ring2_Et), 0, (1 << jet.ring_two_ptt.width) - 1);
68 jet.ring_three_ptt = std::clamp(static_cast<int>(ering_info.ring3_Et), 0, (1 << jet.ring_three_ptt.width) - 1);
69 jet.ring_four_ptt = std::clamp(static_cast<int>(ering_info.ring4_Et), 0, (1 << jet.ring_four_ptt.width) - 1);
70 jet.total_tobs =std::clamp(static_cast<int>(ering_info.total_TobN), 0, (1 << jet.total_tobs.width) - 1);
71 jet.ring_one_tobs = std::clamp(static_cast<int>(ering_info.ring1_TobN), 0, (1 << jet.ring_one_tobs.width) - 1);
72 jet.ring_two_tobs = std::clamp(static_cast<int>(ering_info.ring2_TobN), 0, (1 << jet.ring_two_tobs.width) - 1);
73 jet.ring_three_tobs = std::clamp(static_cast<int>(ering_info.ring3_TobN), 0, (1 << jet.ring_three_tobs.width) - 1);
74 jet.ring_four_tobs = std::clamp(static_cast<int>(ering_info.ring4_TobN), 0, (1 << jet.ring_four_tobs.width) - 1);
75 // The WTA engine does not provide the flags yet, so they are written as
76 // false. The fields still have to be filled: without them the aux variable
77 // does not exist and packing the word throws. Note et_overflow is genuinely
78 // set in the reference data, so this is a placeholder, not a final value.
79 jet.flag_et_overflow = false;
80 jet.flag_error = false;
81 jet.flag_next_tob_same_et = false;
82 jet.flag_truncate = false;
83 }
84
85 return StatusCode::SUCCESS;
86 }
87
88
89}
#define ATH_MSG_DEBUG(x,...)
#define CHECK(...)
Evaluate an expression and check for errors.
SG::WriteHandleKey< xAOD::BaseContainer > m_outputKey
Key for the output jets.
Definition JET1Alg.h:40
SG::ReadHandleKey< xAOD::BaseContainer > m_inputTowersKey
Key for the Input cell towers.
Definition JET1Alg.h:37
virtual StatusCode initialize() override
initialize function running before first event
Definition JET1Alg.cxx:12
virtual StatusCode execute(const EventContext &) const override
execute function running for every event
Definition JET1Alg.cxx:20
Spec::bitset_type bits() const
Definition Object.h:35
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)
const WTA4JetERingInfo & GetERingInfo() const
Definition WTAObject.h:176
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 BDT Algorithm.
Definition BitSpec.h:23
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
ring4_tobn_t ring4_TobN
Definition WTAObject.h:147
ring1_tobn_t ring1_TobN
Definition WTAObject.h:144
ring2_tobn_t ring2_TobN
Definition WTAObject.h:145
ring3_tobn_t ring3_TobN
Definition WTAObject.h:146