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