ATLAS Offline Software
Loading...
Searching...
No Matches
LVL1::CrateEnergy Class Reference

CrateEnergy class declaration Simulates behaviour of the Crate-CMM System CMM logic is done in EnergyTrigger. More...

#include <CrateEnergy.h>

Collaboration diagram for LVL1::CrateEnergy:

Public Member Functions

 CrateEnergy (unsigned int crate, const DataVector< ModuleEnergy > *modules, uint32_t maskXE=0xff, uint32_t maskTE=0xff, bool restricted=false)
 CrateEnergy (unsigned int crate, const DataVector< EnergyCMXData > *modules, uint32_t maskXE=0xff, uint32_t maskTE=0xff, bool restricted=false)
 CrateEnergy (unsigned int crate, unsigned int et, unsigned int exTC, unsigned int eyTC, unsigned int overflowT, unsigned int overflowX, unsigned int overflowY, bool restricted=false)
 ~CrateEnergy ()
unsigned int crate () const
 return crate number
int et () const
 return et, ex, ey sums
int ex () const
 return crate Ex
int ey () const
 return crate Ey
unsigned int exTC () const
 15 bit twos-complement format
unsigned int eyTC () const
 return crate Ey in 15-bit twos-complement format (hardware format)
unsigned int exOverflow () const
 Overflow bits.
unsigned int eyOverflow () const
 return Ey overflow bit
unsigned int etOverflow () const
 return Et overflow bit
bool restricted () const
 Full or restricted eta range?

Private Member Functions

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

Private Attributes

unsigned int m_crate
unsigned int m_crateEt
int m_crateEx
int m_crateEy
unsigned int m_overflowT
unsigned int m_overflowX
unsigned int m_overflowY
bool m_restricted
bool m_debug

Static Private Attributes

static const unsigned int m_sumBitsTC =15
static const unsigned int m_sumBits =14
static const unsigned int m_jemEtSaturation = 0x3fff

Detailed Description

CrateEnergy class declaration Simulates behaviour of the Crate-CMM System CMM logic is done in EnergyTrigger.

Definition at line 30 of file CrateEnergy.h.

Constructor & Destructor Documentation

◆ CrateEnergy() [1/3]

LVL1::CrateEnergy::CrateEnergy ( unsigned int crate,
const DataVector< ModuleEnergy > * modules,
uint32_t maskXE = 0xff,
uint32_t maskTE = 0xff,
bool restricted = false )

Check crate in range

Added for restricted eta triggers in Run 2

Summing within a crate proceeds as follows:
unsigned 14 bit Ex, Ey, Et sums are formed for each half crate
these sums (= opposite quadrants) are added (Et) or subtracted (Ex, Ey)
to give the crate totals
overflows are propagated using separate bits

Sum ET from modules belonging to this crate in two halves

Check for overflows then truncate quadrant sums

Form crate sums

For total ET we must check for further overflows

Definition at line 18 of file CrateEnergy.cxx.

18 :
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;
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}
unsigned int crate() const
return crate number
unsigned int m_overflowT
Definition CrateEnergy.h:60
static const unsigned int m_sumBits
Definition CrateEnergy.h:66
unsigned int m_overflowY
Definition CrateEnergy.h:62
bool restricted() const
Full or restricted eta range?
unsigned int m_crate
Definition CrateEnergy.h:56
unsigned int m_crateEt
Definition CrateEnergy.h:57
unsigned int m_overflowX
Definition CrateEnergy.h:61
static const unsigned int m_jemEtSaturation
Definition CrateEnergy.h:67
float eT(const U &p)
Accessor utility function for getting the value of Tranverse energy.

◆ CrateEnergy() [2/3]

LVL1::CrateEnergy::CrateEnergy ( unsigned int crate,
const DataVector< EnergyCMXData > * modules,
uint32_t maskXE = 0xff,
uint32_t maskTE = 0xff,
bool restricted = false )

Check crate in range

Added for restricted eta triggers in Run 2

Summing within a crate proceeds as follows:
unsigned 14 bit Ex, Ey, Et sums are formed for each half crate
these sums (= opposite quadrants) are added (Et) or subtracted (Ex, Ey)
to give the crate totals
overflows are propagated using separate bits

