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>();
144 if (feds.isValid()) {
148 LogDebug(
"GCT") <<
"Upacking FEDRawData of size " << std::dec << gctRcd.
size();
151 if(gctRcd.
size() < 16) {
152 LogDebug(
"GCT") <<
"Cannot unpack: empty/invalid GCT raw data (size = "
153 << gctRcd.
size() <<
"). Returning empty collections!";
188 const unsigned char *
data = d.
data();
195 const unsigned dEnd = d.
size() - 8;
198 for (
unsigned nb=0; dPtr<dEnd; ++nb)
201 LogDebug(
"GCT") <<
"Reached block limit - bailing out from this event!";
212 LogDebug(
"GCT") <<
"Encountered block unpack error - bailing out from this event!";
231 LogDebug(
"GCT") <<
"About to auto-detect the required format translator from the firmware version header.";
233 const uint32_t * p32 =
reinterpret_cast<const uint32_t *
>(d);
234 unsigned firmwareHeader = p32[2];
239 if( firmwareHeader >= 25 && firmwareHeader <= 35 )
241 edm::LogInfo(
"GCT") <<
"Firmware Version V" << firmwareHeader <<
" detected: GctFormatTranslateV" << firmwareHeader <<
" will be used to unpack.";
245 else if( firmwareHeader == 38 )
247 edm::LogInfo(
"GCT") <<
"Firmware Version V" << firmwareHeader <<
" detected: GctFormatTranslateV" << firmwareHeader <<
" will be used to unpack.";
251 else if( firmwareHeader == 0x00000000 )
253 edm::LogInfo(
"GCT") <<
"Legacy Monte-Carlo data detected: GctFormatTranslateMCLegacy will be used to unpack.";
262 LogDebug(
"GCT") <<
"Failed to determine unpacker to use from the firmware version header! "
263 "(firmware header = 0x" << hex << firmwareHeader << dec <<
")";
280 std::ostringstream os;
281 os <<
"Found " << bHdrs.size() <<
" GCT block headers" << endl;
282 for (
unsigned i=0,
size = bHdrs.size();
i <
size; ++
i)
286 os << *colls << endl;
296 LogDebug(
"GCT") <<
"Unknown error code : " << code;
302 std::ostringstream os;
304 case 0: os <<
"Reserved error code - not in use";
break;
305 case 1: os <<
"FED record empty or too short";
break;
306 case 2: os <<
"Unknown raw data version";
break;
307 case 3: os <<
"Detected unknown firmware version";
break;
308 case 4: os <<
"Detected unknown data block";
break;
309 case 5: os <<
"Block headers out of sync";
break;
310 case 6: os <<
"Too many blocks";
break;
311 default: os <<
"Unknown error code";
313 edm::LogError(
"GCT") <<
"Unpacking error " << code <<
" : " << os.str();
323 else LogDebug(
"GCT") <<
"Detected error (code=" << code <<
") but no error collection available!";
331 std::ostringstream os;
340 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...
virtual void produce(edm::Event &, const edm::EventSetup &)
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.
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
L1TriggerErrorCollection * errors_
pointer to error collection
tuple size
Write out results.