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

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

#include <SystemEnergy.h>

Collaboration diagram for LVL1::SystemEnergy:

Public Member Functions

 SystemEnergy (const DataVector< CrateEnergy > *crates, const TrigConf::L1Menu *l1Menu)
 SystemEnergy (unsigned int et, unsigned int exTC, unsigned int eyTC, unsigned int overflowT, unsigned int overflowX, unsigned int overflowY, unsigned int restricted, const TrigConf::L1Menu *l1Menu)
 ~SystemEnergy ()=default
int et () const
 return global 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
unsigned int etMissHits () const
 Trigger Results.
unsigned int etSumHits () const
 return EtSum hits
unsigned int metSigHits () const
 return MEtSig hits
unsigned int roiWord0 () const
 RoI words.
unsigned int roiWord1 () const
 return RoI word 1 (Ey value & overflow, EtSum hits)
unsigned int roiWord2 () const
 return RoI word 2 (Et value & overflow, EtMiss hits)

Private Member Functions

void etMissTrigger ()
 Test Ex, Ey sums against ETmiss thresholds
Regrettably not as simple as it sounds if we emulate hardware!
void etSumTrigger ()
 Test Et sum against ETsum thresholds.
void metSigTrigger ()
 Test MEt Significance against METSig thresholds.
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

const TrigConf::L1Menum_L1Menu
int m_systemEx
int m_systemEy
int m_systemEt
unsigned int m_overflowX
unsigned int m_overflowY
unsigned int m_overflowT
unsigned int m_restricted
unsigned int m_etMissHits
unsigned int m_etSumHits
unsigned int m_metSigHits
uint32_t m_etMissQ
bool m_debug

Static Private Attributes

static const unsigned int m_sumBits =15
static const int m_maxEtSumThr =0x3fff
static const int m_etSumOverflow =0x7fff

Detailed Description

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

Definition at line 30 of file SystemEnergy.h.

Constructor & Destructor Documentation

◆ SystemEnergy() [1/2]

LVL1::SystemEnergy::SystemEnergy ( const DataVector< CrateEnergy > * crates,
const TrigConf::L1Menu * l1Menu )

Get Ex, Ey, ET sums from crates and form global sums
Propagate overflows and test for new ones

Check for EtSum overflow

Having completed sums, we can now compare with thresholds

Definition at line 21 of file SystemEnergy.cxx.

21 : m_L1Menu(l1Menu),
22 m_systemEx(0),
23 m_systemEy(0),
24 m_systemEt(0),
25 m_overflowX(0),
26 m_overflowY(0),
27 m_overflowT(0),
28 m_restricted(0),
29 m_etMissHits(0),
30 m_etSumHits(0),
31 m_metSigHits(0),
32 m_debug(false)
33{
34
35 int xyMax = 1 << (m_sumBits - 1);
36
39
40 for (const CrateEnergy* cr : *crates)
41 {
42 if (cr->crate() == 0)
43 {
44 m_systemEx += cr->ex();
45 m_systemEy += cr->ey();
46 m_systemEt += cr->et();
47 }
48 else if (cr->crate() == 1)
49 {
50 m_systemEx -= cr->ex();
51 m_systemEy += cr->ey();
52 m_systemEt += cr->et();
53 }
54
55 m_overflowX = m_overflowX | (cr->ex() == -xyMax);
56 m_overflowY = m_overflowY | (cr->ey() == -xyMax);
57 m_overflowT = m_overflowT | (cr->et() == m_maxEtSumThr);
58
59 if (cr->restricted())
60 m_restricted = 1;
61 }
62
64 if (m_overflowT != 0) {
66 }
67
68
69
70 if ((abs(m_systemEx) >= xyMax) || m_overflowX)
71 {
72 m_overflowX = 1;
73 m_systemEx = -xyMax;
74 }
75
76 if ((abs(m_systemEy) >= xyMax) || m_overflowY)
77 {
78 m_overflowY = 1;
79 m_systemEy = -xyMax;
80 }
81
82 if (m_debug)
83 {
84 std::cout << "SystemEnergy results: " << std::endl
85 << " Et " << m_systemEt << " overflow " << m_overflowT << std::endl
86 << " Ex " << m_systemEx << " overflow " << m_overflowX << std::endl
87 << " Ey " << m_systemEy << " overflow " << m_overflowY << std::endl;
88 }
89
94}
unsigned int m_metSigHits
void etMissTrigger()
Test Ex, Ey sums against ETmiss thresholds Regrettably not as simple as it sounds if we emulate har...
unsigned int m_restricted
unsigned int m_etMissHits
static const unsigned int m_sumBits
unsigned int m_overflowT
void metSigTrigger()
Test MEt Significance against METSig thresholds.
const TrigConf::L1Menu * m_L1Menu
void etSumTrigger()
Test Et sum against ETsum thresholds.
unsigned int m_overflowX
unsigned int m_etSumHits
static const int m_maxEtSumThr
unsigned int m_overflowY
static const int m_etSumOverflow

