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