ATLAS Offline Software
Loading...
Searching...
No Matches
eFEXtauAlgo.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5//*************************************************************************
6// eFEXtauAlgo - description
7// --------------------
8// begin : 06 05 2020
9// email : nicholas.andrew.luongo@cern.ch
10//*************************************************************************
11
12#include "eFEXtauAlgo.h"
14#include "L1CaloFEXSim/eTower.h"
15#include <algorithm> //for std::copy
16#include <vector>
17
18// default constructor for persistency
19LVL1::eFEXtauAlgo::eFEXtauAlgo(const std::string &type, const std::string &name,
20 const IInterface *parent)
21 : eFEXtauAlgoBase(type, name, parent) {
22
23}
24
27
29 ATH_CHECK(m_eTowerContainerKey.initialize());
30
31 ATH_MSG_INFO("tau Algorithm version: heuristic");
32 return StatusCode::SUCCESS;
33}
34
35void LVL1::eFEXtauAlgo::setup(int inputTable[3][3], int efex_id, int fpga_id,
36 int central_eta) {
37
38 std::copy(&inputTable[0][0], &inputTable[0][0] + 9, &m_eFexalgoTowerID[0][0]);
39
40 buildLayers(efex_id, fpga_id, central_eta);
43}
44
45std::unique_ptr<LVL1::eFEXtauTOB> LVL1::eFEXtauAlgo::getTauTOB() const {
46 std::unique_ptr<eFEXtauTOB> tob = std::make_unique<eFEXtauTOB>();
47 unsigned int et = getEt();
48 tob->setEt(et);
49 tob->setRcoreCore(rCoreCore());
50 tob->setRcoreEnv(rCoreEnv());
51 tob->setRhadCore(rHadCore());
52 tob->setRhadEnv(rHadEnv());
53 tob->setBitwiseEt(getBitwiseEt());
54 tob->setIso(getRealRCore());
55 tob->setSeedUnD(getUnD());
56 tob->setBDTScore(0);
57 tob->setIsBDTAlgo(0);
58 return tob;
59}
60
61// Calculate reconstructed ET value
62unsigned int LVL1::eFEXtauAlgo::getEt() const {
63 if (m_cellsSet == false) {
64 ATH_MSG_DEBUG("Layers not built, cannot accurately calculate Et.");
65 }
66
67 unsigned int out = 0;
68
69 out += m_em0cells[0][1];
70
71 if (m_AlgoVersion==0){
72 out += m_em0cells[1][1];
73 out += m_em0cells[2][1];
74 out += m_em0cells[0][m_offPhi];
75 out += m_em0cells[1][m_offPhi];
76 out += m_em0cells[2][m_offPhi];
77 }
78
79 out += m_em1cells[m_seed][1];
80 out += m_em1cells[m_seed + 1][1];
81 out += m_em1cells[m_seed + 2][1];
82 out += m_em1cells[m_seed - 1][1];
83 out += m_em1cells[m_seed - 2][1];
84 out += m_em1cells[m_seed][m_offPhi];
85 out += m_em1cells[m_seed + 1][m_offPhi];
86 out += m_em1cells[m_seed + 2][m_offPhi];
87 out += m_em1cells[m_seed - 1][m_offPhi];
88 out += m_em1cells[m_seed - 2][m_offPhi];
89
90 out += m_em2cells[m_seed][1];
91 out += m_em2cells[m_seed + 1][1];
92 out += m_em2cells[m_seed + 2][1];
93 out += m_em2cells[m_seed - 1][1];
94 out += m_em2cells[m_seed - 2][1];
95 out += m_em2cells[m_seed][m_offPhi];
96 out += m_em2cells[m_seed + 1][m_offPhi];
97 out += m_em2cells[m_seed + 2][m_offPhi];
98 out += m_em2cells[m_seed - 1][m_offPhi];
99 out += m_em2cells[m_seed - 2][m_offPhi];
100
101 out += m_em3cells[0][1];
102 out += m_em3cells[1][1];
103 out += m_em3cells[2][1];
104 out += m_em3cells[0][m_offPhi];
105 out += m_em3cells[1][m_offPhi];
106 out += m_em3cells[2][m_offPhi];
107
108 out += m_hadcells[0][1];
109 out += m_hadcells[1][1];
110 out += m_hadcells[2][1];
111 out += m_hadcells[0][m_offPhi];
112 out += m_hadcells[1][m_offPhi];
113 out += m_hadcells[2][m_offPhi];
114
115 // Overflow handling
116 if (out > 0xffff)
117 out = 0xffff;
118
119 return out;
120}
121
122unsigned int LVL1::eFEXtauAlgo::rCoreCore() const {
123 if (m_cellsSet == false) {
124 ATH_MSG_DEBUG("Layers not built, cannot calculate rCore core value");
125 }
126
127 unsigned int out = 0;
128
129 out += m_em2cells[m_seed][1];
130 out += m_em2cells[m_seed + 1][1];
131 out += m_em2cells[m_seed - 1][1];
132 out += m_em2cells[m_seed][m_offPhi];
133 out += m_em2cells[m_seed + 1][m_offPhi];
134 out += m_em2cells[m_seed - 1][m_offPhi];
135
136 // Overflow handling
137 if (out > 0xffff)
138 out = 0xffff;
139
140 return out;
141}
142
143unsigned int LVL1::eFEXtauAlgo::rCoreEnv() const {
144 if (m_cellsSet == false) {
145 ATH_MSG_DEBUG("Layers not built, cannot calculate rCore environment value");
146 }
147
148 unsigned int out = 0;
149
150 out += m_em2cells[m_seed + 2][1];
151 out += m_em2cells[m_seed - 2][1];
152 out += m_em2cells[m_seed + 3][1];
153 out += m_em2cells[m_seed - 3][1];
154 out += m_em2cells[m_seed + 4][1];
155 out += m_em2cells[m_seed - 4][1];
156 out += m_em2cells[m_seed + 2][m_offPhi];
157 out += m_em2cells[m_seed - 2][m_offPhi];
158 out += m_em2cells[m_seed + 3][m_offPhi];
159 out += m_em2cells[m_seed - 3][m_offPhi];
160 out += m_em2cells[m_seed + 4][m_offPhi];
161 out += m_em2cells[m_seed - 4][m_offPhi];
162
163 // Overflow handling
164 if (out > 0xffff)
165 out = 0xffff;
166
167 return out;
168}
169
170unsigned int LVL1::eFEXtauAlgo::rHadCore() const {
171 if (m_cellsSet == false) {
172 ATH_MSG_DEBUG("Layers not built, cannot calculate rHad core value");
173 }
174
175 unsigned int out = 0;
176
177 out += m_hadcells[0][1];
178 out += m_hadcells[1][1];
179 out += m_hadcells[2][1];
180 out += m_hadcells[0][m_offPhi];
181 out += m_hadcells[1][m_offPhi];
182 out += m_hadcells[2][m_offPhi];
183
184 // Overflow handling
185 if (out > 0xffff)
186 out = 0xffff;
187
188 return out;
189}
190
191unsigned int LVL1::eFEXtauAlgo::rHadEnv() const {
192 if (m_cellsSet == false) {
193 ATH_MSG_DEBUG("Layers not built, cannot calculate rHad environment value");
194 }
195
196 unsigned int out = 0;
197
198 out += m_em2cells[m_seed][1];
199 out += m_em2cells[m_seed - 1][1];
200 out += m_em2cells[m_seed + 1][1];
201 out += m_em2cells[m_seed - 2][1];
202 out += m_em2cells[m_seed + 2][1];
203 out += m_em2cells[m_seed][m_offPhi];
204 out += m_em2cells[m_seed - 1][m_offPhi];
205 out += m_em2cells[m_seed + 1][m_offPhi];
206 out += m_em2cells[m_seed - 2][m_offPhi];
207 out += m_em2cells[m_seed + 2][m_offPhi];
208 out += m_em1cells[m_seed][1];
209 out += m_em1cells[m_seed - 1][1];
210 out += m_em1cells[m_seed + 1][1];
211 out += m_em1cells[m_seed][m_offPhi];
212 out += m_em1cells[m_seed - 1][m_offPhi];
213 out += m_em1cells[m_seed + 1][m_offPhi];
214
215 // Overflow handling
216 if (out > 0xffff)
217 out = 0xffff;
218
219 return out;
220}
221
222// Set the off phi value used to calculate ET and isolation
224 if (m_cellsSet == false) {
225 ATH_MSG_DEBUG("Layers not built, cannot accurately set phi direction.");
226 }
227
228 unsigned int upwardEt = m_em2cells[m_seed][2];
229 unsigned int downwardEt = m_em2cells[m_seed][0];
230
231 if (m_AlgoVersion==3){
232 upwardEt = m_em1cells[m_seed][2];
233 downwardEt = m_em1cells[m_seed][0];
234 }
235
236 if (downwardEt > upwardEt) {
237 m_offPhi = 0;
238 m_und = false;
239 } else {
240 m_offPhi = 2;
241 m_und = true;
242 }
243}
244
245// Utility function to calculate and return jet discriminant sums for specified
246// location Intended to allow xAOD TOBs to be decorated with this information
247void LVL1::eFEXtauAlgo::getSums(unsigned int seed, bool UnD,
248 std::vector<unsigned int> &RcoreSums,
249 std::vector<unsigned int> &RemSums) {
250 // Set seed parameters to supplied values
251 m_und = UnD;
252 m_seed = seed + 4; // In this function seed has range 4-7
253
254 // Now just call the 2 discriminant calculation methods
255 getRCore(RcoreSums);
256 getRHad(RemSums);
257}
258
259// Find the supercell seed eta value, must be in central cell so in the range
260// 4-7 inclusive
262 unsigned int seed = 7;
263 int max_et = 0;
264 int cell_et = 0;
265 for (unsigned int i = 7; i > 3; --i) {
266 cell_et = m_em2cells[i][1];
267
268 if (m_AlgoVersion==3){
269 cell_et = m_em1cells[i][1];
270 }
271 if (cell_et > max_et) {
272 seed = i;
273 max_et = cell_et;
274 }
275 }
276 m_seed = seed;
277}
278
279// Return the bitwise value of the given Et
280// See eFEXtauBaseAlgo for a first attempt at this
282 unsigned int out = 0;
283 return out;
284}
285
286bool LVL1::eFEXtauAlgo::getUnD() const { return m_und; }
287
288unsigned int LVL1::eFEXtauAlgo::getSeed() const { return m_seed; }
289
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
unsigned int m_em1cells[12][3]
SG::ReadHandleKey< LVL1::eTowerContainer > m_eTowerContainerKey
unsigned int m_hadcells[3][3]
eFEXtauAlgoBase(const std::string &type, const std::string &name, const IInterface *parent)
Constructors.
virtual void getRHad(std::vector< unsigned int > &rHadVec) const
unsigned int m_em0cells[3][3]
unsigned int m_em2cells[12][3]
virtual float getRealRCore() const
virtual void getRCore(std::vector< unsigned int > &rCoreVec) const
void buildLayers(int efex_id, int fpga_id, int central_eta)
unsigned int m_em3cells[3][3]
eFEXtauAlgo(const std::string &type, const std::string &name, const IInterface *parent)
Constructors.
unsigned int m_seed
Definition eFEXtauAlgo.h:63
unsigned int m_offPhi
Definition eFEXtauAlgo.h:65
virtual StatusCode initialize() override
standard Athena-Algorithm method
virtual unsigned int rCoreCore() const override
virtual void setSupercellSeed() override
virtual void setUnDAndOffPhi() override
virtual unsigned int rHadCore() const override
virtual bool getUnD() const override
virtual unsigned int getBitwiseEt() const override
virtual void getSums(unsigned int seed, bool UnD, std::vector< unsigned int > &RcoreSums, std::vector< unsigned int > &Remums) override
virtual void setup(int inputTable[3][3], int efex_id, int fpga_id, int central_eta) override
unsigned int m_AlgoVersion
Definition eFEXtauAlgo.h:66
virtual ~eFEXtauAlgo()
Destructor.
virtual unsigned int getSeed() const override
virtual std::unique_ptr< eFEXtauTOB > getTauTOB() const override
virtual unsigned int rHadEnv() const override
virtual unsigned int rCoreEnv() const override
virtual unsigned int getEt() const override
virtual void setAlgoVersion(unsigned int ver) override
Extra patterns decribing particle interation process.