◆ SystemEnergy() [2/2]

LVL1::SystemEnergy::SystemEnergy ( unsigned int et,
unsigned int exTC,
unsigned int eyTC,
unsigned int overflowT,
unsigned int overflowX,
unsigned int overflowY,
unsigned int restricted,
const TrigConf::L1Menu * l1Menu )

Having completed sums, we can now compare with thresholds

Definition at line 96 of file SystemEnergy.cxx.

99 : m_L1Menu(l1Menu),
100 m_systemEx(0),
101 m_systemEy(0),
102 m_systemEt(et),
103 m_overflowX(overflowX),
104 m_overflowY(overflowY),
105 m_overflowT(overflowT),
106 m_restricted(restricted),
107 m_etMissHits(0),
108 m_etSumHits(0),
109 m_metSigHits(0),
110 m_debug(false)
111{
112
115
116 int xyMax = 1 << (m_sumBits - 1);
117
119 m_overflowX = m_systemEx == -xyMax;
120 m_overflowY = m_systemEy == -xyMax;
121
122 if (m_debug)
123 {
124 std::cout << "SystemEnergy results: " << std::endl
125 << " Et " << m_systemEt << " overflow " << m_overflowT << std::endl
126 << " Ex " << m_systemEx << " overflow " << m_overflowX << std::endl
127 << " Ey " << m_systemEy << " overflow " << m_overflowY << std::endl;
128 }
129
132 etSumTrigger();
134}
int decodeTC(unsigned int input) const
decode 15-bit twos-complement format (hardware Ex/Ey format) as int
unsigned int eyTC() const
return crate Ey in 15-bit twos-complement format (hardware format)
unsigned int exTC() const
15 bit twos-complement format
int et() const
return global et, ex, ey sums

◆ ~SystemEnergy()

LVL1::SystemEnergy::~SystemEnergy ( )
default

Member Function Documentation

◆ decodeTC()

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

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

Definition at line 430 of file SystemEnergy.cxx.

431{
432
433 int mask = (1 << m_sumBits) - 1;
434 int value = input & mask;
435
436 if ((value >> (m_sumBits - 1)))
437 {
438 int complement = ~value;
439 value = -((complement + 1) & mask);
440 }
441
442 return value;
443}
T complement(const T &v, const unsigned int &p)

◆ encodeTC()

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

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

Definition at line 412 of file SystemEnergy.cxx.

413{
414 unsigned int value;
415
416 if (input > 0)
417 {
418 value = input;
419 }
420 else
421 {
422 value = (1 << m_sumBits) + input;
423 }
424
425 int mask = (1 << m_sumBits) - 1;
426 return value & mask;
427}

◆ et()

int LVL1::SystemEnergy::et ( ) const

return global et, ex, ey sums

return crate Et

Definition at line 138 of file SystemEnergy.cxx.

139{
140 return m_systemEt;
141}

◆ etMissHits()

unsigned int LVL1::SystemEnergy::etMissHits ( ) const

Trigger Results.

return EtMiss hits

Definition at line 186 of file SystemEnergy.cxx.

187{
188 return m_etMissHits;
189}

◆ etMissTrigger()

void LVL1::SystemEnergy::etMissTrigger ( )
private

Test Ex, Ey sums against ETmiss thresholds
Regrettably not as simple as it sounds if we emulate hardware!


See CMM specificiation from L1Calo web pages for details

Start cleanly

Calculate MET^2

Ex or Ey overflow automatically fires all thresholds

Otherwise see which thresholds were passed

Definition at line 257 of file SystemEnergy.cxx.

