ATLAS Offline Software
Loading...
Searching...
No Matches
L1Topo/L1TopoRDO/src/Header.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 "L1TopoRDO/Header.h"
7#include "L1TopoRDO/Helpers.h"
8//#include <cassert>
9
10namespace L1Topo {
11
12 Header::Header(const uint32_t version, const uint32_t active_fibres, const uint32_t payload_crc, const uint32_t fpga, const uint32_t last_block, const uint32_t bcn_sign, const uint32_t bcn_offset)
15 this->encode();
17 }
18
19 Header::Header(const uint32_t word)
20 : m_word(word){
21 this->decode();
23 }
24
25 /* See https://twiki.cern.ch/twiki/pub/Atlas/L1CaloUpgrade/ROD_data_format_v1.0.9.xlsx */
26
28 // assert (L1Topo::blockType(m_word)==L1Topo::BlockTypes::HEADER);
29 m_bcn_offset = m_word & 0x7;
30 m_bcn_sign = (m_word>>3) & 0x1;
31 m_last_block = (m_word>>4) & 0x1;
32 m_fpga = (m_word >> 5 ) & 0x1;
33 m_payload_crc = (m_word>>8) & 0xff;
34 m_active_fibres = (m_word>>16) & 0xff;
35 m_version = (m_word>>24) & 0xf;
36 return;
37 }
38
40 m_word = static_cast<uint32_t>(L1Topo::BlockTypes::HEADER) << 28;
41 m_word |= (m_bcn_offset & 0x7);
42 m_word |= (m_bcn_sign & 0x1) << 3;
43 m_word |= (m_last_block & 0x1) << 4;
44 m_word |= (m_fpga & 0x1) << 5;
45 m_word |= (m_payload_crc & 0xff) << 8;
46 m_word |= (m_active_fibres & 0xff) << 16;
47 m_word |= (m_version & 0xf) << 24;
48 return;
49 }
50
51 uint32_t Header::version() const{
52 return m_version;
53 }
54 uint32_t Header::active_fibres() const{
55 return m_active_fibres;
56 }
57 uint32_t Header::payload_crc() const{
58 return m_payload_crc;
59 }
60 uint32_t Header::fpga() const{
61 return m_fpga;
62 }
63 uint32_t Header::last_block() const{
64 return m_last_block;
65 }
66 uint32_t Header::bcn_sign() const{
67 return m_bcn_sign;
68 }
69 uint32_t Header::bcn_offset() const{
70 return m_bcn_offset;
71 }
72 int Header::bcn() const{
73 return m_bcn;
74 }
75 uint32_t Header::word() const{
76 return m_word;
77 }
78
79 int signedBCN(const uint32_t sign, uint32_t offset){
80 return static_cast<int>(offset) * (sign>0 ? -1 : 1); // sign=0 is false
81 }
82
83 std::pair<uint32_t,uint32_t> signAndOffsetBCN(const int bcn){
84 uint32_t offset = std::abs(bcn);
85 uint32_t sign = (bcn<0)?1:0; // negative bcn encoded as 1
86 return std::pair<uint32_t,uint32_t>(sign,offset);
87 }
88
89 std::ostream& operator<<(std::ostream& os, const Header& h) {
90 os << " Block header:"
91 << " version " << h.version()
92 << std::hex
93 << " active_fibres 0x" << h.active_fibres()
94 << " payload_crc 0x" << h.payload_crc()
95 << std::dec
96 << " fpga " << h.fpga()
97 << " relative bcn " << h.bcn()
98 << " last_block " << h.last_block();
99 return os;
100 }
101
102} // namespace L1Topo
103
int sign(int a)
Header file for AthHistogramAlgorithm.
Represents the L1Topo header word of the L1Topo DAQ data, with decoder and encoder.
uint32_t payload_crc() const
access method
uint32_t fpga() const
access method
Header(const uint32_t version, const uint32_t active_fibres, const uint32_t payload_crc, const uint32_t fpga, const uint32_t last_block, const uint32_t bcn_sign, const uint32_t bcn_offset)
Construct from contents and encode word.
uint32_t word() const
access method
uint32_t active_fibres() const
access method
void encode()
method used by constructor to encode word
uint32_t bcn_offset() const
access method
uint32_t last_block() const
access method
void decode()
method used by constructor to decode word
uint32_t version() const
access method
uint32_t bcn_sign() const
access method
int bcn() const
access method
std::pair< uint32_t, uint32_t > signAndOffsetBCN(const int bcn)
reverse helper function to return the sign and offset bits given a relative bunch crossing number
std::ostream & operator<<(std::ostream &, const Error)
Helper to print errors as text rather than numbers.
Definition Error.cxx:8
int signedBCN(const uint32_t sign, uint32_t offset)
helper function to return a relative bunch crossing as a signed integer, given the sign bit and offse...