ATLAS Offline Software
BaseTOB.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2 
3 #include "L1TopoEvent/BaseTOB.h"
5 
6 #include <iostream>
7 #include <iomanip>
8 
9 using namespace std;
10 
11 TCS::BaseTOB::BaseTOB(uint32_t roiWord, const std::string& tobName) :
12  m_roiWord(roiWord),
13  m_tobName(tobName)
14 {}
15 
16 TCS::BaseTOB::~BaseTOB() = default;
17 
18 int
19 TCS::BaseTOB::sizeCheckM(int value, unsigned int size) const
20 {
21  int max(0x1 << (size-1));
22  int min(~max + 1);
23  --max;
24  if( (-value)>max || (-value)<min) {
25  TCS_EXCEPTION("Integer value " << -value << " outside firmware specifications. Maximum number of bits is " << size << " -> range ["<<min<<" - "<<max<<"]" << ", for " << m_tobName);
26  }
27  return value;
28 }
29 
30 
31 int
32 TCS::BaseTOB::sizeCheck(int value, unsigned int size) const
33 {
34  int max(0x1 << (size-1));
35  int min(~max + 1);
36  --max;
37  if(value>max || value<min) {
38  TCS_EXCEPTION("Integer value " << value << " outside firmware specifications. Maximum number of bits is " << size << " -> range ["<<min<<" - "<<max<<"]" << ", for " << m_tobName);
39  }
40  return value;
41 }
42 
43 unsigned int
44 TCS::BaseTOB::sizeCheck(unsigned int value, unsigned int size) const
45 {
46  unsigned int max( (0x1 << size)-1 );
47  if(value>max) {
48  TCS_EXCEPTION("Unsigned integer value " << value << " outside firmware specifications. Maximum number of bits is " << size << " -> range [0"<<" - "<<max<<"]" << ", for " << m_tobName);
49  }
50  return value;
51 }
52 
53 
54 namespace TCS {
55 
56 
57 std::ostream & operator<< (std::ostream & o, const TCS::BaseTOB& top) {
58  top.print(o);
59  return o;
60 }
61 
62 
63 }
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
max
#define max(a, b)
Definition: cfImp.cxx:41
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
BaseTOB.h
athena.value
value
Definition: athena.py:124
TCS::BaseTOB::sizeCheck
int sizeCheck(int value, unsigned int size) const
Definition: BaseTOB.cxx:32
xAOD::roiWord
roiWord
Definition: TrigMissingET_v1.cxx:36
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
TCS::BaseTOB::BaseTOB
BaseTOB(uint32_t roiWord, const std::string &tobType)
Definition: BaseTOB.cxx:11
TCS::BaseTOB
Definition: BaseTOB.h:12
TCS_EXCEPTION
#define TCS_EXCEPTION(MSG)
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/Exception.h:14
min
#define min(a, b)
Definition: cfImp.cxx:40
TCS::BaseTOB::~BaseTOB
virtual ~BaseTOB()
TCS::BaseTOB::sizeCheckM
int sizeCheckM(int value, unsigned int size) const
Definition: BaseTOB.cxx:19
TCS
Definition: Global/GlobalSimulation/src/IO/Decision.h:18
top
@ top
Definition: TruthClasses.h:64
TCS::operator<<
std::ostream & operator<<(std::ostream &, const TCS::CountingConnector &)
Definition: CountingConnector.cxx:93
Exception.h