ATLAS Offline Software
Loading...
Searching...
No Matches
eFEXTOBEtTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5//***************************************************************************
6// eFEXTOBEtTool - description
7// -------------------
8// begin : 13 12 2022
9// email : Alan.Watson@CERN.CH
10// ***************************************************************************/
13#include "eFEXtauAlgo.h"
15#include <vector>
16
17namespace LVL1 {
18
19 // default constructor for persistency
20
21eFEXTOBEtTool::eFEXTOBEtTool(const std::string& type,const std::string& name,const IInterface* parent):
22 AthAlgTool(type,name,parent)
23{
24 declareInterface<eFEXTOBEtTool>(this);
25}
26
27
32
33//---------------- Initialisation -------------------------------------------------
34
36{
37
38 ATH_CHECK( m_eFEXegAlgoTool.retrieve() );
39 ATH_CHECK( m_eFEXtauAlgoTool.retrieve() );
40 ATH_CHECK(m_eTowerContainerKey.initialize());
41
42 return StatusCode::SUCCESS;
43}
44
45// The main user calls
46StatusCode eFEXTOBEtTool::getegSums(const EventContext& ctx,
47 float etaTOB, float phiTOB, int seed, int UnD,
48 std::vector<unsigned int> &ClusterCellETs,
49 std::vector<unsigned int> &RetaSums,
50 std::vector<unsigned int> &RhadSums,
51 std::vector<unsigned int> &WstotSums)
52{
53
55 int tobtable[3][3];
56
57 for (int iphi = -1; iphi <= 1; ++iphi) {
58 float phiTable = phiTOB + iphi*m_dphiTower;
59 if (phiTable > M_PI) phiTable -= 2*M_PI;
60 if (phiTable < -M_PI) phiTable += 2*M_PI;
61
62 for (int ieta = -1; ieta <= 1; ++ieta) {
63 float etaTable = etaTOB + ieta*m_detaTower;
64
65 // Set the tower ID if within acceptance, else 0
66 if (std::abs(etaTable)<2.5) tobtable[iphi+1][ieta+1] = eTowerID(etaTable, phiTable);
67 else tobtable[iphi+1][ieta+1] = 0;
68
69 } // eta loop
70 } // phi loop
71
73 int eFEX, FPGA, fpgaEta;
74 location(etaTOB,phiTOB, eFEX, FPGA, fpgaEta);
75
76 // Set up e/g algorithm for this location
77 ATH_CHECK( m_eFEXegAlgoTool->safetyTest(ctx) );
78 m_eFEXegAlgoTool->setup(tobtable, eFEX, FPGA, fpgaEta);
79
80 // Get ETs of cells making up the ET clusters
81 m_eFEXegAlgoTool->getClusterCells(ClusterCellETs);
82
83 // Get sums from algorithm
84 // This will override the seed calculated by the algorithm with the one supplied here
85 m_eFEXegAlgoTool->getSums(seed, UnD, RetaSums, RhadSums, WstotSums);
86
87 // and we're done
88 return StatusCode::SUCCESS;
89
90}
91
92StatusCode eFEXTOBEtTool::getTOBCellEnergies(float etaTOB, float phiTOB, std::vector<unsigned int> &ClusterCellETs) const {
93
95 int tobtable[3][3];
96
97 for (int iphi = -1; iphi <= 1; ++iphi) {
98 float phiTable = phiTOB + iphi*m_dphiTower;
99 if (phiTable > M_PI) phiTable -= 2*M_PI;
100 if (phiTable < -M_PI) phiTable += 2*M_PI;
101
102 for (int ieta = -1; ieta <= 1; ++ieta) {
103 float etaTable = etaTOB + ieta*m_detaTower;
104
105 // Set the tower ID if within acceptance, else 0
106 if (std::abs(etaTable)<2.5) tobtable[iphi+1][ieta+1] = eTowerID(etaTable, phiTable);
107 else tobtable[iphi+1][ieta+1] = 0;
108
109 } // eta loop
110 } // phi loop
111
113 ClusterCellETs.reserve(99); // will have a total of 99 supercell values (they are in counts of 25 MeV)
114
115 for (unsigned int il = 0; il < 5; il++) { // layer loop
116 size_t nCells = (il==1 || il==2) ? 4 : 1;
117 for (unsigned int iphi = 0; iphi < 3; iphi++) { // tower phi loop
118 for (unsigned int ieta = 0; ieta < 3; ieta++) { // tower eta loop
119 if (tobtable[iphi][ieta]==0){
120 for(size_t c=0;c<nCells;c++) {
121 ClusterCellETs.push_back(0); // no energies for TOBs are the extreme eta values
122 }
123 } else {
124 const eTower * tower = eTowerContainer->findTower(tobtable[iphi][ieta]);
125 if (tower==nullptr) {
126 ATH_MSG_ERROR("No tower with id " << tobtable[iphi][ieta]);
127 return StatusCode::FAILURE;
128 }
129 for(size_t c=0;c<nCells;c++) {
130 // Note: energy counts can technically be negative (although noise cuts should usually prevent this)
131 // But algo developers wanted the energy count decoration to be a vector of unsigned int for historical reasons
132 // It is therefore possible for the unsigned int to be an overflow of int max
133 ClusterCellETs.push_back( tower->getET(il,c) );
134 }
135 }
136 }
137 }
138 }
139
140 /*----------- SuperCells eta, phi, layer coordinates ----------------------
141 0:{0, 0, 0}, 1:{1, 0, 0}, 2:{2, 0, 0},
142 3:{0, 1, 0}, 4:{1, 1, 0}, 5:{2, 1, 0},
143 6:{0, 2, 0}, 7:{1, 2, 0}, 8:{2, 2, 0},
144 9:{0, 0, 1}, 10:{1, 0, 1}, 11:{2, 0, 1}, 12:{3, 0, 1}, 13:{4, 0, 1}, 14:{5, 0, 1}, 15:{6, 0, 1}, 16:{7, 0, 1}, 17:{8, 0, 1}, 18:{9, 0, 1}, 19:{10, 0, 1}, 20:{11, 0, 1},
145 21:{0, 1, 1}, 22:{1, 1, 1}, 23:{2, 1, 1}, 24:{3, 1, 1}, 25:{4, 1, 1}, 26:{5, 1, 1}, 27:{6, 1, 1}, 28:{7, 1, 1}, 29:{8, 1, 1}, 30:{9, 1, 1}, 31:{10, 1, 1}, 32:{11, 1, 1},
146 33:{0, 2, 1}, 34:{1, 2, 1}, 35:{2, 2, 1}, 36:{3, 2, 1}, 37:{4, 2, 1}, 38:{5, 2, 1}, 39:{6, 2, 1}, 40:{7, 2, 1}, 41:{8, 2, 1}, 42:{9, 2, 1}, 43:{10, 2, 1}, 44:{11, 2, 1},
147 44:{0, 0, 2}, 45:{1, 0, 2}, 46:{2, 0, 2}, 47:{3, 0, 2}, 48:{4, 0, 2}, 49:{5, 0, 2}, 50:{6, 0, 2}, 51:{7, 0, 2}, 52:{8, 0, 2}, 53:{9, 0, 2}, 54:{10, 0, 2}, 55:{11, 0, 2},
148 56:{0, 1, 2}, 57:{1, 1, 2}, 58:{2, 1, 2}, 59:{3, 1, 2}, 60:{4, 1, 2}, 61:{5, 1, 2}, 62:{6, 1, 2}, 63:{7, 1, 2}, 64:{8, 1, 2}, 65:{9, 1, 2}, 66:{10, 1, 2}, 67:{11, 1, 2},
149 68:{0, 2, 2}, 69:{1, 2, 2}, 70:{2, 2, 2}, 71:{3, 2, 2}, 72:{4, 2, 2}, 73:{5, 2, 2}, 74:{6, 2, 2}, 75:{7, 2, 2}, 76:{8, 2, 2}, 77:{9, 2, 2}, 78:{10, 2, 2}, 79:{11, 2, 2},
150 81:{0, 0, 3}, 82:{1, 0, 3}, 83:{2, 0, 3},
151 84:{0, 1, 3}, 85:{1, 1, 3}, 86:{2, 1, 3},
152 87:{0, 2, 3}, 88:{1, 2, 3}, 89:{2, 2, 3},
153 90:{0, 0, 4}, 91:{1, 0, 4}, 92:{2, 0, 4},
154 93:{0, 1, 4}, 94:{1, 1, 4}, 95:{2, 1, 4},
155 96:{0, 2, 4}, 97:{1, 2, 4}, 98:{2, 2, 4}; */
156
157 return StatusCode::SUCCESS;
158}
159
160
161StatusCode eFEXTOBEtTool::gettauSums(const EventContext& ctx,
162 float etaTOB, float phiTOB, int seed, int UnD,
163 std::vector<unsigned int> &RcoreSums,
164 std::vector<unsigned int> &RemSums)
165{
166
168 int tobtable[3][3];
169
170 for (int iphi = -1; iphi <= 1; ++iphi) {
171 float phiTable = phiTOB + iphi*m_dphiTower;
172 if (phiTable > M_PI) phiTable -= 2*M_PI;
173 if (phiTable < -M_PI) phiTable += 2*M_PI;
174
175 for (int ieta = -1; ieta <= 1; ++ieta) {
176 float etaTable = etaTOB + ieta*m_detaTower;
177
178 // Set the tower ID if within acceptance, else 0
179 if (std::abs(etaTable)<2.5) tobtable[iphi+1][ieta+1] = eTowerID(etaTable, phiTable);
180 else tobtable[iphi+1][ieta+1] = 0;
181
182 } // eta loop
183 } // phi loop
184
186 int eFEX, FPGA, fpgaEta;
187 location(etaTOB,phiTOB, eFEX, FPGA, fpgaEta);
188
189 // Set up e/g algorithm for this location
190 ATH_CHECK( m_eFEXtauAlgoTool->safetyTest(ctx) );
191 m_eFEXtauAlgoTool->setup(tobtable, eFEX, FPGA, fpgaEta);
192
193 // Get sums from algorithm
194 // This will override the seed calculated by the algorithm with the one supplied here
195 m_eFEXtauAlgoTool->getSums(seed, UnD, RcoreSums, RemSums);
196
197 // and we're done
198 return StatusCode::SUCCESS;
199
200}
201
202
203// Find eTower ID from a floating point coordinate pair
204unsigned int eFEXTOBEtTool::eTowerID(float eta, float phi) const
205{
206 // Calculate ID by hand from coordinate
207 int posneg = (eta >= 0 ? 1 : -1);
208 int towereta = std::abs(eta)/0.1;
209 if (phi < 0) phi += 2*M_PI;
210 int towerphi = int(32*phi/M_PI);
211 unsigned int tower_id = towerphi + 64*towereta;
212
213 if (towereta < 14) {
214 tower_id += (posneg > 0 ? 200000 : 100000);
215 }
216 else if (towereta == 14) {
217 tower_id += (posneg > 0 ? 400000 : 300000);
218 }
219 else {
220 tower_id += (posneg > 0 ? 600000 : 500000);
221 }
222
223 return tower_id;
224}
225
226
227// Find eFEX and FPGA numbers and eta index within FPGA
228void eFEXTOBEtTool::location(float etaTOB, float phiTOB, int& eFEX, int& FPGA, int& etaIndex) const
229{
230 // indices of central tower within a 0->49, 0->63 eta,phi map
231 int ieta = (etaTOB + 2.5)/m_detaTower;
232 float phiShifted = phiTOB + 2*m_dphiTower; // eFEX boundary does not line up with phi = 0
233 int iphi = (phiShifted > 0 ? phiShifted/m_dphiTower : (phiShifted + 2*M_PI)/m_dphiTower );
234
235 // Now we have global 0->N indices we can simply calculate which eFEX these come from
236 int eFEXPhi = iphi/8;
237 int eFEXeta = 0;
238 if (ieta > 16) eFEXeta = 1;
239 if (ieta > 32) eFEXeta = 2;
240
241 // eFEX number in range 0 -> 23
242 eFEX = eFEXeta + 3*eFEXPhi;
243
244 // Now which FPGA within the eFEX?
245 // This logic will give an index: 0 -> 16 for eFEX 0
246 // 1 -> 16 for eFEX 1
247 // 1 -> 17 for eFEX 2
248 // which puts FPGA boundaries at 4, 8, 12 in all cases
249 int eFEXIndex;
250 switch(eFEXeta) {
251 case 0: {
252 eFEXIndex = ieta;
253 break;
254 }
255 case 1: {
256 eFEXIndex = ieta -16;
257 break;
258 }
259 case 2: {
260 eFEXIndex = ieta -32;
261 break;
262 }
263 }
264
265 // Finally we can calculate the FPGA number
266 if (eFEXIndex <= 4) FPGA = 0;
267 else if (eFEXIndex <= 8) FPGA = 1;
268 else if (eFEXIndex <= 12) FPGA = 2;
269 else FPGA = 3;
270
271 // And eta index within the FPGA = 1-4 in most cases
272 // except for eFEX 0 FPGA 0 => 0-4 and eFEX 2 FPGA 3 => 1-5
273 etaIndex = eFEXIndex - 4*FPGA;
274
275 // And return the results by reference
276 return;
277}
278
279} // end of namespace bracket
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
SG::ReadHandleKey< LVL1::eTowerContainer > m_eTowerContainerKey
virtual StatusCode initialize()
standard Athena-Algorithm method
virtual void location(float etaTOB, float phiTOB, int &eFEX, int &FPGA, int &fpgaEta) const
Tool to find eFEX and FPGA numbers and eta index of a TOB within the FPGA.
const float m_dphiTower
Internal data.
virtual ~eFEXTOBEtTool()
Destructor.
ToolHandle< eFEXegAlgo > m_eFEXegAlgoTool
eFEXTOBEtTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructors.
virtual StatusCode gettauSums(const EventContext &ctx, float etaTOB, float phiTOB, int seed, int UnD, std::vector< unsigned int > &RcoreSums, std::vector< unsigned int > &RemSums)
Tool to calculate eTaudiscriminant sums.
virtual StatusCode getegSums(const EventContext &ctx, float etaTOB, float phiTOB, int seed, int UnD, std::vector< unsigned int > &ClusterCellETs, std::vector< unsigned int > &RetaSums, std::vector< unsigned int > &RhadSums, std::vector< unsigned int > &WstotSums)
Tool to calculate eEM discriminant sums.
virtual unsigned int eTowerID(float eta, float phi) const
Tool to find eTower identifier from an eta, phi coordinate pair.
ToolHandle< eFEXtauAlgoBase > m_eFEXtauAlgoTool
virtual StatusCode getTOBCellEnergies(float etaTOB, float phiTOB, std::vector< unsigned int > &ClusterCellETs) const
const float m_detaTower
const LVL1::eTower * findTower(int towerID) const
fast find method given identifier.
The eTower class is an interface object for eFEX trigger algorithms The purposes are twofold:
Definition eTower.h:38
int getET(unsigned int layer, int cell=0) const
Get ET of a specified cell in MeV.
Definition eTower.cxx:172
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...