37 inputLabel_(iConfig.getParameter<edm::
InputTag>(
"inputLabel")),
38 fedId_(iConfig.getUntrackedParameter<int>(
"gctFedId",
FEDNumbering::MINTriggerGCTFEDID)),
39 hltMode_(iConfig.getParameter<bool>(
"hltMode")),
40 numberOfGctSamplesToUnpack_(iConfig.getParameter<unsigned>(
"numberOfGctSamplesToUnpack")),
41 numberOfRctSamplesToUnpack_(iConfig.getParameter<unsigned>(
"numberOfRctSamplesToUnpack")),
42 unpackSharedRegions_(iConfig.getParameter<bool>(
"unpackSharedRegions")),
43 formatVersion_(iConfig.getParameter<unsigned>(
"unpackerVersion")),
44 checkHeaders_(iConfig.getUntrackedParameter<bool>(
"checkHeaders",
false)),
45 verbose_(iConfig.getUntrackedParameter<bool>(
"verbose",
false)),
48 errorCounters_(MAX_ERR_CODE+1),
56 if(
formatVersion_ == 0) {
edm::LogInfo(
"GCT") <<
"The required GCT Format Translator will be automatically determined from the first S-Link packet header."; }
59 edm::LogInfo(
"GCT") <<
"You have selected to use GctFormatTranslateMCLegacy";
64 edm::LogInfo(
"GCT") <<
"You have selected to use GctFormatTranslateV35";
69 edm::LogInfo(
"GCT") <<
"You have selected to use GctFormatTranslateV38";
74 edm::LogWarning(
"GCT") <<
"You have requested a version of GctFormatTranslate that does not exist! Will attempt to auto-detect "
75 "the required GCT Format Translator from the first S-Link packet header instead.";
78 if(
hltMode_) {
edm::LogInfo(
"GCT") <<
"HLT unpack mode selected: HLT unpack optimisations will be used."; }
80 "this is for commissioning purposes only!"; }
84 produces<L1GctFibreCollection>();
85 produces<L1CaloEmCollection>();
86 produces<L1CaloRegionCollection>();
89 produces<L1GctInternEmCandCollection>();
90 produces<L1GctInternJetDataCollection>();
91 produces<L1GctInternEtSumCollection>();
92 produces<L1GctInternHFDataCollection>();
93 produces<L1GctInternHtMissCollection>();
96 produces<L1GctEmCandCollection>(
"isoEm");
97 produces<L1GctEmCandCollection>(
"nonIsoEm");
98 produces<L1GctJetCandCollection>(
"cenJets");
99 produces<L1GctJetCandCollection>(
"forJets");
100 produces<L1GctJetCandCollection>(
"tauJets");
101 produces<L1GctHFBitCountsCollection>();
102 produces<L1GctHFRingEtSumsCollection>();
103 produces<L1GctEtTotalCollection>();
104 produces<L1GctEtHadCollection>();
105 produces<L1GctEtMissCollection>();
106 produces<L1GctHtMissCollection>();
107 produces<L1GctJetCountsCollection>();
110 produces<L1TriggerErrorCollection>();
124 desc.
add<
bool>(
"unpackSharedRegions",
false);
125 desc.
add<
unsigned int>(
"numberOfGctSamplesToUnpack",1);
126 desc.
add<
unsigned int>(
"numberOfRctSamplesToUnpack",1);
127 desc.
add<
bool>(
"hltMode",
false);
131 " value | Unpacker/RAW Format Version \n"
132 "-----------|---------------------------------------------------------------------------- \n"
133 " 0 | Auto-detects RAW Format in use - the recommended option \n"
134 " 1 | Force usage of the Monte-Carlo Legacy unpacker (unpacks DigiToRaw events) \n"
135 " 2 | Force usage of the RAW Format V35 unpacker \n"
136 " 3 | Force usage of the RAW Format V38 unpacker \n";
137 desc.
add<
unsigned int>(
"unpackerVersion",0)->setComment(kComment);
141 descriptions.
add(
"gctRawToDigi",desc);
162 if (
feds.isValid()) {
169 if(gctRcd.
size() < 16) {
170 LogDebug(
"GCT") <<
"Cannot unpack: empty/invalid GCT raw data (size = "
171 << gctRcd.
size() <<
"). Returning empty collections!";
206 const unsigned char *
data = d.
data();
213 const unsigned dEnd = d.
size() - 8;
216 for (
unsigned nb=0; dPtr<dEnd; ++nb)
219 LogDebug(
"GCT") <<
"Reached block limit - bailing out from this event!";
230 LogDebug(
"GCT") <<
"Encountered block unpack error - bailing out from this event!";
249 LogDebug(
"GCT") <<
"About to auto-detect the required format translator from the firmware version header.";
251 const uint32_t * p32 =
reinterpret_cast<const uint32_t *
>(
d);
252 unsigned firmwareHeader = p32[2];
257 if( firmwareHeader >= 25 && firmwareHeader <= 35 )
259 edm::LogInfo(
"GCT") <<
"Firmware Version V" << firmwareHeader <<
" detected: GctFormatTranslateV" << firmwareHeader <<
" will be used to unpack.";
263 else if( firmwareHeader == 38 )
265 edm::LogInfo(
"GCT") <<
"Firmware Version V" << firmwareHeader <<
" detected: GctFormatTranslateV" << firmwareHeader <<
" will be used to unpack.";
269 else if( firmwareHeader == 0x00000000 )
271 edm::LogInfo(
"GCT") <<
"Legacy Monte-Carlo data detected: GctFormatTranslateMCLegacy will be used to unpack.";
280 LogDebug(
"GCT") <<
"Failed to determine unpacker to use from the firmware version header! "
281 "(firmware header = 0x" << hex << firmwareHeader <<
dec <<
")";
298 std::ostringstream os;
299 os <<
"Found " << bHdrs.size() <<
" GCT block headers" << endl;
300 for (
unsigned i=0,
size = bHdrs.size();
i <
size; ++
i)
304 os << *colls << endl;
314 LogDebug(
"GCT") <<
"Unknown error code : " << code;
320 std::ostringstream os;
322 case 0: os <<
"Reserved error code - not in use";
break;
323 case 1: os <<
"FED record empty or too short";
break;
324 case 2: os <<
"Unknown raw data version";
break;
325 case 3: os <<
"Detected unknown firmware version";
break;
326 case 4: os <<
"Detected unknown data block";
break;
327 case 5: os <<
"Block headers out of sync";
break;
328 case 6: os <<
"Too many blocks";
break;
329 default: os <<
"Unknown error code";
331 edm::LogError(
"GCT") <<
"Unpacking error " << code <<
" : " << os.str();
341 else LogDebug(
"GCT") <<
"Detected error (code=" << code <<
") but no error collection available!";
349 std::ostringstream os;
358 edm::LogError(
"GCT") <<
"Encountered " << total <<
" unpacking errors: " << os.str();
bool autoDetectRequiredFormatTranslator(const unsigned char *data)
Looks at the firmware version header in the S-Link packet and instantiates relevant format translator...
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
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...
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...
void checkHeaders()
check block headers for consistency
virtual void endJob()
method called at job end - use to print summary report
size_t size() const
Lenght of the data buffer in bytes.
virtual 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
bool get(ProductID const &oid, Handle< PROD > &result) const
const unsigned numberOfRctSamplesToUnpack_
Number of BXs of RCT data to unpack (assuming they are in the raw data)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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.
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.
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
std::vector< unsigned > errorCounters_
Counts number of errors for each code (index)
GctFormatTranslateBase * formatTranslator_
pointer to the block-to-digi converter
volatile std::atomic< bool > shutdown_flag false
L1TriggerErrorCollection * errors_
pointer to error collection
tuple size
Write out results.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)