35 : inputLabel_(iConfig.getParameter<
edm::
InputTag>(
"inputLabel")),
36 fedId_(iConfig.getUntrackedParameter<
int>(
"gctFedId",
FEDNumbering::MINTriggerGCTFEDID)),
37 hltMode_(iConfig.getParameter<
bool>(
"hltMode")),
38 numberOfGctSamplesToUnpack_(iConfig.getParameter<unsigned>(
"numberOfGctSamplesToUnpack")),
39 numberOfRctSamplesToUnpack_(iConfig.getParameter<unsigned>(
"numberOfRctSamplesToUnpack")),
40 unpackSharedRegions_(iConfig.getParameter<
bool>(
"unpackSharedRegions")),
41 formatVersion_(iConfig.getParameter<unsigned>(
"unpackerVersion")),
42 checkHeaders_(iConfig.getUntrackedParameter<
bool>(
"checkHeaders",
false)),
43 verbose_(iConfig.getUntrackedParameter<
bool>(
"verbose",
false)),
44 formatTranslator_(nullptr),
46 errorCounters_(MAX_ERR_CODE + 1),
55 <<
"The required GCT Format Translator will be automatically determined from the first S-Link packet header.";
57 edm::LogInfo(
"GCT") <<
"You have selected to use GctFormatTranslateMCLegacy";
60 edm::LogInfo(
"GCT") <<
"You have selected to use GctFormatTranslateV35";
63 edm::LogInfo(
"GCT") <<
"You have selected to use GctFormatTranslateV38";
68 <<
"You have requested a version of GctFormatTranslate that does not exist! Will attempt to auto-detect " 69 "the required GCT Format Translator from the first S-Link packet header instead.";
73 edm::LogInfo(
"GCT") <<
"HLT unpack mode selected: HLT unpack optimisations will be used.";
76 edm::LogInfo(
"GCT") <<
"You have selected to unpack shared RCT calo regions - be warned: " 77 "this is for commissioning purposes only!";
82 produces<L1GctFibreCollection>();
83 produces<L1CaloEmCollection>();
84 produces<L1CaloRegionCollection>();
87 produces<L1GctInternEmCandCollection>();
88 produces<L1GctInternJetDataCollection>();
89 produces<L1GctInternEtSumCollection>();
90 produces<L1GctInternHFDataCollection>();
91 produces<L1GctInternHtMissCollection>();
94 produces<L1GctEmCandCollection>(
"isoEm");
95 produces<L1GctEmCandCollection>(
"nonIsoEm");
96 produces<L1GctJetCandCollection>(
"cenJets");
97 produces<L1GctJetCandCollection>(
"forJets");
98 produces<L1GctJetCandCollection>(
"tauJets");
99 produces<L1GctHFBitCountsCollection>();
100 produces<L1GctHFRingEtSumsCollection>();
101 produces<L1GctEtTotalCollection>();
102 produces<L1GctEtHadCollection>();
103 produces<L1GctEtMissCollection>();
104 produces<L1GctHtMissCollection>();
105 produces<L1GctJetCountsCollection>();
108 produces<L1TriggerErrorCollection>();
120 desc.add<
bool>(
"unpackSharedRegions",
false);
121 desc.add<
unsigned int>(
"numberOfGctSamplesToUnpack", 1);
122 desc.add<
unsigned int>(
"numberOfRctSamplesToUnpack", 1);
123 desc.add<
bool>(
"hltMode",
false);
127 " value | Unpacker/RAW Format Version \n" 128 "-----------|---------------------------------------------------------------------------- \n" 129 " 0 | Auto-detects RAW Format in use - the recommended option \n" 130 " 1 | Force usage of the Monte-Carlo Legacy unpacker (unpacks DigiToRaw events) \n" 131 " 2 | Force usage of the RAW Format V35 unpacker \n" 132 " 3 | Force usage of the RAW Format V38 unpacker \n";
133 desc.add<
unsigned int>(
"unpackerVersion", 0)->setComment(
kComment);
134 desc.addUntracked<
int>(
"gctFedId", 745);
135 desc.addUntracked<
bool>(
"checkHeaders",
false),
desc.addUntracked<
bool>(
"verbose",
false);
136 descriptions.
add(
"gctRawToDigi",
desc);
156 if (
feds.isValid()) {
162 if (gctRcd.
size() < 16) {
163 LogDebug(
"GCT") <<
"Cannot unpack: empty/invalid GCT raw data (size = " << gctRcd.
size()
164 <<
"). Returning empty collections!";
198 const unsigned char*
data =
d.data();
205 const unsigned dEnd =
d.size() - 8;
208 for (
unsigned nb = 0; dPtr < dEnd; ++nb) {
210 LogDebug(
"GCT") <<
"Reached block limit - bailing out from this event!";
222 LogDebug(
"GCT") <<
"Encountered block unpack error - bailing out from this event!";
239 LogDebug(
"GCT") <<
"About to auto-detect the required format translator from the firmware version header.";
241 const uint32_t* p32 =
reinterpret_cast<const uint32_t*
>(
d);
242 unsigned firmwareHeader = p32[2];
247 if (firmwareHeader >= 25 && firmwareHeader <= 35) {
248 edm::LogInfo(
"GCT") <<
"Firmware Version V" << firmwareHeader <<
" detected: GctFormatTranslateV" << firmwareHeader
249 <<
" will be used to unpack.";
252 }
else if (firmwareHeader == 38) {
253 edm::LogInfo(
"GCT") <<
"Firmware Version V" << firmwareHeader <<
" detected: GctFormatTranslateV" << firmwareHeader
254 <<
" will be used to unpack.";
258 }
else if (firmwareHeader == 0x00000000) {
259 edm::LogInfo(
"GCT") <<
"Legacy Monte-Carlo data detected: GctFormatTranslateMCLegacy will be used to unpack.";
268 LogDebug(
"GCT") <<
"Failed to determine unpacker to use from the firmware version header! " 269 "(firmware header = 0x" 270 << hex << firmwareHeader <<
dec <<
")";
282 std::ostringstream os;
283 os <<
"Found " << bHdrs.size() <<
" GCT block headers" << endl;
284 for (
unsigned i = 0,
size = bHdrs.size();
i <
size; ++
i) {
287 os << *colls << endl;
294 LogDebug(
"GCT") <<
"Unknown error code : " << code;
300 std::ostringstream os;
303 os <<
"Reserved error code - not in use";
306 os <<
"FED record empty or too short";
309 os <<
"Unknown raw data version";
312 os <<
"Detected unknown firmware version";
315 os <<
"Detected unknown data block";
318 os <<
"Block headers out of sync";
321 os <<
"Too many blocks";
324 os <<
"Unknown error code";
326 edm::LogError(
"GCT") <<
"Unpacking error " << code <<
" : " << os.str();
336 LogDebug(
"GCT") <<
"Detected error (code=" << code <<
") but no error collection available!";
342 std::ostringstream os;
Log< level::Info, true > LogVerbatim
bool autoDetectRequiredFormatTranslator(const unsigned char *data)
Looks at the firmware version header in the S-Link packet and instantiates relevant format translator...
const bool unpackSharedRegions_
Commissioning option: if true, where applicable the shared RCT calo regions will also be unpacked...
GctBlockHeaderCollection blockHeaders_
#define DEFINE_FWK_MODULE(type)
const unsigned numberOfGctSamplesToUnpack_
Number of BXs of GCT data to unpack (assuming they are in the raw data)
void addError(const unsigned code)
const bool hltMode_
If true, only outputs the GCT data sent to the GT (number of BXs defined by numberOfGctSamplesToUnpac...
size_t size() const
Lenght of the data buffer in bytes.
Log< level::Error, false > LogError
void checkHeaders()
check block headers for consistency
virtual void endJob()
method called at job end - use to print summary report
void produce(edm::Event &, const edm::EventSetup &) override
static const unsigned MAX_BLOCKS
The maximum number of blocks we will try to unpack before thinking something is wrong.
edm::InputTag inputLabel_
FED collection label.
const unsigned formatVersion_
Defines unpacker verison to be used (e.g.: "Auto-detect", "MCLegacy", "V35", etc).
GctRawToDigi(const edm::ParameterSet &)
static const char *const kComment
const unsigned numberOfRctSamplesToUnpack_
Number of BXs of RCT data to unpack (assuming they are in the raw data)
RAII and useful methods for the many dataformat collections required by the GCT unpacker.
const bool verbose_
If true, then debug print out for each event.
Log< level::Info, false > LogInfo
const bool checkHeaders_
If true, check block headers for synchronisation.
static const unsigned MAX_ERR_CODE
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void unpack(const FEDRawData &d, edm::Event &e, GctUnpackCollections *const colls)
Unpacks the raw data.
char data[epos_bytes_allocation]
std::vector< unsigned > errorCounters_
Counts number of errors for each code (index)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
GctFormatTranslateBase * formatTranslator_
pointer to the block-to-digi converter
Log< level::Warning, false > LogWarning
void doVerboseOutput(const GctBlockHeaderCollection &bHdrs, const GctUnpackCollections *const colls) const
Prints out a list of blocks and the various numbers of trigger objects that have been unpacked from t...
L1TriggerErrorCollection * errors_
pointer to error collection
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)