65 std::unique_ptr<PackingSetup>
prov_;
84 o <<
"L1T Block Header " << h.
getID() <<
" with size " << h.
getSize();
91 minFeds_(config.getParameter<unsigned
int>(
"MinFeds")),
92 fwId_(config.getParameter<unsigned
int>(
"FWId")),
93 fwOverride_(config.getParameter<bool>(
"FWOverride")),
94 ctp7_mode_(config.getUntrackedParameter<bool>(
"CTP7")),
95 mtf7_mode_(config.getUntrackedParameter<bool>(
"MTF7"))
100 throw cms::Exception(
"L1TRawToDigi") <<
"Can only use one unpacking mode concurrently!";
104 prov_->registerProducts(*
this);
134 std::unique_ptr<UnpackerCollections>
coll =
prov_->getCollections(event);
140 LogError(
"L1T") <<
"Cannot unpack: no FEDRawDataCollection found";
144 unsigned valid_count = 0;
145 for (
const auto& fedId:
fedIds_) {
148 LogDebug(
"L1T") <<
"Found FEDRawDataCollection with ID " << fedId <<
" and size " << l1tRcd.
size();
151 if (l1tRcd.
size() > 0) {
152 LogError(
"L1T") <<
"Cannot unpack: invalid L1T raw data (size = " 153 << l1tRcd.
size() <<
") for ID " << fedId <<
". Returning empty collections!";
156 LogInfo(
"L1T") <<
"During unpacking, encountered empty L1T raw data (size = " 157 << l1tRcd.
size() <<
") for FED ID " << fedId <<
".";
164 const unsigned char *
data = l1tRcd.
data();
167 if (header.
check()) {
168 LogDebug(
"L1T") <<
"Found SLink header:" 170 <<
" L1 event ID " << header.
lvl1ID()
171 <<
" BX Number " << header.
bxID()
172 <<
" FED source " << header.
sourceID()
173 <<
" FED version " << header.
version();
175 LogWarning(
"L1T") <<
"Did not find a SLink header!";
180 if (trailer.
check()) {
181 LogDebug(
"L1T") <<
"Found SLink trailer:" 182 <<
" Length " << trailer.
lenght()
183 <<
" CRC " << trailer.
crc()
185 <<
" Throttling bits " << trailer.
ttsBits();
187 LogWarning(
"L1T") <<
"Did not find a SLink trailer!";
205 <<
"Could not extract AMC13 Packet.";
213 auto payload64 =
amc.data();
214 const uint32_t *
start = (
const uint32_t*) payload64.get();
217 const uint32_t *
end = start + (
amc.size() * 2);
219 std::unique_ptr<Payload>
payload;
221 LogDebug(
"L1T") <<
"Using CTP7 mode";
224 LogDebug(
"L1T") <<
"Using MTF7 mode";
227 LogDebug(
"L1T") <<
"Using MP7 mode";
228 payload.reset(
new MP7Payload(start, end, legacy_mc));
230 unsigned fw = payload->getAlgorithmFWVersion();
236 unsigned board =
amc.blockHeader().getBoardID();
237 unsigned amc_no =
amc.blockHeader().getAMCNumber();
239 auto unpackers =
prov_->getUnpackers(fedId, board, amc_no, fw);
242 std::unique_ptr<Block>
block;
243 while ((block = payload->getBlock()).
get()) {
245 std::cout <<
">>> block to unpack <<<" << std::endl
246 <<
"hdr: " << std::hex << std::setw(8) << std::setfill(
'0') << block->header().raw() <<
std::dec 247 <<
" (ID " << block->header().getID() <<
", size " << block->header().getSize()
248 <<
", CapID 0x" << std::hex << std::setw(2) << std::setfill(
'0') << block->header().getCapID()
250 for (
const auto& word: block->payload()) {
252 std::cout <<
"data: " << std::hex << std::setw(8) << std::setfill(
'0') << word <<
std::dec << std::endl;
256 auto unpacker = unpackers.find(block->header().getID());
258 block->amc(
amc.header());
260 if (unpacker == unpackers.end()) {
261 LogDebug(
"L1T") <<
"Cannot find an unpacker for" 262 <<
"\n\tblock: ID " << block->header().getID() <<
", size " << block->header().getSize()
263 <<
"\n\tAMC: # " << amc_no <<
", board ID 0x" << std::hex << board <<
std::dec 264 <<
"\n\tFED ID " << fedId <<
", and FW ID " << fw;
266 }
else if (!unpacker->second->unpack(*block, coll.get())) {
267 LogDebug(
"L1T") <<
"Error unpacking data for block ID " 268 << block->header().getID() <<
", AMC # " << amc_no
269 <<
", board ID " << board <<
", FED ID " << fedId
270 <<
", and FW ID " << fw <<
"!";
279 LogWarning(
"L1T") <<
"Unpacked " << valid_count <<
" non-empty FED IDs but minimum is set to " <<
minFeds_ <<
"\n";
289 desc.
add<std::vector<int>>(
"FedIds", {})->setComment(
"required parameter: default value is invalid");
290 desc.
add<
std::string>(
"Setup",
"")->setComment(
"required parameter: default value is invalid");
293 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");
294 desc.
add<
bool>(
"FWOverride",
false)->setComment(
"Firmware version should be taken as FWId parameters");
304 desc.
addUntracked<
bool>(
"debug",
false)->setComment(
"turn on verbose output");
305 desc.
add<
unsigned int>(
"MinFeds", 0)->setComment(
"optional parameter: warn if less than MinFeds non-empty FED ids unpacked.");
306 descriptions.
add(
"l1tRawToDigi", desc);
virtual 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)
#define DEFINE_FWK_MODULE(type)
int evtStatus()
Event fragment status information.
def setup(process, global_tag, zero_tesla=False)
size_t size() const
Lenght of the data buffer in bytes.
L1TRawToDigi(const edm::ParameterSet &)
payload
payload postfix for testing
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
std::vector< int > fedIds_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::unique_ptr< PackingSetup > make(const std::string &) const
int ttsBits()
Current value of the Trigger Throttling System bitsAQ).
std::ostream & operator<<(std::ostream &os, const l1t::CaloParamsHelper &p)
unsigned long long uint64_t
int lenght()
The length of the event fragment counted in 64-bit words including header and trailer.
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)
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static const PackingSetupFactory * get()
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
char data[epos_bytes_allocation]
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.
int crc()
Cyclic Redundancy Code of the event fragment including header and trailer.
virtual void endRun(edm::Run const &, edm::EventSetup const &) override
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override