ATLAS Offline Software
Loading...
Searching...
No Matches
CTPResult_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6// System include(s):
7#include <iostream>
8#include <stdexcept>
9
10// xAOD include(s):
12
13// Local include(s):
15
16namespace xAOD {
17
18 // get/set the number of the CTP version to be used
19 AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(CTPResult_v1, uint32_t, ctpVersionNumber, setCtpVersionNumber);
20
21 // Get/set the header marker word
23
24 // Get/set the number of header words
26
27 // Get/set the version of header format
28 AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(CTPResult_v1, uint32_t, headerFormatVersion, setHeaderFormatVersion);
29
30 // Get/set the sub detector source ID
32
33 // Get/set the run number
35
36 // Get/set the extended LVL1 ID
38
39 // Get/set the bunch crossing ID
41
42 // Get/set the LVL1 trigger type
44
45 // Get/set the LVL1 event type
47
48 // get/set the vector TIP words for all bunch crossings
49 AUXSTORE_OBJECT_SETTER_AND_GETTER(CTPResult_v1, std::vector<std::vector<uint32_t>>, tipWords, setTIPWords)
50
51 // get/set the vector TBP words for all bunch crossings
52 AUXSTORE_OBJECT_SETTER_AND_GETTER(CTPResult_v1, std::vector<std::vector<uint32_t>>, tbpWords, setTBPWords)
53
54 // get/set the vector TAP words for all bunch crossings
55 AUXSTORE_OBJECT_SETTER_AND_GETTER(CTPResult_v1, std::vector<std::vector<uint32_t>>, tapWords, setTAPWords)
56
57 // get/set the vector TAV words for all bunch crossings
58 AUXSTORE_OBJECT_SETTER_AND_GETTER(CTPResult_v1, std::vector<std::vector<uint32_t>>, tavWords, setTAVWords)
59
60 // get the time stamp in seconds
62
63 // get the time stamp in nanoseconds
65
66 // get/set the raw data words
67 AUXSTORE_OBJECT_SETTER_AND_GETTER(CTPResult_v1, std::vector<uint32_t>, additionalWords, setAdditionalWords)
68
69 // get/set the turn counter
70 AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( CTPResult_v1, uint32_t, turnCounter, setTurnCounter )
71
72 // Get/set the error status word
74
75 // Get/set the info status word
77
78 // Get/set the number of status words
79 AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(CTPResult_v1, uint32_t, numStatusWords, setNumStatusWords);
80
81 // Get/set the number data words
83
84 // Get/set the position of status information in ROD (LVL1 assumes 1)
85 AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(CTPResult_v1, uint32_t, statusPosition, setStatusPosition);
86
87 // get the number of bunches
89
90 // get the L1 Accept Bunch Position
91 AUXSTORE_PRIMITIVE_GETTER(CTPResult_v1, uint32_t, l1AcceptBunchPosition)
92
93 // Get the CTPBunchCrossing object for a specific bunch in the readout window. Returns L1A bunch by default.
95
96 // If there are no bunches, then return an empty CTPBunchCrossing struct
97 if (numberOfBunches() == 0) return {};
98
99 // Test to see what index to use
100 int idx = (bunch == -1) ? l1AcceptBunchPosition() : bunch;
101
102 // Grab words
103 const auto& tip = tipWords();
104 const auto& tbp = tbpWords();
105 const auto& tap = tapWords();
106 const auto& tav = tavWords();
107
108 // Check the index is valid, if not then return an empty CTPBunchCrossing struct
109 if (idx < 0 ||
110 idx >= static_cast<int>(numberOfBunches()) ||
111 idx >= static_cast<int>(tbp.size()) ||
112 idx >= static_cast<int>(tip.size()) ||
113 idx >= static_cast<int>(tap.size()) ||
114 idx >= static_cast<int>(tav.size())) {
115 return {};
116 }
117
118 // Return the appropriate bunch information
120 bc.tipWords = tip[idx];
121 bc.tbpWords = tbp[idx];
122 bc.tapWords = tap[idx];
123 bc.tavWords = tav[idx];
124
125 return bc;
126 }
127
128 // set the number of bunches
130 static const SG::AuxElement::Accessor< uint32_t > accNumOfBunches("numberOfBunches");
131 static const SG::AuxElement::Accessor< std::vector<std::vector<uint32_t> > > accTIPWords("tipWords");
132 static const SG::AuxElement::Accessor< std::vector<std::vector<uint32_t> > > accTBPWords("tbpWords");
133 static const SG::AuxElement::Accessor< std::vector<std::vector<uint32_t> > > accTAPWords("tapWords");
134 static const SG::AuxElement::Accessor< std::vector<std::vector<uint32_t> > > accTAVWords("tavWords");
135 accNumOfBunches( *this ) = nBCs;
136 accTIPWords( *this ).resize(nBCs);
137 accTBPWords( *this ).resize(nBCs);
138 accTAPWords( *this ).resize(nBCs);
139 accTAVWords( *this ).resize(nBCs);
140 }
141
142 // set the L1 Accept Bunch Position
144 if (numberOfBunches() == 1 && pos > 0) {pos=0;}
145 static const SG::Accessor<uint32_t> acc("l1AcceptBunchPosition");
146 acc(*this) = pos;
147 }
148
149 // Get TIP words for a specific bunch crossing
150 std::vector<uint32_t> CTPResult_v1::getTIPWords(const int bunch) const {
151 return getBC(bunch).tipWords;
152 }
153
154 // Get TBP words for a specific bunch crossing
155 std::vector<uint32_t> CTPResult_v1::getTBPWords(const int bunch) const {
156 return getBC(bunch).tbpWords;
157 }
158
159 // Get TAP words for a specific bunch crossing
160 std::vector<uint32_t> CTPResult_v1::getTAPWords(const int bunch) const {
161 return getBC(bunch).tapWords;
162 }
163
164 // Get TAV words for a specific bunch crossing
165 std::vector<uint32_t> CTPResult_v1::getTAVWords(const int bunch) const {
166 return getBC(bunch).tavWords;
167 }
168
169 // Get a vector of header words
170 const std::vector<uint32_t> CTPResult_v1::header() const {
171 return {
172 headerMarker(),
173 headerSize(),
175 sourceID(),
176 runNumber(),
177 L1ID(),
178 BCID(),
179 triggerType(),
180 eventType()
181 };
182 }
183
184 // Get the header words
185 void CTPResult_v1::setHeader(const uint32_t marker, const uint32_t version, const uint32_t sourceid, const uint32_t l1id, const uint32_t runNum, const uint32_t bcid, const uint32_t trigType, const uint32_t evtType) {
186 setHeaderMarker(marker);
187 setHeaderSize(8);
188 setHeaderFormatVersion(version);
189 setSourceID(sourceid);
190 setRunNumber(runNum);
191 setL1ID(l1id);
192 setBCID(bcid);
193 setTriggerType(trigType);
194 setEventType(evtType);
195 }
196
197 // Get a vector of trailer words
198 const std::vector<uint32_t> CTPResult_v1::trailer() const {
199 return {
200 errorStatus(),
201 infoStatus(),
203 numDataWords(),
205 };
206 }
207
208 // Set the trailer words
209 void CTPResult_v1::setTrailer(const uint32_t numData, const uint32_t errStat, const uint32_t infoStat, const uint32_t numStat, const uint32_t statPos) {
210 setErrorStatus(errStat);
211 setInfoStatus(infoStat);
212 setNumStatusWords(numStat);
213 setNumDataWords(numData);
214 setStatusPosition(statPos);
215 }
216
217 // Check the object using requirements of the CTP data format (for Run 3)
218 std::vector<std::string> CTPResult_v1::checkForIssues() const {
219
220 // Create vector to store warnings
221 std::vector<std::string> msg;
222
223 // Check for completely empty payload
224 if (numberOfBunches() == 0 && additionalWords().empty()) {
225 msg.push_back("CTPResult has a completely empty payload!");
226 }
227
228 // Expect exactly 2 status words
229 if (numStatusWords() != 2) {
230 msg.push_back("CTPResult does not have exactly 2 status words!");
231 }
232
233 // Both status words must be zero
234 if (errorStatus() != 0 || infoStatus() != 0) {
235 msg.push_back("CTPResult has non-zero status words!");
236 }
237
238 // Status information position must be 1
239 if (statusPosition() != 1) {
240 msg.push_back("CTPResult has incorrect status info position!");
241 }
242
243 // L1 accept position must be valid
244 uint32_t nBCs = numberOfBunches(); {
245 if (nBCs != 0 && l1AcceptBunchPosition() >= nBCs)
246 msg.push_back("CTPResult has an invalid L1A accept position!");
247 }
248
249 return msg;
250 }
251}
#define AUXSTORE_PRIMITIVE_GETTER(CL, TYPE, NAME)
Macro creating the reader function for a primitive auxiliary property.
#define AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of primitive auxiliary properties.
#define AUXSTORE_OBJECT_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of complex auxiliary properties.
static const Attributes_t empty
Helper class to provide type-safe access to aux data.
This is the trigger result for each item before prescale, after prescale and after veto.
void setHeaderFormatVersion(const uint32_t word)
Set the format version of the header.
uint32_t numDataWords() const
Retrieve the number of data words.
void setEventType(const uint32_t word)
Set the LVL1 event type.
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.
void setInfoStatus(const uint32_t word)
Set the info status word.
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.
std::vector< uint32_t > getTBPWords(const int bunchPosition=-1) const
Get the TBP (Trigger Before Prescale) words.
void setNumberOfBunches(const uint32_t nBCs)
Set the number of bunch crossings.
uint32_t infoStatus() const
Retrieve the info status word.
uint32_t headerSize() const
Retrieve the number of words in the header.
void setHeader(const uint32_t marker, const uint32_t version, const uint32_t sourceid, const uint32_t l1id=0, const uint32_t runNum=0, const uint32_t bcid=0, const uint32_t trigType=0, const uint32_t evtType=0)
Set the header words.
void setHeaderSize(const uint32_t word)
Set the number of words in the header.
std::vector< uint32_t > getTAPWords(const int bunchPosition=-1) const
Get the TAP (Trigger After Prescale) words.
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.
void setNumStatusWords(const uint32_t word)
Set the number of status words in the trailer.
uint32_t headerFormatVersion() const
Retrieve the format version of the header.
void setHeaderMarker(const uint32_t word)
Set the header marker word.
const std::vector< uint32_t > trailer() const
Get the trailer words.
void setRunNumber(const uint32_t word)
Set the run number.
uint32_t errorStatus() const
Retrieve the error status word.
void setTriggerType(const uint32_t word)
Set the LVL1 trigger type.
void setBCID(const uint32_t word)
Set the bunch crossing ID.
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.
void setL1ID(const uint32_t word)
Set the extended LVL1 ID.
void setSourceID(const uint32_t word)
Set the sub-detector source ID.
void setStatusPosition(const uint32_t word)
Set the position of status information in the ROD.
void setTrailer(const uint32_t numData, const uint32_t errStat=0, const uint32_t infoStat=0, const uint32_t numStat=2, const uint32_t statPos=1)
Set the trailer words.
uint32_t eventType() const
Retrieve the LVL1 event type.
void setNumDataWords(const uint32_t num)
Set the number of data words.
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.
std::vector< uint32_t > getTIPWords(const int bunchPosition=-1) const
Get the TIP (Trigger Inputs to the CTP) words (in Run3 512 items).
std::vector< uint32_t > getTAVWords(const int bunchPosition=-1) const
Get the TAV (Trigger After Veto) words.
uint32_t numberOfBunches() const
Get the number of bunch crossings.
const std::vector< uint32_t > header() const
Get the header words.
void setErrorStatus(const uint32_t word)
Set the error status word.
uint32_t sourceID() const
Retrieve the sub-detector source ID.
void setL1AcceptBunchPosition(uint32_t pos)
Set the L1Accept bunch position.
uint32_t l1AcceptBunchPosition() const
Get the L1 accept bunch position.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
setBGCode tap
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1, float, IP2D_pb, setIP2D_pb) AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1
setEventNumber setTimeStamp bcid
setEventNumber uint32_t
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.
This is the trigger result for each item before prescale, after prescale and after veto for a single ...
std::vector< uint32_t > tapWords
std::vector< uint32_t > tbpWords
std::vector< uint32_t > tavWords
std::vector< uint32_t > tipWords
MsgStream & msg
Definition testRead.cxx:32