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();
MP7FileReader rxFileReader_
unsigned nFramesPerEvent_
const std::vector< uint64_t > & link(uint32_t i) const
MP7FileReader txFileReader_
MP7PacketReader txPacketReader_
size_t size() const
Lenght of the data buffer in bytes.
Log< level::Error, false > LogError
std::vector< Block > getBlocks(int iAmc)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T getUntrackedParameter(std::string const &, T const &) const
const PacketData & get(size_t i)
void addDefault(ParameterSetDescription const &psetDescription)
static void set(unsigned char *trailer, uint32_t lenght, uint16_t crc, uint8_t evt_stat, uint8_t tts, bool moreTrailers=false)
Set all fields in the trailer.
void resize(size_t newsize)
MP7BufferDumpToRaw(const edm::ParameterSet &)
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< unsigned > rxIndex_
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
std::vector< std::vector< int > > rxBlockLength_
void formatAMC(amc13::Packet &amc13, const std::vector< Block > &blocks, int iAmc)
~MP7BufferDumpToRaw() override
std::vector< std::vector< int > > txBlockLength_
#define DEFINE_FWK_MODULE(type)
std::vector< unsigned > txIndex_
unsigned long long uint64_t
size_t size() const
number of rawdata objects stored
std::vector< Packet >::const_iterator const_iterator
char data[epos_bytes_allocation]
std::vector< int > boardId_
const FileData & get(size_t k) const
data getter via index
MP7PacketReader rxPacketReader_
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
void formatRaw(edm::Event &iEvent, amc13::Packet &amc13, FEDRawData &fed_data)