File indexing completed on 2024-09-07 04:36:13
0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 #include "EventFilter/L1TRawToDigi/plugins/UnpackerFactory.h"
0003
0004 #include "CaloCollections.h"
0005 #include "LegacyEtSumUnpacker.h"
0006
0007 namespace l1t {
0008 namespace stage1 {
0009 namespace legacy {
0010 bool EtSumUnpacker::unpack(const Block& block, UnpackerCollections* coll) {
0011 LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
0012
0013 int nBX, firstBX, lastBX;
0014 nBX = int(ceil(block.header().getSize() / 2.));
0015 getBXRange(nBX, firstBX, lastBX);
0016
0017 auto res_ = static_cast<CaloCollections*>(coll)->getEtSums();
0018 res_->setBXRange(firstBX, lastBX);
0019
0020 LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
0021
0022
0023 int unsigned i = 0;
0024
0025
0026 for (int bx = firstBX; bx <= lastBX; bx++) {
0027 uint32_t raw_data0 = block.payload()[i++];
0028 uint32_t raw_data1 = block.payload()[i++];
0029
0030
0031
0032 uint16_t candbit[4];
0033 candbit[0] = raw_data0 & 0xFFFF;
0034 candbit[1] = (raw_data0 >> 16) & 0xFFFF;
0035 candbit[2] = raw_data1 & 0xFFFF;
0036 candbit[3] = (raw_data1 >> 16) & 0xFFFF;
0037
0038 int totet = candbit[0] & 0xFFF;
0039 int overflowtotet = (candbit[0] >> 12) & 0x1;
0040 int etmiss = candbit[1] & 0xFFF;
0041 int overflowetmiss = (candbit[1] >> 12) & 0x1;
0042 int totht = candbit[2] & 0xFFF;
0043 int overflowtotht = (candbit[2] >> 12) & 0x1;
0044 int etmissphi = candbit[3] & 0x7F;
0045
0046 l1t::EtSum et{l1t::EtSum::kTotalEt};
0047 et.setHwPt(totet);
0048 int flagtotet = et.hwQual();
0049 flagtotet |= overflowtotet;
0050 et.setHwQual(flagtotet);
0051 LogDebug("L1T") << "ET: pT " << et.hwPt() << "is overflow " << overflowtotet << std::endl;
0052 res_->push_back(bx, et);
0053
0054 l1t::EtSum ht{l1t::EtSum::kTotalHt};
0055 ht.setHwPt(totht);
0056 int flagtotht = ht.hwQual();
0057 flagtotht |= overflowtotht;
0058 ht.setHwQual(flagtotht);
0059 LogDebug("L1T") << "HT: pT " << ht.hwPt() << "is overflow " << overflowtotht << std::endl;
0060 res_->push_back(bx, ht);
0061
0062 l1t::EtSum met{l1t::EtSum::kMissingEt};
0063 met.setHwPt(etmiss);
0064 met.setHwPhi(etmissphi);
0065 int flagetmiss = met.hwQual();
0066 flagetmiss |= overflowetmiss;
0067 met.setHwQual(flagetmiss);
0068 LogDebug("L1T") << "MET: pT " << met.hwPt() << "is overflow " << overflowetmiss << std::endl;
0069 res_->push_back(bx, met);
0070 }
0071
0072 return true;
0073 }
0074 }
0075 }
0076 }
0077
0078 DEFINE_L1T_UNPACKER(l1t::stage1::legacy::EtSumUnpacker);