ATLAS Offline Software
Loading...
Searching...
No Matches
TrigMonROBSum.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5// C/C++
6#include <iostream>
7#include <sstream>
8
11
12namespace SumBits
13{
14 const uint32_t maskHist = 0x0000000f;
15 const uint32_t maskNrob = 0x00000ff0;
16 const uint32_t maskSize = 0xfffff000;
17
18 const uint32_t shiftNrob = 4;
19 const uint32_t shiftSize = 12;
20}
21
22
23//--------------------------------------------------------------------------------------
28
29//--------------------------------------------------------------------------------------
31 :m_word(word)
32{
33}
34
35//--------------------------------------------------------------------------------------
36bool TrigMonROBSum::setHistory(uint32_t hist)
37{
38 //
39 // Set encoded state
40 //
41 if(hist < 16) {
42 m_word = m_word & (~SumBits::maskHist);
43 m_word |= hist;
44 return true;
45 }
46 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "TrigMonROBSum") << "setHistory: Bad int";
47 return false;
48}
49
50//--------------------------------------------------------------------------------------
51bool TrigMonROBSum::setNROB(uint32_t nrob)
52{
53 //
54 // Set number of robs
55 //
56 if(nrob < 256) {
57 m_word = m_word & (~SumBits::maskNrob);
58 m_word |= (nrob << SumBits::shiftNrob);
59 return true;
60 }
61 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "TrigMonROBSum") << "setNROB: Bad int";
62 return false;
63}
64
65//--------------------------------------------------------------------------------------
66bool TrigMonROBSum::setSize(uint32_t size)
67{
68 //
69 // Set number of robs
70 //
71 if(size < 1048576) {
72 m_word = m_word & (~SumBits::maskSize);
73 m_word |= (size << SumBits::shiftSize);
74 return true;
75 }
76 REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "TrigMonROBSum") << "setSize: Bad int";
77 return false;
78}
79
80//--------------------------------------------------------------------------------------
82{
83 //
84 // Add rob data
85 //
86
87 if(getNROB() > 254) return false;
88 if(getSize() > 1048574) return false;
89
90 setHistory(data.getHistory());
91 setSize(getSize()+data.getROBSize());
92
93 if(subdet < 0) {
94 setNROB(getNROB()+1);
95 }
96 else {
97 setNROB(subdet);
98 }
99
100 return true;
101}
102
103//--------------------------------------------------------------------------------------
105{
106 //
107 // Return History enum
108 //
110}
111
112//--------------------------------------------------------------------------------------
114{
115 //
116 // Return History enum
117 //
119}
120
121//--------------------------------------------------------------------------------------
123{
124 //
125 // Return History enum
126 //
128}
129
130//--------------------------------------------------------------------------------------
132{
133 //
134 // Return History enum
135 //
137}
138
139//--------------------------------------------------------------------------------------
140void TrigMonROBSum::print(std::ostream &os) const
141{
142 os << str(*this) << "\n";
143}
144
145//--------------------------------------------------------------------------------------
146std::string str(const TrigMonROBSum &o)
147{
148 std::stringstream s;
149 s << "TrigMonROBSum: "
151 << " nrob=" << o.getNROB()
152 << " size=" << o.getSize();
153
154 return s.str();
155}
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
uint32_t getNROB() const
uint32_t m_word
void print(std::ostream &os=std::cout) const
bool setSize(uint32_t size)
bool setNROB(uint32_t nrob)
TrigMonROBData::History getHistory() const
uint32_t getSize() const
uint32_t getSubDet() const
bool setHistory(uint32_t hist)
bool addROB(const TrigMonROBData &data, int subdet=-1)
const uint32_t shiftSize
const uint32_t maskSize
const uint32_t maskHist
const uint32_t shiftNrob
const uint32_t maskNrob
TrigMonROBData::History getROBHistory(unsigned int val)
std::string AsStringROBHistory(TrigMonROBData::History hist)