ATLAS Offline Software
Loading...
Searching...
No Matches
gTower.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// gTower - Defines all properties and methods for the gFEX towers
6// -------------------
7// begin : 01 04 2021
8// email : cecilia.tosciri@cern.ch
9//***************************************************************************
10
11#include "L1CaloFEXSim/gTower.h"
13
14
15namespace LVL1 {
16
17 // default constructors
19 {
20 m_et_float_perlayer.assign(2, 0.0);
21 }
22
24 gTower::gTower(int ieta, int iphi, int nphi, int id_modifier, int posneg):
25 m_eta(ieta),
26 m_phi(iphi),
27 m_tower_id(id_modifier + iphi + (nphi * ieta)),
28 m_posneg(posneg)
29 {
30 m_et_float_perlayer.assign(2, 0.0);
32 }
33
36 {
37 m_et = 0;
38 m_et_float = 0.0;
39 m_et_float_perlayer.assign(2, 0.0);
40 }
41
44 {
45 m_scID.clear();
46 }
47
48 void gTower::setPosNeg(int posneg){
49
50 m_posneg = posneg;
51
52 return;
53
54 }
55
56
58 void gTower::addET(float et, int layer)
59 {
60
61 m_et_float_perlayer[layer] += et; // for monitoring
62 m_et_float += et;
63
64 return;
65
66 }
67
69 {
70
71 // addET(et, layer);
72
73 //multi linear digitisation encoding
74 unsigned int gcode = gFEXCompression::compress(m_et_float_perlayer[0]);//Only decode EM energy
75 int emET = gFEXCompression::expand(gcode);
76 int outET = emET + m_et_float_perlayer[1];//Sum EM and HAD energy
77
78 outET = outET/200.;//Convert to gFEX digit scale (200 MeV tbc)
79
80 //noise cut
81 const bool SCpass = noiseCut(outET);
82 if (SCpass){ m_et = outET; }
83 else{ m_et = 0; }
84 }
85
86 void gTower::setTotalEt(int totEt)
87 {
88
89 m_et = totEt;
90
91 return;
92 }
93
96 {
97
98 m_scID.push_back(ID);
99
100 return;
101
102 }
103
105 bool gTower::noiseCut(int et) const
106 {
107
108 bool pass = true;
109
110 if(et < m_noisecut){ pass = false; }
111
112 return pass;
113
114 }
115
117 int gTower::getID() const {
118 return m_tower_id;
119 }
120
121 // Return global eta index.
122 int gTower::iEta() const {
123 int index = (m_eta * m_posneg);
124 if (m_posneg < 0){
125 index = index + 19;
126 }
127 else if ((m_posneg > 0)){
128 index = index + 20;
129 }
130
131 return index;
132 }
133
134 // Return global phi index.
135 int gTower::iPhi() const {
136 return m_phi;
137 }
138
140 int gTower::getET() const {
141
142 return m_et;
143
144 }
145
147 float gTower::getET_float() const {
148
149 // Return ET
150 return m_et_float;
151
152 }
153
156
157 return m_et_float_perlayer[0];
158
159 }
160
163
164 return m_et_float_perlayer[1];
165
166 }
167
171
172 char gTower::isSaturated() const {
173 return m_saturated;
174 }
175
176
177 int gTower::getFWID() const {
178 int iPhiFW, iEtaFW;
179 return getFWID(iPhiFW, iEtaFW);
180 }
181
182
184 //This is about assigning a unique ID to the gTowers, that reflects as much as possible
185 //the tower identification in firmware.
186 //Some descriptions of this can be found in https://its.cern.ch/jira/browse/ATLGFEX-95.
187 //Since the indices used in firmware are the same for each FPGA (0-383), here we add a prefix
188 //for FPGA 1 (which corresponds to FPGA-B) and for FPGA 2 (FPGA-C) of 10000 and 20000, respectively,
189 //for differentiating the FPGAs. So we have 0-383 for FPGA 1 (FPGA-A), 10000-10383 FPGA 2 (FPGA-B),
190 //and 20000-20383 FPGA 3 (FPGA-C).
191 //iEta and iPhi are global indices, with iEta in 0-39 and iPhi in 0-32, and they uniquely determine
192 //one gTower object in the simulation. We assign here a unique ID to each gTower.
193 //The hardcoded numbers come from the definition of local FPGA IDs from global eta, phi indices.
194
195 int gTower::getFWID(int & iPhiFW, int & iEtaFW) const {
196
197 int gFEXtowerID; // the firmware ID to be calculated
198
199 int iEta = this->iEta();
200 int iPhi = this->iPhi();
201 float Eta = this->eta();
202
203 iPhiFW = iPhi;
204 iEtaFW = iEta;
205
206 bool is_central = true;
207 if (iEta <= 7 || iEta >= 32) is_central = false;
208
209 if (is_central)
210 {
211
212 if (iEta < 20)
213 {
214 // FPGA 0
215 gFEXtowerID = (iEta - 8) + (iPhi * 12);
216 } else
217 {
218 // FPGA 1
219 gFEXtowerID = 10000 + (iEta - 20) + (iPhi * 12);
220
221 }
222
223 } else
224 {
225 gFEXtowerID = 20000;
226
227 if ( Eta < 0 ){
228
229 if ( iEta == 0 ){
230 gFEXtowerID = gFEXtowerID + (iPhi*24);
231 iPhiFW = iPhi*2;
232 iEtaFW = 2;
233 }
234 else if ( iEta == 1 ){
235 gFEXtowerID = gFEXtowerID + ((iPhi*24) + 12);
236 iPhiFW = (iPhi*2)+1;
237 iEtaFW = 2;
238 }
239 else if ( iEta == 2 ){
240 gFEXtowerID = gFEXtowerID + ((iPhi*24) + 1);
241 iPhiFW = iPhi*2;
242 iEtaFW = 3;
243 }
244 else if ( iEta == 3 ){
245 gFEXtowerID = gFEXtowerID + ((iPhi*24) + 13);
246 iPhiFW = (iPhi*2)+1;
247 iEtaFW = 3;
248 }
249 else if ( iEta >= 4 and iEta <= 7 ){
250 gFEXtowerID = gFEXtowerID + ((iPhi*12) + (iEta -2));
251 }
252
253 }
254
255 else if ( Eta > 0 ){
256
257 if ( iEta >= 32 and iEta <= 35){
258 gFEXtowerID = gFEXtowerID + (iPhi*12) + (iEta -32 +6);
259 }
260 else if ( iEta == 36 ){
261 gFEXtowerID = gFEXtowerID + ((iPhi*24) + 22);
262 iPhiFW = (iPhi*2)+1;
263 iEtaFW = 36;
264 }
265 else if ( iEta == 37 ){
266 gFEXtowerID = gFEXtowerID + ((iPhi*24) + 10);
267 iPhiFW = iPhi*2;
268 iEtaFW = 36;
269 }
270 else if ( iEta == 38 ){
271 gFEXtowerID = gFEXtowerID + ((iPhi*24) + 23);
272 iPhiFW = (iPhi*2)+1;
273 iEtaFW = 37;
274 }
275 else if ( iEta == 39 ){
276 gFEXtowerID = gFEXtowerID + ((iPhi*24) + 11);
277 iPhiFW = iPhi*2;
278 iEtaFW = 37;
279 }
280 }
281
282 }
283
284 return gFEXtowerID;
285
286 }
287
288 void gTower::getEtaPhi ( float &Eta, float &Phi, int iEta, int iPhi) const{
289
290 constexpr float s_centralPhiWidth = (2*M_PI)/32; //In central region, gFex has 32 bins in phi
291 constexpr float s_forwardPhiWidth = (2*M_PI)/16; //In forward region, gFex has 16 bins in phi (before rearranging bins)
292
293 constexpr std::array<float, 40> s_EtaCenter = { -4.5, -3.8, -3.38, -3.18, -3.15, -3,
294 -2.8, -2.6, -2.35, -2.1, -1.9, -1.7, -1.5, -1.3, -1.1, -0.9,
295 -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.7, 0.9, 1.1,
296 1.3, 1.5, 1.7, 1.9, 2.1, 2.35, 2.6, 2.8, 3.0,
297 3.15, 3.18, 3.38, 3.8, 4.5};
298
299 Eta = s_EtaCenter.at(iEta);
300
301 float Phi_gFex = -99;
302 if (( iEta <= 3 ) || ( (iEta >= 36) )){
303 Phi_gFex = ( (iPhi * s_forwardPhiWidth) + s_forwardPhiWidth/2);
304 }
305 else {
306 Phi_gFex = ( (iPhi * s_centralPhiWidth) + s_centralPhiWidth/2);
307 }
308
309 if (Phi_gFex < M_PI) {
310 Phi = Phi_gFex;
311 }
312 else {
313 Phi = (Phi_gFex - 2*M_PI);
314 }
315 }
316
317
318} // end of namespace bracket
#define M_PI
static int expand(unsigned int code)
Uncompress data.
static unsigned int compress(float Energy)
Compress data.
int getET_EM_float() const
Get ET in MeV from EM calo FLOAT VERSION.
Definition gTower.cxx:155
float m_phi_float
Definition gTower.h:126
void setET()
Definition gTower.cxx:68
char m_saturated
Definition gTower.h:135
std::vector< float > m_et_float_perlayer
Definition gTower.h:128
void setIsSaturated(char isSaturated)
Sets saturation flag.
Definition gTower.cxx:168
int getET_HAD_float() const
Get ET in MeV from HAD calo FLOAT VERSION.
Definition gTower.cxx:162
int getFWID() const
Calculates and returns the firmware ID.
Definition gTower.cxx:177
char isSaturated() const
Returns true if is saturated.
Definition gTower.cxx:172
std::vector< Identifier > m_scID
Definition gTower.h:129
void setSCID(Identifier ID)
Set supercell position ID.
Definition gTower.cxx:95
float m_et_float
Definition gTower.h:127
int m_noisecut
Definition gTower.h:133
int getID() const
Add to ET.
Definition gTower.cxx:117
void clear_scIDs()
Clear and resize Identifier value vector.
Definition gTower.cxx:43
int m_posneg
Definition gTower.h:132
void setPosNeg(int posneg)
Definition gTower.cxx:48
int m_eta
Internal data.
Definition gTower.h:122
bool noiseCut(int et) const
Apply supercell noise cut.
Definition gTower.cxx:105
float getET_float() const
Get ET (total) in MeV FLOAT VERSION.
Definition gTower.cxx:147
int iPhi() const
Definition gTower.cxx:135
int m_tower_id
Definition gTower.h:131
int iEta() const
Get coordinates of tower.
Definition gTower.cxx:122
float m_eta_float
Definition gTower.h:125
gTower()
Constructors.
Definition gTower.cxx:18
float eta() const
Definition gTower.h:68
void setTotalEt(int totEt)
Definition gTower.cxx:86
void clearET()
Clear supercell ET values.
Definition gTower.cxx:35
void getEtaPhi(float &Eta, float &Phi, int iEta, int iPhi) const
Calculates eta and phi from ieta and iphi.
Definition gTower.cxx:288
void addET(float et, int layer)
Add ET in MeV, layer refers to EM or HAD (Tile).
Definition gTower.cxx:58
int getET() const
Get ET (total) in MeV.
Definition gTower.cxx:140
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition index.py:1
Extra patterns decribing particle interation process.