Sum ET from modules belonging to this crate in two halves

Check for overflows then truncate quadrant sums

Form crate sums

For total ET we must check for further overflows

Definition at line 97 of file CrateEnergy.cxx.

97 :
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 if (std::in_range<int>(-(mask + 1))) m_crateEx = -(mask + 1);
158 else throw std::out_of_range("m_crateEx set value is out of integer range");
159 }
160 if (!m_overflowY){
161 m_crateEy = eY[0] - eY[1];
162 }else{
163 if (std::in_range<int>(-(mask + 1))) m_crateEy = -(mask + 1);
164 else throw std::out_of_range("m_crateEy set value is out of integer range");
165 }
166
167 if (m_debug) {
168 std::cout << "CrateEnergy: crate " << m_crate << " results "
169 << "\n Et " << m_crateEt << " overflow " << m_overflowT
170 << "\n Ex " << m_crateEx << " overflow " << m_overflowX
171 << "\n Ey " << m_crateEy << " overflow " << m_overflowY << std::endl;
172
173 }
174
175}

◆ CrateEnergy() [3/3]

LVL1::CrateEnergy::CrateEnergy ( unsigned int crate,
unsigned int et,
unsigned int exTC,
unsigned int eyTC,
unsigned int overflowT,
unsigned int overflowX,
unsigned int overflowY,
bool restricted = false )

Check crate in range

Definition at line 177 of file CrateEnergy.cxx.

179 :
180 m_crate(crate),
181 m_crateEt(0),
182 m_crateEx(0),
183 m_crateEy(0),
184 m_overflowT(0),
185 m_overflowX(0),
186 m_overflowY(0),
188 m_debug(false)
189{
191 if (m_crate > 1) return;
192 m_crateEt = et;
195 m_overflowT = overflowT;
196 m_overflowX = overflowX;
197 m_overflowY = overflowY;
198
199 if (m_debug) {
200 std::cout << "CrateEnergy: crate " << m_crate << " results "
201 << "\n Et " << m_crateEt << " overflow " << m_overflowT
202 << "\n Ex " << m_crateEx << " overflow " << m_overflowX
203 << "\n Ey " << m_crateEy << " overflow " << m_overflowY << std::endl;
204
205 }
206}
int et() const
return et, ex, ey sums
int decodeTC(unsigned int input) const
decode 15-bit twos-complement format (hardware Ex/Ey format) as int
unsigned int exTC() const
15 bit twos-complement format
unsigned int eyTC() const
return crate Ey in 15-bit twos-complement format (hardware format)

◆ ~CrateEnergy()

LVL1::CrateEnergy::~CrateEnergy ( )

Definition at line 209 of file CrateEnergy.cxx.

209 {
210}

Member Function Documentation

◆ crate()

unsigned int LVL1::CrateEnergy::crate ( ) const

return crate number

Definition at line 213 of file CrateEnergy.cxx.

213 {
214 return m_crate;
215}

◆ decodeTC()

int LVL1::CrateEnergy::decodeTC ( unsigned int input) const
private

decode 15-bit twos-complement format (hardware Ex/Ey format) as int

Definition at line 278 of file CrateEnergy.cxx.

278 {
279
280 int mask = (1<<m_sumBitsTC) - 1;
281 int value = input&mask;
282
283 if ((value >> (m_sumBitsTC - 1))) {
284 value += (~0U) << m_sumBitsTC;
285 }
286
287 return value;
288}
static const unsigned int m_sumBitsTC
Definition CrateEnergy.h:65

◆ encodeTC()

unsigned int LVL1::CrateEnergy::encodeTC ( int input) const
private

encode int as 15-bit twos-complement format (hardware Ex/Ey format)

Definition at line 263 of file CrateEnergy.cxx.

263 {
264 unsigned int value;
265
266 if (input > 0) {
267 value = input;
268 }
269 else {
270 value = (1<<m_sumBitsTC) + input;
271 }
272
273 int mask = (1<<m_sumBitsTC) - 1;
274 return value&mask ;
275}

