ATLAS Offline Software
Loading...
Searching...
No Matches
ModuleID.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <iostream>
7#include "L1TopoRDO/Helpers.h"
8
9namespace L1Topo {
10
11 ModuleID::ModuleID(unsigned int link, unsigned int module, unsigned int roiDaq)
13 this->encode();
14 }
15
16 ModuleID::ModuleID(const uint16_t id)
17 :m_link(0), m_module(0), m_roiDaq(0), m_id(id) {
18 this->decode();
19 }
20
21 uint16_t ModuleID::roiDaq() const {
22 return m_roiDaq;
23 }
24
25 bool ModuleID::isDAQ() const {
26 return m_roiDaq==0;
27 }
28
29 bool ModuleID::isROI() const {
30 return m_roiDaq==1;
31 }
32
33 uint16_t ModuleID::module() const {
34 return m_module;
35 }
36
37 uint16_t ModuleID::link() const {
38 return m_link;
39 }
40
41 uint16_t ModuleID::id() const {
42 return m_id;
43 }
44
46 m_id = (m_roiDaq & 0x1) << 7;
47 m_id |= (m_module & 0x7) << 4;
48 m_id |= (m_link & 0xf);
49 }
50
52 m_roiDaq = (m_id >> 7) & 0x1;
53 m_module = (m_id >> 4) & 0x7;
54 m_link = m_id & 0xf;
55 }
56
57 std::ostream& operator<<(std::ostream& os, const ModuleID& m) {
58 os << "ModuleID: " << " " << formatHex4(m.id()) << " 0b" << std::bitset<8>(m.id()) << " link " << m.link() << " " << " module " << m.module();
59 if (m.isDAQ()){
60 os << " DAQ";
61 }
62 else if (m.isROI()){
63 os << " ROI";
64 }
65 return os;
66 }
67
68} // namespace L1Topo
69
Represents the L1Topo module ID, with decoder and encoder.
Definition ModuleID.h:28
bool isROI() const
True if this is a ROI module.
Definition ModuleID.cxx:29
void decode()
method used by constructor to decode word
Definition ModuleID.cxx:51
uint16_t m_module
Definition ModuleID.h:53
uint16_t m_link
Definition ModuleID.h:52
bool isDAQ() const
True if this is a DAQ module.
Definition ModuleID.cxx:25
ModuleID(unsigned int link, unsigned int module, unsigned int roiDaq)
Construct from constituent parts and encode word.
Definition ModuleID.cxx:11
uint16_t link() const
access method
Definition ModuleID.cxx:37
uint16_t m_roiDaq
Definition ModuleID.h:54
uint16_t m_id
Definition ModuleID.h:55
void encode()
method used by constructor to encode word
Definition ModuleID.cxx:45
uint16_t roiDaq() const
access method
Definition ModuleID.cxx:21
uint16_t module() const
access method
Definition ModuleID.cxx:33
uint16_t id() const
access method
Definition ModuleID.cxx:41
std::string formatHex4(uint32_t word)
Helper function to format a 32-bit integer as a 4-digit hex number for printing.
std::ostream & operator<<(std::ostream &, const Error)
Helper to print errors as text rather than numbers.
Definition Error.cxx:8