23 #define EDM_ML_DEBUG 1 65 std::unique_ptr<PackingSetup>
setup_;
74 : fedId_(
config.getParameter<
int>(
"FedId")), ctp7_mode_(
config.getUntrackedParameter<
bool>(
"CTP7")) {
76 produces<FEDRawDataCollection>();
98 auto bxId =
event.bunchCrossing();
103 auto evtId =
event.id().event();
104 auto orbit =
event.eventAuxiliary().orbitNumber();
105 LogDebug(
"L1T") <<
"Forming FED with metadata bxId=" << bxId <<
", l1ID=" << evtId <<
", orbit=" << orbit;
109 auto amc_no =
item.first.first;
110 auto board =
item.first.second;
111 auto packers =
item.second;
114 for (
const auto& packer : packers) {
115 LogDebug(
"L1T") <<
"Adding packed blocks";
116 packer->setBoard(board);
118 block_load.insert(block_load.end(),
blocks.begin(),
blocks.end());
121 std::sort(block_load.begin(), block_load.end());
123 LogDebug(
"L1T") <<
"Concatenating blocks";
125 std::vector<uint32_t> load32;
131 load32.push_back(
fwId_);
133 for (
const auto&
block : block_load) {
134 LogDebug(
"L1T") <<
"Adding block " <<
block.header().getID() <<
" with size " <<
block.payload().size();
138 std::stringstream
s(
"");
139 s <<
"Block content:" << std::endl << std::hex << std::setfill(
'0');
141 s << std::setw(8) <<
word << std::endl;
147 load32.push_back(0xA110CA7E);
149 load32.push_back(
block.header().raw());
150 load32.insert(load32.end(),
load.begin(),
load.end());
153 LogDebug(
"L1T") <<
"Converting payload";
155 std::vector<uint64_t> load64;
156 for (
unsigned int i = 0;
i < load32.size();
i += 2) {
158 if (
i + 1 < load32.size()) {
163 load64.push_back(
word);
166 LogDebug(
"L1T") <<
"Creating AMC packet";
168 unsigned amc_user_header = 0;
170 amc_user_header =
fwId_;
171 amc13.add(amc_no, board, evtId, orbit, bxId, load64, amc_user_header);
180 unsigned char* payload_start =
payload;
231 desc.add<
unsigned int>(
"FWId", -1);
232 desc.add<
int>(
"FedId");
233 desc.addUntracked<
int>(
"eventType", 1);
237 desc.addUntracked<
int>(
"lenSlinkHeader", 8);
238 desc.addUntracked<
int>(
"lenSlinkTrailer", 8);
239 desc.addUntracked<
bool>(
"CTP7",
false);
243 descriptions.
add(
"l1tDigiToRaw",
desc);
std::unique_ptr< PackerTokens > tokens_
std::unique_ptr< PackingSetup > setup_
uint32_t cc[maxCellsPerHit]
std::unique_ptr< PackingSetup > make(const std::string &) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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 produce(edm::Event &, const edm::EventSetup &) override
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
std::vector< Block > Blocks
#define DEFINE_FWK_MODULE(type)
L1TDigiToRaw(const edm::ParameterSet &)
unsigned long long uint64_t
void resize(size_t newsize, size_t wordsize=8)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static const PackingSetupFactory * get()
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
void fillDescription(edm::ParameterSetDescription &) const