ATLAS Offline Software
SystemEnergy.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  SystemEnergy.h - description
6  -------------------
7  begin : 06/09/2007
8  email : Alan.Watson@cern.ch
9  ***************************************************************************/
10 
11 
15 
16 using namespace TrigConf;
17 
18 namespace LVL1
19 {
20 
21 SystemEnergy::SystemEnergy(const DataVector<CrateEnergy> *crates, const TrigConf::L1Menu* l1Menu) : 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 
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 
91  etMissTrigger();
92  etSumTrigger();
93  metSigTrigger();
94 }
95 
96 SystemEnergy::SystemEnergy(unsigned int et, unsigned int exTC, unsigned int eyTC,
97  unsigned int overflowT, unsigned int overflowX,
98  unsigned int overflowY, unsigned int restricted,
99  const TrigConf::L1Menu* l1Menu) : 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 
131  etMissTrigger();
132  etSumTrigger();
133  metSigTrigger();
134 }
135 
136 
138 int SystemEnergy::et() const
139 {
140  return m_systemEt;
141 }
142 
144 int SystemEnergy::ex() const
145 {
146  return m_systemEx;
147 }
148 
150 int SystemEnergy::ey() const
151 {
152  return m_systemEy;
153 }
154 
156 unsigned int SystemEnergy::etOverflow() const
157 {
158  return m_overflowT & 0x1;
159 }
160 
162 unsigned int SystemEnergy::exOverflow() const
163 {
164  return m_overflowX & 0x1;
165 }
166 
168 unsigned int SystemEnergy::eyOverflow() const
169 {
170  return m_overflowY & 0x1;
171 }
172 
174 unsigned int SystemEnergy::exTC() const
175 {
176  return encodeTC(m_systemEx);
177 }
178 
180 unsigned int SystemEnergy::eyTC() const
181 {
182  return encodeTC(m_systemEy);
183 }
184 
186 unsigned int SystemEnergy::etMissHits() const
187 {
188  return m_etMissHits;
189 }
190 
192 unsigned int SystemEnergy::etSumHits() const
193 {
194  return m_etSumHits;
195 }
196 
198 unsigned int SystemEnergy::metSigHits() const
199 {
200  return m_metSigHits;
201 }
202 
204 unsigned int SystemEnergy::roiWord0() const
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 }
219 
221 unsigned int SystemEnergy::roiWord1() const
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 }
236 
238 unsigned int SystemEnergy::roiWord2() const
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 }
253 
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::xeType()) {
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 }
300 
303 {
304  // Start cleanly
305  m_etSumHits = 0;
306 
307  // Overflow of any sort automatically fires all thresholds
308  if (m_overflowT != 0 || m_systemEt > m_maxEtSumThr)
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::teType()) {
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 }
349 
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::xsType()) {
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 }
410 
412 unsigned int SystemEnergy::encodeTC(int input) const
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 }
428 
430 int SystemEnergy::decodeTC(unsigned int input) const
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 }
444 
445 } // end of ns
TrigConf::L1Threshold_Calo::thrValuesCounts
virtual ValueWithEtaDependence< unsigned int > thrValuesCounts() const
access to the list of ThresholdValues in energy units
Definition: L1ThresholdBase.cxx:317
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
LVL1::SystemEnergy::exTC
unsigned int exTC() const
15 bit twos-complement format
Definition: SystemEnergy.cxx:174
et
Extra patterns decribing particle interation process.
LVL1::SystemEnergy::etMissHits
unsigned int etMissHits() const
Trigger Results.
Definition: SystemEnergy.cxx:186
LVL1::TrigT1CaloDefs::energyRoI2
@ energyRoI2
Definition: TrigT1CaloDefs.h:198
LVL1::SystemEnergy::metSigHits
unsigned int metSigHits() const
return MEtSig hits
Definition: SystemEnergy.cxx:198
LVL1::SystemEnergy::m_metSigHits
unsigned int m_metSigHits
Definition: SystemEnergy.h:83
LVL1::SystemEnergy::m_etMissHits
unsigned int m_etMissHits
Definition: SystemEnergy.h:81
physval_make_web_display.thresh
thresh
Definition: physval_make_web_display.py:36
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
LVL1::CrateEnergy
CrateEnergy class declaration Simulates behaviour of the Crate-CMM System CMM logic is done in Energy...
Definition: CrateEnergy.h:34
LVL1::SystemEnergy::roiWord0
unsigned int roiWord0() const
RoI words.
Definition: SystemEnergy.cxx:204
TrigConf::L1Menu::thrExtraInfo
const L1ThrExtraInfo & thrExtraInfo() const
Access to extra info for threshold types.
Definition: L1Menu.cxx:307
LVL1::SystemEnergy::etMissTrigger
void etMissTrigger()
Test Ex, Ey sums against ETmiss thresholds Regrettably not as simple as it sounds if we emulate har...
Definition: SystemEnergy.cxx:257
LVL1::SystemEnergy::eyTC
unsigned int eyTC() const
return crate Ey in 15-bit twos-complement format (hardware format)
Definition: SystemEnergy.cxx:180
athena.value
value
Definition: athena.py:124
TrigConf::L1Menu
L1 menu configuration.
Definition: L1Menu.h:28
LVL1::SystemEnergy::m_debug
bool m_debug
Definition: SystemEnergy.h:88
LVL1::SystemEnergy::m_etSumHits
unsigned int m_etSumHits
Definition: SystemEnergy.h:82
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::SystemEnergy::m_systemEx
int m_systemEx
Definition: SystemEnergy.h:74
LVL1::SystemEnergy::ex
int ex() const
return crate Ex
Definition: SystemEnergy.cxx:144
LVL1::SystemEnergy::roiWord2
unsigned int roiWord2() const
return RoI word 2 (Et value & overflow, EtMiss hits)
Definition: SystemEnergy.cxx:238
LVL1::SystemEnergy::etSumTrigger
void etSumTrigger()
Test Et sum against ETsum thresholds.
Definition: SystemEnergy.cxx:302
TrigConf::L1Threshold_Calo
Definition: L1ThresholdBase.h:188
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition: Config.h:22
LVL1::SystemEnergy::encodeTC
unsigned int encodeTC(int input) const
encode int as 15-bit twos-complement format (hardware Ex/Ey format)
Definition: SystemEnergy.cxx:412
LVL1::SystemEnergy::decodeTC
int decodeTC(unsigned int input) const
decode 15-bit twos-complement format (hardware Ex/Ey format) as int
Definition: SystemEnergy.cxx:430
LVL1::SystemEnergy::exOverflow
unsigned int exOverflow() const
Overflow bits.
Definition: SystemEnergy.cxx:162
LVL1::SystemEnergy::m_etSumOverflow
static const int m_etSumOverflow
Definition: SystemEnergy.h:87
LVL1::TrigT1CaloDefs::energyRoI1
@ energyRoI1
Definition: TrigT1CaloDefs.h:197
TrigConf::L1Threshold_Calo::thrValueCounts
virtual unsigned int thrValueCounts(int eta=0) const
Definition: L1ThresholdBase.cxx:278
LVL1::SystemEnergy::etSumHits
unsigned int etSumHits() const
return EtSum hits
Definition: SystemEnergy.cxx:192
LVL1::SystemEnergy::etOverflow
unsigned int etOverflow() const
return Et overflow bit
Definition: SystemEnergy.cxx:156
LVL1::SystemEnergy::m_sumBits
static const unsigned int m_sumBits
Definition: SystemEnergy.h:85
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
LVL1::SystemEnergy::et
int et() const
return global et, ex, ey sums
Definition: SystemEnergy.cxx:138
TrigConf::L1Menu::thresholds
std::vector< std::shared_ptr< TrigConf::L1Threshold > > thresholds() const
Access to list of all L1Thresholds.
Definition: L1Menu.cxx:267
LVL1::SystemEnergy::roiWord1
unsigned int roiWord1() const
return RoI word 1 (Ey value & overflow, EtSum hits)
Definition: SystemEnergy.cxx:221
LVL1::TrigT1CaloDefs::energyRoIType
@ energyRoIType
Definition: TrigT1CaloDefs.h:181
LVL1::SystemEnergy::m_etMissQ
uint32_t m_etMissQ
Definition: SystemEnergy.h:84
LVL1::TrigT1CaloDefs::numOfSumEtThresholds
static const unsigned int numOfSumEtThresholds
Definition: TrigT1CaloDefs.h:129
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
Scale
void Scale(TH1 *h, double d=1)
Definition: comparitor.cxx:77
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
LVL1::SystemEnergy::m_systemEt
int m_systemEt
Definition: SystemEnergy.h:76
LVL1::SystemEnergy::m_overflowT
unsigned int m_overflowT
Definition: SystemEnergy.h:79
LVL1::SystemEnergy::m_maxEtSumThr
static const int m_maxEtSumThr
Definition: SystemEnergy.h:86
LVL1::SystemEnergy::m_overflowY
unsigned int m_overflowY
Definition: SystemEnergy.h:78
LVL1::SystemEnergy::m_systemEy
int m_systemEy
Definition: SystemEnergy.h:75
TrigT1CaloDefs.h
L1DataDef.h
TrigConf::ValueWithEtaDependence::addRangeValue
void addRangeValue(const T &value, int etaMin, int etaMax, unsigned int priority, bool symmetric=true)
LVL1::SystemEnergy::eyOverflow
unsigned int eyOverflow() const
return Ey overflow bit
Definition: SystemEnergy.cxx:168
LVL1::TrigT1CaloDefs::energyRoI0
@ energyRoI0
Definition: TrigT1CaloDefs.h:196
TSU::complement
T complement(const T &v, const unsigned int &p)
Definition: L1TopoDataTypes.cxx:18
LVL1::SystemEnergy::SystemEnergy
SystemEnergy(const DataVector< CrateEnergy > *crates, const TrigConf::L1Menu *l1Menu)
Definition: SystemEnergy.cxx:21
TrigConf::L1ThrExtraInfo::XS
const L1ThrExtraInfo_XSLegacy & XS() const
Definition: L1ThrExtraInfo.cxx:113
LVL1::SystemEnergy::m_L1Menu
const TrigConf::L1Menu * m_L1Menu
Definition: SystemEnergy.h:72
LVL1::TrigT1CaloDefs::numOfMEtSigThresholds
static const unsigned int numOfMEtSigThresholds
Definition: TrigT1CaloDefs.h:130
LVL1::SystemEnergy::m_restricted
unsigned int m_restricted
Definition: SystemEnergy.h:80
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
SystemEnergy.h
LVL1::TrigT1CaloDefs::numOfMissingEtThresholds
static const unsigned int numOfMissingEtThresholds
Definition: TrigT1CaloDefs.h:128
LVL1::SystemEnergy::metSigTrigger
void metSigTrigger()
Test MEt Significance against METSig thresholds.
Definition: SystemEnergy.cxx:351
LVL1::SystemEnergy::ey
int ey() const
return crate Ey
Definition: SystemEnergy.cxx:150
LVL1::SystemEnergy::m_overflowX
unsigned int m_overflowX
Definition: SystemEnergy.h:77