ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GenericTob.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 #include "GenericTob.h"
7 #include "AlgoDataTypes.h"
8 #include "binStrToHexStr.h"
9 #include <sstream>
10 
11 namespace GlobalSim {
12  std::bitset<9> genEtaFromTobEta(const std::bitset<8>& in_eta) {
13  auto result = std::bitset<9>();
14 
15  int val = (-0x64 + bitSetToInt(in_eta));
16  std::bitset<8> bs = val;
17 
18  bool neg{val < 0};
19 
20  for(std::size_t i{0}; i != bs.size(); ++i) {result[i] = bs[i];}
21 
22  if (neg) {
23  result.set(8);
24  }
25 
26  return result;
27  }
28 
29 
30  GenericTob::GenericTob(const eEmTob& in_tob) {
31 
32  {
33  const auto& in = in_tob.Et_bits();
34  auto sz = in.size();
35  for (auto i = 0U; i != sz; ++i) {m_Et_bits[i] = in[i];}
36  }
37 
38 
39  {
40  const auto& in = in_tob.Eta_bits();
41 
42  // vhdl etaL to_signed(unsigned(-100 + in, GenericEtaBitWidth)
43  int val = (-0x64 + bitSetToInt(in));
44 
45  bool neg{val < 0};
46  m_Eta_bits = std::abs(val);
47  if (neg) {m_Eta_bits = m_Eta_bits.flip().to_ulong()+1;}
48  }
49 
50  {
51  const auto& in = in_tob.Phi_bits();
52  m_Phi_bits = 2*(bitSetToInt(in)+2);
53  }
54 
55  }
56 
57  GenericTob::GenericTob(const eEmTobPtr& in_tob): GenericTob(*in_tob){}
58 
59 
61 
62  const auto& etob_et = in_tob.Et_bits();
63  auto sz = etob_et.size();
64  for (auto i = 0U; i != sz; ++i) {m_Et_bits[i] = etob_et[i];}
65 
66 
67  const auto& etob_eta = in_tob.Eta_bits();
68  m_Eta_bits = genEtaFromTobEta(etob_eta);
69 
70  const auto& etob_phi = in_tob.Phi_bits();
71  m_Phi_bits = 2*(bitSetToInt(etob_phi)+2);
72 
73  }
74 
75  GenericTob::GenericTob(const eTauTobPtr& in_tob) : GenericTob(*in_tob) {}
76 
77 
78  GenericTob::GenericTob(const std::string& bit_string) {
79  if(bit_string.size() != GenericTobWidth) {
80  std::stringstream ss;
81  ss << "GenericTob ctr expected " << GenericTobWidth
82  << " bits, received " << bit_string.size();
83  throw std::out_of_range(ss.str());
84  }
85 
86  auto bitstream = std::stringstream(bit_string);
87  bitstream >> m_Overflow_bits;
88  bitstream >> m_Charge_bits;
89  bitstream >> m_Phi_bits;
90  bitstream >> m_Eta_bits;
91  bitstream >> m_Et_bits;
92 
93  }
94 
95  std::bitset<32> GenericTob::as_bits() const {
96 
97  auto result = std::bitset<32>();
98 
99  std::size_t begin = 0;
100  std::size_t end = GenericEtBitWidth;;
101 
102 
103  for(std::size_t i = begin; i != end; ++i) {
104  result[i] = m_Et_bits[i];
105  }
106 
107  begin = end;
109 
110  for(std::size_t i = 0; i != GenericEtaBitWidth; ++i) {
111  result[begin+i] = m_Eta_bits[i];
112  }
113 
114  begin = end;
116 
117  for(std::size_t i = 0; i != GenericPhiBitWidth; ++i) {
118  result[begin+i] = m_Phi_bits[i];
119  }
120 
121 
122  begin = end;
124 
125  for(std::size_t i = 0; i != GenericMuonFlagBitWidth; ++i) {
126  result[begin+i] = m_Phi_bits[i];
127  }
128 
129  begin = end;
131 
132  for(std::size_t i = 0; i != GenericOverflowWidth; ++i) {
134  }
135 
136  return result;
137 
138  }
139 
140 }
141 
142 std::ostream& operator << (std::ostream& os, const GlobalSim::GenericTob& tob) {
143 
144  os << "GlobalSim::GenericTob\n"
145  << "Et: " << tob.Et_bits() << ' '
146  << "0x" << GlobalSim::binStrToHexStr(tob.Et_bits().to_string()) << '\n'
147  << "Eta: " << tob.Eta_bits() << ' '
148  << "0x" << GlobalSim::binStrToHexStr(tob.Eta_bits().to_string()) << '\n'
149  << "Phi: " << tob.Phi_bits() << ' '
150  << "0x" << GlobalSim::binStrToHexStr(tob.Phi_bits().to_string()) << '\n'
151  << "Charge: " << tob.Charge_bits() << ' '
152  << "0x" << GlobalSim::binStrToHexStr(tob.Charge_bits().to_string()) << '\n'
153  << "overflow: " << tob.overflow_bits() << ' '
154  << "0x" << GlobalSim::binStrToHexStr(tob.overflow_bits().to_string()) << '\n'
155  << "bits: " << tob.as_bits() << ' '
156  << "0x" << GlobalSim::binStrToHexStr(tob.as_bits().to_string()) << '\n';
157  return os;
158 }
GlobalSim::GenericTob::GenericEtBitWidth
constexpr static std::size_t GenericEtBitWidth
Definition: GenericTob.h:24
binStrToHexStr.h
GlobalSim::GenericTob::m_Phi_bits
std::bitset< GenericPhiBitWidth > m_Phi_bits
Definition: GenericTob.h:66
GlobalSim::GenericTob::m_Charge_bits
std::bitset< GenericMuonFlagBitWidth > m_Charge_bits
Definition: GenericTob.h:67
fitman.sz
sz
Definition: fitman.py:527
get_generator_info.result
result
Definition: get_generator_info.py:21
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
GlobalSim::GenericTob::m_Eta_bits
std::bitset< GenericEtaBitWidth > m_Eta_bits
Definition: GenericTob.h:65
AlgoDataTypes.h
GlobalSim::GenericTob::Et_bits
const std::bitset< 13 > & Et_bits() const
Definition: GenericTob.h:47
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
GlobalSim::bitSetToInt
int bitSetToInt(BITSET bitset)
Definition: AlgoDataTypes.h:19
GenericTob.h
GlobalSim::eTauTobPtr
std::shared_ptr< eTauTob > eTauTobPtr
Definition: eTauTob.cxx:85
GlobalSim::GenericTob::Phi_bits
const std::bitset< 7 > & Phi_bits() const
Definition: GenericTob.h:49
GlobalSim::GenericTob
Definition: GenericTob.h:20
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
GlobalSim::GenericTob::overflow_bits
const std::bitset< 1 > & overflow_bits() const
Definition: GenericTob.h:51
GlobalSim::eEmTob::Phi_bits
const std::bitset< AlgoConstants::eFexPhiBitWidth > & Phi_bits() const
Definition: eEmTob.h:77
GlobalSim::GenericTob::GenericMuonFlagBitWidth
constexpr static std::size_t GenericMuonFlagBitWidth
Definition: GenericTob.h:31
GlobalSim
AlgTool to obtain a selection of eFex RoIs read in from the event store.
Definition: dump.h:8
GlobalSim::binStrToHexStr
std::string binStrToHexStr(std::string s)
Definition: binStrToHexStr.h:37
lumiFormat.i
int i
Definition: lumiFormat.py:85
GlobalSim::GenericTob::m_Overflow_bits
std::bitset< 1 > m_Overflow_bits
Definition: GenericTob.h:68
GlobalSim::GenericTob::GenericOverflowWidth
constexpr static std::size_t GenericOverflowWidth
Definition: GenericTob.h:32
GlobalSim::GenericTob::Charge_bits
const std::bitset< 2 > & Charge_bits() const
Definition: GenericTob.h:50
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
operator<<
std::ostream & operator<<(std::ostream &os, const GlobalSim::GenericTob &tob)
Definition: GenericTob.cxx:142
GlobalSim::GenericTob::GenericTobWidth
constexpr static std::size_t GenericTobWidth
Definition: GenericTob.h:34
GlobalSim::eTauTob::Eta_bits
const std::bitset< AlgoConstants::eFexEtaBitWidth > & Eta_bits() const
Definition: eTauTob.h:67
GlobalSim::GenericTob::GenericTob
GenericTob()
Definition: GenericTob.h:39
GlobalSim::eTauTob::Et_bits
const std::bitset< AlgoConstants::eFexEtBitWidth > & Et_bits() const
Definition: eTauTob.h:58
GlobalSim::eEmTobPtr
std::shared_ptr< eEmTob > eEmTobPtr
Definition: eEmTob.cxx:93
GlobalSim::GenericTob::GenericEtaBitWidth
constexpr static std::size_t GenericEtaBitWidth
Definition: GenericTob.h:25
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
GlobalSim::eEmTob::Eta_bits
const std::bitset< AlgoConstants::eFexEtaBitWidth > & Eta_bits() const
Definition: eEmTob.h:74
GlobalSim::eTauTob::Phi_bits
const std::bitset< AlgoConstants::eFexPhiBitWidth > & Phi_bits() const
Definition: eTauTob.h:70
GlobalSim::eTauTob
Definition: eTauTob.h:16
GlobalSim::GenericTob::as_bits
std::bitset< 32 > as_bits() const
Definition: GenericTob.cxx:95
GlobalSim::GenericTob::Eta_bits
const std::bitset< 9 > & Eta_bits() const
Definition: GenericTob.h:48
GlobalSim::eEmTob
Definition: eEmTob.h:16
GlobalSim::GenericTob::m_Et_bits
std::bitset< GenericEtBitWidth > m_Et_bits
Definition: GenericTob.h:64
GlobalSim::GenericTob::GenericPhiBitWidth
constexpr static std::size_t GenericPhiBitWidth
Definition: GenericTob.h:30
GlobalSim::genEtaFromTobEta
std::bitset< 9 > genEtaFromTobEta(const std::bitset< 8 > &in_eta)
Definition: GenericTob.cxx:12
GlobalSim::eEmTob::Et_bits
const std::bitset< AlgoConstants::eFexEtBitWidth > & Et_bits() const
Definition: eEmTob.h:62