68 std::unique_ptr<PackingSetup>
prov_;
89 o <<
"L1T Block Header " << h.
getID() <<
" with size " << h.
getSize();
96 minFeds_(config.getParameter<unsigned
int>(
"MinFeds")),
97 fwId_(config.getParameter<unsigned
int>(
"FWId")),
98 dmxFwId_(config.getParameter<unsigned
int>(
"DmxFWId")),
107 throw cms::Exception(
"L1TRawToDigi") <<
"Can only use one unpacking mode concurrently!";
111 prov_->registerProducts(*
this);
141 std::unique_ptr<UnpackerCollections>
coll =
prov_->getCollections(event);
147 LogError(
"L1T") <<
"Cannot unpack: no FEDRawDataCollection found";
151 unsigned valid_count = 0;
155 LogDebug(
"L1T") <<
"Found FEDRawDataCollection with ID " <<
fedId <<
" and size " << l1tRcd.
size();
158 if (l1tRcd.
size() > 0) {
159 LogError(
"L1T") <<
"Cannot unpack: invalid L1T raw data (size = " 160 << l1tRcd.
size() <<
") for ID " <<
fedId <<
". Returning empty collections!";
163 LogInfo(
"L1T") <<
"During unpacking, encountered empty L1T raw data (size = " 164 << l1tRcd.
size() <<
") for FED ID " <<
fedId <<
".";
171 const unsigned char *
data = l1tRcd.
data();
174 if (header.
check()) {
175 LogDebug(
"L1T") <<
"Found SLink header:" 177 <<
" L1 event ID " << header.
lvl1ID()
178 <<
" BX Number " << header.
bxID()
179 <<
" FED source " << header.
sourceID()
180 <<
" FED version " << header.
version();
182 LogWarning(
"L1T") <<
"Did not find a SLink header!";
187 if (trailer.
check()) {
188 LogDebug(
"L1T") <<
"Found SLink trailer:" 190 <<
" CRC " << trailer.
crc()
192 <<
" Throttling bits " << trailer.
ttsBits();
194 LogWarning(
"L1T") <<
"Did not find a SLink trailer!";
212 <<
"Could not extract AMC13 Packet.";
220 auto payload64 =
amc.data();
221 const uint32_t *
start = (
const uint32_t*) payload64.get();
224 const uint32_t *
end = start + (
amc.size() * 2);
226 std::unique_ptr<Payload>
payload;
228 LogDebug(
"L1T") <<
"Using CTP7 mode";
232 LogDebug(
"L1T") <<
"Using MTF7 mode";
235 LogDebug(
"L1T") <<
"Using MP7 mode";
236 payload.reset(
new MP7Payload(start, end, legacy_mc));
238 unsigned fw = payload->getAlgorithmFWVersion();
239 unsigned board =
amc.blockHeader().getBoardID();
240 unsigned amc_no =
amc.blockHeader().getAMCNumber();
246 else if (
fedId == 1366)
250 auto unpackers =
prov_->getUnpackers(
fedId, board, amc_no, fw);
253 std::unique_ptr<Block>
block;
254 while ((block = payload->getBlock()).
get()) {
258 unsigned bxId = header.
bxID();
259 unsigned unpackTMT = ( !
tmtCheck_ || ( ( tmtId - 1 ) == ( ( bxId - 1 + 3 ) % 9 ) ) );
262 if( !isCaloL2TMT || unpackTMT ) {
264 std::cout <<
">>> block to unpack <<<" << std::endl
265 <<
"hdr: " << std::hex << std::setw(8) << std::setfill(
'0') << block->header().raw() <<
std::dec 266 <<
" (ID " << block->header().getID() <<
", size " << block->header().getSize()
267 <<
", CapID 0x" << std::hex << std::setw(2) << std::setfill(
'0') << block->header().getCapID()
269 for (
const auto& word: block->payload()) {
271 std::cout <<
"data: " << std::hex << std::setw(8) << std::setfill(
'0') << word <<
std::dec << std::endl;
275 auto unpacker = unpackers.find(block->header().getID());
277 block->amc(
amc.header());
279 if (unpacker == unpackers.end()) {
280 LogDebug(
"L1T") <<
"Cannot find an unpacker for" 281 <<
"\n\tblock: ID " << block->header().getID() <<
", size " << block->header().getSize()
282 <<
"\n\tAMC: # " << amc_no <<
", board ID 0x" << std::hex << board <<
std::dec 283 <<
"\n\tFED ID " <<
fedId <<
", and FW ID " << fw;
285 }
else if (!unpacker->second->unpack(*block, coll.get())) {
286 LogDebug(
"L1T") <<
"Error unpacking data for block ID " 287 << block->header().getID() <<
", AMC # " << amc_no
288 <<
", board ID " << board <<
", FED ID " <<
fedId 289 <<
", and FW ID " << fw <<
"!";
299 LogWarning(
"L1T") <<
"Unpacked " << valid_count <<
" non-empty FED IDs but minimum is set to " <<
minFeds_ <<
"\n";
309 desc.
add<std::vector<int>>(
"FedIds", {})->setComment(
"required parameter: default value is invalid");
310 desc.
add<
std::string>(
"Setup",
"")->setComment(
"required parameter: default value is invalid");
313 desc.
add<
unsigned int>(
"FWId",0)->setComment(
"Ignored unless FWOverride is true. Calo Stage1: 32 bits: if the first eight bits are 0xff, will read the 74x MC format.\n");
314 desc.
add<
unsigned int>(
"DmxFWId",0)->setComment(
"Ignored unless FWOverride is true. Calo Stage1: 32 bits: if the first eight bits are 0xff, will read the 74x MC format.\n");
315 desc.
add<
bool>(
"FWOverride",
false)->setComment(
"Firmware version should be taken as FWId parameters");
316 desc.
add<
bool>(
"TMTCheck",
true)->setComment(
"Flag for turning on/off Calo Layer 2 TMT node check");
326 desc.
addUntracked<
bool>(
"debug",
false)->setComment(
"turn on verbose output");
327 desc.
add<
unsigned int>(
"MinFeds", 0)->setComment(
"optional parameter: warn if less than MinFeds non-empty FED ids unpacked.");
328 descriptions.
add(
"l1tRawToDigi", desc);
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< amc::Packet > payload() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void endRun(edm::Run const &, edm::EventSetup const &) override
void beginRun(edm::Run const &, edm::EventSetup const &) override
def setup(process, global_tag, zero_tesla=False)
uint16_t crc() const
Cyclic Redundancy Code of the event fragment including header and trailer.
bool check() const
Check that the trailer is OK.
size_t size() const
Lenght of the data buffer in bytes.
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
L1TRawToDigi(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
const unsigned int offsetBoardId
std::vector< int > fedIds_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::unique_ptr< PackingSetup > make(const std::string &) const
const unsigned int amcSlotNum
std::ostream & operator<<(std::ostream &os, const l1t::CaloParamsHelper &p)
uint8_t ttsBits() const
Current value of the Trigger Throttling System bits.
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
unsigned long long uint64_t
bool parse(const uint64_t *start, const uint64_t *data, unsigned int size, unsigned int lv1, unsigned int bx, bool legacy_mc=false, bool mtf7_mode=false)
uint8_t evtStatus() const
Event fragment status information.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static const PackingSetupFactory * get()
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
char data[epos_bytes_allocation]
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
std::unique_ptr< PackingSetup > prov_
edm::EDGetTokenT< FEDRawDataCollection > fedData_
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.