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