1 #ifndef DataFormats_L1TrackTrigger_TTBV_h
2 #define DataFormats_L1TrackTrigger_TTBV_h
20 static constexpr
int S = 64;
34 const char*
c =
reinterpret_cast<const char*
>(&
d);
35 for (
int iByte = 0; iByte < (int)
sizeof(d); iByte++) {
36 const std::bitset<std::numeric_limits<unsigned char>::digits> byte(*(c + iByte));
37 for (
int bit = 0; bit < std::numeric_limits<unsigned char>::digits; bit++)
38 bs_[index++] = byte[bit];
47 :
twos_(Signed),
size_(size),
bs_(std::bitset<
S>((!Signed || value >= 0) ? value : value +
iMax())) {}
50 TTBV(
double value,
double base,
int size,
bool Signed =
false) :
TTBV((int)std::floor(value / base), size, Signed) {}
61 std::bitset<S>
bs()
const {
return bs_; }
72 bool all()
const {
return bs_.all(); }
73 bool any()
const {
return bs_.any(); }
146 bs_ = std::bitset<S>(
bs_.to_ullong() + 1);
202 }
else if (size < size_ && size > 0) {
220 int val(
bool Signed)
const {
return (Signed && this->
msb()) ? (int)
bs_.to_ullong() -
iMax() :
bs_.to_ullong(); }
231 for (
int i = begin;
i <
end;
i++)
247 for (
int e =
size_ - 1;
e > -1;
e--)
255 constexpr std::array<unsigned long long int, S>
powersOfTwo()
const {
256 std::array<unsigned long long int, S> lut = {};
257 for (
int i = 0;
i <
S;
i++)
263 unsigned long long int iMax()
const {
264 static const std::array<unsigned long long int, S> lut =
powersOfTwo();
unsigned long long int iMax() const
std::bitset< S > bs() const
const edm::EventSetup & c
int pmEncode(bool b=true) const
TTBV(unsigned long long int value, int size)
TTBV & operator&=(const TTBV &rhs)
Bit vector used by Track Trigger emulators. Mainly used to convert integers into arbitrary (within ma...
TTBV & operator+=(const TTBV &rhs)
TTBV & operator|=(const TTBV &rhs)
bool operator==(const TTBV &rhs) const
std::bitset< S >::reference msb()
int val(bool Signed) const
double val(double base) const
int plEncode(bool b=true) const
TTBV & operator>>=(int pos)
std::string str(int start, int end=0) const
int count(int begin, int end, bool b=true) const
int val(int start, int end=0, bool Signed=false) const
bool operator[](int pos) const
TTBV(int value, int size, bool Signed=false)
TTBV(const std::bitset< S > &bs, bool Signed=false)
constexpr std::array< unsigned long long int, S > powersOfTwo() const
TTBV operator<<(int pos) const
TTBV operator>>(int pos) const
std::bitset< S >::reference operator[](int pos)
TTBV & operator^=(const TTBV &rhs)
TTBV(double value, double base, int size, bool Signed=false)
TTBV(const std::string &str, bool Signed=false)
TTBV operator+(const TTBV &rhs) const
bool operator!=(const TTBV &rhs) const
TTBV & operator<<=(int pos)
Power< A, B >::type pow(const A &a, const B &b)