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