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 
137 {
138 }
139 
141 int SystemEnergy::et() const
142 {
143  return m_systemEt;
144 }
145 
147 int SystemEnergy::ex() const
148 {
149  return m_systemEx;
150 }
151 
153 int SystemEnergy::ey() const
154 {
155  return m_systemEy;
156 }
157 
159 unsigned int SystemEnergy::etOverflow() const
160 {
161  return m_overflowT & 0x1;
162 }
163 
165 unsigned int SystemEnergy::exOverflow() const
166 {
167  return m_overflowX & 0x1;
168 }
169 
171 unsigned int SystemEnergy::eyOverflow() const
172 {
173  return m_overflowY & 0x1;
174 }
175 
177 unsigned int SystemEnergy::exTC() const
178 {
179  return encodeTC(m_systemEx);
180 }
181 
183 unsigned int SystemEnergy::eyTC() const
184 {
185  return encodeTC(m_systemEy);
186 }
187 
189 unsigned int SystemEnergy::etMissHits() const
190 {
191  return m_etMissHits;
192 }
193 
195 unsigned int SystemEnergy::etSumHits() const
196 {
197  return m_etSumHits;
198 }
199 
201 unsigned int SystemEnergy::metSigHits() const
202 {
203  return m_metSigHits;
204 }
205 
207 unsigned int SystemEnergy::roiWord0() const
208 {
209  // Start by setting up header
210  unsigned int word = TrigT1CaloDefs::energyRoIType << 30;
211  word += TrigT1CaloDefs::energyRoI0 << 28;
212  // set full/restricted eta range flag
213  word += (m_restricted & 1) << 26;
214  // add MET Significance hits
215  word += metSigHits() << 16;
216  // add Ex overflow bit
217  word += exOverflow() << 15;
218  // add Ex value (twos-complement)
219  word += exTC();
220  return word;
221 }
222 
224 unsigned int SystemEnergy::roiWord1() const
225 {
226  // Start by setting up header
227  unsigned int word = TrigT1CaloDefs::energyRoIType << 30;
228  word += TrigT1CaloDefs::energyRoI1 << 28;
229  // set full/restricted eta range flag
230  word += (m_restricted & 1) << 26;
231  // add EtSum hits
232  word += etSumHits() << 16;
233  // add Ey overflow bit
234  word += eyOverflow() << 15;
235  // add Ey value (twos-complement)
236  word += eyTC();
237  return word;
238 }
239 
241 unsigned int SystemEnergy::roiWord2() const
242 {
243  // Start by setting up header
244  unsigned int word = TrigT1CaloDefs::energyRoIType << 30;
245  word += TrigT1CaloDefs::energyRoI2 << 28;
246  // set full/restricted eta range flag
247  word += (m_restricted & 1) << 26;
248  // add EtMiss hits
249  word += etMissHits() << 16;
250  // add Et overflow bit
251  word += etOverflow() << 15;
252  // add Et value (unsigned)
253  word += et();
254  return word;
255 }
256 
261 {
263  m_etMissHits = 0;
264 
267 
269  if ((m_overflowX != 0) || (m_overflowY != 0))
270  {
272  return;
273  }
274 
276 
277  // Get thresholds
278  std::vector<std::shared_ptr<TrigConf::L1Threshold>> allThresholds = m_L1Menu->thresholds();
279 
280  // get Threshold values and test
281 
282  for ( const auto& thresh : allThresholds ) {
283  if ( thresh->type() == L1DataDef::xeType()) {
284  std::shared_ptr<TrigConf::L1Threshold_Calo> thresh_Calo = std::static_pointer_cast<TrigConf::L1Threshold_Calo>(thresh);
285  unsigned int thresholdValue = thresh_Calo->thrValueCounts();
286  uint32_t tvQ = thresholdValue * thresholdValue;
287  int threshNumber = thresh->mapping();
288  if (m_restricted == 0 && threshNumber < 8)
289  {
290  if (m_etMissQ > tvQ)
291  m_etMissHits = m_etMissHits | (1 << threshNumber);
292  }
293  else if (m_restricted != 0 && threshNumber >= 8)
294  {
295  if (m_etMissQ > tvQ)
296  m_etMissHits = m_etMissHits | (1 << (threshNumber - 8));
297  }
298  }
299  }
300 
301  return;
302 }
303 
306 {
307  // Start cleanly
308  m_etSumHits = 0;
309 
310  // Overflow of any sort automatically fires all thresholds
311  if (m_overflowT != 0 || m_systemEt > m_maxEtSumThr)
312  {
314  return;
315  }
316 
317  // Get thresholds
318  std::vector<std::shared_ptr<TrigConf::L1Threshold>> allThresholds = m_L1Menu->thresholds();
319 
320  // get Threshold values and test
321  // Since eta-dependent values are being used to disable TE in regions, must find lowest value for each threshold
322  for ( const auto& thresh : allThresholds ) {
323  if ( thresh->type() == L1DataDef::teType()) {
324  int threshNumber = thresh->mapping();
325  int thresholdValue = m_maxEtSumThr;
326  std::shared_ptr<TrigConf::L1Threshold_Calo> thresh_Calo = std::static_pointer_cast<TrigConf::L1Threshold_Calo>(thresh);
327  auto tvcs = thresh_Calo->thrValuesCounts();
328  if (tvcs.size() == 0) {
329  tvcs.addRangeValue(thresh_Calo->thrValueCounts(),-49, 49, 1, true);
330  }
331  for (const auto& tVC : tvcs) {
332  if (static_cast<int>(tVC.value()) < thresholdValue) {
333  thresholdValue = tVC.value();
334  }
335  }
336 
337  if (m_restricted == 0 && threshNumber < 8)
338  {
339  if (static_cast<int>(m_systemEt) > thresholdValue)
340  m_etSumHits = m_etSumHits | (1 << threshNumber);
341  }
342  else if (m_restricted != 0 && threshNumber >= 8)
343  {
344  if (static_cast<int>(m_systemEt) > thresholdValue)
345  m_etSumHits = m_etSumHits | (1 << (threshNumber - 8));
346  }
347  }
348  }
349 
350  return;
351 }
352 
355 {
357  m_metSigHits = 0;
358 
360  if (m_restricted != 0)
361  return;
362 
364  auto& params = m_L1Menu->thrExtraInfo().XS();
365  unsigned int Scale = params.xsSigmaScale();
366  unsigned int Offset = params.xsSigmaOffset();
367  unsigned int XEmin = params.xeMin();
368  unsigned int XEmax = params.xeMax();
369  int sqrtTEmin = params.teSqrtMin();
370  int sqrtTEmax = params.teSqrtMax();
371 
373  if ((m_overflowX > 0) || (m_overflowY > 0) || (m_etMissQ > XEmax * XEmax))
374  {
376  return;
377  }
378  else if ((m_etMissQ < XEmin * XEmin) || (m_systemEt < sqrtTEmin * sqrtTEmin) || (m_systemEt > sqrtTEmax * sqrtTEmax))
379  {
380  return;
381  }
382 
386  unsigned long aQ = Scale * Scale;
387  unsigned int bQ = ceil(Offset * Offset * 1.e-6);
388  unsigned long fourbQTE = 4 * bQ * m_systemEt;
389 
390  // Get thresholds
391  std::vector<std::shared_ptr<TrigConf::L1Threshold>> allThresholds = m_L1Menu->thresholds();
392 
395  for ( const auto& thresh : allThresholds ) {
396  if ( thresh->type() == L1DataDef::xsType()) {
397 
398  int threshNumber = thresh->mapping();
399  std::shared_ptr<TrigConf::L1Threshold_Calo> thresh_Calo = std::static_pointer_cast<TrigConf::L1Threshold_Calo>(thresh);
400  unsigned int Ti = thresh_Calo->thrValueCounts();
401  unsigned long aQTiQ = (0.5 + double(aQ * 1.e-8) * Ti * Ti);
402 
403  long left = aQTiQ * aQTiQ * fourbQTE;
404  long right = aQTiQ * (m_systemEt + bQ) - m_etMissQ;
405 
406  if (right < 0 || left > right * right)
407  m_metSigHits = m_metSigHits | (1 << threshNumber);
408  }
409  }
410 
411  return;
412 }
413 
415 unsigned int SystemEnergy::encodeTC(int input) const
416 {
417  unsigned int value;
418 
419  if (input > 0)
420  {
421  value = input;
422  }
423  else
424  {
425  value = (1 << m_sumBits) + input;
426  }
427 
428  int mask = (1 << m_sumBits) - 1;
429  return value & mask;
430 }
431 
433 int SystemEnergy::decodeTC(unsigned int input) const
434 {
435 
436  int mask = (1 << m_sumBits) - 1;
437  int value = input & mask;
438 
439  if ((value >> (m_sumBits - 1)))
440  {
441  int complement = ~value;
442  value = -((complement + 1) & mask);
443  }
444 
445  return value;
446 }
447 
448 } // 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
LVL1::SystemEnergy::exTC
unsigned int exTC() const
15 bit twos-complement format
Definition: SystemEnergy.cxx:177
et
Extra patterns decribing particle interation process.
LVL1::SystemEnergy::etMissHits
unsigned int etMissHits() const
Trigger Results.
Definition: SystemEnergy.cxx:189
LVL1::TrigT1CaloDefs::energyRoI2
@ energyRoI2
Definition: TrigT1CaloDefs.h:197
LVL1::SystemEnergy::metSigHits
unsigned int metSigHits() const
return MEtSig hits
Definition: SystemEnergy.cxx:201
LVL1::SystemEnergy::m_metSigHits
unsigned int m_metSigHits
Definition: SystemEnergy.h:83
LVL1::SystemEnergy::m_etMissHits
unsigned int m_etMissHits
Definition: SystemEnergy.h:81
LVL1::SystemEnergy::~SystemEnergy
~SystemEnergy()
Definition: SystemEnergy.cxx:136
physval_make_web_display.thresh
thresh
Definition: physval_make_web_display.py:35
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:207
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:260
LVL1::SystemEnergy::eyTC
unsigned int eyTC() const
return crate Ey in 15-bit twos-complement format (hardware format)
Definition: SystemEnergy.cxx:183
athena.value
value
Definition: athena.py:122
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:147
LVL1::SystemEnergy::roiWord2
unsigned int roiWord2() const
return RoI word 2 (Et value & overflow, EtMiss hits)
Definition: SystemEnergy.cxx:241
LVL1::SystemEnergy::etSumTrigger
void etSumTrigger()
Test Et sum against ETsum thresholds.
Definition: SystemEnergy.cxx:305
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:415
LVL1::SystemEnergy::decodeTC
int decodeTC(unsigned int input) const
decode 15-bit twos-complement format (hardware Ex/Ey format) as int
Definition: SystemEnergy.cxx:433
LVL1::SystemEnergy::exOverflow
unsigned int exOverflow() const
Overflow bits.
Definition: SystemEnergy.cxx:165
LVL1::SystemEnergy::m_etSumOverflow
static const int m_etSumOverflow
Definition: SystemEnergy.h:87
LVL1::TrigT1CaloDefs::energyRoI1
@ energyRoI1
Definition: TrigT1CaloDefs.h:196
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:195
LVL1::SystemEnergy::etOverflow
unsigned int etOverflow() const
return Et overflow bit
Definition: SystemEnergy.cxx:159
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:141
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:224
LVL1::TrigT1CaloDefs::energyRoIType
@ energyRoIType
Definition: TrigT1CaloDefs.h:180
LVL1::SystemEnergy::m_etMissQ
uint32_t m_etMissQ
Definition: SystemEnergy.h:84
LVL1::TrigT1CaloDefs::numOfSumEtThresholds
static const unsigned int numOfSumEtThresholds
Definition: TrigT1CaloDefs.h:128
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
Scale
void Scale(TH1 *h, double d=1)
Definition: comparitor.cxx:76
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
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
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
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:171
LVL1::TrigT1CaloDefs::energyRoI0
@ energyRoI0
Definition: TrigT1CaloDefs.h:195
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:129
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:127
LVL1::SystemEnergy::metSigTrigger
void metSigTrigger()
Test MEt Significance against METSig thresholds.
Definition: SystemEnergy.cxx:354
LVL1::SystemEnergy::ey
int ey() const
return crate Ey
Definition: SystemEnergy.cxx:153
LVL1::SystemEnergy::m_overflowX
unsigned int m_overflowX
Definition: SystemEnergy.h:77