ATLAS Offline Software
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
19 LVL1::eFEXtauAlgo::eFEXtauAlgo(const std::string &type, const std::string &name,
20  const IInterface *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 
35 void 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);
41  setSupercellSeed();
42  setUnDAndOffPhi();
43 }
44 
45 std::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
62 unsigned 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  out += m_em0cells[1][1];
71  out += m_em0cells[2][1];
72  out += m_em0cells[0][m_offPhi];
73  out += m_em0cells[1][m_offPhi];
74  out += m_em0cells[2][m_offPhi];
75 
76  out += m_em1cells[m_seed][1];
77  out += m_em1cells[m_seed + 1][1];
78  out += m_em1cells[m_seed + 2][1];
79  out += m_em1cells[m_seed - 1][1];
80  out += m_em1cells[m_seed - 2][1];
81  out += m_em1cells[m_seed][m_offPhi];
82  out += m_em1cells[m_seed + 1][m_offPhi];
83  out += m_em1cells[m_seed + 2][m_offPhi];
84  out += m_em1cells[m_seed - 1][m_offPhi];
85  out += m_em1cells[m_seed - 2][m_offPhi];
86 
87  out += m_em2cells[m_seed][1];
88  out += m_em2cells[m_seed + 1][1];
89  out += m_em2cells[m_seed + 2][1];
90  out += m_em2cells[m_seed - 1][1];
91  out += m_em2cells[m_seed - 2][1];
92  out += m_em2cells[m_seed][m_offPhi];
93  out += m_em2cells[m_seed + 1][m_offPhi];
94  out += m_em2cells[m_seed + 2][m_offPhi];
95  out += m_em2cells[m_seed - 1][m_offPhi];
96  out += m_em2cells[m_seed - 2][m_offPhi];
97 
98  out += m_em3cells[0][1];
99  out += m_em3cells[1][1];
100  out += m_em3cells[2][1];
101  out += m_em3cells[0][m_offPhi];
102  out += m_em3cells[1][m_offPhi];
103  out += m_em3cells[2][m_offPhi];
104 
105  out += m_hadcells[0][1];
106  out += m_hadcells[1][1];
107  out += m_hadcells[2][1];
108  out += m_hadcells[0][m_offPhi];
109  out += m_hadcells[1][m_offPhi];
110  out += m_hadcells[2][m_offPhi];
111 
112  // Overflow handling
113  if (out > 0xffff)
114  out = 0xffff;
115 
116  return out;
117 }
118 
119 unsigned int LVL1::eFEXtauAlgo::rCoreCore() const {
120  if (m_cellsSet == false) {
121  ATH_MSG_DEBUG("Layers not built, cannot calculate rCore core value");
122  }
123 
124  unsigned int out = 0;
125 
126  out += m_em2cells[m_seed][1];
127  out += m_em2cells[m_seed + 1][1];
128  out += m_em2cells[m_seed - 1][1];
129  out += m_em2cells[m_seed][m_offPhi];
130  out += m_em2cells[m_seed + 1][m_offPhi];
131  out += m_em2cells[m_seed - 1][m_offPhi];
132 
133  // Overflow handling
134  if (out > 0xffff)
135  out = 0xffff;
136 
137  return out;
138 }
139 
140 unsigned int LVL1::eFEXtauAlgo::rCoreEnv() const {
141  if (m_cellsSet == false) {
142  ATH_MSG_DEBUG("Layers not built, cannot calculate rCore environment value");
143  }
144 
145  unsigned int out = 0;
146 
147  out += m_em2cells[m_seed + 2][1];
148  out += m_em2cells[m_seed - 2][1];
149  out += m_em2cells[m_seed + 3][1];
150  out += m_em2cells[m_seed - 3][1];
151  out += m_em2cells[m_seed + 4][1];
152  out += m_em2cells[m_seed - 4][1];
153  out += m_em2cells[m_seed + 2][m_offPhi];
154  out += m_em2cells[m_seed - 2][m_offPhi];
155  out += m_em2cells[m_seed + 3][m_offPhi];
156  out += m_em2cells[m_seed - 3][m_offPhi];
157  out += m_em2cells[m_seed + 4][m_offPhi];
158  out += m_em2cells[m_seed - 4][m_offPhi];
159 
160  // Overflow handling
161  if (out > 0xffff)
162  out = 0xffff;
163 
164  return out;
165 }
166 
167 unsigned int LVL1::eFEXtauAlgo::rHadCore() const {
168  if (m_cellsSet == false) {
169  ATH_MSG_DEBUG("Layers not built, cannot calculate rHad core value");
170  }
171 
172  unsigned int out = 0;
173 
174  out += m_hadcells[0][1];
175  out += m_hadcells[1][1];
176  out += m_hadcells[2][1];
177  out += m_hadcells[0][m_offPhi];
178  out += m_hadcells[1][m_offPhi];
179  out += m_hadcells[2][m_offPhi];
180 
181  // Overflow handling
182  if (out > 0xffff)
183  out = 0xffff;
184 
185  return out;
186 }
187 
188 unsigned int LVL1::eFEXtauAlgo::rHadEnv() const {
189  if (m_cellsSet == false) {
190  ATH_MSG_DEBUG("Layers not built, cannot calculate rHad environment value");
191  }
192 
193  unsigned int out = 0;
194 
195  out += m_em2cells[m_seed][1];
196  out += m_em2cells[m_seed - 1][1];
197  out += m_em2cells[m_seed + 1][1];
198  out += m_em2cells[m_seed - 2][1];
199  out += m_em2cells[m_seed + 2][1];
200  out += m_em2cells[m_seed][m_offPhi];
201  out += m_em2cells[m_seed - 1][m_offPhi];
202  out += m_em2cells[m_seed + 1][m_offPhi];
203  out += m_em2cells[m_seed - 2][m_offPhi];
204  out += m_em2cells[m_seed + 2][m_offPhi];
205  out += m_em1cells[m_seed][1];
206  out += m_em1cells[m_seed - 1][1];
207  out += m_em1cells[m_seed + 1][1];
208  out += m_em1cells[m_seed][m_offPhi];
209  out += m_em1cells[m_seed - 1][m_offPhi];
210  out += m_em1cells[m_seed + 1][m_offPhi];
211 
212  // Overflow handling
213  if (out > 0xffff)
214  out = 0xffff;
215 
216  return out;
217 }
218 
219 // Set the off phi value used to calculate ET and isolation
221  if (m_cellsSet == false) {
222  ATH_MSG_DEBUG("Layers not built, cannot accurately set phi direction.");
223  }
224 
225  unsigned int upwardEt = m_em2cells[m_seed][2];
226 
227  unsigned int downwardEt = m_em2cells[m_seed][0];
228 
229  if (downwardEt > upwardEt) {
230  m_offPhi = 0;
231  m_und = false;
232  } else {
233  m_offPhi = 2;
234  m_und = true;
235  }
236 }
237 
238 // Utility function to calculate and return jet discriminant sums for specified
239 // location Intended to allow xAOD TOBs to be decorated with this information
240 void LVL1::eFEXtauAlgo::getSums(unsigned int seed, bool UnD,
241  std::vector<unsigned int> &RcoreSums,
242  std::vector<unsigned int> &RemSums) {
243  // Set seed parameters to supplied values
244  m_und = UnD;
245  m_seed = seed + 4; // In this function seed has range 4-7
246 
247  // Now just call the 2 discriminant calculation methods
248  getRCore(RcoreSums);
249  getRHad(RemSums);
250 }
251 
252 // Find the supercell seed eta value, must be in central cell so in the range
253 // 4-7 inclusive
255  unsigned int seed = 7;
256  int max_et = 0;
257  int cell_et = 0;
258  for (unsigned int i = 7; i > 3; --i) {
259  cell_et = m_em2cells[i][1];
260  if (cell_et > max_et) {
261  seed = i;
262  max_et = cell_et;
263  }
264  }
265  m_seed = seed;
266 }
267 
268 // Return the bitwise value of the given Et
269 // See eFEXtauBaseAlgo for a first attempt at this
270 unsigned int LVL1::eFEXtauAlgo::getBitwiseEt() const {
271  unsigned int out = 0;
272  return out;
273 }
274 
275 bool LVL1::eFEXtauAlgo::getUnD() const { return m_und; }
276 
277 unsigned int LVL1::eFEXtauAlgo::getSeed() const { return m_seed; }
LVL1::eFEXtauAlgo::rCoreCore
virtual unsigned int rCoreCore() const override
Definition: eFEXtauAlgo.cxx:119
et
Extra patterns decribing particle interation process.
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LVL1::eFEXtauAlgo::rHadCore
virtual unsigned int rHadCore() const override
Definition: eFEXtauAlgo.cxx:167
LVL1::eFEXtauAlgo::rCoreEnv
virtual unsigned int rCoreEnv() const override
Definition: eFEXtauAlgo.cxx:140
eFEXtauTOB.h
LVL1::eFEXtauAlgo::getSums
virtual void getSums(unsigned int seed, bool UnD, std::vector< unsigned int > &RcoreSums, std::vector< unsigned int > &Remums) override
Definition: eFEXtauAlgo.cxx:240
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:70
LVL1::eFEXtauAlgo::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: eFEXtauAlgo.cxx:28
LVL1::eFEXtauAlgo::rHadEnv
virtual unsigned int rHadEnv() const override
Definition: eFEXtauAlgo.cxx:188
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
LVL1::eFEXtauTOB::setEt
void setEt(unsigned int)
Definition: eFEXtauTOB.cxx:26
LVL1::eFEXtauAlgo::getSeed
virtual unsigned int getSeed() const override
Definition: eFEXtauAlgo.cxx:277
LVL1::eFEXtauAlgoBase
Definition: eFEXtauAlgoBase.h:28
LVL1::eFEXtauAlgo::getEt
virtual unsigned int getEt() const override
Definition: eFEXtauAlgo.cxx:62
LVL1::eFEXtauTOB::setSeedUnD
void setSeedUnD(bool)
Definition: eFEXtauTOB.cxx:51
LVL1::eFEXtauAlgo::getBitwiseEt
virtual unsigned int getBitwiseEt() const override
Definition: eFEXtauAlgo.cxx:270
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LVL1::eFEXtauAlgo::~eFEXtauAlgo
virtual ~eFEXtauAlgo()
Destructor.
Definition: eFEXtauAlgo.cxx:26
test_pyathena.parent
parent
Definition: test_pyathena.py:15
LVL1::eFEXtauTOB::setRhadEnv
void setRhadEnv(unsigned int)
Definition: eFEXtauTOB.cxx:76
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TrigConf::name
Definition: HLTChainList.h:35
LVL1::eFEXtauAlgo::setUnDAndOffPhi
virtual void setUnDAndOffPhi() override
Definition: eFEXtauAlgo.cxx:220
LVL1::eFEXtauTOB::setRcoreCore
void setRcoreCore(unsigned int)
Definition: eFEXtauTOB.cxx:61
LVL1::eFEXtauAlgo::setSupercellSeed
virtual void setSupercellSeed() override
Definition: eFEXtauAlgo.cxx:254
LVL1::eFEXtauAlgo::getTauTOB
virtual std::unique_ptr< eFEXtauTOB > getTauTOB() const override
Definition: eFEXtauAlgo.cxx:45
LVL1::eFEXtauTOB::setBitwiseEt
void setBitwiseEt(unsigned int)
Definition: eFEXtauTOB.cxx:31
LVL1::eFEXtauTOB::setRcoreEnv
void setRcoreEnv(unsigned int)
Definition: eFEXtauTOB.cxx:66
LVL1::eFEXtauTOB::setIso
void setIso(unsigned int)
Definition: eFEXtauTOB.cxx:36
LVL1::eFEXtauTOB::setIsBDTAlgo
void setIsBDTAlgo(unsigned int)
Definition: eFEXtauTOB.cxx:86
calibdata.copy
bool copy
Definition: calibdata.py:26
LVL1::eFEXtauTOB::setRhadCore
void setRhadCore(unsigned int)
Definition: eFEXtauTOB.cxx:71
eTower.h
LVL1::eFEXtauTOB::setBDTScore
void setBDTScore(unsigned int)
Definition: eFEXtauTOB.cxx:81
LVL1::eFEXtauAlgo::getUnD
virtual bool getUnD() const override
Definition: eFEXtauAlgo.cxx:275
LVL1::eFEXtauAlgo::eFEXtauAlgo
eFEXtauAlgo(const std::string &type, const std::string &name, const IInterface *parent)
Constructors.
Definition: eFEXtauAlgo.cxx:19
LVL1::eFEXtauAlgo::setup
virtual void setup(int inputTable[3][3], int efex_id, int fpga_id, int central_eta) override
Definition: eFEXtauAlgo.cxx:35
eFEXtauAlgo.h