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)),
46 errorCounters_(MAX_ERR_CODE+1),
54 if(
formatVersion_ == 0) {
edm::LogInfo(
"GCT") <<
"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";
62 edm::LogInfo(
"GCT") <<
"You have selected to use GctFormatTranslateV35";
67 edm::LogInfo(
"GCT") <<
"You have selected to use GctFormatTranslateV38";
72 edm::LogWarning(
"GCT") <<
"You have requested a version of GctFormatTranslate that does not exist! Will attempt to auto-detect "
73 "the required GCT Format Translator from the first S-Link packet header instead.";
76 if(
hltMode_) {
edm::LogInfo(
"GCT") <<
"HLT unpack mode selected: HLT unpack optimisations will be used."; }
78 "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>();
139 if (feds.isValid()) {
146 if(gctRcd.
size() < 16) {
147 LogDebug(
"GCT") <<
"Cannot unpack: empty/invalid GCT raw data (size = "
148 << gctRcd.
size() <<
"). Returning empty collections!";
183 const unsigned char *
data = d.
data();
190 const unsigned dEnd = d.
size() - 8;
193 for (
unsigned nb=0; dPtr<dEnd; ++nb)
196 LogDebug(
"GCT") <<
"Reached block limit - bailing out from this event!";
207 LogDebug(
"GCT") <<
"Encountered block unpack error - bailing out from this event!";
226 LogDebug(
"GCT") <<
"About to auto-detect the required format translator from the firmware version header.";
228 const uint32_t * p32 =
reinterpret_cast<const uint32_t *
>(d);
229 unsigned firmwareHeader = p32[2];
234 if( firmwareHeader >= 25 && firmwareHeader <= 35 )
236 edm::LogInfo(
"GCT") <<
"Firmware Version V" << firmwareHeader <<
" detected: GctFormatTranslateV" << firmwareHeader <<
" will be used to unpack.";
240 else if( firmwareHeader == 38 )
242 edm::LogInfo(
"GCT") <<
"Firmware Version V" << firmwareHeader <<
" detected: GctFormatTranslateV" << firmwareHeader <<
" will be used to unpack.";
246 else if( firmwareHeader == 0x00000000 )
248 edm::LogInfo(
"GCT") <<
"Legacy Monte-Carlo data detected: GctFormatTranslateMCLegacy will be used to unpack.";
257 LogDebug(
"GCT") <<
"Failed to determine unpacker to use from the firmware version header! "
258 "(firmware header = 0x" << hex << firmwareHeader <<
dec <<
")";
275 std::ostringstream os;
276 os <<
"Found " << bHdrs.size() <<
" GCT block headers" << endl;
277 for (
unsigned i=0,
size = bHdrs.size();
i <
size; ++
i)
281 os << *colls << endl;
291 LogDebug(
"GCT") <<
"Unknown error code : " << code;
297 std::ostringstream os;
299 case 0: os <<
"Reserved error code - not in use";
break;
300 case 1: os <<
"FED record empty or too short";
break;
301 case 2: os <<
"Unknown raw data version";
break;
302 case 3: os <<
"Detected unknown firmware version";
break;
303 case 4: os <<
"Detected unknown data block";
break;
304 case 5: os <<
"Block headers out of sync";
break;
305 case 6: os <<
"Too many blocks";
break;
306 default: os <<
"Unknown error code";
308 edm::LogError(
"GCT") <<
"Unpacking error " << code <<
" : " << os.str();
318 else LogDebug(
"GCT") <<
"Detected error (code=" << code <<
") but no error collection available!";
326 std::ostringstream os;
335 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...
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 &)
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)
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 unpack(const FEDRawData &d, edm::Event &e, GctUnpackCollections *const colls)
Unpacks the raw data.
char data[epos_bytes_allocation]
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.