File indexing completed on 2024-04-06 12:10:48
0001 #include "FWCore/Framework/interface/MakerMacros.h"
0002 #include "EventFilter/L1TRawToDigi/plugins/UnpackerFactory.h"
0003
0004 #include "CaloCollections.h"
0005 #include "MissEtUnpacker.h"
0006
0007 namespace l1t {
0008 namespace stage1 {
0009 bool MissEtUnpacker::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 etmiss = candbit[0] & 0xFFF;
0038 int overflowetmiss = (candbit[0] >> 12) & 0x1;
0039 int etmissphi = candbit[1] & 0x7F;
0040
0041 l1t::EtSum met{l1t::EtSum::kMissingEt};
0042 met.setHwPt(etmiss);
0043 met.setHwPhi(etmissphi);
0044 int flagetmiss = met.hwQual();
0045 flagetmiss |= overflowetmiss;
0046 met.setHwQual(flagetmiss);
0047 LogDebug("L1T") << "MET: pT " << met.hwPt() << "is overflow " << overflowetmiss << std::endl;
0048 res_->set(bx, 0, met);
0049 }
0050
0051 return true;
0052 }
0053 }
0054 }
0055
0056 DEFINE_L1T_UNPACKER(l1t::stage1::MissEtUnpacker);