43 #include <boost/algorithm/string.hpp> 125 : rxFileReader_(iConfig.getUntrackedParameter<
std::
string>(
"rxFile",
"rx_summary.txt")),
126 txFileReader_(iConfig.getUntrackedParameter<
std::
string>(
"txFile",
"tx_summary.txt")),
127 rxPacketReader_(iConfig.getUntrackedParameter<
std::
string>(
"rxFile",
"rx_summary.txt"),
128 iConfig.getUntrackedParameter<
int>(
"rxHeaderFrames", 1),
130 iConfig.getUntrackedParameter<
int>(
"rxKeyLink", 0)),
131 txPacketReader_(iConfig.getUntrackedParameter<
std::
string>(
"txFile",
"tx_summary.txt"),
132 iConfig.getUntrackedParameter<
int>(
"txHeaderFrames", 1),
134 iConfig.getUntrackedParameter<
int>(
"txKeyLink", 0)),
135 packetisedData_(iConfig.getUntrackedParameter<
bool>(
"packetisedData",
true)),
136 nFramesPerEvent_(iConfig.getUntrackedParameter<
int>(
"nFramesPerEvent", 6)),
137 iBoard_(iConfig.getUntrackedParameter<
int>(
"boardOffset", 0)),
138 boardId_(iConfig.getUntrackedParameter<
std::
vector<
int> >(
"boardId")),
139 mux_(iConfig.getUntrackedParameter<
bool>(
"mux",
false)),
140 fedId_(iConfig.getUntrackedParameter<
int>(
"fedId", 1)),
141 evType_(iConfig.getUntrackedParameter<
int>(
"eventType", 1)),
142 fwVer_(iConfig.getUntrackedParameter<
int>(
"fwVersion", 1)),
143 slinkHeaderSize_(iConfig.getUntrackedParameter<
int>(
"lenSlinkHeader", 8)),
144 slinkTrailerSize_(iConfig.getUntrackedParameter<
int>(
"lenSlinkTrailer", 8)) {
145 produces<FEDRawDataCollection>();
149 edm::LogError(
"L1T") <<
"Different number of boards in Rx and Tx files";
175 std::vector<edm::ParameterSet> vpset = iConfig.
getUntrackedParameter<std::vector<edm::ParameterSet> >(
"blocks");
178 edm::LogError(
"L1T") <<
"Wrong number of block specs " << vpset.size();
185 std::vector<int>
rx = vpset.at(
i).getUntrackedParameter<std::vector<int> >(
"rxBlockLength");
189 for (
unsigned j = 0;
j <
rx.size(); ++
j) {
197 std::vector<int> tx = vpset.at(
i).getUntrackedParameter<std::vector<int> >(
"txBlockLength");
200 for (
unsigned j = 0;
j < tx.size(); ++
j) {
235 for (
unsigned iBoard = 0; iBoard <
nBoard_; ++iBoard) {
263 <<
" Rx links, " <<
txBlockLength_.at(iBoard).size() <<
" Tx links";
265 std::vector<Block>
blocks;
269 unsigned id =
link * 2;
275 std::vector<uint32_t>
data;
282 LogDebug(
"L1T") <<
"Found packet [" << itr->first_ <<
", " << itr->last_ <<
"]";
283 LogDebug(
"L1T") <<
"Link " <<
link <<
" has " << itr->links_.find(
link)->second.size() <<
" frames";
285 for (
unsigned iFrame = 0; iFrame < itr->links_.find(
link)->second.size(); ++iFrame) {
292 LogDebug(
"L1T") <<
"Frame " << iFrame <<
" : " << std::hex <<
d;
293 if ((
d & 0x100000000) > 0)
294 data.push_back(
d & 0xffffffff);
298 LogDebug(
"L1T") <<
"Board " << iBoard <<
" block " <<
id <<
", size " <<
data.size();
306 unsigned id = (
link * 2) + 1;
312 LogDebug(
"L1T") <<
"Block " <<
id <<
" expecting size " <<
size;
314 std::vector<uint32_t>
data;
321 LogDebug(
"L1T") <<
"Found packet [" << itr->first_ <<
", " << itr->last_ <<
"]";
322 LogDebug(
"L1T") <<
"Link " <<
link <<
" has " << itr->links_.find(
link)->second.size() <<
" frames";
324 for (
unsigned iFrame = 0; iFrame < itr->links_.find(
link)->second.size(); ++iFrame) {
332 LogDebug(
"L1T") <<
"Frame " << iFrame <<
" : " << std::hex <<
d;
333 if ((
d & 0x100000000) > 0)
334 data.push_back(
d & 0xffffffff);
338 LogDebug(
"L1T") <<
"Board " << iBoard <<
" block " <<
id <<
", size " <<
data.size();
353 LogDebug(
"L1T") <<
"Board " << iBoard <<
", read " <<
blocks.size() <<
" blocks";
359 LogDebug(
"L1T") <<
"Formatting Board " << iBoard;
361 std::vector<uint32_t> load32;
368 LogDebug(
"L1T") <<
"Adding block " <<
block.header().getID() <<
" with size " <<
block.payload().size();
372 std::stringstream
s(
"");
373 s <<
"Block content:" << std::endl << std::hex << std::setfill(
'0');
375 s << std::setw(8) <<
word << std::endl;
379 load32.push_back(
block.header().raw());
380 load32.insert(load32.end(),
load.begin(),
load.end());
383 LogDebug(
"L1T") <<
"Converting payload " << iBoard;
385 std::vector<uint64_t> load64;
386 for (
unsigned int i = 0;
i < load32.size();
i += 2) {
388 if (
i + 1 < load32.size())
389 word |= static_cast<uint64_t>(load32[
i + 1]) << 32;
390 load64.push_back(
word);
393 LogDebug(
"L1T") <<
"Creating AMC packet " << iBoard;
403 unsigned char* payload_start =
payload;
405 auto bxId =
iEvent.bunchCrossing();
406 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)