ATLAS Offline Software
CTPResult.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 // this header file
8 
9 // gaudi includes
10 #include "GaudiKernel/Bootstrap.h"
11 #include "GaudiKernel/ISvcLocator.h"
12 #include "GaudiKernel/IMessageSvc.h"
13 #include "GaudiKernel/MsgStream.h"
14 
15 // STL includes
16 #include <sstream>
17 #include <iomanip>
18 
19 // Local include(s):
21 
22 
23 namespace ROIB {
24 
25 
26 
27  CTPResult::CTPResult(unsigned int ctpVersion, Header&& head, Trailer &&trail, std::vector<CTPRoI>&& rois) :
28  m_CTPResultHeader( std::move(head) ),
29  m_CTPResultTrailer( std::move(trail) ),
30  m_CTPResultRoIVec( std::move(rois) ),
31  //m_ctpVersionNumber( ctpVersion ),
32  m_ctpDataformat( ctpVersion ),
33  m_useRoIB(false),
34  m_l1aBunch(0)
35  {
36  m_useRoIB = (m_CTPResultHeader.sourceID() == 0x770001);
37  if (!m_useRoIB) m_l1aBunch = (m_CTPResultHeader.formatVersion() >> m_ctpDataformat.getL1APositionShift()) & m_ctpDataformat.getL1APositionMask();
38  }
39 
40 
41  CTPResult::CTPResult(unsigned int ctpVersion, Header&& head, Trailer&& trail, const std::vector<uint32_t>& v ) :
42  m_CTPResultHeader( std::move(head) ),
43  m_CTPResultTrailer( std::move(trail) ),
44  //m_ctpVersionNumber( ctpVersion ),
45  m_ctpDataformat( ctpVersion ),
46  m_useRoIB(false),
47  m_l1aBunch(0)
48  {
49  m_useRoIB = (m_CTPResultHeader.sourceID() == 0x770001);
50 
51  std::copy(v.begin(), v.end(), back_inserter(m_CTPResultRoIVec));
52  if (!m_useRoIB) m_l1aBunch = (m_CTPResultHeader.formatVersion() >> m_ctpDataformat.getL1APositionShift()) & m_ctpDataformat.getL1APositionMask();
53  }
54 
55 
56  const std::string CTPResult::dump() const
57  {
58  std::ostringstream s;
59 
60  s << " [" << this->header().dump() << "] ";
61  s << " [";
62  for (std::vector<CTPRoI>::size_type i(0); i < roIVec().size(); ++i) {
63  s << LVL1CTP::convertToHex(roIVec()[i].roIWord());
64  }
65  s << "] ";
66  s << " [" << this->trailer().dump() << "] ";
67 
68  return s.str();
69  }
70 
71  const std::string CTPResult::print(const bool longFormat) const
72  {
73  std::ostringstream s;
74 
75  s << "header [" << this->header().print(longFormat) << "] ";
76  if (longFormat) s << std::endl;
77  s << "data [" << convert(this->roIVec(), longFormat) << "] ";
78  if (longFormat) s << std::endl;
79  s << "trailer [" << this->trailer().print(longFormat) << "] ";
80 
81  return s.str();
82  }
83 
84  const std::string CTPResult::convert(const std::vector<CTPRoI>& data, const bool longFormat) const
85  {
86  std::ostringstream s;
87 
88  // time
89  for (size_t i(0); (i < m_ctpDataformat.getNumberTimeWords()) && (i < data.size()); ++i) {
90  if (longFormat) s << "\n";
91  if (i == 0 || longFormat) s << " Time";
92  if (longFormat) s << std::setw(1) << i;
93  s << " " << std::setw(8) << data[i].roIWord();
94  if (longFormat) s << std::endl;
95  }
96 
97  // TIP
98  for (size_t i(0), p(((m_useRoIB) ? m_ctpDataformat.getTIPpos():m_l1aBunch*m_ctpDataformat.getDAQwordsPerBunch())+m_ctpDataformat.getTIPpos());
99  (i < ((m_useRoIB) ? m_ctpDataformat.getRoIBTIPwords():m_ctpDataformat.getTIPwords())) && (p < data.size());
100  ++i, ++p) {
101  if (longFormat) s << "\n";
102  if (i == 0 || longFormat) s << " TIP";
103  if (longFormat) s << std::setw(1) << i;
104  s << LVL1CTP::convertToHex(data[p].roIWord());
105  if (longFormat) s << std::endl;
106  }
107 
108  // FPI
109  // for (size_t i(0), p(m_ctpDataformat.getFPIpos());
110  // (i < m_ctpDataformat.getFPIwords()) && (p < data.size());
111  // ++i, ++p) {
112  // if (longFormat) s << "\n";
113  // if (i == 0 || longFormat) s << " FPI";
114  // if (longFormat) s << std::setw(1) << i;
115  // s << LVL1CTP::convertToHex(data[p].roIWord());
116  // if (longFormat) s << std::endl;
117  // }
118 
119  // TBP
120  for (size_t i(0), p(((m_useRoIB) ? m_ctpDataformat.getRoIBTBPpos():m_l1aBunch*m_ctpDataformat.getDAQwordsPerBunch()+m_ctpDataformat.getTBPpos()));
121  (i < m_ctpDataformat.getTBPwords()) && (p < data.size());
122  ++i, ++p) {
123  if (longFormat) s << "\n";
124  if (i == 0 || longFormat) s << " TBP";
125  if (longFormat) s << std::setw(1) << i;
126  s << LVL1CTP::convertToHex(data[p].roIWord());
127  if (longFormat) s << std::endl;
128  }
129 
130  // TAP
131  for (size_t i(0), p(((m_useRoIB) ? m_ctpDataformat.getTAPpos():m_l1aBunch*m_ctpDataformat.getDAQwordsPerBunch())+m_ctpDataformat.getTAPpos());
132  (i < ((m_useRoIB) ? m_ctpDataformat.getRoIBTAPwords():m_ctpDataformat.getTAPwords())) && (p < data.size());
133  ++i, ++p) {
134  if (longFormat) s << "\n";
135  if (i == 0 || longFormat) s << " TAP";
136  if (longFormat) s << std::setw(1) << i;
137  s << LVL1CTP::convertToHex(data[p].roIWord());
138  if (longFormat) s << std::endl;
139  }
140 
141  // TAV
142  for (size_t i(0), p(((m_useRoIB) ? m_ctpDataformat.getRoIBTAVpos():m_l1aBunch*m_ctpDataformat.getDAQwordsPerBunch()+m_ctpDataformat.getTAVpos()));
143  (i < m_ctpDataformat.getTAVwords()) && (p < data.size());
144  ++i, ++p) {
145  if (longFormat) s << "\n";
146  if (i == 0 || longFormat) s << " TAV";
147  if (longFormat) s << std::setw(1) << i;
148  s << LVL1CTP::convertToHex(data[p].roIWord());
149  if (longFormat) s << std::endl;
150  }
151 
152  return s.str();
153  }
154 
155 
156  void CTPResult::dumpData() const
157  {
158  IMessageSvc* msgSvc;
159  ISvcLocator* svcLoc = Gaudi::svcLocator( );
160  StatusCode sc = svcLoc->service( "MessageSvc", msgSvc );
161  if ( sc.isFailure() ) {
162  return;
163  }
164  MsgStream log(msgSvc, "CTPResult");
165  dumpData(log);
166  }
167 
168  void CTPResult::dumpData(MsgStream& log) const
169  {
170  log << MSG::DEBUG << "*BEGIN* CTPResult" << endmsg;
172  int counter = 0;
173  std::vector< CTPRoI >::const_iterator it = m_CTPResultRoIVec.begin();
174  for(; it != m_CTPResultRoIVec.end(); ++it,++counter) {
175  log << MSG::DEBUG << "RoI word[" << counter << "] : 0x"
176  << MSG::hex << it->roIWord() << MSG::dec << endmsg;
177  }
179  log << MSG::DEBUG << "*END* CTPResult" << endmsg;
180  }
181 
182  // convert vector of ints into bitset
183  std::bitset<512> convertToBitset(const std::vector<uint32_t>& words)
184  {
185  std::bitset<512> bitset;
186 
187  for (size_t i(0); i < words.size(); ++i) {
188  std::bitset<512> bs = words[i];
189  bs <<= (i * 32);
190  bitset |= bs;
191  }
192 
193  return bitset;
194  }
195 
196  // convert vector of CTPRoIs into bitset
197  std::bitset<512> convertToBitset(const std::vector<CTPRoI>& words)
198  {
199  std::bitset<512> bitset;
200 
201  for (size_t i(0); i < words.size(); ++i) {
202  std::bitset<512> bs = words[i].roIWord();
203  bs <<= (i * 32);
204  bitset |= bs;
205  }
206 
207  return bitset;
208  }
209 
210 } // namespace ROIB
ROIB::Trailer::dumpData
void dumpData() const
print object content to default message stream
Definition: Trailer.cxx:76
ROIB::Header::sourceID
uint32_t sourceID() const
get sub detector source ID
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
ROIB::Header::formatVersion
uint32_t formatVersion() const
get version of header format
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ROIB::Header::print
const std::string print(const bool longFormat=false) const
print object content in a human readable format to string
Definition: TrigT1Result/src/Header.cxx:80
ROIB::CTPResult::convert
const std::string convert(const std::vector< CTPRoI > &data, const bool longFormat=false) const
convert data content into string (used by dump and print)
Definition: CTPResult.cxx:84
ROIB::CTPResult::trailer
const Trailer & trailer() const
return trailer
ROIB::CTPResult::header
const Header & header() const
return header
skel.it
it
Definition: skel.GENtoEVGEN.py:423
ROIB::CTPResult::m_CTPResultRoIVec
std::vector< CTPRoI > m_CTPResultRoIVec
raw data content (RoIs)
Definition: CTPResult.h:122
ROIB::CTPResult::dump
const std::string dump() const
dump raw object content to string
Definition: CTPResult.cxx:56
ROIB
Namespace of the LVL1 RoIB simulation.
Definition: ILvl1ResultAccessTool.h:19
LVL1CTP::convertToHex
const std::string convertToHex(const uint32_t word)
helper function to dump a number in hex format
Definition: TrigT1CTPDefs.h:41
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
CTPResult.h
ROIB::CTPResult::m_CTPResultTrailer
Trailer m_CTPResultTrailer
trailer fragment in LVL1 eformat
Definition: CTPResult.h:121
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
ROIB::CTPResult::m_l1aBunch
unsigned int m_l1aBunch
Definition: CTPResult.h:135
ROIB::Trailer::print
const std::string print(const bool longFormat=false) const
print object content in a human readable format to string
Definition: Trailer.cxx:56
lumiFormat.i
int i
Definition: lumiFormat.py:92
ROIB::Header
Header models the LVL1 ROD Header.
Definition: TrigT1Result/TrigT1Result/Header.h:37
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ROIB::Header::dump
const std::string dump() const
dump raw object content to string
Definition: TrigT1Result/src/Header.cxx:69
ROIB::CTPResult::m_useRoIB
bool m_useRoIB
Definition: CTPResult.h:132
ROIB::Trailer::dump
const std::string dump() const
dump raw object content to string
Definition: Trailer.cxx:45
ROIB::CTPResult::m_CTPResultHeader
Header m_CTPResultHeader
header fragment in LVL1 eformat
Definition: CTPResult.h:120
ROIB::CTPResult::CTPResult
CTPResult()
default constructor: empty object
Definition: CTPResult.h:56
head
std::string head(std::string s, const std::string &pattern)
head of a string
Definition: computils.cxx:310
ROIB::Trailer
ROIB::Trailer models the LVL1 ROD Trailer.
Definition: Trailer.h:37
ROIB::convertToBitset
std::bitset< 512 > convertToBitset(const std::vector< uint32_t > &words)
convert vector of unsigned int into bitset
Definition: CTPResult.cxx:183
python.PyAthena.v
v
Definition: PyAthena.py:157
ROIB::CTPResult::m_ctpDataformat
CTPdataformatVersion m_ctpDataformat
Definition: CTPResult.h:126
ROIB::CTPResult::print
const std::string print(const bool longFormat=false) const
print object content in a human readable format to string
Definition: CTPResult.cxx:71
ROIB::CTPResult::dumpData
void dumpData() const
print object content to default message stream
Definition: CTPResult.cxx:156
ROIB::CTPResult::roIVec
const std::vector< CTPRoI > & roIVec() const
return the RoI vector *‍/
ROIB::Header::dumpData
void dumpData() const
print object content to default message stream
Definition: TrigT1Result/src/Header.cxx:103
DEBUG
#define DEBUG
Definition: page_access.h:11
TriggerTest.rois
rois
Definition: TriggerTest.py:23
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
calibdata.copy
bool copy
Definition: calibdata.py:27
test_pyathena.counter
counter
Definition: test_pyathena.py:15
checkFileSG.words
words
Definition: checkFileSG.py:76
TrigT1CTPDefs.h