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