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 
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 
122 unsigned 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 
143 unsigned 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 
170 unsigned 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 
191 unsigned 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
247 void 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
281 unsigned int LVL1::eFEXtauAlgo::getBitwiseEt() const {
282  unsigned int out = 0;
283  return out;
284 }
285 
286 bool LVL1::eFEXtauAlgo::getUnD() const { return m_und; }
287 
288 unsigned int LVL1::eFEXtauAlgo::getSeed() const { return m_seed; }
289 
290 void LVL1::eFEXtauAlgo::setAlgoVersion(unsigned int ver) {m_AlgoVersion = ver;}
LVL1::eFEXtauAlgo::rCoreCore
virtual unsigned int rCoreCore() const override
Definition: eFEXtauAlgo.cxx:122
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:170
LVL1::eFEXtauAlgo::rCoreEnv
virtual unsigned int rCoreEnv() const override
Definition: eFEXtauAlgo.cxx:143
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:247
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:191
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:288
Pythia8_A14_NNPDF23LO_Var1Down_Common.ver
ver
Definition: Pythia8_A14_NNPDF23LO_Var1Down_Common.py:26
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:281
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:223
LVL1::eFEXtauTOB::setRcoreCore
void setRcoreCore(unsigned int)
Definition: eFEXtauTOB.cxx:61
LVL1::eFEXtauAlgo::setSupercellSeed
virtual void setSupercellSeed() override
Definition: eFEXtauAlgo.cxx:261
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
LVL1::eFEXtauAlgo::setAlgoVersion
virtual void setAlgoVersion(unsigned int ver) override
Definition: eFEXtauAlgo.cxx:290
eTower.h
LVL1::eFEXtauTOB::setBDTScore
void setBDTScore(unsigned int)
Definition: eFEXtauTOB.cxx:81
LVL1::eFEXtauAlgo::getUnD
virtual bool getUnD() const override
Definition: eFEXtauAlgo.cxx:286
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