ATLAS Offline Software
Loading...
Searching...
No Matches
CPCMXTopoData.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Local include(s):
7
8#include <algorithm>
9
10namespace LVL1 {
11
13 const unsigned int CPCMXTopoData::s_maxTOBsPerLink;
14 const unsigned int CPCMXTopoData::s_maxTOBsPerCpm;
15
16
19 CPCMXTopoData::CPCMXTopoData( int crate, int cmx, bool overflow, const std::vector< CPTopoTOB >& tobs )
21 m_cpm_overflow(false)
22 {
23
24 m_tobWords.clear();
25 for (std::vector<CPTopoTOB>::const_iterator it = tobs.begin(); it != tobs.end(); ++it) {
26 if (m_tobWords.size() < s_maxTOBsPerLink) m_tobWords.push_back( (*it).tobWord() );
27 else m_overflow = true;
28 }
30 }
31
32
34 CPCMXTopoData::CPCMXTopoData( int crate, int cmx, bool overflow, const std::vector< uint32_t >& tobWords )
36 m_cpm_overflow(false)
37 {
38
39 m_tobWords.clear();
40 for (std::vector<uint32_t>::const_iterator it = tobWords.begin(); it != tobWords.end(); ++it) {
41 if (m_tobWords.size() < s_maxTOBsPerLink) m_tobWords.push_back( (*it) );
42 else m_overflow = true;
43 }
45 }
46
47
49 CPCMXTopoData::CPCMXTopoData( int crate, int cmx, const std::vector< uint32_t >& roiWords )
50 : m_crate( crate ), m_cmx( cmx ),
51 m_cpm_overflow(false)
52 {
53
54 m_overflow = false;
55 m_tobWords.clear();
56
57 for (std::vector<uint32_t>::const_iterator it = roiWords.begin(); it != roiWords.end(); ++it) {
58 CPTopoTOB tob((*it));
59 if (tob.crate() == m_crate && tob.cmx() == m_cmx) m_tobWords.push_back( tob.tobWord() );
60 }
62 }
63
64
67 : m_crate( crate ), m_cmx( cmx ), m_overflow( false ),
68 m_cpm_overflow(false)
69 {
70 m_tobWords.clear();
71 }
72
73
76 : m_crate( 0 ), m_cmx( 0 ), m_overflow( false ),
77 m_cpm_overflow(false)
78
79 {
80 m_tobWords.clear();
81 }
82
83
87
89 void CPCMXTopoData::addTOB( uint32_t tobWord ) {
90 if (m_tobWords.size() < s_maxTOBsPerLink) m_tobWords.push_back(tobWord);
91 else m_overflow = true;
92 }
93
94
96 void CPCMXTopoData::addTOB( const CPTopoTOB tob ) {
97 if (m_tobWords.size() < s_maxTOBsPerLink)
98 m_tobWords.push_back( tob.tobWord() );
99 else m_overflow = true;
100 }
101
102
104 void CPCMXTopoData::addRoI( uint32_t roiWord ) {
105
106 CPTopoTOB tob(roiWord);
107
108 if (tob.crate() == m_crate && tob.cmx() == m_cmx) m_tobWords.push_back( tob.tobWord() );
109
110 }
111
112
117
118
121 return m_crate;
122 }
123
124
125 int CPCMXTopoData::cmx() const {
126 return m_cmx;
127 }
128
129
131 if ( m_overflow ||
132 (m_tobWords.size() > s_maxTOBsPerLink) ||
133 m_cpm_overflow ) return true;
134 return false;
135 }
136
137
138 const std::vector< uint32_t >& CPCMXTopoData::tobWords() const {
139 return m_tobWords;
140 }
141
142
143 void CPCMXTopoData::tobs(std::vector< CPTopoTOB >& tobs) const {
144 tobs.clear();
145
146 std::vector< uint32_t >::const_iterator it = m_tobWords.begin();
147 for ( ; it != m_tobWords.end(); ++it)
148 tobs.push_back( CPTopoTOB(m_crate, m_cmx, (*it)) );
149
150 return;
151 }
152
154{
155 const size_t max_cpm_index = 14; // as indicated in CPTopoTOB::cpm(), but we start from 0, not 1
156 std::vector<uint32_t> counters_tob_per_cpm(max_cpm_index, 0);
157 for(const uint32_t word : m_tobWords) {
158 CPTopoTOB tob(m_crate, m_cmx, word);
159 const size_t iCpm = tob.cpm()-1;
160 const bool icpmValid = iCpm < counters_tob_per_cpm.size();
161 if(icpmValid) {
162 counters_tob_per_cpm[iCpm] += 1;
163 } else {
164 /*
165 // cout discouraged in athena, but this occurrence is
166 // rare and not deemed to deserve Athena::MsgStreamMember
167 cout<<"CPCMXTopoData::checkCpmOverflow :"
168 <<" invalid iCpm "<<iCpm<<","
169 <<" vector size is "<<counters_tob_per_cpm.size()
170 <<endl;
171 */
172 }
173 }
175 std::any_of(counters_tob_per_cpm.begin(),
176 counters_tob_per_cpm.end(),
177 [](const uint32_t &c) { return (c >= s_maxTOBsPerCpm); }));
178 return *this;
179}
180
181
182} // namespace bracket
static const unsigned int s_maxTOBsPerCpm
as specified in BackplaneFormats_v3.xlsx
const std::vector< uint32_t > & tobWords() const
Return vector of TOB words.
void addTOB(const CPTopoTOB tob)
Add TOB to record.
int m_crate
Data members.
CPCMXTopoData(int crate, int cmx, bool overflow, const std::vector< uint32_t > &tobWords)
Constructor with Crate, CMX numbers, overflow flag and vector of TOB words.
int crate() const
Return crate number (0-3)
bool overflow() const
Return overflow flag.
int cmx() const
Return CMX number (0 = EM, 1 = TAU)
std::vector< uint32_t > m_tobWords
CPCMXTopoData & checkCpmOverflow()
count whether any transmission CPM -> CMX had too many TOBs
CPCMXTopoData()
Default constructor.
void addRoI(uint32_t roiWord)
Add TOB from RoI word.
bool m_cpm_overflow
overflow on CPM -> CMX transmission
~CPCMXTopoData()
Destructor.
static const unsigned int s_maxTOBsPerLink
Static constants.
void setOverflow(bool overflow)
Set overflow flag.
bool m_overflow
overflow on CMX -> L1Topo transmission
void tobs(std::vector< CPTopoTOB > &tobs) const
Fill a vector of TOBs.
CP TOB data for L1Topo.
Definition CPTopoTOB.h:19
uint32_t tobWord() const
Return packed TOB word.
Definition CPTopoTOB.h:133
int crate() const
Return crate number (0-3)
Definition CPTopoTOB.h:98
int cpm() const
Return CPM number (1-14)
Definition CPTopoTOB.h:108
int cmx() const
Return CMX number (0-1)
Definition CPTopoTOB.h:103
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...