100 {
102
103 const EventContext& ctx = Gaudi::Hive::currentContext();
104
105
108 if (!castSuccessful || !l1TriggerResult) {
109 ATH_MSG_ERROR(
"Failed to convert DataObject to xAOD::TrigCompositeContainer for L1TriggerResult");
110 return StatusCode::FAILURE;
111 }
112
113
116 ATH_MSG_ERROR(
"Failed to obtain a pointer to RawEventWrite");
117 return StatusCode::FAILURE;
118 }
120
121
122
123
125
126
130
131
132 auto wordsToBitset = [](
const std::vector<uint32_t>&
words) {
133 std::bitset<512>
out;
134 for (
size_t i = 0;
i <
words.size(); ++
i) {
136 for (
size_t b = 0;
b < 32; ++
b) {
137 if (w & (1u << b)) {
139 }
140 }
141 }
143 };
144
145 std::bitset<512> tbp = wordsToBitset(
result->getTBPWords());
146 std::bitset<512>
tap = wordsToBitset(
result->getTAPWords());
147 std::bitset<512> tav = wordsToBitset(
result->getTAVWords());
148
149
150 constexpr size_t wordSize = 32;
151 constexpr size_t wordsPerSet = 512 / wordSize;
152 constexpr size_t numWords = 3 * wordsPerSet;
153
154
155 std::vector<uint32_t> l1BitsData(numWords, 0);
156
157
158 size_t iset{0};
159 for (
const std::bitset<512>& bset : {tbp,
tap, tav}) {
160 const std::string
sbits = bset.to_string();
161 const size_t iWordOutputStart = wordsPerSet * iset;
162 for (size_t iWordInSet = 0; iWordInSet < wordsPerSet; ++iWordInSet) {
163 const size_t bwordPos = 512 - (iWordInSet + 1) * wordSize;
164 std::bitset<wordSize> bword{
sbits.substr(bwordPos, wordSize)};
165 l1BitsData[iWordOutputStart + iWordInSet] =
static_cast<uint32_t>(bword.to_ulong());
166 }
167 ++iset;
168 }
170
171
172 re->lvl1_trigger_info(l1BitsData.size(), l1BitsData.data());
173 re->lvl1_trigger_type(
static_cast<uint8_t>(triggerType & 0xFF));
174
175
176 std::vector<WROBF*> ctpResultROBs;
179 for (
WROBF* rob : ctpResultROBs) {
181
182 rob->rod_lvl1_type(
re->lvl1_trigger_type());
183
184 rob->rod_lvl1_id(
re->lvl1_id());
185
187 ATH_MSG_DEBUG(
"Added ROB fragment 0x" << MSG::hex << rob->source_id() << MSG::dec <<
" to the output raw event");
188 }
189 }
190
191
192
194 if (not
tool.isEnabled()) {
continue;}
195 std::vector<WROBF*> muon_robs;
197 ATH_MSG_DEBUG(
tool.name() <<
" created " << muon_robs.size() <<
" L1Muon ROB Fragments");
198 for (
WROBF* rob : muon_robs) {
200
201 rob->rod_lvl1_type(
re->lvl1_trigger_type());
202
203 rob->rod_lvl1_id(
re->lvl1_id());
204
206 ATH_MSG_DEBUG(
"Added ROB fragment 0x" << MSG::hex << rob->source_id() << MSG::dec <<
" to the output raw event");
207 }
208 }
209
210
211
212
213 if ( pAddr != nullptr ) pAddr->release();
214 ByteStreamAddress* bsAddr =
new ByteStreamAddress(
classID(), pObj->registry()->name(),
"");
215 pAddr = static_cast<IOpaqueAddress*>(bsAddr);
216 pAddr->addRef();
217
219 return StatusCode::SUCCESS;
220}
const boost::regex re(r_e)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
#define sbits(u, n)
Intrinsic functions which do not work correctly due to differences in byte ordering.
void printRob(const OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment &rob) const
Helper method for debug printouts.
ToolHandle< IL1TriggerByteStreamTool > m_ctpResultEncoderTool
Encoder tool for CTP result.
ToolHandle< IL1TriggerByteStreamTool > m_efexEncoderTool
eFEX tool
SG::ReadHandleKey< xAOD::CTPResult > m_inKeyCTPResult
ToolHandle< IL1TriggerByteStreamTool > m_muonEncoderTool
Encoder tools for L1Muon RoIs (one writing RoIB ROB, one writing DAQ ROB)
ServiceHandle< IByteStreamEventAccess > m_ByteStreamEventAccess
Helper to obtain the RawEvent pointer.
ToolHandle< IL1TriggerByteStreamTool > m_muonEncoderToolDaq
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
TrigCompositeContainer_v1 TrigCompositeContainer
Declare the latest version of the container.
CTPResult_v1 CTPResult
Define the latest version of the CTPResult class.