File indexing completed on 2024-04-06 12:10:51
0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 #include "EventFilter/L1TRawToDigi/plugins/UnpackerFactory.h"
0003
0004 #include "GTCollections.h"
0005 #include "GlobalExtBlkUnpacker.h"
0006
0007 namespace l1t {
0008 namespace stage2 {
0009 bool GlobalExtBlkUnpacker::unpack(const Block& block, UnpackerCollections* coll) {
0010 LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
0011
0012 unsigned int wdPerBX = 6;
0013 int nBX = int(ceil(
0014 block.header().getSize() /
0015 6.));
0016
0017
0018 int firstBX = -(ceil((double)nBX / 2.) - 1);
0019 int lastBX;
0020 if (nBX % 2 == 0) {
0021 lastBX = ceil((double)nBX / 2.);
0022 } else {
0023 lastBX = ceil((double)nBX / 2.) - 1;
0024 }
0025
0026 auto res_ = static_cast<GTCollections*>(coll)->getExts();
0027 res_->setBXRange(firstBX, lastBX);
0028
0029 LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
0030
0031
0032 int numBX = 0;
0033 for (int bx = firstBX; bx <= lastBX; bx++) {
0034
0035 if (block.header().getID() == 24) {
0036 LogDebug("L1T") << "Creating GT External Block for BX =" << bx;
0037 GlobalExtBlk tExt = GlobalExtBlk();
0038 res_->push_back(bx, tExt);
0039 }
0040
0041
0042 GlobalExtBlk ext = res_->at(bx, 0);
0043
0044
0045
0046 int extOffset = ((block.header().getID() - 24) / 2) * 64;
0047
0048 for (unsigned int wd = 0; wd < wdPerBX; wd++) {
0049 uint32_t raw_data = block.payload()[wd + numBX * wdPerBX];
0050 LogDebug("L1T") << " payload word " << wd << " 0x" << hex << raw_data;
0051
0052 if (wd < 2) {
0053 for (unsigned int bt = 0; bt < 32; bt++) {
0054 int val = ((raw_data >> bt) & 0x1);
0055 int extBit = bt + wd * 32 + extOffset;
0056 if (val == 1)
0057 ext.setExternalDecision(extBit, true);
0058 }
0059 }
0060 }
0061
0062
0063 res_->set(bx, 0, ext);
0064
0065
0066 numBX++;
0067 }
0068
0069 return true;
0070 }
0071 }
0072 }
0073
0074 DEFINE_L1T_UNPACKER(l1t::stage2::GlobalExtBlkUnpacker);