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