ATLAS Offline Software
CrateEnergy.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 /***************************************************************************
5  CrateEnergy.h - description
6  -------------------
7  begin : 06/09/2007
8  email : Alan.Watson@cern.ch
9  ***************************************************************************/
10 
11 
13 
14 namespace LVL1 {
15 
16 CrateEnergy::CrateEnergy(unsigned int crate, const DataVector<ModuleEnergy>* JEMs, uint32_t maskXE, uint32_t maskTE, bool restricted):
17  m_crate(crate),
18  m_crateEt(0),
19  m_crateEx(0),
20  m_crateEy(0),
21  m_overflowT(0),
22  m_overflowX(0),
23  m_overflowY(0),
24  m_restricted(restricted),
25  m_debug(false)
26  {
28  if (m_crate > 1) return;
29 
31  if ((maskXE&0xff) != 0xff || (maskTE&0xff) != 0xff) m_restricted = true;
32 
40  unsigned int eT[2] = {0,0};
41  unsigned int eX[2] = {0,0};
42  unsigned int eY[2] = {0,0};
43  for ( const ModuleEnergy* jem : *JEMs ) {
44  int moduleInQuad = jem->module() % 8;
45  if (jem->crate() == m_crate) {
46  int quad = ( jem->module() < 8 ? 0 : 1 );
47  if ((maskTE>>moduleInQuad)&1) {
48  eT[quad] += jem->et();
49  if ( jem->et() >= m_jemEtSaturation ) m_overflowT = 1;
50  }
51  if ((maskXE>>moduleInQuad)&1) {
52  eX[quad] += jem->ex();
53  eY[quad] += jem->ey();
54  if ( jem->ex() >= m_jemEtSaturation ) m_overflowX = 1;
55  if ( jem->ey() >= m_jemEtSaturation ) m_overflowY = 1;
56  }
57  } // Right crate?
58  } // Loop over JEMs
59 
61  unsigned int mask = (1 << m_sumBits) - 1;
62 
65  m_crateEt = eT[0] + eT[1];
66  if (m_crateEt >= mask){
67  m_overflowT = 1;
68  m_crateEt = mask;
69  }
70 
71 
72  if (!m_overflowX){
73  m_crateEx = eX[0] - eX[1];
74  } else{
75  m_crateEx = -(mask + 1);
76  }
77  if (!m_overflowY){
78  m_crateEy = eY[0] - eY[1];
79  }else{
80  m_crateEy = -(mask + 1);
81  }
82 
83 
84  if (m_debug) {
85  std::cout << "CrateEnergy: crate " << m_crate << " results " << std::endl
86  << " Et " << m_crateEt << " overflow " << m_overflowT << std::endl
87  << " Ex " << m_crateEx << " overflow " << m_overflowX << std::endl
88  << " Ey " << m_crateEy << " overflow " << m_overflowY << std::endl;
89 
90  }
91 
92 }
93 
94 CrateEnergy::CrateEnergy(unsigned int crate, const DataVector<EnergyCMXData>* JEMs, uint32_t maskXE, uint32_t maskTE, bool restricted):
95  m_crate(crate),
96  m_crateEt(0),
97  m_crateEx(0),
98  m_crateEy(0),
99  m_overflowT(0),
100  m_overflowX(0),
101  m_overflowY(0),
102  m_restricted(restricted),
103  m_debug(false)
104  {
106  if (m_crate > 1) return;
107 
109  if ((maskXE&0xff) != 0xff || (maskTE&0xff) != 0xff) m_restricted = true;
110 
118  unsigned int eT[2] = {0,0};
119  unsigned int eX[2] = {0,0};
120  unsigned int eY[2] = {0,0};
121  for ( const EnergyCMXData* jem : *JEMs ) {
122  int moduleInQuad = jem->module() % 8;
123  if ((unsigned int)jem->crate() == m_crate) {
124  int quad = ( jem->module() < 8 ? 0 : 1 );
125 
126  if ((maskTE>>moduleInQuad)&1) {
127  eT[quad] += jem->Et();
128  if ( jem->Et() >= m_jemEtSaturation ) m_overflowT = 1;
129  }
130  if ((maskXE>>moduleInQuad)&1) {
131  eX[quad] += jem->Ex();
132  eY[quad] += jem->Ey();
133  if ( jem->Ex() >= m_jemEtSaturation ) m_overflowX = 1;
134  if ( jem->Ey() >= m_jemEtSaturation ) m_overflowY = 1;
135  }
136  }
137  }
138 
140  unsigned int mask = (1<<m_sumBits) - 1;
141 
142 
145  m_crateEt = eT[0] + eT[1];
146  if (m_crateEt >= mask){
147  m_overflowT = 1;
148  m_crateEt = mask;
149  }
150 
151  if (!m_overflowX){
152  m_crateEx = eX[0] - eX[1];
153  } else{
154  m_crateEx = -(mask + 1);
155  }
156  if (!m_overflowY){
157  m_crateEy = eY[0] - eY[1];
158  }else{
159  m_crateEy = -(mask + 1);
160  }
161 
162  if (m_debug) {
163  std::cout << "CrateEnergy: crate " << m_crate << " results " << std::endl
164  << " Et " << m_crateEt << " overflow " << m_overflowT << std::endl
165  << " Ex " << m_crateEx << " overflow " << m_overflowX << std::endl
166  << " Ey " << m_crateEy << " overflow " << m_overflowY << std::endl;
167 
168  }
169 
170 }
171 
172 CrateEnergy::CrateEnergy(unsigned int crate, unsigned int et, unsigned int exTC,
173  unsigned int eyTC, unsigned int overflowT, unsigned int overflowX,
174  unsigned int overflowY, bool restricted) :
175  m_crate(crate),
176  m_crateEt(0),
177  m_crateEx(0),
178  m_crateEy(0),
179  m_overflowT(0),
180  m_overflowX(0),
181  m_overflowY(0),
182  m_restricted(restricted),
183  m_debug(false)
184 {
186  if (m_crate > 1) return;
187  m_crateEt = et;
188  m_crateEx = decodeTC(exTC);
189  m_crateEy = decodeTC(eyTC);
190  m_overflowT = overflowT;
191  m_overflowX = overflowX;
192  m_overflowY = overflowY;
193 
194  if (m_debug) {
195  std::cout << "CrateEnergy: crate " << m_crate << " results " << std::endl
196  << " Et " << m_crateEt << " overflow " << m_overflowT << std::endl
197  << " Ex " << m_crateEx << " overflow " << m_overflowX << std::endl
198  << " Ey " << m_crateEy << " overflow " << m_overflowY << std::endl;
199 
200  }
201 }
202 
203 
205 }
206 
208 unsigned int CrateEnergy::crate() const {
209  return m_crate;
210 }
211 
213 int CrateEnergy::et() const {
214  return m_crateEt;
215 }
216 
218 int CrateEnergy::ex() const {
219  return m_crateEx;
220 }
221 
223 int CrateEnergy::ey() const {
224  return m_crateEy;
225 }
226 
228 unsigned int CrateEnergy::etOverflow() const {
229  return m_overflowT;
230 }
231 
233 unsigned int CrateEnergy::exOverflow() const {
234  return m_overflowX;
235 }
236 
238 unsigned int CrateEnergy::eyOverflow() const {
239  return m_overflowY;
240 }
241 
244  return m_restricted;
245 }
246 
248 unsigned int CrateEnergy::exTC() const {
249  return encodeTC(m_crateEx);
250 }
251 
253 unsigned int CrateEnergy::eyTC() const {
254  return encodeTC(m_crateEy);
255 }
256 
258 unsigned int CrateEnergy::encodeTC(int input) const {
259  unsigned int value;
260 
261  if (input > 0) {
262  value = input;
263  }
264  else {
265  value = (1<<m_sumBitsTC) + input;
266  }
267 
268  int mask = (1<<m_sumBitsTC) - 1;
269  return value&mask ;
270 }
271 
273 int CrateEnergy::decodeTC(unsigned int input) const {
274 
275  int mask = (1<<m_sumBitsTC) - 1;
276  int value = input&mask;
277 
278  if ((value >> (m_sumBitsTC - 1))) {
279  value += (~0U) << m_sumBitsTC;
280  }
281 
282  return value;
283 }
284 } // end of ns
LVL1::CrateEnergy::decodeTC
int decodeTC(unsigned int input) const
decode 15-bit twos-complement format (hardware Ex/Ey format) as int
Definition: CrateEnergy.cxx:278
et
Extra patterns decribing particle interation process.
LVL1::CrateEnergy::exOverflow
unsigned int exOverflow() const
Overflow bits.
Definition: CrateEnergy.cxx:238
LVL1::CrateEnergy::~CrateEnergy
~CrateEnergy()
Definition: CrateEnergy.cxx:209
LVL1::CrateEnergy::eyOverflow
unsigned int eyOverflow() const
return Ey overflow bit
Definition: CrateEnergy.cxx:243
LVL1::CrateEnergy::etOverflow
unsigned int etOverflow() const
return Et overflow bit
Definition: CrateEnergy.cxx:233
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
LVL1::CrateEnergy::m_crateEt
unsigned int m_crateEt
Definition: CrateEnergy.h:66
LVL1::EnergyCMXData
The EnergyCMXData object contains the data transferred from the JEM to the EnergySum CMX in the crate...
Definition: EnergyCMXData.h:24
LVL1::CrateEnergy::m_overflowT
unsigned int m_overflowT
Definition: CrateEnergy.h:69
LVL1::CrateEnergy::et
int et() const
return et, ex, ey sums
Definition: CrateEnergy.cxx:218
athena.value
value
Definition: athena.py:124
LVL1::CrateEnergy::m_overflowX
unsigned int m_overflowX
Definition: CrateEnergy.h:70
LVL1::CrateEnergy::CrateEnergy
CrateEnergy(unsigned int crate, const DataVector< ModuleEnergy > *modules, uint32_t maskXE=0xff, uint32_t maskTE=0xff, bool restricted=false)
Definition: CrateEnergy.cxx:21
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
LVL1::CrateEnergy::m_sumBitsTC
static const unsigned int m_sumBitsTC
Definition: CrateEnergy.h:74
CrateEnergy.h
IDTPM::eT
float eT(const U &p)
Accessor utility function for getting the value of Tranverse energy.
Definition: TrackParametersHelper.h:122
LVL1::CrateEnergy::eyTC
unsigned int eyTC() const
return crate Ey in 15-bit twos-complement format (hardware format)
Definition: CrateEnergy.cxx:258
LVL1::CrateEnergy::crate
unsigned int crate() const
return crate number
Definition: CrateEnergy.cxx:213
LVL1::CrateEnergy::exTC
unsigned int exTC() const
15 bit twos-complement format
Definition: CrateEnergy.cxx:253
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
LVL1::CrateEnergy::m_crateEx
int m_crateEx
Definition: CrateEnergy.h:67
LVL1::ModuleEnergy
This is an internal class, used in the Energy trigger.
Definition: ModuleEnergy.h:45
LVL1::CrateEnergy::encodeTC
unsigned int encodeTC(int input) const
encode int as 15-bit twos-complement format (hardware Ex/Ey format)
Definition: CrateEnergy.cxx:263
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
LVL1::CrateEnergy::m_overflowY
unsigned int m_overflowY
Definition: CrateEnergy.h:71
LVL1::CrateEnergy::restricted
bool restricted() const
Full or restricted eta range?
Definition: CrateEnergy.cxx:248
LVL1::CrateEnergy::ex
int ex() const
return crate Ex
Definition: CrateEnergy.cxx:223
LVL1::CrateEnergy::m_crateEy
int m_crateEy
Definition: CrateEnergy.h:68
LVL1::CrateEnergy::ey
int ey() const
return crate Ey
Definition: CrateEnergy.cxx:228
LVL1::CrateEnergy::m_crate
unsigned int m_crate
Definition: CrateEnergy.h:65
LVL1::CrateEnergy::m_restricted
bool m_restricted
Definition: CrateEnergy.h:72
dumpNswErrorDb.quad
def quad
Definition: dumpNswErrorDb.py:24