ATLAS Offline Software
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"
9 #include "L1TopoRDO/BlockTypes.h"
10 
11 namespace 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.
25  void Fibre::encode(){
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 
36  void Fibre::decode(){
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 
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 
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
L1Topo::Fibre::Fibre
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
L1Topo::operator<<
std::ostream & operator<<(std::ostream &, const Error)
Helper to print errors as text rather than numbers.
Definition: Error.cxx:8
L1Topo::Fibre::status
const std::vector< uint32_t > & status() const
access method
Definition: Fibre.cxx:48
Fibre.h
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
BlockTypes.h
L1Topo::BlockTypes::FIBRE
@ FIBRE
L1Topo::Fibre::m_count
std::vector< uint32_t > m_count
fibre counts
Definition: Fibre.h:43
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
L1Topo::Fibre::decode
void decode()
method used by constructor to decode word
Definition: Fibre.cxx:36
lumiFormat.i
int i
Definition: lumiFormat.py:85
hist_file_dump.f
f
Definition: hist_file_dump.py:135
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
L1Topo::Fibre::m_word
uint32_t m_word
The raw data representation.
Definition: Fibre.h:45
L1Topo::Fibre::word
uint32_t word() const
access method
Definition: Fibre.cxx:44
L1Topo::Fibre::encode
void encode()
method used by constructor to encode word
Definition: Fibre.cxx:25
L1Topo::Fibre
Represents the L1Topo fibre word of the L1Topo DAQ header, with decoder and encoder.
Definition: Fibre.h:22
L1Topo::Fibre::count
const std::vector< uint32_t > & count() const
access method
Definition: Fibre.cxx:52
merge.status
status
Definition: merge.py:17
L1Topo::Fibre::m_status
std::vector< uint32_t > m_status
fibre status
Definition: Fibre.h:41
L1Topo
Definition: BlockTypes.h:11
Helpers.h