Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:48

0001 #include "FWCore/Framework/interface/Event.h"
0002 #include "EventFilter/L1TRawToDigi/plugins/PackerFactory.h"
0003 
0004 #include "CaloTokens.h"
0005 #include "EtSumPacker.h"
0006 
0007 namespace l1t {
0008   namespace stage1 {
0009     Blocks EtSumPacker::pack(const edm::Event& event, const PackerTokens* toks) {
0010       edm::Handle<EtSumBxCollection> etSums;
0011       event.getByToken(static_cast<const CaloTokens*>(toks)->getEtSumToken(), etSums);
0012 
0013       std::vector<uint32_t> load;
0014 
0015       for (int i = etSums->getFirstBX(); i <= etSums->getLastBX(); ++i) {
0016         int n = 0;
0017 
0018         uint16_t objectTotalEt = 0;
0019         uint16_t objectTotalHt = 0;
0020         int flagTotalEt = 0;
0021         int flagTotalHt = 0;
0022 
0023         for (auto j = etSums->begin(i); j != etSums->end(i) && n < 4; ++j, ++n) {
0024           if (j->getType() == l1t::EtSum::kTotalEt) {
0025             flagTotalEt = j->hwQual() & 0x1;
0026             objectTotalEt = std::min(j->hwPt(), 0xFFF) | (flagTotalEt << 12);
0027           }
0028 
0029           else if (j->getType() == l1t::EtSum::kTotalHt) {
0030             flagTotalHt = j->hwQual() & 0x1;
0031             objectTotalHt = std::min(j->hwPt(), 0xFFF) | (flagTotalHt << 12);
0032           }
0033         }
0034 
0035         uint32_t word0 = (objectTotalEt & 0xFFFF);
0036         uint32_t word1 = (objectTotalHt & 0xFFFF);
0037 
0038         word0 |= (1 << 15);
0039         word1 |= ((i == 0) << 15);
0040 
0041         load.push_back(word0);
0042         load.push_back(word1);
0043       }
0044 
0045       return {Block(93, load)};
0046     }
0047   }  // namespace stage1
0048 }  // namespace l1t
0049 
0050 DEFINE_L1T_PACKER(l1t::stage1::EtSumPacker);