ATLAS Offline Software
Global/GlobalSimulation/src/IO/Decision.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 // Decision.cxx
5 // TopoCore
6 // Created by Joerg Stelzer on 11/16/12.
7 //
8 // Adapted for GlobalL1TopoSim
9 
10 
11 #include "Decision.h"
12 
13 #include <ostream>
14 #include <sstream>
15 #include <stdexcept>
16 
17 namespace GlobalSim {
18  void
19  Decision::setBit(unsigned int index, bool set) {
20  if(index >= m_nBits) {
21  std::stringstream ss;
22  ss << "Setting bit "
23  << index << ", but max index allowed is " << m_nBits-1;
24  throw std::runtime_error(ss.str());
25  }
26 
27  if(set) {
28  m_decision |= (0x1<<index);
29  } else {
30  m_decision &= ~(0x1<<index);
31  }
32  }
33 
34  std::ostream&
35  operator<<(std::ostream& os, const Decision& dec) {
36  unsigned int bit = dec.nBits();
37  if(dec.nBits()==1) {
38  os << "decision (1 bit, position " << dec.firstBit() << "): ";
39  } else {
40  os << "decision (" << dec.nBits()
41  << " bits, position " << dec.firstBit()
42  << " - "
43  << dec.lastBit() << "): ";
44  }
45 
46  while(bit!=0) {
47  os << (dec.bit(--bit)?1:0);
48  }
49  os << "(overflow "<<dec.overflow()<<")";
50  return os;
51  }
52 }
53 
54 std::ostream & operator<<(std::ostream& os, const GlobalSim::Decision& d){
55  os << "Decision:\n"
56  << " decision : " << d.decision()
57  << " first bit : " << d.firstBit()
58  << " last bit : " << d.lastBit()
59  << " n bits : " << d.nBits()
60  << std::boolalpha
61  << " overflow : " << d.overflow()
62  << " ambiguity : " << d.ambiguity()
63  <<'\n'<< std::noboolalpha; //restore stream state
64  return os;
65 }
66 
67 
operator<<
std::ostream & operator<<(std::ostream &os, const GlobalSim::Decision &d)
Definition: Global/GlobalSimulation/src/IO/Decision.cxx:54
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
GlobalSim::Decision::m_nBits
unsigned int m_nBits
Definition: Global/GlobalSimulation/src/IO/Decision.h:56
GlobalSim::Decision::setBit
void setBit(unsigned int index, bool value)
Definition: Global/GlobalSimulation/src/IO/Decision.cxx:19
index
Definition: index.py:1
hist_file_dump.d
d
Definition: hist_file_dump.py:137
GlobalSim::Decision
Definition: Global/GlobalSimulation/src/IO/Decision.h:24
Decision.h
GlobalSim
AlgTool to obtain a GlobalSim::cTAUTOBArray This class uses ReadHandls to jFex and eFex Tau Rois If t...
Definition: dump.h:8
GlobalSim::Decision::nBits
unsigned int nBits() const
Definition: Global/GlobalSimulation/src/IO/Decision.h:49
GlobalSim::Decision::m_decision
uint32_t m_decision
Definition: Global/GlobalSimulation/src/IO/Decision.h:54
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
GlobalSim::Decision::firstBit
unsigned int firstBit() const
Definition: Global/GlobalSimulation/src/IO/Decision.h:47
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
GlobalSim::operator<<
std::ostream & operator<<(std::ostream &os, const Decision &dec)
Definition: Global/GlobalSimulation/src/IO/Decision.cxx:35
GlobalSim::Decision::overflow
bool overflow() const
Definition: Global/GlobalSimulation/src/IO/Decision.h:50
DeMoScan.index
string index
Definition: DeMoScan.py:362
GlobalSim::Decision::lastBit
unsigned int lastBit() const
Definition: Global/GlobalSimulation/src/IO/Decision.h:48
GlobalSim::Decision::bit
bool bit(unsigned int index) const
Definition: Global/GlobalSimulation/src/IO/Decision.h:45