Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:01

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