ATLAS Offline Software
Loading...
Searching...
No Matches
Fibre.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
6#include <iostream>
7#include "L1TopoRDO/Fibre.h"
8#include "L1TopoRDO/Helpers.h"
10
11namespace L1Topo {
12
13 Fibre::Fibre(std::vector<uint32_t> &&status, std::vector<uint32_t> &&count)
14 :m_status(std::move(status)), m_count(std::move(count)), m_word(0) {
15 this->encode();
16 }
17
18 Fibre::Fibre(const uint32_t word)
19 :m_status(5,0), m_count(5,0), m_word(word) {
20 this->decode();
21 }
22
23 // assume the vectors are correctly ordered - no way to know what they mean nor what order they should be in
24 // will read vector from left to right and pack word left to right, unusually.
26 m_word = static_cast<uint32_t>(L1Topo::BlockTypes::FIBRE) << 28;
27 // assert(status.size()<=5);
28 // assert(status.size()==count.size());
29 for (unsigned int i=0; i<5 && i<m_status.size() && i<m_count.size(); ++i){
30 // assert(m_count.at(i)<0x10); // should not exceed 4 bits
31 uint32_t fibre = (m_status.at(i) & 0x1) << 4 | (m_count.at(i) & 0xf) ;
32 m_word |= (fibre << (((4-i)*5)+3) );
33 }
34 }
35
37 for (unsigned int i=0; i<5; ++i){
38 uint32_t fibre = m_word >> (((4-i)*5)+3) & 0x1f;
39 m_status.at(i) = (fibre >> 4) & 0x1;
40 m_count.at(i) = fibre & 0xf;
41 }
42 }
43
44 uint32_t Fibre::word() const{
45 return m_word;
46 }
47
48 const std::vector<uint32_t>& Fibre::status() const{
49 return m_status;
50 }
51
52 const std::vector<uint32_t>& Fibre::count() const{
53 return m_count;
54 }
55
56 std::ostream& operator<<(std::ostream& os, const Fibre& f) {
57
58 os << " Fibre status,sizes: ";
59 for (unsigned int i=0; i<5 && i<f.status().size() && i<f.count().size(); ++i){
60 os << "(" << f.status().at(i) << "," << f.count().at(i) << ") ";
61 }
62 return os;
63 }
64
65
66} // namespace L1Topo
67
Represents the L1Topo fibre word of the L1Topo DAQ header, with decoder and encoder.
Definition Fibre.h:22
Fibre(std::vector< uint32_t > &&status, std::vector< uint32_t > &&count)
Construct from contents and encode word: vectors of up to 5 status flags and sizes....
Definition Fibre.cxx:13
void encode()
method used by constructor to encode word
Definition Fibre.cxx:25
std::vector< uint32_t > m_status
fibre status
Definition Fibre.h:41
uint32_t m_word
The raw data representation.
Definition Fibre.h:45
const std::vector< uint32_t > & status() const
access method
Definition Fibre.cxx:48
uint32_t word() const
access method
Definition Fibre.cxx:44
std::vector< uint32_t > m_count
fibre counts
Definition Fibre.h:43
const std::vector< uint32_t > & count() const
access method
Definition Fibre.cxx:52
void decode()
method used by constructor to decode word
Definition Fibre.cxx:36
std::ostream & operator<<(std::ostream &, const Error)
Helper to print errors as text rather than numbers.
Definition Error.cxx:8
STL namespace.