258{
260 m_etMissHits = 0;
261
264
266 if ((m_overflowX != 0) || (m_overflowY != 0))
267 {
269 return;
270 }
271
273
274 // Get thresholds
275 std::vector<std::shared_ptr<TrigConf::L1Threshold>> allThresholds = m_L1Menu->thresholds();
276
277 // get Threshold values and test
278
279 for ( const auto& thresh : allThresholds ) {
280 if ( thresh->type() == L1DataDef::typeAsString(L1DataDef::XE) ) {
281 auto thresh_Calo = static_cast<const TrigConf::L1Threshold_Calo*>(thresh.get());
282 unsigned int thresholdValue = thresh_Calo->thrValueCounts();
283 uint32_t tvQ = thresholdValue * thresholdValue;
284 int threshNumber = thresh->mapping();
285 if (m_restricted == 0 && threshNumber < 8)
286 {
287 if (m_etMissQ > tvQ)
288 m_etMissHits = m_etMissHits | (1 << threshNumber);
289 }
290 else if (m_restricted != 0 && threshNumber >= 8)
291 {
292 if (m_etMissQ > tvQ)
293 m_etMissHits = m_etMissHits | (1 << (threshNumber - 8));
294 }
295 }
296 }
297
298 return;
299}
static const unsigned int numOfMissingEtThresholds
static std::string & typeAsString(TriggerType tt)
Definition L1DataDef.h:53
setEventNumber uint32_t

◆ etOverflow()

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

return Et overflow bit

Definition at line 156 of file SystemEnergy.cxx.

157{
158 return m_overflowT & 0x1;
159}

◆ etSumHits()

unsigned int LVL1::SystemEnergy::etSumHits ( ) const

return EtSum hits

Definition at line 192 of file SystemEnergy.cxx.

193{
194 return m_etSumHits;
195}

◆ etSumTrigger()

void LVL1::SystemEnergy::etSumTrigger ( )
private

Test Et sum against ETsum thresholds.

Definition at line 302 of file SystemEnergy.cxx.

303{
304 // Start cleanly
305 m_etSumHits = 0;
306
307 // Overflow of any sort automatically fires all thresholds
309 {
311 return;
312 }
313
314 // Get thresholds
315 std::vector<std::shared_ptr<TrigConf::L1Threshold>> allThresholds = m_L1Menu->thresholds();
316
317 // get Threshold values and test
318 // Since eta-dependent values are being used to disable TE in regions, must find lowest value for each threshold
319 for ( const auto& thresh : allThresholds ) {
320 if ( thresh->type() == L1DataDef::typeAsString(L1DataDef::TE) ) {
321 int threshNumber = thresh->mapping();
322 int thresholdValue = m_maxEtSumThr;
323 auto thresh_Calo = static_cast<const TrigConf::L1Threshold_Calo*>(thresh.get());
324 auto tvcs = thresh_Calo->thrValuesCounts();
325 if (tvcs.size() == 0) {
326 tvcs.addRangeValue(thresh_Calo->thrValueCounts(),-49, 49, 1, true);
327 }
328 for (const auto& tVC : tvcs) {
329 if (static_cast<int>(tVC.value()) < thresholdValue) {
330 thresholdValue = tVC.value();
331 }
332 }
333
334 if (m_restricted == 0 && threshNumber < 8)
335 {
336 if (static_cast<int>(m_systemEt) > thresholdValue)
337 m_etSumHits = m_etSumHits | (1 << threshNumber);
338 }
339 else if (m_restricted != 0 && threshNumber >= 8)
340 {
341 if (static_cast<int>(m_systemEt) > thresholdValue)
342 m_etSumHits = m_etSumHits | (1 << (threshNumber - 8));
343 }
344 }
345 }
346
347 return;
348}
static const unsigned int numOfSumEtThresholds

◆ ex()

int LVL1::SystemEnergy::ex ( ) const

return crate Ex

Definition at line 144 of file SystemEnergy.cxx.

145{
146 return m_systemEx;
147}

◆ exOverflow()

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

Overflow bits.

return Ex overflow bit

Definition at line 162 of file SystemEnergy.cxx.

163{
164 return m_overflowX & 0x1;
165}

◆ exTC()

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

15 bit twos-complement format

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

Definition at line 174 of file SystemEnergy.cxx.

