ATLAS Offline Software
Loading...
Searching...
No Matches
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#include <iostream>
14
15
16namespace LVL1 {
17
18CrateEnergy::CrateEnergy(unsigned int crate, const DataVector<ModuleEnergy>* JEMs, uint32_t maskXE, uint32_t maskTE, bool restricted):
20 m_crateEt(0),
21 m_crateEx(0),
22 m_crateEy(0),
23 m_overflowT(0),
24 m_overflowX(0),
25 m_overflowY(0),
27 m_debug(false)
28 {
30 if (m_crate > 1) return;
31
33 if ((maskXE&0xff) != 0xff || (maskTE&0xff) != 0xff) m_restricted = true;
34
40
42 unsigned int eT[2] = {0,0};
43 unsigned int eX[2] = {0,0};
44 unsigned int eY[2] = {0,0};
45 for ( const ModuleEnergy* jem : *JEMs ) {
46 int moduleInQuad = jem->module() % 8;
47 if (jem->crate() == m_crate) {
48 int quad = ( jem->module() < 8 ? 0 : 1 );
49 if ((maskTE>>moduleInQuad)&1) {
50 eT[quad] += jem->et();
51 if ( jem->et() >= m_jemEtSaturation ) m_overflowT = 1;
52 }
53 if ((maskXE>>moduleInQuad)&1) {
54 eX[quad] += jem->ex();
55 eY[quad] += jem->ey();
56 if ( jem->ex() >= m_jemEtSaturation ) m_overflowX = 1;
57 if ( jem->ey() >= m_jemEtSaturation ) m_overflowY = 1;
58 }
59 } // Right crate?
60 } // Loop over JEMs
61
63 const unsigned int mask = (1U << m_sumBits) - 1U;
64 const int overflowValue = -static_cast<int>(mask + 1U);
67 m_crateEt = eT[0] + eT[1];
68 if (m_crateEt >= mask){
69 m_overflowT = 1;
70 m_crateEt = mask;
71 }
72
73
74 if (!m_overflowX) {
75 m_crateEx = static_cast<int>(eX[0]) - static_cast<int>(eX[1]);
76 } else {
77 m_crateEx = overflowValue;
78 }
79
80 if (!m_overflowY) {
81 m_crateEy = static_cast<int>(eY[0]) - static_cast<int>(eY[1]);
82 } else {
83 m_crateEy = overflowValue;
84 }
85
86
87 if (m_debug) {
88 std::cout << "CrateEnergy: crate " << m_crate << " results "
89 << "\n Et " << m_crateEt << " overflow " << m_overflowT
90 << "\n Ex " << m_crateEx << " overflow " << m_overflowX
91 << "\n Ey " << m_crateEy << " overflow " << m_overflowY << std::endl;
92
93 }
94
95}
96
97CrateEnergy::CrateEnergy(unsigned int crate, const DataVector<EnergyCMXData>* JEMs, uint32_t maskXE, uint32_t maskTE, bool restricted):
99 m_crateEt(0),
100 m_crateEx(0),
101 m_crateEy(0),
102 m_overflowT(0),
103 m_overflowX(0),
104 m_overflowY(0),
106 m_debug(false)
107 {
109 if (m_crate > 1) return;
110
112 if ((maskXE&0xff) != 0xff || (maskTE&0xff) != 0xff) m_restricted = true;
113
119
121 unsigned int eT[2] = {0,0};
122 unsigned int eX[2] = {0,0};
123 unsigned int eY[2] = {0,0};
124 for ( const EnergyCMXData* jem : *JEMs ) {
125 int moduleInQuad = jem->module() % 8;
126 if ((unsigned int)jem->crate() == m_crate) {
127 int quad = ( jem->module() < 8 ? 0 : 1 );
128
129 if ((maskTE>>moduleInQuad)&1) {
130 eT[quad] += jem->Et();
131 if ( jem->Et() >= m_jemEtSaturation ) m_overflowT = 1;
132 }
133 if ((maskXE>>moduleInQuad)&1) {
134 eX[quad] += jem->Ex();
135 eY[quad] += jem->Ey();
136 if ( jem->Ex() >= m_jemEtSaturation ) m_overflowX = 1;
137 if ( jem->Ey() >= m_jemEtSaturation ) m_overflowY = 1;
138 }
139 }
140 }
141
143 unsigned int mask = (1<<m_sumBits) - 1;
144
145
148 m_crateEt = eT[0] + eT[1];
149 if (m_crateEt >= mask){
150 m_overflowT = 1;
151 m_crateEt = mask;
152 }
153
154 if (!m_overflowX){
155 m_crateEx = eX[0] - eX[1];
156 } else{
157 m_crateEx = -(mask + 1);
158 }
159 if (!m_overflowY){
160 m_crateEy = eY[0] - eY[1];
161 }else{
162 m_crateEy = -(mask + 1);
163 }
164
165 if (m_debug) {
166 std::cout << "CrateEnergy: crate " << m_crate << " results "
167 << "\n Et " << m_crateEt << " overflow " << m_overflowT
168 << "\n Ex " << m_crateEx << " overflow " << m_overflowX
169 << "\n Ey " << m_crateEy << " overflow " << m_overflowY << std::endl;
170
171 }
172
173}
174
175CrateEnergy::CrateEnergy(unsigned int crate, unsigned int et, unsigned int exTC,
176 unsigned int eyTC, unsigned int overflowT, unsigned int overflowX,
177 unsigned int overflowY, bool restricted) :
178 m_crate(crate),
179 m_crateEt(0),
180 m_crateEx(0),
181 m_crateEy(0),
182 m_overflowT(0),
183 m_overflowX(0),
184 m_overflowY(0),
186 m_debug(false)
187{
189 if (m_crate > 1) return;
190 m_crateEt = et;
193 m_overflowT = overflowT;
194 m_overflowX = overflowX;
195 m_overflowY = overflowY;
196
197 if (m_debug) {
198 std::cout << "CrateEnergy: crate " << m_crate << " results "
199 << "\n Et " << m_crateEt << " overflow " << m_overflowT
200 << "\n Ex " << m_crateEx << " overflow " << m_overflowX
201 << "\n Ey " << m_crateEy << " overflow " << m_overflowY << std::endl;
202
203 }
204}
205
206
209
211unsigned int CrateEnergy::crate() const {
212 return m_crate;
213}
214
216int CrateEnergy::et() const {
217 return m_crateEt;
218}
219
221int CrateEnergy::ex() const {
222 return m_crateEx;
223}
224
226int CrateEnergy::ey() const {
227 return m_crateEy;
228}
229
231unsigned int CrateEnergy::etOverflow() const {
232 return m_overflowT;
233}
234
236unsigned int CrateEnergy::exOverflow() const {
237 return m_overflowX;
238}
239
241unsigned int CrateEnergy::eyOverflow() const {
242 return m_overflowY;
243}
244
247 return m_restricted;
248}
249
251unsigned int CrateEnergy::exTC() const {
252 return encodeTC(m_crateEx);
253}
254
256unsigned int CrateEnergy::eyTC() const {
257 return encodeTC(m_crateEy);
258}
259
261unsigned int CrateEnergy::encodeTC(int input) const {
262 unsigned int value;
263
264 if (input > 0) {
265 value = input;
266 }
267 else {
268 value = (1<<m_sumBitsTC) + input;
269 }
270
271 int mask = (1<<m_sumBitsTC) - 1;
272 return value&mask ;
273}
274
276int CrateEnergy::decodeTC(unsigned int input) const {
277
278 int mask = (1<<m_sumBitsTC) - 1;
279 int value = input&mask;
280
281 if ((value >> (m_sumBitsTC - 1))) {
282 value += (~0U) << m_sumBitsTC;
283 }
284
285 return value;
286}
287} // end of ns
Derived DataVector<T>.
Definition DataVector.h:795
unsigned int crate() const
return crate number
int ex() const
return crate Ex
unsigned int m_overflowT
Definition CrateEnergy.h:60
int ey() const
return crate Ey
int et() const
return et, ex, ey sums
static const unsigned int m_sumBits
Definition CrateEnergy.h:66
unsigned int exOverflow() const
Overflow bits.
unsigned int m_overflowY
Definition CrateEnergy.h:62
bool restricted() const
Full or restricted eta range?
unsigned int eyOverflow() const
return Ey overflow bit
unsigned int m_crate
Definition CrateEnergy.h:56
unsigned int etOverflow() const
return Et overflow bit
CrateEnergy(unsigned int crate, const DataVector< ModuleEnergy > *modules, uint32_t maskXE=0xff, uint32_t maskTE=0xff, bool restricted=false)
unsigned int encodeTC(int input) const
encode int as 15-bit twos-complement format (hardware Ex/Ey format)
int decodeTC(unsigned int input) const
decode 15-bit twos-complement format (hardware Ex/Ey format) as int
static const unsigned int m_sumBitsTC
Definition CrateEnergy.h:65
unsigned int exTC() const
15 bit twos-complement format
unsigned int m_crateEt
Definition CrateEnergy.h:57
unsigned int eyTC() const
return crate Ey in 15-bit twos-complement format (hardware format)
unsigned int m_overflowX
Definition CrateEnergy.h:61
static const unsigned int m_jemEtSaturation
Definition CrateEnergy.h:67
The EnergyCMXData object contains the data transferred from the JEM to the EnergySum CMX in the crate...
This is an internal class, used in the Energy trigger.
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...