24 #define EDM_ML_DEBUG 1
65 std::auto_ptr<PackingSetup>
prov_;
83 o <<
"L1T Block Header " << h.
getID() <<
" with size " << h.
getSize();
89 fedIds_(config.getParameter<std::vector<int>>(
"FedIds")),
90 fwId_(config.getParameter<unsigned int>(
"FWId")),
91 fwOverride_(config.getParameter<bool>(
"FWOverride")),
92 ctp7_mode_(config.getUntrackedParameter<bool>(
"CTP7")),
93 mtf7_mode_(config.getUntrackedParameter<bool>(
"MTF7"))
98 throw cms::Exception(
"L1TRawToDigi") <<
"Can only use one unpacking mode concurrently!";
102 prov_->registerProducts(*
this);
131 std::unique_ptr<UnpackerCollections>
coll =
prov_->getCollections(event);
136 if (!
feds.isValid()) {
137 LogError(
"L1T") <<
"Cannot unpack: no FEDRawDataCollection found";
144 LogDebug(
"L1T") <<
"Found FEDRawDataCollection with ID " <<
fedId <<
" and size " << l1tRcd.
size();
147 if (l1tRcd.
size() > 0) {
148 LogError(
"L1T") <<
"Cannot unpack: invalid L1T raw data (size = "
149 << l1tRcd.
size() <<
") for ID " <<
fedId <<
". Returning empty collections!";
152 LogWarning(
"L1T") <<
"Cannot unpack: empty L1T raw data (size = "
153 << l1tRcd.
size() <<
") for ID " <<
fedId <<
". Returning empty collections!";
158 const unsigned char *
data = l1tRcd.
data();
161 if (header.
check()) {
162 LogDebug(
"L1T") <<
"Found SLink header:"
164 <<
" L1 event ID " << header.
lvl1ID()
165 <<
" BX Number " << header.
bxID()
166 <<
" FED source " << header.
sourceID()
167 <<
" FED version " << header.
version();
169 LogWarning(
"L1T") <<
"Did not find a SLink header!";
174 if (trailer.
check()) {
175 LogDebug(
"L1T") <<
"Found SLink trailer:"
176 <<
" Length " << trailer.
lenght()
177 <<
" CRC " << trailer.
crc()
179 <<
" Throttling bits " << trailer.
ttsBits();
181 LogWarning(
"L1T") <<
"Did not find a SLink trailer!";
198 <<
"Could not extract AMC13 Packet.";
206 auto payload64 =
amc.data();
207 const uint32_t *
start = (
const uint32_t*) payload64.get();
210 const uint32_t *
end = start + (
amc.size() * 2);
212 std::auto_ptr<Payload> payload;
214 LogDebug(
"L1T") <<
"Using CTP7 mode";
217 LogDebug(
"L1T") <<
"Using MTF7 mode";
220 LogDebug(
"L1T") <<
"Using MP7 mode";
221 payload.reset(
new MP7Payload(start, end, legacy_mc));
223 unsigned fw = payload->getAlgorithmFWVersion();
229 unsigned board =
amc.blockHeader().getBoardID();
230 unsigned amc_no =
amc.blockHeader().getAMCNumber();
235 std::auto_ptr<Block>
block;
236 while ((block = payload->getBlock()).
get()) {
238 std::cout <<
">>> block to unpack <<<" << std::endl
239 <<
"hdr: " << std::hex << std::setw(8) << std::setfill(
'0') << block->header().raw() <<
std::dec
240 <<
" (ID " << block->header().getID() <<
", size " << block->header().getSize()
241 <<
", CapID 0x" << std::hex << std::setw(2) << std::setfill(
'0') << block->header().getCapID()
243 for (
const auto& word: block->payload()) {
245 std::cout <<
"data: " << std::hex << std::setw(8) << std::setfill(
'0') << word <<
std::dec << std::endl;
249 auto unpacker =
unpackers.find(block->header().getID());
251 block->amc(
amc.header());
254 LogDebug(
"L1T") <<
"Cannot find an unpacker for"
255 <<
"\n\tblock: ID " << block->header().getID() <<
", size " << block->header().getSize()
256 <<
"\n\tAMC: # " << amc_no <<
", board ID 0x" << std::hex << board <<
std::dec
257 <<
"\n\tFED ID " <<
fedId <<
", and FW ID " << fw;
259 }
else if (!unpacker->second->unpack(*block,
coll.get())) {
260 LogDebug(
"L1T") <<
"Error unpacking data for block ID "
261 << block->header().getID() <<
", AMC # " << amc_no
262 <<
", board ID " << board <<
", FED ID " <<
fedId
263 <<
", and FW ID " << fw <<
"!";
276 desc.
add<std::vector<int>>(
"FedIds", {})->setComment(
"required parameter: default value is invalid");
277 desc.
add<
std::string>(
"Setup",
"")->setComment(
"required parameter: default value is invalid");
280 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");
281 desc.
add<
bool>(
"FWOverride",
false)->setComment(
"Firmware version should be taken as FWId parameters");
291 desc.
addUntracked<
bool>(
"debug",
false)->setComment(
"turn on verbose output");
292 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
tuple start
Check for commandline option errors.
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::auto_ptr< PackingSetup > prov_
#define DEFINE_FWK_MODULE(type)
std::auto_ptr< PackingSetup > make(const std::string &) const
int evtStatus()
Event fragment status information.
std::ostream & operator<<(std::ostream &out, const ALILine &li)
size_t size() const
Lenght of the data buffer in bytes.
L1TRawToDigi(const edm::ParameterSet &)
std::vector< int > fedIds_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
int ttsBits()
Current value of the Trigger Throttling System bitsAQ).
unsigned long long uint64_t
int lenght()
The length of the event fragment counted in 64-bit words including header and trailer.
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)
edm::EDGetTokenT< FEDRawDataCollection > fedData_
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
bool parse(const uint64_t *start, const uint64_t *data, unsigned int size, unsigned int lv1, unsigned int bx, bool legacy_mc=false)
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
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override