175{
176 return encodeTC(m_systemEx);
177}
unsigned int encodeTC(int input) const
encode int as 15-bit twos-complement format (hardware Ex/Ey format)

◆ ey()

int LVL1::SystemEnergy::ey ( ) const

return crate Ey

Definition at line 150 of file SystemEnergy.cxx.

151{
152 return m_systemEy;
153}

◆ eyOverflow()

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

return Ey overflow bit

Definition at line 168 of file SystemEnergy.cxx.

169{
170 return m_overflowY & 0x1;
171}

◆ eyTC()

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

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

Definition at line 180 of file SystemEnergy.cxx.

181{
182 return encodeTC(m_systemEy);
183}

◆ metSigHits()

unsigned int LVL1::SystemEnergy::metSigHits ( ) const

return MEtSig hits

Definition at line 198 of file SystemEnergy.cxx.

199{
200 return m_metSigHits;
201}

◆ metSigTrigger()

void LVL1::SystemEnergy::metSigTrigger ( )
private

Test MEt Significance against METSig thresholds.

Start cleanly

No restricted eta MET significance trigger

Obtain parameters from configuration service

Start with overflow and range checks

Perform threshold tests. Emulate firmware logic for this, so don't explicitly calculate XS Prepare factors we wil re-use for each threshold. Scale bQ to hardware precision

get Threshold values and test aQTiQ has to be scaled to hardware precision after product formed

Definition at line 351 of file SystemEnergy.cxx.

352{
354 m_metSigHits = 0;
355
357 if (m_restricted != 0)
358 return;
359
361 auto& params = m_L1Menu->thrExtraInfo().XS();
362 unsigned int Scale = params.xsSigmaScale();
363 unsigned int Offset = params.xsSigmaOffset();
364 unsigned int XEmin = params.xeMin();
365 unsigned int XEmax = params.xeMax();
366 int sqrtTEmin = params.teSqrtMin();
367 int sqrtTEmax = params.teSqrtMax();
368
370 if ((m_overflowX > 0) || (m_overflowY > 0) || (m_etMissQ > XEmax * XEmax))
371 {
373 return;
374 }
375 else if ((m_etMissQ < XEmin * XEmin) || (m_systemEt < sqrtTEmin * sqrtTEmin) || (m_systemEt > sqrtTEmax * sqrtTEmax))
376 {
377 return;
378 }
379
383 unsigned long aQ = Scale * Scale;
384 unsigned int bQ = ceil(Offset * Offset * 1.e-6);
385 unsigned long fourbQTE = 4 * bQ * m_systemEt;
386
387 // Get thresholds
388 std::vector<std::shared_ptr<TrigConf::L1Threshold>> allThresholds = m_L1Menu->thresholds();
389
392 for ( const auto& thresh : allThresholds ) {
393 if ( thresh->type() == L1DataDef::typeAsString(L1DataDef::XS) ) {
394
395 int threshNumber = thresh->mapping();
396 auto thresh_Calo = static_cast<const TrigConf::L1Threshold_Calo*>(thresh.get());
397 unsigned int Ti = thresh_Calo->thrValueCounts();
398 unsigned long aQTiQ = (0.5 + double(aQ * 1.e-8) * Ti * Ti);
399
400 long left = aQTiQ * aQTiQ * fourbQTE;
401 long right = aQTiQ * (m_systemEt + bQ) - m_etMissQ;
402
403 if (right < 0 || left > right * right)
404 m_metSigHits = m_metSigHits | (1 << threshNumber);
405 }
406 }
407
408 return;
409}
static const unsigned int numOfMEtSigThresholds
void Scale(TH1 *h, double d=1)

◆ roiWord0()

unsigned int LVL1::SystemEnergy::roiWord0 ( ) const

RoI words.

return RoI word 0 (Ex value & overflow)

Definition at line 204 of file SystemEnergy.cxx.

205{
206 // Start by setting up header
207 unsigned int word = TrigT1CaloDefs::energyRoIType << 30;
208 word += TrigT1CaloDefs::energyRoI0 << 28;
209 // set full/restricted eta range flag
210 word += (m_restricted & 1) << 26;
211 // add MET Significance hits
212 word += metSigHits() << 16;
213 // add Ex overflow bit
214 word += exOverflow() << 15;
215 // add Ex value (twos-complement)
216 word += exTC();
217 return word;
218}
unsigned int exOverflow() const
Overflow bits.
unsigned int metSigHits() const
return MEtSig hits

