ATLAS Offline Software
CTP_RDO.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 
6 // this header file
7 #include "TrigT1Result/CTP_RDO.h"
8 
9 // STL includes:
10 #include <iostream>
11 #include <iomanip>
12 #include <sstream>
13 
14 #include "GaudiKernel/MsgStream.h"
17 
18 
19 CTP_RDO::CTP_RDO(unsigned int ctpVersionNumber, const uint32_t nBCs, uint32_t nExtraWords)
20  : m_ctpVersionNumber(ctpVersionNumber),
21  m_ctpDataFormat(ctpVersionNumber),
22  m_numberOfBunches(nBCs),
23  m_numberOfAdditionalWords(nExtraWords)
24 {
25 
26  // create correct length, zero filled data member
27  m_dataWords.resize(m_ctpDataFormat.getNumberTimeWords()+(nBCs*m_ctpDataFormat.getDAQwordsPerBunch() )+nExtraWords);
28 }
29 
30 CTP_RDO::CTP_RDO(unsigned int ctpVersionNumber, std::vector<uint32_t>&& data, uint32_t nExtraWords)
31  : m_ctpVersionNumber(ctpVersionNumber),
32  m_ctpDataFormat(ctpVersionNumber),
33  m_dataWords(std::move(data))
34 {
35 
36  m_numberOfAdditionalWords=nExtraWords;
37  if(!m_dataWords.size()) {
39  } else {
40  uint32_t dataWords = static_cast<uint32_t>(m_dataWords.size()) - m_ctpDataFormat.getNumberTimeWords() - nExtraWords;
41  m_numberOfBunches = dataWords / m_ctpDataFormat.getDAQwordsPerBunch();
42  }
43 }
44 
46 
47 const CTPdataformatVersion &
49  if(m_ctpVersionNumber==0) {
50  MsgStream log(Athena::getMessageSvc(), "CTP_RDO");
51  log << MSG::WARNING << "CTPVersion has not been set, no information about data format available, please fix your code" << endmsg;
52  }
53  return m_ctpDataFormat;
54 }
55 
56 
57 void
58 CTP_RDO::setCTPVersionNumber( unsigned int ctpVersion ) {
59  m_ctpVersionNumber = ctpVersion;
60 }
61 
62 void CTP_RDO::setTimeSec(const uint32_t sec)
63 {
64  if(getCTPVersion().getTimeSecondsPos() < m_dataWords.size()) {
65  m_dataWords[getCTPVersion().getTimeSecondsPos()] = sec;
66  }
67 }
68 
70 {
71  if(getCTPVersion().getTimeNanosecondsPos() < m_dataWords.size()) {
72  m_dataWords[getCTPVersion().getTimeNanosecondsPos()] =
73  (nano/getCTPVersion().getTimeNanosecondsTicks()) << getCTPVersion().getTimeNanosecondsOffset();
74  }
75 }
76 
78 {
79  if(m_dataWords.size() <= getCTPVersion().getTimeSecondsPos()) return 0;
80  return m_dataWords.at(getCTPVersion().getTimeSecondsPos() );
81 }
82 
84 {
85  if(m_dataWords.size() <= getCTPVersion().getTimeNanosecondsPos()) return 0;
86  return (m_dataWords.at(getCTPVersion().getTimeNanosecondsPos() ) >> getCTPVersion().getTimeNanosecondsOffset() ) * getCTPVersion().getTimeNanosecondsTicks();
87 }
88 
90 {
91  return m_numberOfBunches;
92 }
93 
95 {
96  return m_l1AcceptPosition;
97 }
98 
100 {
101  if(getEXTRAWords().size())
102  return getEXTRAWords().at(0);
103  return -999;
104 }
105 
107 {
108  return m_turnCounter;
109 }
110 
111 
112 
114 {
116 }
117 
119 {
120  if (iBC < m_numberOfBunches) {
121  m_activeBunch = iBC;
122  } else {
123  m_activeBunch = 0u;
124  }
125 }
126 
128 {
129  ++m_activeBunch;
131 }
132 
134 {
135  if (nBCs > m_numberOfBunches) {
136  m_numberOfBunches = nBCs;
137  m_dataWords.resize(getCTPVersion().getNumberTimeWords()+(nBCs*getCTPVersion().getDAQwordsPerBunch() )+m_numberOfAdditionalWords);
138  }
139 }
140 
142 {
143  if (pos < m_numberOfBunches) {
145  }
146 }
147 
149 {
150  m_turnCounter=tc;
151 }
152 
154 {
155  if(nExtraWords > m_numberOfAdditionalWords) {
156  m_dataWords.resize(m_dataWords.size()+nExtraWords-m_numberOfAdditionalWords);//Add the difference
157  }
158  m_numberOfAdditionalWords = nExtraWords;
159 }
160 
161 //void CTP_RDO::setPITWord(const unsigned int i, const uint32_t word)
162 //{
163 // setWord(i + (m_activeBunch*getCTPVersion().getDAQwordsPerBunch()) + getCTPVersion().getPITpos(), word);
164 //}
165 
166 //void CTP_RDO::setFPIWord(const unsigned int i, const uint32_t word)
167 //{
168 // setWord(i + (m_activeBunch*getCTPVersion().getDAQwordsPerBunch()) + getCTPVersion().getFPIpos(), word);
169 //}
170 
171 void CTP_RDO::setTIPWord(const unsigned int i, const uint32_t word)
172 {
173  setWord(i + (m_activeBunch*getCTPVersion().getDAQwordsPerBunch()) + getCTPVersion().getTIPpos(), word);
174 }
175 
176 void CTP_RDO::setTBPWord(const unsigned int i, const uint32_t word)
177 {
178  setWord(i + (m_activeBunch*getCTPVersion().getDAQwordsPerBunch() ) + getCTPVersion().getTBPpos(), word);
179 }
180 
181 void CTP_RDO::setTAPWord(const unsigned int i, const uint32_t word)
182 {
183  setWord(i + (m_activeBunch*getCTPVersion().getDAQwordsPerBunch() ) + getCTPVersion().getTAPpos(), word);
184 }
185 
186 void CTP_RDO::setTAVWord(const unsigned int i, const uint32_t word)
187 {
188  setWord(i + (m_activeBunch*getCTPVersion().getDAQwordsPerBunch()) + getCTPVersion().getTAVpos(), word);
189 }
190 
191 //std::vector<uint32_t> CTP_RDO::getPITWords() const
192 //{
193 // return getWords(PIT);
194 //}
195 //
196 //std::vector<uint32_t> CTP_RDO::getFPIWords() const
197 //{
198 // return getWords(FPI);
199 //}
200 
201 std::vector<uint32_t> CTP_RDO::getTIPWords() const
202 {
203  return getWords(TIP);
204 }
205 
206 std::vector<uint32_t> CTP_RDO::getTBPWords() const
207 {
208  return getWords(TBP);
209 }
210 
211 std::vector<uint32_t> CTP_RDO::getTAPWords() const
212 {
213  return getWords(TAP);
214 }
215 
216 std::vector<uint32_t> CTP_RDO::getTAVWords() const
217 {
218  return getWords(TAV);
219 }
220 
221 std::vector<uint32_t> CTP_RDO::getEXTRAWords() const
222 {
223  return getWords(EXTRA);
224 }
225 
226 void CTP_RDO::setWord(const unsigned int i, const uint32_t word)
227 {
228  if (i < m_dataWords.size()) {
229  m_dataWords[i] = word;
230  } else {
231  MsgStream log(Athena::getMessageSvc(), "CTP_RDO");
232  log << MSG::WARNING << "ignoring word " << word << " for position " << i << endmsg;
233  }
234 
235  return;
236 }
237 
238 std::vector<uint32_t> CTP_RDO::getWords(WordType type) const
239 {
240  unsigned int nWords = 0;
241  unsigned int offset = 0;
242  std::vector<uint32_t> vec;
243  vec.clear();
244 
245  switch (type) {
246  //case PIT:
247 // nWords = getCTPVersion().getPITwords();
248 // offset = getCTPVersion().getPITpos();
249 // break;
250 // case FPI:
251 // nWords = getCTPVersion().getFPIwords();
252 // offset = getCTPVersion().getFPIpos();
253 // break;
254  case TIP:
255  nWords = getCTPVersion().getTIPwords();
256  offset = getCTPVersion().getTIPpos();
257  break;
258  case TBP:
259  nWords = getCTPVersion().getTBPwords();
260  offset = getCTPVersion().getTBPpos();
261  break;
262  case TAP:
263  nWords = getCTPVersion().getTAPwords();
264  offset = getCTPVersion().getTAPpos();
265  break;
266  case TAV:
267  nWords = getCTPVersion().getTAVwords();
268  offset = getCTPVersion().getTAVpos();
269  break;
270  case EXTRA:
271  vec.assign(m_dataWords.begin() + (m_dataWords.size()-m_numberOfAdditionalWords), m_dataWords.end());
272  return vec;
273  break;
274 
275  default:
276  // error
277  break;
278  }
279 
280  for(unsigned int bunch = 0 ; bunch < m_numberOfBunches ; ++bunch) {
281  for(unsigned int tbp = 0; tbp < nWords; ++tbp) {
282  // take offset of TBPwords into account
283  unsigned int index = offset + tbp;
284  // go to the correct bunch
285  index += (bunch * getCTPVersion().getDAQwordsPerBunch());
286  if( index < m_dataWords.size() ) vec.push_back(m_dataWords[index]);
287  }
288  }
289  // this is now a list of consecutive data words for all bunches
290  return vec;
291 }
292 
293 const std::string CTP_RDO::dump() const
294 {
295  std::ostringstream s;
296 
298 
299  return s.str();
300 }
301 
302 const std::string CTP_RDO::print(const bool longFormat) const
303 {
304  std::ostringstream s;
305 
306  // lvl1 accept position
307  s << "\n L1APos:" << std::setw(3) << getL1AcceptBunchPosition();
308  if (longFormat) s << std::endl;
309  s << "\n Turn counter:" << std::setw(3) << getTurnCounter();
310  if (longFormat) s << std::endl;
311 
312  // time is only stored once for the whole fragment
313  for (size_t i(0); (i < getCTPVersion().getNumberTimeWords() ) && (i < m_dataWords.size()); ++i) {
314  if (i == 0 || longFormat) s << "\n Time";
315  if (longFormat) s << std::setw(1) << i;
316  s << " " << std::setw(8) << m_dataWords[i];
317  if (longFormat) s << std::endl;
318  }
319 
320  // return if data content is too short
321  if (m_dataWords.size() < 2) return s.str();
322 
323 
324  // loop over the rest of the data fragment
325  for (unsigned int k(0); k < (m_dataWords.size()-2)/getCTPVersion().getDAQwordsPerBunch(); ++k) {
326 
327  // print single fragment
328 
329  // TIP
330  for (size_t i(0), p(k*getCTPVersion().getDAQwordsPerBunch() + getCTPVersion().getTIPpos());
331  (i < getCTPVersion().getTIPwords()) && (p < m_dataWords.size());
332  ++i, ++p) {
333  if (i == 0 || longFormat) s << "\n TIP";
334  if (longFormat) s << std::setw(1) << i;
336  if (longFormat) s << std::endl;
337  }
338 
339 
340  // TBP
341  for (size_t i(0), p(k*getCTPVersion().getDAQwordsPerBunch() + getCTPVersion().getTBPpos());
342  (i < getCTPVersion().getTBPwords()) && (p < m_dataWords.size());
343  ++i, ++p) {
344  if (i == 0 || longFormat) s << "\n TBP";
345  if (longFormat) s << std::setw(1) << i;
347  if (longFormat) s << std::endl;
348  }
349 
350  // TAP
351  for (size_t i(0), p(k*getCTPVersion().getDAQwordsPerBunch() + getCTPVersion().getTAPpos());
352  (i < getCTPVersion().getTAPwords()) && (p < m_dataWords.size());
353  ++i, ++p) {
354  if (i == 0 || longFormat) s << "\n TAP";
355  if (longFormat) s << std::setw(1) << i;
357  if (longFormat) s << std::endl;
358  }
359 
360  // TAV
361  for (size_t i(0), p(k*getCTPVersion().getDAQwordsPerBunch() + getCTPVersion().getTAVpos() );
362  (i < getCTPVersion().getTAVwords()) && (p < m_dataWords.size());
363  ++i, ++p) {
364  if (i == 0 || longFormat) s << "\n TAV";
365  if (longFormat) s << std::setw(1) << i;
367  if (longFormat) s << std::endl;
368  }
369 
370  }
371 
372  //EXTRA WORDS
373  for (size_t i(m_dataWords.size()-m_numberOfAdditionalWords); i < m_dataWords.size(); ++i) {
374  if (i == m_dataWords.size()-m_numberOfAdditionalWords || longFormat ) s << "\n EXTRA";
375  if (longFormat) s << std::setw(1) << i;
377  if (longFormat) s << std::endl;
378  }
379 
380  return s.str();
381 }
CTP_RDO::setNumberOfBunches
void setNumberOfBunches(const uint32_t nBCs)
Definition: CTP_RDO.cxx:133
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
CTP_RDO::getEXTRAWords
std::vector< uint32_t > getEXTRAWords() const
Definition: CTP_RDO.cxx:221
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
index
Definition: index.py:1
CTP_RDO::m_ctpVersionNumber
unsigned int m_ctpVersionNumber
number of the CTP version to be used
Definition: CTP_RDO.h:96
CTP_RDO::getTimeSinceLastL1A
uint32_t getTimeSinceLastL1A() const
Definition: CTP_RDO.cxx:99
CTP_RDO::selectBunch
void selectBunch(const uint32_t iBC)
Definition: CTP_RDO.cxx:118
CTP_RDO::m_ctpDataFormat
CTPdataformatVersion m_ctpDataFormat
CTP data format for a specified version.
Definition: CTP_RDO.h:97
CTP_RDO::setTIPWord
void setTIPWord(const unsigned int i, const uint32_t word)
Definition: CTP_RDO.cxx:171
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
CTP_RDO::setWord
void setWord(const unsigned int i, const uint32_t word)
Definition: CTP_RDO.cxx:226
CTP_RDO::CTP_RDO
CTP_RDO()=default
Default constructor needed for pool converters.
CTP_RDO::getWords
std::vector< uint32_t > getWords(WordType type) const
Definition: CTP_RDO.cxx:238
LVL1CTP::convertToHex
const std::string convertToHex(const uint32_t word)
helper function to dump a number in hex format
Definition: TrigT1CTPDefs.h:41
CTP_RDO::getDataWords
const std::vector< uint32_t > & getDataWords() const
Definition: CTP_RDO.h:39
CTP_RDO::setTAVWord
void setTAVWord(const unsigned int i, const uint32_t word)
Definition: CTP_RDO.cxx:186
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
CTP_RDO::getNumberOfBunches
uint32_t getNumberOfBunches() const
Definition: CTP_RDO.cxx:89
CTP_RDO::TAV
@ TAV
Definition: CTP_RDO.h:22
CTP_RDO::EXTRA
@ EXTRA
Definition: CTP_RDO.h:22
CTP_RDO::m_dataWords
std::vector< uint32_t > m_dataWords
raw data words
Definition: CTP_RDO.h:98
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
CTP_RDO::getNumberOfAdditionalWords
uint32_t getNumberOfAdditionalWords() const
Definition: CTP_RDO.cxx:113
CTP_RDO::TIP
@ TIP
Definition: CTP_RDO.h:22
CTP_RDO::TBP
@ TBP
Definition: CTP_RDO.h:22
CTP_RDO::m_activeBunch
uint32_t m_activeBunch
active bunch, for book keepting (transient)
Definition: CTP_RDO.h:102
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
CTP_RDO::TAP
@ TAP
Definition: CTP_RDO.h:22
CTP_RDO::selectNextBunch
void selectNextBunch()
Definition: CTP_RDO.cxx:127
CTP_RDO::setTimeNanoSec
void setTimeNanoSec(const uint32_t nano)
Definition: CTP_RDO.cxx:69
CTP_RDO::setL1AcceptBunchPosition
void setL1AcceptBunchPosition(const uint8_t)
Definition: CTP_RDO.cxx:141
CTP_RDO::m_numberOfAdditionalWords
uint32_t m_numberOfAdditionalWords
number of configurable extra words in the fragment
Definition: CTP_RDO.h:103
CTP_RDO::m_turnCounter
uint32_t m_turnCounter
turn counter
Definition: CTP_RDO.h:100
CTP_RDO::print
const std::string print(const bool longFormat=false) const
print object content in a human readable format to string
Definition: CTP_RDO.cxx:302
CTP_RDO::setTurnCounter
void setTurnCounter(const uint32_t)
Definition: CTP_RDO.cxx:148
CTP_RDO::WordType
WordType
Definition: CTP_RDO.h:22
CTP_RDO::getL1AcceptBunchPosition
uint32_t getL1AcceptBunchPosition() const
Definition: CTP_RDO.cxx:94
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
CTP_RDO.h
CTP_RDO::~CTP_RDO
~CTP_RDO()
empty default destructor
Definition: CTP_RDO.cxx:45
CTP_RDO::getTAVWords
std::vector< uint32_t > getTAVWords() const
Definition: CTP_RDO.cxx:216
CTP_RDO::getTurnCounter
uint32_t getTurnCounter() const
Definition: CTP_RDO.cxx:106
CTP_RDO::getTBPWords
std::vector< uint32_t > getTBPWords() const
Definition: CTP_RDO.cxx:206
CTP_RDO::setTAPWord
void setTAPWord(const unsigned int i, const uint32_t word)
Definition: CTP_RDO.cxx:181
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CTP_RDO::setTBPWord
void setTBPWord(const unsigned int i, const uint32_t word)
Definition: CTP_RDO.cxx:176
CTP_RDO::getCTPVersion
const CTPdataformatVersion & getCTPVersion() const
Definition: CTP_RDO.cxx:48
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
CTP_RDO::dump
const std::string dump() const
dump raw object content to string
Definition: CTP_RDO.cxx:293
CTP_RDO::m_numberOfBunches
uint32_t m_numberOfBunches
number of bunches in raw data (transient)
Definition: CTP_RDO.h:101
CTP_RDO::m_l1AcceptPosition
uint8_t m_l1AcceptPosition
bunch position, from which the level1 accept was calculated
Definition: CTP_RDO.h:99
CTP_RDO::getTIPWords
std::vector< uint32_t > getTIPWords() const
Definition: CTP_RDO.cxx:201
CTP_RDO::getTimeNanoSec
uint32_t getTimeNanoSec() const
Definition: CTP_RDO.cxx:83
CTP_RDO::setNumberOfAdditionalWords
void setNumberOfAdditionalWords(const uint32_t nExtraWords)
Definition: CTP_RDO.cxx:153
CTP_RDO::setTimeSec
void setTimeSec(const uint32_t sec)
Definition: CTP_RDO.cxx:62
CTP_RDO::setCTPVersionNumber
void setCTPVersionNumber(unsigned int ctpVersion)
Definition: CTP_RDO.cxx:58
CTP_RDO::getTAPWords
std::vector< uint32_t > getTAPWords() const
Definition: CTP_RDO.cxx:211
fitman.k
k
Definition: fitman.py:528
TrigT1CTPDefs.h
CTP_RDO::getTimeSec
uint32_t getTimeSec() const
Definition: CTP_RDO.cxx:77