94 {
96
97 const EventContext& ctx = Gaudi::Hive::currentContext();
98
99
102 if (!castSuccessful || !l1TriggerResult) {
103 ATH_MSG_ERROR(
"Failed to convert DataObject to xAOD::TrigCompositeContainer for L1TriggerResult");
104 return StatusCode::FAILURE;
105 }
106
107
110 ATH_MSG_ERROR(
"Failed to obtain a pointer to RawEventWrite");
111 return StatusCode::FAILURE;
112 }
114
115
116
117
119
120
124
125
126 auto wordsToBitset = [](
const std::vector<uint32_t>&
words) {
127 std::bitset<512>
out;
128 for (
size_t i = 0;
i <
words.size(); ++
i) {
130 for (
size_t b = 0;
b < 32; ++
b) {
131 if (w & (1u << b)) {
133 }
134 }
135 }
137 };
138
139 std::bitset<512> tbp = wordsToBitset(
result->getTBPWords());
140 std::bitset<512>
tap = wordsToBitset(
result->getTAPWords());
141 std::bitset<512> tav = wordsToBitset(
result->getTAVWords());
142
143
144 constexpr size_t wordSize = 32;
145 constexpr size_t wordsPerSet = 512 / wordSize;
146 constexpr size_t numWords = 3 * wordsPerSet;
147
148
149 std::vector<uint32_t> l1BitsData(numWords, 0);
150
151
152 size_t iset{0};
153 for (
const std::bitset<512>& bset : {tbp,
tap, tav}) {
154 const std::string
sbits = bset.to_string();
155 const size_t iWordOutputStart = wordsPerSet * iset;
156 for (size_t iWordInSet = 0; iWordInSet < wordsPerSet; ++iWordInSet) {
157 const size_t bwordPos = 512 - (iWordInSet + 1) * wordSize;
158 std::bitset<wordSize> bword{
sbits.substr(bwordPos, wordSize)};
159 l1BitsData[iWordOutputStart + iWordInSet] =
static_cast<uint32_t>(bword.to_ulong());
160 }
161 ++iset;
162 }
164
165
166 re->lvl1_trigger_info(l1BitsData.size(), l1BitsData.data());
167 re->lvl1_trigger_type(
static_cast<uint8_t>(triggerType & 0xFF));
168
169
170 std::vector<WROBF*> ctpResultROBs;
173 for (
WROBF* rob : ctpResultROBs) {
175
176 rob->rod_lvl1_type(
re->lvl1_trigger_type());
177
178 rob->rod_lvl1_id(
re->lvl1_id());
179
181 ATH_MSG_DEBUG(
"Added ROB fragment 0x" << MSG::hex << rob->source_id() << MSG::dec <<
" to the output raw event");
182 }
183 }
184
185
186
188 if (not
tool.isEnabled()) {
continue;}
189 std::vector<WROBF*> muon_robs;
191 ATH_MSG_DEBUG(
tool.name() <<
" created " << muon_robs.size() <<
" L1Muon ROB Fragments");
192 for (
WROBF* rob : muon_robs) {
194
195 rob->rod_lvl1_type(
re->lvl1_trigger_type());
196
197 rob->rod_lvl1_id(
re->lvl1_id());
198
200 ATH_MSG_DEBUG(
"Added ROB fragment 0x" << MSG::hex << rob->source_id() << MSG::dec <<
" to the output raw event");
201 }
202 }
203
204
205
206
207 if ( pAddr != nullptr ) pAddr->release();
208 ByteStreamAddress* bsAddr =
new ByteStreamAddress(
classID(), pObj->registry()->name(),
"");
209 pAddr = static_cast<IOpaqueAddress*>(bsAddr);
210 pAddr->addRef();
211
213 return StatusCode::SUCCESS;
214}
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.
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.