◆ roiWord1()

unsigned int LVL1::SystemEnergy::roiWord1 ( ) const

return RoI word 1 (Ey value & overflow, EtSum hits)

Definition at line 221 of file SystemEnergy.cxx.

222{
223 // Start by setting up header
224 unsigned int word = TrigT1CaloDefs::energyRoIType << 30;
225 word += TrigT1CaloDefs::energyRoI1 << 28;
226 // set full/restricted eta range flag
227 word += (m_restricted & 1) << 26;
228 // add EtSum hits
229 word += etSumHits() << 16;
230 // add Ey overflow bit
231 word += eyOverflow() << 15;
232 // add Ey value (twos-complement)
233 word += eyTC();
234 return word;
235}
unsigned int etSumHits() const
return EtSum hits
unsigned int eyOverflow() const
return Ey overflow bit

◆ roiWord2()

unsigned int LVL1::SystemEnergy::roiWord2 ( ) const

return RoI word 2 (Et value & overflow, EtMiss hits)

Definition at line 238 of file SystemEnergy.cxx.

239{
240 // Start by setting up header
241 unsigned int word = TrigT1CaloDefs::energyRoIType << 30;
242 word += TrigT1CaloDefs::energyRoI2 << 28;
243 // set full/restricted eta range flag
244 word += (m_restricted & 1) << 26;
245 // add EtMiss hits
246 word += etMissHits() << 16;
247 // add Et overflow bit
248 word += etOverflow() << 15;
249 // add Et value (unsigned)
250 word += et();
251 return word;
252}
unsigned int etOverflow() const
return Et overflow bit
unsigned int etMissHits() const
Trigger Results.

Member Data Documentation

◆ m_debug

bool LVL1::SystemEnergy::m_debug
private

Definition at line 78 of file SystemEnergy.h.

◆ m_etMissHits

unsigned int LVL1::SystemEnergy::m_etMissHits
private

Definition at line 71 of file SystemEnergy.h.

◆ m_etMissQ

uint32_t LVL1::SystemEnergy::m_etMissQ
private

Definition at line 74 of file SystemEnergy.h.

◆ m_etSumHits

unsigned int LVL1::SystemEnergy::m_etSumHits
private

Definition at line 72 of file SystemEnergy.h.

◆ m_etSumOverflow

const int LVL1::SystemEnergy::m_etSumOverflow =0x7fff
staticprivate

Definition at line 77 of file SystemEnergy.h.

◆ m_L1Menu

const TrigConf::L1Menu* LVL1::SystemEnergy::m_L1Menu
private

Definition at line 62 of file SystemEnergy.h.

◆ m_maxEtSumThr

const int LVL1::SystemEnergy::m_maxEtSumThr =0x3fff
staticprivate

Definition at line 76 of file SystemEnergy.h.

◆ m_metSigHits

unsigned int LVL1::SystemEnergy::m_metSigHits
private

Definition at line 73 of file SystemEnergy.h.

◆ m_overflowT

unsigned int LVL1::SystemEnergy::m_overflowT
private

Definition at line 69 of file SystemEnergy.h.

◆ m_overflowX

unsigned int LVL1::SystemEnergy::m_overflowX
private

Definition at line 67 of file SystemEnergy.h.

◆ m_overflowY

unsigned int LVL1::SystemEnergy::m_overflowY
private

Definition at line 68 of file SystemEnergy.h.

◆ m_restricted

unsigned int LVL1::SystemEnergy::m_restricted
private

Definition at line 70 of file SystemEnergy.h.

◆ m_sumBits

const unsigned int LVL1::SystemEnergy::m_sumBits =15
staticprivate

Definition at line 75 of file SystemEnergy.h.

◆ m_systemEt

int LVL1::SystemEnergy::m_systemEt
private

Definition at line 66 of file SystemEnergy.h.

◆ m_systemEx

int LVL1::SystemEnergy::m_systemEx
private

Definition at line 64 of file SystemEnergy.h.

◆ m_systemEy

int LVL1::SystemEnergy::m_systemEy
private

Definition at line 65 of file SystemEnergy.h.


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