◆ et()

int LVL1::CrateEnergy::et ( ) const

return et, ex, ey sums

return crate Et

Definition at line 218 of file CrateEnergy.cxx.

218 {
219 return m_crateEt;
220}

◆ etOverflow()

unsigned int LVL1::CrateEnergy::etOverflow ( ) const

return Et overflow bit

Definition at line 233 of file CrateEnergy.cxx.

233 {
234 return m_overflowT;
235}

◆ ex()

int LVL1::CrateEnergy::ex ( ) const

return crate Ex

Definition at line 223 of file CrateEnergy.cxx.

223 {
224 return m_crateEx;
225}

◆ exOverflow()

unsigned int LVL1::CrateEnergy::exOverflow ( ) const

Overflow bits.

return Ex overflow bit

Definition at line 238 of file CrateEnergy.cxx.

238 {
239 return m_overflowX;
240}

◆ exTC()

unsigned int LVL1::CrateEnergy::exTC ( ) const

15 bit twos-complement format

return crate Ex in 15-bit twos-complement format (hardware format)

Definition at line 253 of file CrateEnergy.cxx.

253 {
254 return encodeTC(m_crateEx);
255}
unsigned int encodeTC(int input) const
encode int as 15-bit twos-complement format (hardware Ex/Ey format)

◆ ey()

int LVL1::CrateEnergy::ey ( ) const

return crate Ey

Definition at line 228 of file CrateEnergy.cxx.

228 {
229 return m_crateEy;
230}

◆ eyOverflow()

unsigned int LVL1::CrateEnergy::eyOverflow ( ) const

return Ey overflow bit

Definition at line 243 of file CrateEnergy.cxx.

243 {
244 return m_overflowY;
245}

◆ eyTC()

unsigned int LVL1::CrateEnergy::eyTC ( ) const

return crate Ey in 15-bit twos-complement format (hardware format)

Definition at line 258 of file CrateEnergy.cxx.

258 {
259 return encodeTC(m_crateEy);
260}

◆ restricted()

bool LVL1::CrateEnergy::restricted ( ) const

Full or restricted eta range?

Full or Restricted eta range.

Definition at line 248 of file CrateEnergy.cxx.

248 {
249 return m_restricted;
250}

Member Data Documentation

◆ m_crate

unsigned int LVL1::CrateEnergy::m_crate
private

Definition at line 56 of file CrateEnergy.h.

◆ m_crateEt

unsigned int LVL1::CrateEnergy::m_crateEt
private

Definition at line 57 of file CrateEnergy.h.

◆ m_crateEx

int LVL1::CrateEnergy::m_crateEx
private

Definition at line 58 of file CrateEnergy.h.

◆ m_crateEy

int LVL1::CrateEnergy::m_crateEy
private

Definition at line 59 of file CrateEnergy.h.

◆ m_debug

bool LVL1::CrateEnergy::m_debug
private

Definition at line 64 of file CrateEnergy.h.

◆ m_jemEtSaturation

const unsigned int LVL1::CrateEnergy::m_jemEtSaturation = 0x3fff
staticprivate

Definition at line 67 of file CrateEnergy.h.

◆ m_overflowT

unsigned int LVL1::CrateEnergy::m_overflowT
private

Definition at line 60 of file CrateEnergy.h.

◆ m_overflowX

unsigned int LVL1::CrateEnergy::m_overflowX
private

Definition at line 61 of file CrateEnergy.h.

◆ m_overflowY

unsigned int LVL1::CrateEnergy::m_overflowY
private

Definition at line 62 of file CrateEnergy.h.

◆ m_restricted

bool LVL1::CrateEnergy::m_restricted
private

Definition at line 63 of file CrateEnergy.h.

◆ m_sumBits

const unsigned int LVL1::CrateEnergy::m_sumBits =14
staticprivate

Definition at line 66 of file CrateEnergy.h.

◆ m_sumBitsTC

const unsigned int LVL1::CrateEnergy::m_sumBitsTC =15
staticprivate

Definition at line 65 of file CrateEnergy.h.


The documentation for this class was generated from the following files: