ATLAS Offline Software
CTPSLink.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 // STL includes(s):
8 #include <sstream>
9 #include <iostream>
10 #include <iomanip>
11 
12 // local LVL1 include(s):
14 
15 namespace LVL1CTP {
16 
17  // CTPSLink contains only information of triggered bunch!
18  //const unsigned int CTPSLink::wordsPerCTPSLink = CTPdataformat::NumberTimeWords+CTPdataformat::DAQwordsPerBunch;
19 
20  CTPSLink::CTPSLink( const std::vector<uint32_t>& roiVec, unsigned int ctpVersionNumber )
21  : m_CTPSLinkVector( roiVec ), m_ctpVersionNumber(ctpVersionNumber),
22  m_wordsPerHeader(0), m_wordsPerDataElement(0), m_wordsPerTrailer(0)
23  {
24  m_ctpVersion = new CTPdataformatVersion(m_ctpVersionNumber);
25  const uint32_t numExtraWords = (m_CTPSLinkVector[2] >> m_ctpVersion->getProgrammableExtraWordsShift()) & m_ctpVersion->getProgrammableExtraWordsMask();
26  m_wordsPerCTPSLink = m_ctpVersion->getNumberTimeWords() + m_ctpVersion->getDAQwordsPerBunch() + numExtraWords;
27 
29  if (m_CTPSLinkVector.size() > (m_wordsPerHeader+3)) {
32  }
33 
34  if (m_wordsPerHeader == 0 ||
35  m_wordsPerTrailer == 0 ||
37  std::cout << "Warning: CTPSLink inconsistency! " << std::endl;
38  }
39  }
40 
42  if(m_ctpVersion) delete m_ctpVersion;
43  m_ctpVersion = NULL;
44 
45  }
46 
47  unsigned int CTPSLink::getSize() const
48  {
49  return m_CTPSLinkVector.size();
50  }
51 
52  unsigned int CTPSLink::getHeaderSize() const
53  {
54  return m_wordsPerHeader;
55  }
56 
57  unsigned int CTPSLink::getDataElementSize() const
58  {
59  return m_wordsPerDataElement;
60  }
61 
62  unsigned int CTPSLink::getTrailerSize() const
63  {
64  return m_wordsPerTrailer;
65  }
66 
67  const std::vector< uint32_t > CTPSLink::getHeader() const
68  {
69  std::vector<uint32_t> result;
70 
71  unsigned int start(0);
72  unsigned int end(getHeaderSize());
73 
74  for (size_t i(start); i < end; ++i) {
75  result.push_back(m_CTPSLinkVector[i]);
76  }
77 
78  return result;
79  }
80 
81  const std::vector< uint32_t > CTPSLink::getTrailer() const
82  {
83  std::vector<uint32_t> result;
84 
85  unsigned int start(getSize() - getTrailerSize());
86  unsigned int end(getSize());
87 
88  for (size_t i(start); i < end; ++i) {
89  result.push_back(m_CTPSLinkVector[i]);
90  }
91 
92  return result;
93  }
94 
95  const std::vector< uint32_t >& CTPSLink::getCTPToRoIBWords() const {
96 
97  return m_CTPSLinkVector;
98 
99  }
100 
101  const std::vector< uint32_t > CTPSLink::getDataElements() const
102  {
103  // strip of header and trailer
104  std::vector<uint32_t> dataElements;
105 
106  unsigned int start(getHeaderSize());
107  unsigned int end(getSize() - getTrailerSize());
108 
109  for (size_t i(start); i < end; ++i) {
110  dataElements.push_back(m_CTPSLinkVector[i]);
111  }
112 
113  return dataElements;
114  }
115 
116  const std::vector< uint32_t > CTPSLink::getTBP() const
117  {
118  std::vector<uint32_t> result;
119 
120  unsigned int start(getHeaderSize()+m_ctpVersion->getTBPpos());
121  unsigned int end(start+m_ctpVersion->getTBPwords());
122 
123  for (size_t i(start); i < end; ++i) {
124  result.push_back(m_CTPSLinkVector[i]);
125  }
126 
127  return result;
128  }
129 
130  const std::vector< uint32_t > CTPSLink::getTAP() const
131  {
132  std::vector<uint32_t> result;
133 
134  unsigned int start(getHeaderSize()+m_ctpVersion->getTAPpos());
135  unsigned int end(start+m_ctpVersion->getTAPwords());
136 
137  for (size_t i(start); i < end; ++i) {
138  result.push_back(m_CTPSLinkVector[i]);
139  }
140 
141  return result;
142  }
143 
144  const std::vector< uint32_t > CTPSLink::getTAV() const
145  {
146  std::vector<uint32_t> result;
147 
148  unsigned int start(getHeaderSize()+m_ctpVersion->getTAVpos());
149  unsigned int end(start+m_ctpVersion->getTAVwords());
150 
151  for (size_t i(start); i < end; ++i) {
152  result.push_back(m_CTPSLinkVector[i]);
153  }
154 
155  return result;
156  }
157 
159  {
160  const std::vector<uint32_t> result(this->getTBP());
161 
162  for (size_t i(0); i < result.size(); ++i) {
163  if (result[i] > 0) return true;
164  }
165 
166  return false;
167  }
168 
170  {
171  const std::vector<uint32_t> result(this->getTAP());
172 
173  for (size_t i(0); i < result.size(); ++i) {
174  if (result[i] > 0) return true;
175  }
176 
177  return false;
178  }
179 
181  {
182  const std::vector<uint32_t> result(this->getTAV());
183 
184  for (size_t i(0); i < result.size(); ++i) {
185  if (result[i] > 0) return true;
186  }
187 
188  return false;
189  }
190 
191 
192  const std::string CTPSLink::dump() const
193  {
194  std::ostringstream s;
195 
196 
197  s << "CTPSLink: header [" << LVL1CTP::convertToHex(this->getHeader()) << "]" << std::endl;
198  s << "CTPSLink: data [" << LVL1CTP::convertToHex(this->getDataElements()) << "]" << std::endl;
199  s << "CTPSLink: trailer [" << LVL1CTP::convertToHex(this->getTrailer()) << "]";
200 
201  return s.str();
202  }
203 
204  const std::string CTPSLink::print(const bool longFormat) const
205  {
206  std::ostringstream s;
207 
208  s << "CTPSLink: header [" << LVL1CTP::convertToHex(this->getHeader()) << "]" << std::endl;
209  s << "CTPSLink: data content" << convert(this->getDataElements(), longFormat) << std::endl;
210  s << "CTPSLink: trailer: [" << LVL1CTP::convertToHex(this->getTrailer()) << "]";
211 
212  return s.str();
213  }
214 
215  const std::string CTPSLink::convert(const std::vector<uint32_t>& data, const bool longFormat) const
216  {
217  std::ostringstream s;
218 
219  // time
220  for (size_t i(0); (i < m_ctpVersion->getNumberTimeWords()) && (i < data.size()); ++i) {
221  if (i == 0 || longFormat) s << "\nTime";
222  if (longFormat) s << std::setw(1) << i;
223  s << " " << std::setw(8) << data[i];
224  if (longFormat) s << std::endl;
225  }
226 
227  // TIP
228  for (size_t i(0), p(m_ctpVersion->getTIPpos());
229  (i < m_ctpVersion->getTIPwords()) && (p < data.size());
230  ++i, ++p) {
231  if (i == 0 || longFormat) s << "\nTIP";
232  if (longFormat) s << std::setw(1) << i;
233  s << " 0x" << std::hex << std::setw(8) << std::setfill( '0' ) << data[p] << std::dec << std::setfill(' ');
234  if (longFormat) s << std::endl;
235  }
236 
237  // FPI
238  //for (size_t i(0), p(m_ctpVersion->getFPIpos());
239 // (i < m_ctpVersion->getFPIwords()) && (p < data.size());
240 // ++i, ++p) {
241 // if (i == 0 || longFormat) s << "\nFPI";
242 // if (longFormat) s << std::setw(1) << i;
243 // s << " 0x" << std::hex << std::setw(8) << std::setfill( '0' ) << data[p] << std::dec << std::setfill(' ');
244 // if (longFormat) s << std::endl;
245 // }
246 
247  // TBP
248  for (size_t i(0), p(m_ctpVersion->getTBPpos());
249  (i < m_ctpVersion->getTBPwords()) && (p < data.size());
250  ++i, ++p) {
251  if (i == 0 || longFormat) s << "\nTBP";
252  if (longFormat) s << std::setw(1) << i;
253  s << " 0x" << std::hex << std::setw(8) << std::setfill( '0' ) << data[p] << std::dec << std::setfill(' ');
254  if (longFormat) s << std::endl;
255  }
256 
257  // TAP
258  for (size_t i(0), p(m_ctpVersion->getTAPpos());
259  (i < m_ctpVersion->getTAPwords()) && (p < data.size());
260  ++i, ++p) {
261  if (i == 0 || longFormat) s << "\nTAP";
262  if (longFormat) s << std::setw(1) << i;
263  s << " 0x" << std::hex << std::setw(8) << std::setfill( '0' ) << data[p] << std::dec << std::setfill(' ');
264  if (longFormat) s << std::endl;
265  }
266 
267  // TAV
268  for (size_t i(0), p(m_ctpVersion->getTAVpos());
269  (i < m_ctpVersion->getTAVwords()) && (p < data.size());
270  ++i, ++p) {
271  if (i == 0 || longFormat) s << "\nTAV";
272  if (longFormat) s << std::setw(1) << i;
273  s << " 0x" << std::hex << std::setw(8) << std::setfill( '0' ) << data[p] << std::dec << std::setfill(' ');
274  if (longFormat) s << std::endl;
275  }
276 
277  return s.str();
278  }
279 
280 
281 } // namesapce LVL1CTP
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
get_generator_info.result
result
Definition: get_generator_info.py:21
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
LVL1CTP::convertToHex
const std::string convertToHex(const uint32_t word)
helper function to dump a number in hex format
Definition: TrigT1CTPDefs.h:41
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
lumiFormat.i
int i
Definition: lumiFormat.py:85
LVL1CTP
Definition: Lvl1ResultAccessTool.h:20
TrigT1CTPDefs.h