ATLAS Offline Software
eTower.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 // eTower.h - description
7 // -------------------
8 // begin : 19 02 2019
9 // email : Alan.Watson@cern.ch, jacob.julian.kempster@cern.ch
10 // ***************************************************************************/
11 
12 #include "L1CaloFEXSim/eTower.h"
14 #include <cmath>
15 
16 
17 namespace LVL1 {
18 
19  const size_t s_nLayers = 5;
20  const int s_cells[s_nLayers] = {1,4,4,1,4};
21  const int s_offsets[s_nLayers] = {0,1,5,9,10};
22  const int s_eFEXOverflow = 0xffff;
23 
24  // default constructor
26  m_eta(0.),
27  m_phi(0.),
28  m_tower_id(-9999999),
29  m_posneg(0)
30  {
31  this->clear_scIDs();
32  this->clearET();
33  }
34 
36  eTower::eTower(float eta, float phi, int id_modifier, int posneg):
37  m_eta(eta),
38  m_phi(phi),
39  m_tower_id(id_modifier + phi + (64 * eta)),
40  m_posneg(posneg)
41  {
42  this->clear_scIDs();
43  this->clearET();
44  }
45 
48  {
49  m_et.clear();
50  m_et.resize(14);
51  m_et_float.clear();
52  m_et_float.resize(14);
53  for (unsigned int i=0; i<m_et.size(); i++){
54  m_et[i] = 0;
55  m_et_float[i] = 0.0;
56  }
57 
58  m_etSplits.clear();
59  m_etSplits.resize(14);
60  for (unsigned int i=0; i<m_etSplits.size(); i++){
61  m_etSplits[i] = 0;
62  }
63 
64  }
65 
68  {
69  m_scID.clear();
70  m_scID.resize(14);
71  m_scID_split.clear();
72  m_scID_split.resize(14);
73  for (unsigned int i=0; i<m_scID.size(); i++){
74  m_scID[i] = Identifier();
76  }
77  }
78 
79 
80  void eTower::setPosNeg(int posneg){
81 
82  m_posneg = posneg;
83 
84  return;
85 
86  }
87 
89  void eTower::addET(float et, int cell)
90  {
92  if (cell < 0 || cell > 13){ return; }
93 
94  m_et_float[cell] += et;
95 
96  return;
97 
98  }
99  void eTower::setET(int cell, float et, int layer, bool ignoreDisable) {
101  if (cell < 0 || cell > 13){ return; }
102 
103  addET(et, cell);
104 
105  //multi linear digitisation encoding ... except in tile (indicated by passing layer=5) .. just convert to 25 MeV steps
107  }
108 
110  void eTower::setSCID(Identifier ID, int cell, float et, int layer, bool doenergysplit)
111  {
112 
114  if (cell < 0 || cell > 13){ return; }
115 
116  if(!doenergysplit){
117 
118  addET(et, cell);
119 
120  m_scID[cell] = ID;
121 
122  //multi linear digitisation encoding
124  m_et[cell] = outET;
125  }
126  else{
127 
128  float et_half = et*0.5;
129  addET(et_half, cell);
130  addET(et_half, cell+1);
131 
132  m_etSplits[cell] = 1;
133  m_etSplits[cell+1] = 1;
134 
135  if(cell==1){
136  m_scID[12] = ID;
137  }
138  else if(cell==3){
139  m_scID[13] = ID;
140  }
141 
142 
143  m_scID_split[cell] = ID;
144  m_scID_split[cell+1] = ID;
145 
146  m_scID.push_back(ID);
147 
150  }
151 
152  return;
153 
154  }
155 
159  int eTower::iEta() const {
160  const int index = (m_eta * m_posneg);
161  return index;
162  }
163 
167  int eTower::iPhi() const {
168  return m_phi;
169  }
170 
172  int eTower::getET(unsigned int layer, int cell) const {
173 
175  if (layer >= s_nLayers || cell < 0 || cell >= s_cells[layer]) return 0;
176 
177  // Return ET
178  return m_et[s_offsets[layer] + cell];
179 
180  }
181 
183  float eTower::getET_float(unsigned int layer, int cell) const {
184 
186  if (layer >= s_nLayers || cell < 0 || cell >= s_cells[layer]) return 0;
187 
188  // Return ET
189  return m_et_float[s_offsets[layer] + cell];
190 
191  }
192 
194  int eTower::getTotalET() const{
195  int tmp = 0;
196  for (unsigned int i=0; i<m_et.size(); i++){
197  tmp += m_et[i];
198  }
199  // Sum saturates at 16 bits
200  return std::min(tmp,s_eFEXOverflow);
201  }
202 
205 
206  float tmp = 0;
207  for (unsigned int i=0; i<m_et_float.size(); i++){
208  tmp += m_et_float[i];
209  }
210 
211  return tmp;
212 
213  }
214 
215 
217  std::vector<int> eTower::getLayerETvec(unsigned int layer) const {
218 
220  std::vector<int> cells;
221 
223  if (layer >= s_nLayers) return cells;
224 
226  for (int cell = 0; cell < s_cells[layer]; ++cell) cells.push_back(m_et[s_offsets[layer] + cell]);
227 
228  return cells;
229  }
230 
231 
233  std::vector<float> eTower::getLayerETvec_float(unsigned int layer) const {
234 
236  std::vector<float> cells;
237 
239  if (layer >= s_nLayers) return cells;
240 
242  for (int cell = 0; cell < s_cells[layer]; ++cell) cells.push_back(m_et_float[s_offsets[layer] + cell]);
243 
244  return cells;
245  }
246 
247 
249  int eTower::getLayerTotalET(unsigned int layer) const {
250 
251  if (layer == 0){
252  return m_et[0];
253  }
254  else if (layer == 1){
255  return (m_et[1] + m_et[2] + m_et[3] + m_et[4]);
256  }
257  else if (layer == 2){
258  return (m_et[5] + m_et[6] + m_et[7] + m_et[8]);
259  }
260  else if (layer == 3){
261  return m_et[9];
262  }
263  else if (layer == 4){
264  return (m_et[10] + m_et[11]);
265  }
266 
267 
268  return 0;
269 
270  }
271 
273  float eTower::getLayerTotalET_float(unsigned int layer) const {
274 
275  if (layer == 0){
276  return m_et_float[0];
277  }
278  else if (layer == 1){
279  return (m_et_float[1] + m_et_float[2] + m_et_float[3] + m_et_float[4]);
280  }
281  else if (layer == 2){
282  return (m_et_float[5] + m_et_float[6] + m_et_float[7] + m_et_float[8]);
283  }
284  else if (layer == 3){
285  return m_et_float[9];
286  }
287  else if (layer == 4){
288  return (m_et_float[10] + m_et_float[11]);
289  }
290 
291 
292  return 0;
293 
294  }
295 
296  std::vector<Identifier> eTower::getLayerSCIDs(unsigned int layer) const{
297 
298  std::vector<Identifier> cells_in_layer;
299 
300  if (layer == 0){
301  cells_in_layer.push_back(m_scID[0]);
302  }
303  else if (layer == 1){
304  cells_in_layer.push_back(m_scID[1]);
305  cells_in_layer.push_back(m_scID[2]);
306  cells_in_layer.push_back(m_scID[3]);
307  cells_in_layer.push_back(m_scID[4]);
308  }
309  else if (layer == 2){
310  cells_in_layer.push_back(m_scID[5]);
311  cells_in_layer.push_back(m_scID[6]);
312  cells_in_layer.push_back(m_scID[7]);
313  cells_in_layer.push_back(m_scID[8]);
314  }
315  else if (layer == 3){
316  cells_in_layer.push_back(m_scID[9]);
317  }
318  else if (layer == 4){
319  cells_in_layer.push_back(m_scID[10]);
320  cells_in_layer.push_back(m_scID[11]);
321  }
322 
323  return cells_in_layer;
324 
325  }
326 
327 
328 } // end of namespace bracket
LVL1::eTower::iPhi
int iPhi() const
Return global phi index.
Definition: eTower.cxx:167
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:271
et
Extra patterns decribing particle interation process.
LVL1::eTower::getLayerTotalET_float
float getLayerTotalET_float(unsigned int layer) const
Get total ET sum of all cells in a given layer in MeV FLOAT VERSION.
Definition: eTower.cxx:273
LVL1::s_nLayers
const size_t s_nLayers
Definition: eTower.cxx:19
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
LVL1::eTower::getTotalET
int getTotalET() const
Get ET sum of all cells in the eTower in MeV.
Definition: eTower.cxx:194
LVL1::eTower::getLayerETvec_float
std::vector< float > getLayerETvec_float(unsigned int layer) const
Get vector of ET values for a given layer in MeV FLOAT VERSION.
Definition: eTower.cxx:233
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
index
Definition: index.py:1
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
LVL1::eTower::clearET
void clearET()
Clear supercell ET values.
Definition: eTower.cxx:47
LVL1::eTower::setPosNeg
void setPosNeg(int posneg)
Definition: eTower.cxx:80
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
LVL1::eTower::m_et
std::vector< int > m_et
Definition: eTower.h:129
LVL1::s_eFEXOverflow
const int s_eFEXOverflow
Definition: eTower.cxx:22
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1::s_cells
const int s_cells[s_nLayers]
Definition: eTower.cxx:20
LVL1::eTower::setSCID
void setSCID(Identifier ID, int cell, float et, int layer, bool doenergysplit)
Set supercell position ID.
Definition: eTower.cxx:110
LVL1::s_offsets
const int s_offsets[s_nLayers]
Definition: eTower.cxx:21
eFEXCompression.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
LVL1::eTower::m_phi
float m_phi
Definition: eTower.h:126
LVL1::eTower::getLayerSCIDs
std::vector< Identifier > getLayerSCIDs(unsigned int layer) const
Definition: eTower.cxx:296
LVL1::eFEXCompression::decode
static int decode(int EtVal, int layer, bool ignoreDisable=false)
Full sequence.
Definition: eFEXCompression.cxx:118
LVL1::eTower::eTower
eTower()
Constructors.
Definition: eTower.cxx:25
LVL1::eTower::m_et_float
std::vector< float > m_et_float
Definition: eTower.h:130
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
LVL1::eTower::getET
int getET(unsigned int layer, int cell=0) const
Get ET of a specified cell in MeV.
Definition: eTower.cxx:172
LVL1::eTower::getLayerTotalET
int getLayerTotalET(unsigned int layer) const
Get total ET sum of all cells in a given layer in MeV.
Definition: eTower.cxx:249
LVL1::eTower::clear_scIDs
void clear_scIDs()
Clear and resize Identifier value vector.
Definition: eTower.cxx:67
LVL1::eTower::addET
void addET(float et, int cell)
Add to ET of a specified cell in MeV.
Definition: eTower.cxx:89
LVL1::eTower::m_posneg
int m_posneg
Definition: eTower.h:133
LVL1::eTower::m_scID
std::vector< Identifier > m_scID
Definition: eTower.h:127
LVL1::eTower::getLayerETvec
std::vector< int > getLayerETvec(unsigned int layer) const
Get vector of ET values for a given layer in MeV.
Definition: eTower.cxx:217
LVL1::eTower::m_etSplits
std::vector< unsigned int > m_etSplits
Definition: eTower.h:131
DeMoScan.index
string index
Definition: DeMoScan.py:364
LVL1::eTower::getET_float
float getET_float(unsigned int layer, int cell=0) const
Get ET of a specified cell in MeV FLOAT VERSION.
Definition: eTower.cxx:183
LVL1::eTower::m_eta
float m_eta
Internal data.
Definition: eTower.h:125
LVL1::eTower::getTotalET_float
float getTotalET_float() const
Get ET sum of all cells in the eTower in MeV FLOAT VERSION.
Definition: eTower.cxx:204
eTower.h
LVL1::eTower::setET
void setET(int cell, float et, int layer, bool ignoreDisable=false)
Definition: eTower.cxx:99
LVL1::eTower::iEta
int iEta() const
Get coordinates of tower.
Definition: eTower.cxx:159
LVL1::eTower::m_scID_split
std::vector< Identifier > m_scID_split
Definition: eTower.h:128
Identifier
Definition: IdentifierFieldParser.cxx:14