ATLAS Offline Software
Loading...
Searching...
No Matches
Decision.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3*/
4// Decision.cxx
5// TopoCore
6// Created by Joerg Stelzer on 11/16/12.
7
10
11void
12TCS::Decision::setBit(unsigned int index, bool set) {
13 if(index>=m_nBits) {
14 TCS_EXCEPTION("Trying to set bit " << index << ", while max index allowed is " << m_nBits-1)
15 }
16 if(set) {
17 m_decision |= (0x1<<index);
18 } else {
19 m_decision &= ~(0x1<<index);
20 }
21}
22
23std::ostream &
24operator<<(std::ostream & o, const TCS::Decision & dec) {
25 unsigned int bit = dec.nBits();
26 if(dec.nBits()==1) {
27 o << "decision (1 bit, position " << dec.firstBit() << "): ";
28 } else {
29 o << "decision (" << dec.nBits() << " bits, position " << dec.firstBit() << " - " << dec.lastBit() << "): ";
30 }
31 while(bit!=0) {
32 o << (dec.bit(--bit)?1:0);
33 }
34 o << "(overflow "<<dec.overflow()<<")";
35 return o;
36}
bool overflow() const
Definition Decision.h:45
unsigned int m_nBits
Definition Decision.h:51
unsigned int lastBit() const
Definition Decision.h:43
bool bit(unsigned int index) const
Definition Decision.h:40
uint32_t m_decision
Definition Decision.h:49
unsigned int nBits() const
Definition Decision.h:44
void setBit(unsigned int index, bool value)
Definition Decision.cxx:12
unsigned int firstBit() const
Definition Decision.h:42
STL class.
std::ostream & operator<<(std::ostream &os, const TCS::Bin &bin)
Definition index.py:1