File indexing completed on 2024-04-06 12:10:40
0001 #include "EventFilter/GctRawToDigi/src/GctFormatTranslateBase.h"
0002
0003
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005
0006
0007 const std::string GctFormatTranslateBase::INVALID_BLOCK_HEADER_STR = "UNKNOWN/INVALID BLOCK HEADER";
0008
0009
0010
0011 GctFormatTranslateBase::GctFormatTranslateBase(bool hltMode, bool unpackSharedRegions)
0012 : m_collections(nullptr),
0013 m_hltMode(hltMode),
0014 m_unpackSharedRegions(unpackSharedRegions),
0015 m_srcCardRouting(),
0016 m_packingBxId(0),
0017 m_packingEventId(0) {}
0018
0019 GctFormatTranslateBase::~GctFormatTranslateBase() {}
0020
0021 const std::string& GctFormatTranslateBase::getBlockDescription(const GctBlockHeader& header) const {
0022 if (!header.valid()) {
0023 return INVALID_BLOCK_HEADER_STR;
0024 }
0025 return blockNameMap().find(header.blockId())->second;
0026 }
0027
0028
0029
0030 L1GctJetCandCollection* const GctFormatTranslateBase::gctJets(const unsigned cat) const {
0031 switch (cat) {
0032 case TAU_JETS:
0033 return colls()->gctTauJets();
0034 case FORWARD_JETS:
0035 return colls()->gctForJets();
0036 default:
0037 return colls()->gctCenJets();
0038 }
0039 }
0040
0041 void GctFormatTranslateBase::writeRawHeader(unsigned char* data, uint32_t blockId, uint32_t nSamples) const {
0042 uint32_t hdr = generateRawHeader(blockId, nSamples, packingBxId(), packingEventId());
0043 uint32_t* p = reinterpret_cast<uint32_t*>(const_cast<unsigned char*>(data));
0044 *p = hdr;
0045 }
0046
0047 bool GctFormatTranslateBase::checkBlock(const GctBlockHeader& hdr) const {
0048
0049 if (!hdr.valid()) {
0050 LogDebug("GCT") << "Block unpack error: cannot unpack the following unknown/invalid block:\n" << hdr;
0051 return false;
0052 }
0053
0054
0055 if (hdr.nSamples() >= 0xf) {
0056 LogDebug("GCT") << "Block unpack error: cannot unpack a block with 15 or more time samples:\n" << hdr;
0057 return false;
0058 }
0059 return true;
0060 }