ATLAS Offline Software
L1TopoTOB.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <iostream>
6 #include <iomanip>
7 #include <bitset>
8 #include "L1TopoRDO/L1TopoTOB.h"
9 #include "L1TopoRDO/Helpers.h"
10 #include "L1TopoRDO/BlockTypes.h"
11 
12 namespace L1Topo {
13 
14  L1TopoTOB::L1TopoTOB(const uint32_t ctp_signal, uint32_t overflow_bits, uint32_t trigger_bits, uint32_t error_bits)
15  : m_ctp_signal(ctp_signal), m_overflow_bits(overflow_bits), m_trigger_bits(trigger_bits),m_error_bits(error_bits),m_word(0){
16  this->encode();
17  }
18  L1TopoTOB::L1TopoTOB(const uint32_t ctp_signal, uint32_t overflow_bits, uint32_t trigger_bits)
19  : m_ctp_signal(ctp_signal), m_overflow_bits(overflow_bits), m_trigger_bits(trigger_bits),m_error_bits(0),m_word(0){
20  this->encode();
21  }
23  : m_word(word){
24  this->decode();
25  }
26 
27  bool operator==(const L1Topo::L1TopoTOB& lhs, const L1Topo::L1TopoTOB& rhs){
28  return (lhs.word()==rhs.word());
29  }
30  bool operator!=(const L1Topo::L1TopoTOB& lhs, const L1Topo::L1TopoTOB& rhs){
31  return (lhs.word()!=rhs.word());
32  }
33  bool operator<(const L1Topo::L1TopoTOB& lhs, const L1Topo::L1TopoTOB& rhs){
34  return (lhs.word()<rhs.word());
35  }
36  bool operator>(const L1Topo::L1TopoTOB& lhs, const L1Topo::L1TopoTOB& rhs){
37  return (lhs.word()>rhs.word());
38  }
39 
40  /* See https://twiki.cern.ch/twiki/pub/Atlas/L1CaloUpgrade/ROD_data_format_v1.0.8.xlsx */
41 
43  // assert (L1Topo::blockType(m_word)==L1Topo::BlockTypes::L1TOPO_TOB);
44  m_trigger_bits = m_word & 0xff;
45  m_overflow_bits = (m_word>>8) & 0xff;
46  m_error_bits = (m_word>>16) & 0x1f;
47  m_ctp_signal = (m_word>>24) & 0xf;
48  return;
49  }
50 
52  m_word = static_cast<uint32_t>(L1Topo::BlockTypes::L1TOPO_TOB) << 28;
53  m_word |= (m_trigger_bits & 0xff);
54  m_word |= (m_overflow_bits & 0xff) << 8;
55  m_word |= (m_error_bits & 0x1f) << 16;
56  m_word |= (m_ctp_signal &= 0xf) << 24;
57  return;
58  }
59 
61  return m_ctp_signal;
62  }
64  return m_error_bits;
65  }
66  bool L1TopoTOB::crc_EM() const{
67  return (m_error_bits & 0x01);
68  }
69  bool L1TopoTOB::crc_Tau() const{
70  return (m_error_bits & 0x02);
71  }
72  bool L1TopoTOB::crc_Muon() const{
73  return (m_error_bits & 0x04);
74  }
75  bool L1TopoTOB::crc_Jet() const{
76  return (m_error_bits & 0x08);
77  }
78  bool L1TopoTOB::crc_Energy() const{
79  return (m_error_bits & 0x10);
80  }
82  return m_overflow_bits;
83  }
85  return m_trigger_bits;
86  }
88  return m_word;
89  }
90 
91  // CTP index can be unpacked into 3 bits: index, clock and fpga
92  //
94  return m_ctp_signal & 0x1;
95  }
97  return (m_ctp_signal >> 1) & 0x1;
98  }
100  return (m_ctp_signal >> 3) & 0x1;
101  }
102 
103  std::ostream& operator<<(std::ostream& os, const L1TopoTOB& c) {
104  os << " L1Topo TOB: "
105  << " ctp_signal 0x" << std::hex << c.ctp_signal() << std::dec
106  << " ( index " << c.index() << " clock " << c.clock() << " fpga " << c.fpga() << " )"
107  << " CRC error bits 0b" << std::bitset<5>(c.error_bits())
108  << " overflow bits 0b" << std::bitset<8>(c.overflow_bits())
109  << " trigger bits 0b" << std::bitset<8>(c.trigger_bits())
110  << std::dec << "\n";
111  return os;
112  }
113 
114 } // namespace L1Topo
115 
L1Topo::L1TopoTOB::m_overflow_bits
uint32_t m_overflow_bits
Definition: L1TopoTOB.h:58
L1Topo::operator<<
std::ostream & operator<<(std::ostream &, const Error)
Helper to print errors as text rather than numbers.
Definition: Error.cxx:8
L1Topo::L1TopoTOB::error_bits
uint32_t error_bits() const
access to five bits which flag CRC errors on the input links. They are available as individual flags ...
Definition: L1TopoTOB.cxx:63
L1Topo::L1TopoTOB::clock
uint32_t clock() const
clock cycle bit, 0 or 1, part ofthe ctp_signal
Definition: L1TopoTOB.cxx:96
L1Topo::L1TopoTOB::m_word
uint32_t m_word
Definition: L1TopoTOB.h:61
L1Topo::L1TopoTOB
Represents the L1Topo TOB word of the L1Topo ROI data, with decode and encoder.
Definition: L1TopoTOB.h:17
L1Topo::L1TopoTOB::crc_Jet
bool crc_Jet() const
flag true if Jet TOB input links have errors (bit 19)
Definition: L1TopoTOB.cxx:75
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
BlockTypes.h
L1Topo::L1TopoTOB::L1TopoTOB
L1TopoTOB(const uint32_t ctp_signal, uint32_t overflow_bits, uint32_t trigger_bits, uint32_t error_bits)
Construct from contents and encode word.
Definition: L1TopoTOB.cxx:14
L1Topo::L1TopoTOB::crc_Energy
bool crc_Energy() const
flag true if Energy TOB input links have errors (bit 20)
Definition: L1TopoTOB.cxx:78
L1Topo::operator!=
bool operator!=(const L1TopoTOB &, const L1TopoTOB &)
Comparison operators, based on word.
Definition: L1TopoTOB.cxx:30
L1Topo::BlockTypes::L1TOPO_TOB
@ L1TOPO_TOB
L1Topo::L1TopoTOB::decode
void decode()
method used by constructor to decode word
Definition: L1TopoTOB.cxx:42
L1Topo::L1TopoTOB::encode
void encode()
method used by constructor to encode word
Definition: L1TopoTOB.cxx:51
L1Topo::L1TopoTOB::index
uint32_t index() const
index bit, 0 or 1, part ofthe ctp_signal
Definition: L1TopoTOB.cxx:93
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
L1Topo::operator<
bool operator<(const L1TopoTOB &, const L1TopoTOB &)
Comparison operators, based on word.
Definition: L1TopoTOB.cxx:33
L1Topo::L1TopoTOB::m_error_bits
uint32_t m_error_bits
Definition: L1TopoTOB.h:60
L1Topo::L1TopoTOB::crc_EM
bool crc_EM() const
flag true if EM TOB input links have errors (bit 16)
Definition: L1TopoTOB.cxx:66
L1Topo::operator==
bool operator==(const L1TopoTOB &, const L1TopoTOB &)
Comparison operators, based on word.
Definition: L1TopoTOB.cxx:27
L1Topo::L1TopoTOB::m_trigger_bits
uint32_t m_trigger_bits
Definition: L1TopoTOB.h:59
L1Topo::L1TopoTOB::m_ctp_signal
uint32_t m_ctp_signal
Definition: L1TopoTOB.h:57
L1Topo::L1TopoTOB::trigger_bits
uint32_t trigger_bits() const
accessor method for trigger bits
Definition: L1TopoTOB.cxx:84
L1Topo::L1TopoTOB::overflow_bits
uint32_t overflow_bits() const
accessor method for overflow bits
Definition: L1TopoTOB.cxx:81
L1Topo::L1TopoTOB::crc_Muon
bool crc_Muon() const
flag true if Muon TOB input links have errors (bit 18)
Definition: L1TopoTOB.cxx:72
L1Topo::L1TopoTOB::fpga
uint32_t fpga() const
fpga number bit , 0 or 1, part ofthe ctp_signal
Definition: L1TopoTOB.cxx:99
L1Topo::L1TopoTOB::crc_Tau
bool crc_Tau() const
flag true if Tau TOB input links have errors (bit 17)
Definition: L1TopoTOB.cxx:69
L1TopoTOB.h
L1Topo
Definition: BlockTypes.h:11
python.compressB64.c
def c
Definition: compressB64.py:93
L1Topo::L1TopoTOB::ctp_signal
uint32_t ctp_signal() const
access method for ctp signal bits
Definition: L1TopoTOB.cxx:60
L1Topo::operator>
bool operator>(const L1TopoTOB &, const L1TopoTOB &)
Comparison operators, based on word.
Definition: L1TopoTOB.cxx:36
L1Topo::L1TopoTOB::word
uint32_t word() const
accessor method for data word
Definition: L1TopoTOB.cxx:87
Helpers.h