37 uint16_t, std::map<uint16_t, std::map<uint32_t, uint32_t>
42 sorted_samples(digis.getNumSamplesPerDigi());
54 for (
auto digi : digis) {
58 for (std::size_t i_bx{0}; i_bx < digis.getNumSamplesPerDigi(); i_bx++) {
59 sorted_samples[i_bx][eid.fiber()][eid.elink()][eid.channel()] =
74 std::vector<uint32_t> buffer;
78 for (
auto const& bunch : sorted_samples) {
83 uint32_t bunch_id =
event.getEventNumber();
85 uint32_t orbit =
event.getEventHeader().getRun();
88 for (
auto const& [fpga_id, links] : bunch) {
100 std::vector<uint32_t> link_lengths;
101 for (
auto const& [link_id, channels] : links) {
102 link_lengths.push_back(3 + 1 + channels.size() + 1);
115 uint32_t n_linkwords =
116 link_lengths.size() / 4 + (link_lengths.size() % 4 != 0);
117 uint32_t total_length{2 + n_linkwords + 1};
118 for (uint32_t
const& link_len : link_lengths) {
119 total_length += link_len;
140 word |= (1 << (12 + 1 + 6 + 8));
141 word |= (fpga_id & packing::utility::mask<8>) << (12 + 1 + 6);
142 word |= (links.size() & packing::utility::mask<6>) << (12 + 1);
143 word |= (total_length & packing::utility::mask<12>);
144 buffer.push_back(word);
148 word |= (bunch_id & packing::utility::mask<12>) << 20;
149 word |= (rreq & packing::utility::mask<10>) << 10;
150 word |= (orbit & packing::utility::mask<10>);
151 buffer.push_back(word);
157 for (uint32_t i_linkword{0}; i_linkword < n_linkwords; i_linkword++) {
159 for (uint32_t i_linklen{0}; i_linklen < 4; i_linklen++) {
160 uint32_t i_link = 4 * i_linkword + i_linklen;
161 if (i_link <= link_lengths.size()) {
163 word |= (((0b11 << 6) +
164 (link_lengths.at(i_link) & packing::utility::mask<6>))
168 buffer.push_back(word);
173 for (
auto const& [link_id, channels] : links) {
177 std::bitset<40> ro_map;
181 for (
auto const& [channel, sample] : channels) {
196 word |= (link_id & packing::utility::mask<16>) << 16;
199 word |= (ro_map >> 32).to_ulong();
201 buffer.push_back(word);
206 word = (ro_map.to_ulong() & 0xFFFFFFFF);
207 buffer.push_back(word);
213 word |= 0b0101 << 28;
214 word |= (bunch_id & packing::utility::mask<12>) << 16;
215 word |= (rreq & packing::utility::mask<6>) << 10;
216 word |= (orbit & packing::utility::mask<3>) << 7;
220 buffer.push_back(word);
233 for (
auto const& [channel, sample] : channels) {
234 buffer.push_back(sample);
238 buffer.push_back(link_crc.
get());
239 fpga_crc << link_crc.
get();