ATLAS Offline Software
Loading...
Searching...
No Matches
BaseTOB.cxx
Go to the documentation of this file.
1// Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2
5
6#include <iostream>
7#include <iomanip>
8
9using namespace std;
10
11TCS::BaseTOB::BaseTOB(uint32_t roiWord, const std::string& tobName) :
14{}
15
16TCS::BaseTOB::~BaseTOB() = default;
17
18int
19TCS::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
31int
32TCS::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
43unsigned int
44TCS::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
54namespace TCS {
55
56
57std::ostream & operator<< (std::ostream & o, const TCS::BaseTOB& top) {
58 top.print(o);
59 return o;
60}
61
62
63}
@ top
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
const std::string & tobName() const
Definition BaseTOB.h:23
virtual ~BaseTOB()
int sizeCheck(int value, unsigned int size) const
Definition BaseTOB.cxx:32
uint32_t roiWord() const
Definition BaseTOB.h:21
std::string m_tobName
Definition BaseTOB.h:37
int sizeCheckM(int value, unsigned int size) const
Definition BaseTOB.cxx:19
BaseTOB(uint32_t roiWord, const std::string &tobType)
Definition BaseTOB.cxx:11
uint32_t m_roiWord
Definition BaseTOB.h:36
std::ostream & operator<<(std::ostream &os, const TCS::Bin &bin)
STL namespace.