ATLAS Offline Software
L1Topo/L1TopoInterfaces/Root/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 
11 void
12 TCS::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 
23 std::ostream &
24 operator<<(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 }
TCS::Decision::m_nBits
unsigned int m_nBits
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:51
index
Definition: index.py:1
TCS::Decision::overflow
bool overflow() const
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:45
TCS::Decision::lastBit
unsigned int lastBit() const
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:43
Decision.h
TCS::Decision::setBit
void setBit(unsigned int index, bool value)
Definition: L1Topo/L1TopoInterfaces/Root/Decision.cxx:12
TCS::Decision::nBits
unsigned int nBits() const
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:44
TCS_EXCEPTION
#define TCS_EXCEPTION(MSG)
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/Exception.h:14
TCS::Decision
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:19
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:224
DeMoScan.index
string index
Definition: DeMoScan.py:362
TCS::Decision::firstBit
unsigned int firstBit() const
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:42
TCS::Decision::bit
bool bit(unsigned int index) const
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:40
TCS::Decision::m_decision
uint32_t m_decision
Definition: L1Topo/L1TopoInterfaces/L1TopoInterfaces/Decision.h:49
TCS::operator<<
std::ostream & operator<<(std::ostream &, const TCS::CountingConnector &)
Definition: CountingConnector.cxx:93
Exception.h