ATLAS Offline Software
Loading...
Searching...
No Matches
CTPResultUtils Namespace Reference

Utility functions for xAOD::CTPResult objects that rely on tdaq-common. More...

Functions

void initialize (xAOD::CTPResult &ctpRes, const uint32_t ctpVersionNumber, std::vector< uint32_t > &data, const uint32_t nExtraWords=0)
 Initialize the object using xAOD::Header, xAOD::Trailer, and the payload data.
const std::string print (const xAOD::CTPResult &ctpRes)
 Print object content in human readable format in a string.

Detailed Description

Utility functions for xAOD::CTPResult objects that rely on tdaq-common.

Declared here as tdaq-common is used in TrigT1Interfaces and not xAODTrigger. Prevents using XAOD_ANALYSIS macro in xAOD class.

Function Documentation

◆ initialize()

void CTPResultUtils::initialize ( xAOD::CTPResult & ctpRes,
const uint32_t ctpVersionNumber,
std::vector< uint32_t > & data,
const uint32_t nExtraWords = 0 )

Initialize the object using xAOD::Header, xAOD::Trailer, and the payload data.

Optionally, extra words can be included.

Parameters
ctpResReference to the CTPResult object to initialize.
ctpVersionNumberVersion number of the CTPdataformat.
dataVector of words representing the payload data (excluding timestamp words).
nExtraWordsNumber of additional words (default is 0).

Definition at line 23 of file CTPResultUtils.cxx.

23 {
24
25 // CTP version number
26 CTPdataformatVersion ctpDataFormat(ctpVersionNumber);
27 ctpRes.setCtpVersionNumber(ctpVersionNumber);
28
29 // Check for the case we have an empty data vector and return early
30 if (!data.size()) {
31 ctpRes.setNumberOfBunches(0u);
32 ctpRes.setTimeSec(0u);
33 ctpRes.setTimeNanoSec(0u);
34 ctpRes.setTIPWords({});
35 ctpRes.setTBPWords({});
36 ctpRes.setTAPWords({});
37 ctpRes.setTAVWords({});
38 ctpRes.setAdditionalWords({});
39 return;
40 }
41
42 // Set the number of bunches
43 uint32_t numberOfWords = static_cast<uint32_t>(data.size()) - ctpDataFormat.getNumberTimeWords() - nExtraWords;
44 ctpRes.setNumberOfBunches(numberOfWords / ctpDataFormat.getDAQwordsPerBunch());
45
46 // Set the timestamps
47 ctpRes.setTimeSec(data[ctpDataFormat.getTimeSecondsPos()]);
48 ctpRes.setTimeNanoSec(data[ctpDataFormat.getTimeNanosecondsPos()]);
49
50 // Create vectors of vectors for the trigger words for all bunches
51 std::vector<std::vector<uint32_t>> tip(ctpRes.numberOfBunches());
52 std::vector<std::vector<uint32_t>> tbp(ctpRes.numberOfBunches());
53 std::vector<std::vector<uint32_t>> tap(ctpRes.numberOfBunches());
54 std::vector<std::vector<uint32_t>> tav(ctpRes.numberOfBunches());
55
56 // Fill vectors
57 for( uint32_t bunch=0u; bunch != ctpRes.numberOfBunches(); ++bunch){
58
59 // TIP words
60 for(unsigned int tipIdx = 0; tipIdx < ctpDataFormat.getTIPwords(); ++tipIdx) {
61 unsigned int index = ctpDataFormat.getTIPpos() + tipIdx + (bunch * ctpDataFormat.getDAQwordsPerBunch());
62 if( index < data.size() ) {
63 tip[bunch].push_back(data[index]);
64 }
65 }
66
67 // TBP words
68 for(unsigned int tbpIdx = 0; tbpIdx < ctpDataFormat.getTBPwords(); ++tbpIdx) {
69 unsigned int index = ctpDataFormat.getTBPpos() + tbpIdx + (bunch * ctpDataFormat.getDAQwordsPerBunch());
70 if( index < data.size() ) {
71 tbp[bunch].push_back(data[index]);
72 }
73 }
74
75 // TAP words
76 for(unsigned int tapIdx = 0; tapIdx < ctpDataFormat.getTAPwords(); ++tapIdx) {
77 unsigned int index = ctpDataFormat.getTAPpos() + tapIdx + (bunch * ctpDataFormat.getDAQwordsPerBunch());
78 if( index < data.size() ) {
79 tap[bunch].push_back(data[index]);
80 }
81 }
82
83 // TAV words
84 for(unsigned int tavIdx = 0; tavIdx < ctpDataFormat.getTAVwords(); ++tavIdx) {
85 unsigned int index = ctpDataFormat.getTAVpos() + tavIdx + (bunch * ctpDataFormat.getDAQwordsPerBunch());
86 if( index < data.size() ) {
87 tav[bunch].push_back(data[index]);
88 }
89 }
90 }
91 ctpRes.setTIPWords(tip);
92 ctpRes.setTBPWords(tbp);
93 ctpRes.setTAPWords(tap);
94 ctpRes.setTAVWords(tav);
95
96 // Additional words
97 std::vector<uint32_t> vec;
98 vec.assign(data.begin() + (data.size()-nExtraWords), data.end());
99 ctpRes.setAdditionalWords(vec);
100 }
std::vector< size_t > vec
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
void setTimeSec(const uint32_t sec)
Set the time in seconds.
void setTAVWords(const std::vector< std::vector< uint32_t > > &words)
Set the TAV words for all bunch crossings.
void setNumberOfBunches(const uint32_t nBCs)
Set the number of bunch crossings.
void setTAPWords(const std::vector< std::vector< uint32_t > > &words)
Set the TAP words for all bunch crossings.
void setTBPWords(const std::vector< std::vector< uint32_t > > &words)
Set the TBP words for all bunch crossings.
void setAdditionalWords(const std::vector< uint32_t > &words)
Set the additional data words.
void setCtpVersionNumber(const uint32_t ctpNumber)
Set the CTP version number.
uint32_t numberOfBunches() const
Get the number of bunch crossings.
void setTimeNanoSec(const uint32_t nano)
Set the time in nanoseconds.
void setTIPWords(const std::vector< std::vector< uint32_t > > &words)
Set the TIP words for all bunch crossings.
str index
Definition DeMoScan.py:362
setBGCode tap
setEventNumber uint32_t

