Back to home page

Project CMSSW displayed by LXR

 
 

    


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 "MissHtUnpacker.h"
0006 
0007 namespace l1t {
0008   namespace stage1 {
0009     bool MissHtUnpacker::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 reset_ = static_cast<CaloCollections*>(coll)->getEtSums();
0017       reset_->setBXRange(firstBX, lastBX);
0018 
0019       LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
0020 
0021       // Initialise index
0022       int unsigned i = 0;
0023 
0024       // Loop over multiple BX and then number of jets filling jet collection
0025       for (int bx = firstBX; bx <= lastBX; bx++) {
0026         reset_->resize(bx, 4);
0027 
0028         uint32_t raw_data0 = block.payload()[i++];
0029         uint32_t raw_data1 = block.payload()[i++];
0030 
0031         /* if (raw_data0 == 0 || raw_data1==0) continue; */
0032 
0033         uint16_t candbit[2];
0034         candbit[0] = raw_data0 & 0xFFFF;
0035         candbit[1] = raw_data1 & 0xFFFF;
0036 
0037         int htmissphi = candbit[0] & 0x1F;
0038         int htmiss = (candbit[0] >> 5) & 0x7F;
0039         int overflowhtmiss = (candbit[0] >> 12) & 0x1;
0040 
0041         l1t::EtSum mht{l1t::EtSum::kMissingHt};
0042         mht.setHwPt(htmiss);
0043         mht.setHwPhi(htmissphi);
0044         int flaghtmiss = mht.hwQual();
0045         flaghtmiss |= overflowhtmiss;
0046         mht.setHwQual(flaghtmiss);
0047         LogDebug("L1T") << "MHT: pT " << mht.hwPt() << "is overflow " << overflowhtmiss << std::endl;
0048         reset_->set(bx, 1, mht);
0049       }
0050 
0051       return true;
0052     }
0053   }  // namespace stage1
0054 }  // namespace l1t
0055 
0056 DEFINE_L1T_UNPACKER(l1t::stage1::MissHtUnpacker);