115 auto bxId =
event.bunchCrossing();
120 auto evtId =
event.id().event();
121 auto orbit =
event.eventAuxiliary().orbitNumber();
122 LogDebug(
"L1T") <<
"Forming FED with metadata bxId=" << bxId <<
", l1ID=" << evtId <<
", orbit=" << orbit;
126 auto amc_no = item.first.first;
127 auto board = item.first.second;
128 auto packers = item.second;
131 for (
const auto& packer: packers) {
132 LogDebug(
"L1T") <<
"Adding packed blocks";
133 packer->setBoard(board);
135 block_load.insert(block_load.end(),
blocks.begin(),
blocks.end());
138 std::sort(block_load.begin(), block_load.end());
140 LogDebug(
"L1T") <<
"Concatenating blocks";
142 std::vector<uint32_t> load32;
148 load32.push_back(
fwId_);
150 for (
const auto&
block: block_load) {
151 LogDebug(
"L1T") <<
"Adding block " <<
block.header().getID() <<
" with size " <<
block.payload().size();
155 std::stringstream
s(
"");
156 s <<
"Block content:" << std::endl << std::hex << std::setfill(
'0');
157 for (
const auto& word:
load)
158 s << std::setw(8) << word << std::endl;
162 if (
block.header().getType() ==
CTP7 ) {
164 load32.push_back(0xA110CA7E);
166 load32.push_back(
block.header().raw());
167 load32.insert(load32.end(), load.begin(), load.end());
170 LogDebug(
"L1T") <<
"Converting payload";
172 std::vector<uint64_t> load64;
173 for (
unsigned int i = 0;
i < load32.size();
i += 2) {
175 if (
i + 1 < load32.size()) {
176 word |=
static_cast<uint64_t>(load32[
i + 1]) << 32;
178 word |=
static_cast<uint64_t>(0xffffffff) << 32;
180 load64.push_back(word);
183 LogDebug(
"L1T") <<
"Creating AMC packet";
185 unsigned amc_user_header = 0;
186 if ( ctp7_mode_ ) amc_user_header =
fwId_;
187 amc13.
add(amc_no, board, evtId, orbit, bxId, load64, amc_user_header);
196 unsigned char * payload_start =
payload;
204 payload += amc13.
size() * 8;
207 trailer.set(payload, size / 8,
evf::compute_crc(payload_start, size), 0, 0);
std::unique_ptr< PackerTokens > tokens_
std::unique_ptr< PackingSetup > setup_
unsigned int size() const
void add(unsigned int amc_no, unsigned int board, unsigned int lv1id, unsigned int orbit, unsigned int bx, const std::vector< uint64_t > &load, unsigned int user=0)
bool write(const edm::Event &ev, unsigned char *ptr, unsigned int skip, unsigned int size) const
void resize(size_t newsize)
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
std::vector< Block > Blocks
unsigned long long uint64_t
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.