◆ print()

const std::string CTPResultUtils::print ( const xAOD::CTPResult & ctpRes)

Print object content in human readable format in a string.

Parameters
ctpResReference to the CTPResult object to initialize.
Returns
Human readable output as a string.

Definition at line 103 of file CTPResultUtils.cxx.

103 {
104
105 std::ostringstream s;
106
107 s << "\n*BEGIN* xAOD::CTPResult" << std::endl;
108
109 // Check number of bunches
110 if(ctpRes.numberOfBunches() == 0) {
111 s << "xAOD::CTPResult empty" << std::endl;
112 s << "*END* xAOD::CTPResult" << std::endl;
113 return s.str();
114 }
115
116 // Print whether the object has the expected format and has good status
117 std::vector<std::string> ctpResultIssues = ctpRes.checkForIssues();
118 if (ctpResultIssues.empty()) {
119 s << "xAOD::CTPResult status: Good! " << std::endl;
120 } else {
121 s << "xAOD::CTPResult status: Bad! " << std::endl;
122 for (const auto& issue : ctpResultIssues) {
123 s << "xAOD::CTPResult status: " << issue << std::endl;
124 }
125 }
126
127 s << "CTP version number: " << ctpRes.ctpVersionNumber() << std::endl;
128 s << "Number of bunches: " << ctpRes.numberOfBunches() << std::endl;
129 s << "L1A position: " << ctpRes.l1AcceptBunchPosition() << std::endl;
130
131 // Print header info
132 s << "Header information: " << std::endl;
133 s << " Header marker : " << std::hex << ctpRes.headerMarker() << std::dec << std::endl;
134 s << " Header size : " << ctpRes.headerSize() << std::endl;
135 s << " Header format version : " << ctpRes.headerFormatVersion() << std::endl;
136 s << " Source ID : 0x" << std::hex << ctpRes.sourceID() << std::dec << std::endl;
137 s << " Run number : " << ctpRes.runNumber() << std::endl;
138 s << " Ext. LVL1 ID : " << ctpRes.L1ID() << std::endl;
139 s << " BCID : " << ctpRes.BCID() << std::endl;
140 s << " Trigger type : " << ctpRes.triggerType() << std::endl;
141 s << " Det. event type : " << ctpRes.eventType() << std::endl;
142
143 // Print payload info
144 s << "Payload information: " << std::endl;
145 s << " Time " << ctpRes.timeSec() << "s "
146 << std::setw(10) << std::setiosflags(std::ios_base::right) << std::setfill(' ')
147 << ctpRes.timeNanoSec() << std::resetiosflags(std::ios_base::right)
148 << "ns" << std::endl;
149
150 // Print per-bunch information
151 for(unsigned int i = 0; i<ctpRes.numberOfBunches(); ++i) {
152
153 auto bunch = ctpRes.getBC(i);
154 s << " BC dump for bunch " << i << std::endl;
155
156 // TIP words
157 for(unsigned int j = 0; j<ctpRes.tipWords()[i].size(); ++j) {
158 s << " TIP word number " << j << ": 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << ctpRes.tipWords()[i][j] << std::dec << std::endl;
159 }
160 if (ctpRes.tipWords()[i].size() == 0) {
161 s << " No TIP words!" << std::endl;
162 }
163
164 // TBP words
165 for(unsigned int j = 0; j<ctpRes.tbpWords()[i].size(); ++j) {
166 s << " TBP word number " << j << ": 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << ctpRes.tbpWords()[i][j] << std::dec << std::endl;
167 }
168 if (ctpRes.tbpWords()[i].size() == 0) {
169 s << " No TBP words!" << std::endl;
170 }
171
172 // TAP words
173 for(unsigned int j = 0; j<ctpRes.tapWords()[i].size(); ++j) {
174 s << " TAP word number " << j << ": 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << ctpRes.tapWords()[i][j] << std::dec << std::endl;
175 }
176 if (ctpRes.tapWords()[i].size() == 0) {
177 s << " No TAP words!" << std::endl;
178 }
179
180 // TAV words
181 for(unsigned int j = 0; j<ctpRes.tavWords()[i].size(); ++j) {
182 s << " TAV word number " << j << ": 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << ctpRes.tavWords()[i][j] << std::dec << std::endl;
183 }
184 if (ctpRes.tavWords()[i].size() == 0) {
185 s << " No TAV words!" << std::endl;
186 }
187 }
188
189 // Additional words
190 for(unsigned int i = 0; i<ctpRes.additionalWords().size(); ++i) {
191 s << " Additional word number " << i << ": 0x" << std::hex << std::setw( 8 ) << std::setfill( '0' ) << ctpRes.additionalWords()[i] << std::dec << std::endl;
192 }
193 if (ctpRes.additionalWords().size() == 0) {
194 s << " No additional words!" << std::endl;
195 }
196
197 // Print trailer info
198 s << "Trailer information: " << std::endl;
199 s << " Error status : " << ctpRes.errorStatus() << std::endl;
200 s << " Status info : " << ctpRes.infoStatus() << std::endl;
201 s << " Number of status words : " << ctpRes.numStatusWords() << std::endl;
202 s << " Number of data words : " << ctpRes.numDataWords() << std::endl;
203 s << " Status information position : " << ctpRes.statusPosition() << std::endl;
204 s << "*END* xAOD::CTPResult" << std::endl;
205
206 return s.str();
207 }
size_t size() const
Number of registered mappings.
uint32_t numDataWords() const
Retrieve the number of data words.
uint32_t L1ID() const
Retrieve the extended LVL1 ID.
const std::vector< std::vector< uint32_t > > & tbpWords() const
Get the TBP words for all bunch crossings.
uint32_t numStatusWords() const
Retrieve the number of status words in the trailer.
const std::vector< std::vector< uint32_t > > & tapWords() const
Get the TAP words for all bunch crossings.
uint32_t infoStatus() const
Retrieve the info status word.
uint32_t headerSize() const
Retrieve the number of words in the header.
uint32_t triggerType() const
Retrieve the LVL1 trigger type.
uint32_t runNumber() const
Retrieve the run number.
uint32_t statusPosition() const
Retrieve the position of status information in the ROD.
uint32_t BCID() const
Retrieve the bunch crossing ID.
const std::vector< uint32_t > & additionalWords() const
Get the additional data words.
uint32_t headerFormatVersion() const
Retrieve the format version of the header.
uint32_t errorStatus() const
Retrieve the error status word.
uint32_t timeSec() const
Get the time in seconds.
const std::vector< std::vector< uint32_t > > & tipWords() const
Get the TIP words for all bunch crossings.
const std::vector< std::vector< uint32_t > > & tavWords() const
Get the TAV words for all bunch crossings.
uint32_t eventType() const
Retrieve the LVL1 event type.
uint32_t headerMarker() const
Retrieve the header marker word.
const CTPResult_v1::CTPBunchCrossing getBC(const int bunch=-1) const
Get the CTPBunchCrossing object for a specific bunch in the readout window.
std::vector< std::string > checkForIssues() const
Get whether the CTPResult object is in a good state (i.e.
uint32_t ctpVersionNumber() const
Get the CTP version number.
uint32_t timeNanoSec() const
Get the time in nanoseconds.
uint32_t sourceID() const
Retrieve the sub-detector source ID.
uint32_t l1AcceptBunchPosition() const
Get the L1 accept bunch position.
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)