ATLAS Offline Software
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 
10 namespace 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 )
20  : m_crate( crate ), m_cmx( cmx ), m_overflow( overflow),
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 )
35  : m_crate( crate ), m_cmx( cmx ), m_overflow( overflow ),
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 
66  CPCMXTopoData::CPCMXTopoData( int crate, int cmx )
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 
86  }
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 
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 
114  void CPCMXTopoData::setOverflow( bool overflow ) {
116  }
117 
118 
120  int CPCMXTopoData::crate() const {
121  return m_crate;
122  }
123 
124 
125  int CPCMXTopoData::cmx() const {
126  return m_cmx;
127  }
128 
129 
130  bool CPCMXTopoData::overflow() const {
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
LVL1::CPCMXTopoData::tobWords
const std::vector< uint32_t > & tobWords() const
Return vector of TOB words.
Definition: CPCMXTopoData.cxx:138
LVL1::CPCMXTopoData::crate
int crate() const
Return crate number (0-3)
Definition: CPCMXTopoData.cxx:120
LVL1::CPTopoTOB::cpm
int cpm() const
Return CPM number (1-14)
Definition: CPTopoTOB.h:108
LVL1::CPCMXTopoData::s_maxTOBsPerCpm
static const unsigned int s_maxTOBsPerCpm
as specified in BackplaneFormats_v3.xlsx
Definition: CPCMXTopoData.h:72
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
CPCMXTopoData.h
LVL1::CPCMXTopoData::~CPCMXTopoData
~CPCMXTopoData()
Destructor.
Definition: CPCMXTopoData.cxx:85
LVL1::CPCMXTopoData::m_cpm_overflow
bool m_cpm_overflow
overflow on CPM -> CMX transmission
Definition: CPCMXTopoData.h:68
skel.it
it
Definition: skel.GENtoEVGEN.py:396
LVL1::CPCMXTopoData::m_cmx
int m_cmx
Definition: CPCMXTopoData.h:66
LVL1::CPCMXTopoData::s_maxTOBsPerLink
static const unsigned int s_maxTOBsPerLink
Static constants.
Definition: CPCMXTopoData.h:71
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
xAOD::roiWord
roiWord
Definition: TrigMissingET_v1.cxx:36
LVL1::CPTopoTOB
CP TOB data for L1Topo.
Definition: CPTopoTOB.h:19
LVL1::CPTopoTOB::crate
int crate() const
Return crate number (0-3)
Definition: CPTopoTOB.h:98
LVL1::CPCMXTopoData::setOverflow
void setOverflow(bool overflow)
Set overflow flag.
Definition: CPCMXTopoData.cxx:114
LVL1::CPCMXTopoData::addRoI
void addRoI(uint32_t roiWord)
Add TOB from RoI word.
Definition: CPCMXTopoData.cxx:104
LVL1::CPTopoTOB::tobWord
uint32_t tobWord() const
Return packed TOB word.
Definition: CPTopoTOB.h:133
LVL1::CPCMXTopoData::m_crate
int m_crate
Data members.
Definition: CPCMXTopoData.h:65
LVL1::CPCMXTopoData::cmx
int cmx() const
Return CMX number (0 = EM, 1 = TAU)
Definition: CPCMXTopoData.cxx:125
LVL1::CPCMXTopoData::addTOB
void addTOB(const CPTopoTOB tob)
Add TOB to record.
Definition: CPCMXTopoData.cxx:96
LVL1::CPCMXTopoData::overflow
bool overflow() const
Return overflow flag.
Definition: CPCMXTopoData.cxx:130
LVL1::CPCMXTopoData::m_tobWords
std::vector< uint32_t > m_tobWords
Definition: CPCMXTopoData.h:69
LVL1::CPTopoTOB::cmx
int cmx() const
Return CMX number (0-1)
Definition: CPTopoTOB.h:103
LVL1::CPCMXTopoData::tobs
void tobs(std::vector< CPTopoTOB > &tobs) const
Fill a vector of TOBs.
Definition: CPCMXTopoData.cxx:143
LVL1::CPCMXTopoData::checkCpmOverflow
CPCMXTopoData & checkCpmOverflow()
count whether any transmission CPM -> CMX had too many TOBs
Definition: CPCMXTopoData.cxx:153
python.compressB64.c
def c
Definition: compressB64.py:93
LVL1::CPCMXTopoData::CPCMXTopoData
CPCMXTopoData()
Default constructor.
Definition: CPCMXTopoData.cxx:75
LVL1::CPCMXTopoData::m_overflow
bool m_overflow
overflow on CMX -> L1Topo transmission
Definition: CPCMXTopoData.h:67
LVL1::CPCMXTopoData
Definition: CPCMXTopoData.h:22