ATLAS Offline Software
jTower.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //***************************************************************************
6 // jTower.h - description
7 // -------------------
8 // begin : 19 02 2019
9 // email : Alan.Watson@cern.ch, jacob.julian.kempster@cern.ch
10 // ***************************************************************************/
11 
12 #include "L1CaloFEXSim/jTower.h"
14 #include <cmath>
15 
16 
17 namespace LVL1 {
18 
19  const int s_nLayers = 2;
20  const int s_cells[s_nLayers] = {1,1};
21  const int s_offsets[s_nLayers] = {0,1};
22 
23  // default constructor
25  m_iEta(0),
26  m_iPhi(0),
27  m_tower_id(-9999999),
28  m_tower_id_online(0xffff),
29  m_posneg(0),
30  m_centre_eta(0.),
31  m_centre_phi(0.),
32  m_fcal_layer(-1)
33  {
34  this->clearET();
35  }
36 
38  jTower::jTower(int ieta, int iphi, int towerid, int posneg, float centre_eta, float centre_phi, int fcal_layer):
39  m_iEta(ieta),
40  m_iPhi(iphi),
41  m_tower_id(towerid),
42  m_tower_id_online(-9999999),
43  m_posneg(posneg),
44  m_centre_eta(centre_eta),
45  m_centre_phi(centre_phi),
46  m_fcal_layer(fcal_layer)
47  {
48  m_centre_phi_toPI = centre_phi;
49  if(centre_phi>M_PI) m_centre_phi_toPI = centre_phi-2*M_PI;
50  this->clearET();
51  }
52 
53 
56  {
57  m_et.clear();
58  m_et.resize(2,0);
59  m_et_float_raw.clear();
60  m_et_float_raw.resize(2,0.0);
61  }
62 
65  {
66  m_EM_scID.clear();
67  }
68 
71  {
72  m_HAD_scID.clear();
73  }
74 
75 
76 void jTower::setPosNeg(int posneg) {
77 
78  m_posneg = posneg;
79 
80  return;
81 
82 }
83 
85 void jTower::addET(float et, int layer)
86 {
87  if (layer < 0 || layer >= s_nLayers) {
88  std::stringstream errMsg;
89  errMsg << "addET: Attempt to set an invalid JTower layer with value: " << layer << ". Must be 0 (EM) or 1 (HAD) ";
90  throw std::runtime_error(errMsg.str().c_str());
91  return; //need to throw an error really...
92  }
93 
95 
96  return;
97 
98 }
99 
100 void jTower::set_Et(int layer, int et){
101  m_et[layer] = et;
102 }
103 
104 
106 
107  if (layer < 0 || layer >= s_nLayers) {
108  std::stringstream errMsg;
109  errMsg << "set_TileCal_Et: Attempt to set an invalid JTower layer with value: " << layer << ". Must be 0 (EM) or 1 (HAD) ";
110  throw std::runtime_error(errMsg.str().c_str());
111  return; //need to throw an error really...
112  }
113 
114  addET(et, layer);
115 
116  set_Et(layer, et);
117  return;
118 
119 }
120 
122 void jTower::set_LAr_Et(Identifier ID, int cell, float et, int layer)
123 {
124 
125  if((layer < 0) || (layer >= s_nLayers)) {
126  std::stringstream errMsg;
127  errMsg << "Attempt to set jTower SCID in invalid layer (" << layer << ")";
128  throw std::runtime_error(errMsg.str().c_str());
129  return; //need to throw an error really...
130  }
131 
133  if (cell < 0 || cell > 2) {
134  std::stringstream errMsg;
135  errMsg << "Attempt to set jTower SCID in invalid cell slot (" << cell << ")";
136  throw std::runtime_error(errMsg.str().c_str());
137  return;
138  }
139 
140  addET(et, cell);
141 
142  if(layer == 0) {
143  m_EM_scID.push_back(ID);
144  }
145  else if(layer == 1) {
146  m_HAD_scID.push_back(ID);
147  }
148 
149  return;
150 
151 }
152 
153 //** Used to Compress and Expand the LATOME energies accordingly to the scheme
155 
156  //multi linear digitisation encoding
157  for(uint layer=0; layer<m_et_float_raw.size(); layer++){
158  unsigned int ecode = jFEXCompression::Compress( m_et_float_raw[layer] );
159  int outET = jFEXCompression::Expand(ecode);
160  set_Et(layer,outET);
161  }
162 }
163 
164 
166 int jTower::iEta() const {
167  return m_iEta;
168 }
169 
171 int jTower::iPhi() const {
172  return m_iPhi;
173 }
174 
176 int jTower::getET(unsigned int layer, int cell) const {
177 
179  if (layer >= s_nLayers || cell < 0 || cell >= s_cells[layer]) return 0;
180 
181  // Return ET
182  return m_et[s_offsets[layer] + cell];
183 
184 }
185 
187 float jTower::getET_float(unsigned int layer, int cell) const {
188 
190  if (layer >= s_nLayers || cell < 0 || cell >= s_cells[layer]) return 0;
191 
192  // Return ET
193  return m_et_float_raw[s_offsets[layer] + cell];
194 
195 }
196 
198 int jTower::getTotalET() const {
199 
200  int tmp = 0;
201  for (unsigned int i=0; i<m_et.size(); i++) {
202  tmp += m_et[i];
203  }
204 
205  return tmp;
206 
207 }
208 
211 
212  float tmp = 0;
213  for (unsigned int i=0; i<m_et_float_raw.size(); i++) {
214  tmp += m_et_float_raw[i];
215  }
216 
217  return tmp;
218 
219 }
220 
221 
223 std::vector<int> jTower::getLayerETvec(unsigned int layer) const {
224 
226  std::vector<int> cells;
227 
229  if (layer >= s_nLayers) return cells;
230 
232  for (int cell = 0; cell < s_cells[layer]; ++cell) cells.push_back(m_et[s_offsets[layer] + cell]);
233 
234  return cells;
235 }
236 
237 
239 std::vector<float> jTower::getLayerETvec_float(unsigned int layer) const {
240 
242  std::vector<float> cells;
243 
245  if (layer >= s_nLayers) return cells;
246 
248  for (int cell = 0; cell < s_cells[layer]; ++cell) cells.push_back(m_et_float_raw[s_offsets[layer] + cell]);
249 
250  return cells;
251 }
252 
253 
255 int jTower::getLayerTotalET(unsigned int layer) const {
256 
257  if (layer == 0) {
258  return m_et[0];
259  }
260  else if (layer == 1) {
261  return (m_et[1]);
262  }
263 
264  return 0;
265 
266 }
267 
269 float jTower::getLayerTotalET_float(unsigned int layer) const {
270 
271  if (layer == 0) {
272  return m_et_float_raw[0];
273  }
274  else if (layer == 1) {
275  return (m_et_float_raw[1]);
276  }
277 
278  return 0;
279 
280 }
281 
282 std::vector<Identifier> jTower::getLayerSCIDs(unsigned int layer) const {
283 
284  if (layer == 0) {
285  return m_EM_scID;
286  }
287  else if (layer == 1) {
288  return m_HAD_scID;
289  }
290 
291  return std::vector<Identifier>();
292 
293 }
294 
295 void jTower::setCentreEta(float eta){
296  m_centre_eta = eta;
297 }
298 
299 void jTower::setiEta(int eta){
300  m_iEta = eta;
301 }
302 
303 void jTower::setCentrePhi(float phi){
304  m_centre_phi_toPI = phi;
305  m_centre_phi = phi;
306  if(m_centre_phi<0) m_centre_phi = 2*M_PI+phi;
307 }
308 
309 void jTower::setiPhi(int phi){
310  m_iPhi = phi;
311 }
312 
313 void jTower::setOnlineID(int tower_id_online){
314  m_tower_id_online = tower_id_online;
315 }
316 
318  m_TTowerArea.at(layer)=area;
319 }
320 
322  return m_TTowerArea.at(layer);
323 }
324 
327 }
328 
330  return m_TTowerAreaInv.at(layer);
331 }
332 
333 void jTower::setNoiseForMet(int noiseVal,int layer){
334  m_NoiseForMet[layer]=noiseVal;
335 }
336 
337 
339  return m_NoiseForMet[layer];
340 }
341 
342 void jTower::setNoiseForJet(int noiseVal,int layer){
343  m_NoiseForJet[layer]=noiseVal;
344 }
345 
346 
348  return m_NoiseForJet[layer];
349 }
350 
351 } // end of namespace bracket
352 
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:281
et
Extra patterns decribing particle interation process.
LVL1::jTower::m_iPhi
int m_iPhi
Definition: jTower.h:181
LVL1::s_nLayers
const size_t s_nLayers
Definition: eTower.cxx:19
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
LVL1::jTower::setCentreEta
void setCentreEta(float ieta)
Add to eta/phi values of a specified tower.
Definition: jTower.cxx:295
LVL1::jTower::iEta
int iEta() const
Get coordinates of tower.
Definition: jTower.cxx:166
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
LVL1::jTower::setiEta
void setiEta(int ieta)
Definition: jTower.cxx:299
LVL1::jTower::setTTowerAreaInv
void setTTowerAreaInv(int area, int layer)
Add to Area inverted values of a specified tower.
Definition: jTower.cxx:325
LVL1::jTower::setPosNeg
void setPosNeg(int posneg)
Definition: jTower.cxx:76
LVL1::jTower::setNoiseForMet
void setNoiseForMet(int noiseVal, int layer)
Noise values for each layer and object.
Definition: jTower.cxx:333
M_PI
#define M_PI
Definition: ActiveFraction.h:11
LVL1::jTower::getET
int getET(unsigned int layer, int cell=0) const
Get ET of a specified cell in MeV.
Definition: jTower.cxx:176
LVL1::jTower::m_centre_phi
float m_centre_phi
Definition: jTower.h:186
LVL1::jTower::m_TTowerAreaInv
std::vector< int > m_TTowerAreaInv
Definition: jTower.h:194
LVL1::jTower::set_LAr_Et
void set_LAr_Et(Identifier ID, int cell, float et, int layer)
Set LAr supercell position ID.
Definition: jTower.cxx:122
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::jTower::m_tower_id_online
int m_tower_id_online
Definition: jTower.h:183
LVL1::jTower::getTTowerAreaInv
int getTTowerAreaInv(int layer) const
Definition: jTower.cxx:329
LVL1::s_offsets
const int s_offsets[s_nLayers]
Definition: eTower.cxx:21
LVL1::jTower::m_iEta
int m_iEta
Internal data.
Definition: jTower.h:180
LVL1::jFEXCompression::Expand
static int Expand(unsigned int code)
Uncompress data.
Definition: jFEXCompression.cxx:58
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
LVL1::jTower::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: jTower.cxx:239
LVL1::jTower::getNoiseForJet
int getNoiseForJet(int layer) const
Definition: jTower.cxx:347
LVL1::jTower::clearET
void clearET()
Clear supercell ET values.
Definition: jTower.cxx:55
LVL1::jTower::setiPhi
void setiPhi(int iphi)
Definition: jTower.cxx:309
lumiFormat.i
int i
Definition: lumiFormat.py:85
LVL1::jTower::setTTowerArea
void setTTowerArea(int area, int layer)
Add to Area values of a specified tower.
Definition: jTower.cxx:317
LVL1::jFEXCompression::Compress
static unsigned int Compress(float floatEt, bool empty=false)
Compress data.
Definition: jFEXCompression.cxx:25
LVL1::jTower::getET_float
float getET_float(unsigned int layer, int cell=0) const
Get ET of a specified cell in MeV FLOAT VERSION.
Definition: jTower.cxx:187
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
LVL1::jTower::addET
void addET(float et, int cell)
Add to ET of a specified cell in MeV.
Definition: jTower.cxx:85
LVL1::jTower::setCentrePhi
void setCentrePhi(float iphi)
Definition: jTower.cxx:303
LVL1::jTower::getTotalET
int getTotalET() const
Get ET sum of all cells in the jTower in MeV.
Definition: jTower.cxx:198
LVL1::jTower::m_TTowerArea
std::vector< int > m_TTowerArea
Definition: jTower.h:193
LVL1::jTower::iPhi
int iPhi() const
Return global phi index.
Definition: jTower.cxx:171
LVL1::jTower::m_et
std::vector< int > m_et
Definition: jTower.h:191
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
LVL1::jTower::jTower
jTower()
Constructors.
Definition: jTower.cxx:24
LVL1::jTower::set_TileCal_Et
void set_TileCal_Et(int layer, int et)
Definition: jTower.cxx:105
LVL1::jTower::setOnlineID
void setOnlineID(int tower_id_online)
Definition: jTower.cxx:313
LVL1::jTower::getLayerSCIDs
std::vector< Identifier > getLayerSCIDs(unsigned int layer) const
Definition: jTower.cxx:282
LVL1::jTower::Do_LAr_encoding
void Do_LAr_encoding()
Applies LAr digitization scheme.
Definition: jTower.cxx:154
LVL1::jTower::getLayerETvec
std::vector< int > getLayerETvec(unsigned int layer) const
Get vector of ET values for a given layer in MeV.
Definition: jTower.cxx:223
LVL1::jTower::m_HAD_scID
std::vector< Identifier > m_HAD_scID
Definition: jTower.h:190
LVL1::jTower::m_et_float_raw
std::vector< float > m_et_float_raw
Definition: jTower.h:192
LVL1::jTower::m_centre_eta
float m_centre_eta
Definition: jTower.h:185
LVL1::jTower::m_EM_scID
std::vector< Identifier > m_EM_scID
Definition: jTower.h:189
LVL1::jTower::getTTowerArea
int getTTowerArea(int layer) const
Definition: jTower.cxx:321
LVL1::jTower::setNoiseForJet
void setNoiseForJet(int noiseVal, int layer)
Definition: jTower.cxx:342
jFEXCompression.h
LVL1::jTower::getTotalET_float
float getTotalET_float() const
Get ET sum of all cells in the jTower in MeV FLOAT VERSION.
Definition: jTower.cxx:210
LVL1::jTower::set_Et
void set_Et(int layer, int et)
Set ET value in MeV.
Definition: jTower.cxx:100
LVL1::jTower::clear_HAD_scIDs
void clear_HAD_scIDs()
Clear and resize HAD SC Identifier value vector.
Definition: jTower.cxx:70
LVL1::jTower::m_NoiseForJet
int m_NoiseForJet[2]
Definition: jTower.h:197
LVL1::jTower::clear_EM_scIDs
void clear_EM_scIDs()
Clear and resize Identifier value vector.
Definition: jTower.cxx:64
LVL1::jTower::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: jTower.cxx:269
LVL1::jTower::getNoiseForMet
int getNoiseForMet(int layer) const
Definition: jTower.cxx:338
LVL1::jTower::m_posneg
int m_posneg
Definition: jTower.h:184
area
double area(double R)
Definition: ConvertStaveServices.cxx:42
jTower.h
LVL1::jTower::m_centre_phi_toPI
float m_centre_phi_toPI
Definition: jTower.h:187
LVL1::jTower::m_NoiseForMet
int m_NoiseForMet[2]
Definition: jTower.h:196
LVL1::jTower::getLayerTotalET
int getLayerTotalET(unsigned int layer) const
Get total ET sum of all cells in a given layer in MeV.
Definition: jTower.cxx:255
Identifier
Definition: IdentifierFieldParser.cxx:14