43 #include <boost/algorithm/string.hpp>
132 : rxFileReader_(iConfig.getUntrackedParameter<
std::
string>(
"rxFile",
"rx_summary.txt")),
133 txFileReader_(iConfig.getUntrackedParameter<
std::
string>(
"txFile",
"tx_summary.txt")),
134 rxPacketReader_(iConfig.getUntrackedParameter<
std::
string>(
"rxFile",
"rx_summary.txt"),
135 iConfig.getUntrackedParameter<
int>(
"rxHeaderFrames", 1),
137 iConfig.getUntrackedParameter<
int>(
"rxKeyLink", 0)),
138 txPacketReader_(iConfig.getUntrackedParameter<
std::
string>(
"txFile",
"tx_summary.txt"),
139 iConfig.getUntrackedParameter<
int>(
"txHeaderFrames", 1),
141 iConfig.getUntrackedParameter<
int>(
"txKeyLink", 0)),
142 packetisedData_(iConfig.getUntrackedParameter<
bool>(
"packetisedData",
true)),
143 nFramesPerEvent_(iConfig.getUntrackedParameter<
int>(
"nFramesPerEvent", 6)),
144 iBoard_(iConfig.getUntrackedParameter<
int>(
"boardOffset", 0)),
145 boardId_(iConfig.getUntrackedParameter<
std::
vector<
int> >(
"boardId")),
146 mux_(iConfig.getUntrackedParameter<
bool>(
"mux",
false)),
147 fedId_(iConfig.getUntrackedParameter<
int>(
"fedId", 1)),
148 evType_(iConfig.getUntrackedParameter<
int>(
"eventType", 1)),
149 fwVer_(iConfig.getUntrackedParameter<
int>(
"fwVersion", 1)),
150 slinkHeaderSize_(iConfig.getUntrackedParameter<
int>(
"lenSlinkHeader", 8)),
151 slinkTrailerSize_(iConfig.getUntrackedParameter<
int>(
"lenSlinkTrailer", 8)) {
152 produces<FEDRawDataCollection>();
156 edm::LogError(
"L1T") <<
"Different number of boards in Rx and Tx files";
182 std::vector<edm::ParameterSet> vpset = iConfig.
getUntrackedParameter<std::vector<edm::ParameterSet> >(
"blocks");
185 edm::LogError(
"L1T") <<
"Wrong number of block specs " << vpset.size();
192 std::vector<int>
rx = vpset.at(
i).getUntrackedParameter<std::vector<int> >(
"rxBlockLength");
196 for (
unsigned j = 0;
j <
rx.size(); ++
j) {
204 std::vector<int> tx = vpset.at(
i).getUntrackedParameter<std::vector<int> >(
"txBlockLength");
207 for (
unsigned j = 0;
j < tx.size(); ++
j) {
242 for (
unsigned iBoard = 0; iBoard <
nBoard_; ++iBoard) {
270 <<
" Rx links, " <<
txBlockLength_.at(iBoard).size() <<
" Tx links";
272 std::vector<Block>
blocks;
276 unsigned id =
link * 2;
282 std::vector<uint32_t>
data;
289 LogDebug(
"L1T") <<
"Found packet [" << itr->first_ <<
", " << itr->last_ <<
"]";
290 LogDebug(
"L1T") <<
"Link " <<
link <<
" has " << itr->links_.find(
link)->second.size() <<
" frames";
292 for (
unsigned iFrame = 0; iFrame < itr->links_.find(
link)->second.size(); ++iFrame) {
299 LogDebug(
"L1T") <<
"Frame " << iFrame <<
" : " << std::hex <<
d;
300 if ((
d & 0x100000000) > 0)
301 data.push_back(
d & 0xffffffff);
305 LogDebug(
"L1T") <<
"Board " << iBoard <<
" block " <<
id <<
", size " <<
data.size();
313 unsigned id = (
link * 2) + 1;
319 LogDebug(
"L1T") <<
"Block " <<
id <<
" expecting size " <<
size;
321 std::vector<uint32_t>
data;
328 LogDebug(
"L1T") <<
"Found packet [" << itr->first_ <<
", " << itr->last_ <<
"]";
329 LogDebug(
"L1T") <<
"Link " <<
link <<
" has " << itr->links_.find(
link)->second.size() <<
" frames";
331 for (
unsigned iFrame = 0; iFrame < itr->links_.find(
link)->second.size(); ++iFrame) {
339 LogDebug(
"L1T") <<
"Frame " << iFrame <<
" : " << std::hex <<
d;
340 if ((
d & 0x100000000) > 0)
341 data.push_back(
d & 0xffffffff);
345 LogDebug(
"L1T") <<
"Board " << iBoard <<
" block " <<
id <<
", size " <<
data.size();
360 LogDebug(
"L1T") <<
"Board " << iBoard <<
", read " <<
blocks.size() <<
" blocks";
366 LogDebug(
"L1T") <<
"Formatting Board " << iBoard;
368 std::vector<uint32_t> load32;
375 LogDebug(
"L1T") <<
"Adding block " <<
block.header().getID() <<
" with size " <<
block.payload().size();
379 std::stringstream
s(
"");
380 s <<
"Block content:" << std::endl << std::hex << std::setfill(
'0');
382 s << std::setw(8) <<
word << std::endl;
386 load32.push_back(
block.header().raw());
387 load32.insert(load32.end(),
load.begin(),
load.end());
390 LogDebug(
"L1T") <<
"Converting payload " << iBoard;
392 std::vector<uint64_t> load64;
393 for (
unsigned int i = 0;
i < load32.size();
i += 2) {
395 if (
i + 1 < load32.size())
396 word |= static_cast<uint64_t>(load32[
i + 1]) << 32;
397 load64.push_back(
word);
400 LogDebug(
"L1T") <<
"Creating AMC packet " << iBoard;
410 unsigned char* payload_start =
payload;
412 auto bxId =
iEvent.bunchCrossing();
413 auto evtId =
iEvent.id().event();