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 "MissEtPacker.h"
0006 
0007 namespace l1t {
0008   namespace stage1 {
0009     Blocks MissEtPacker::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 objectMissingEt = 0;
0019         uint16_t objectMissingEtPhi = 0;
0020 
0021         int flagMissingEt = 0;
0022 
0023         for (auto j = etSums->begin(i); j != etSums->end(i) && n < 4; ++j, ++n) {
0024           if (j->getType() == l1t::EtSum::kMissingEt) {
0025             flagMissingEt = j->hwQual() & 0x1;
0026             objectMissingEt = std::min(j->hwPt(), 0xFFF) | (flagMissingEt << 12);
0027             objectMissingEtPhi = std::min(j->hwPhi(), 0x7F);
0028           }
0029         }
0030 
0031         uint32_t word0 = (objectMissingEt & 0xFFFF);
0032         uint32_t word1 = (objectMissingEtPhi & 0xFFFF);
0033 
0034         word0 |= (1 << 15);
0035         word1 |= ((i == 0) << 15);
0036 
0037         load.push_back(word0);
0038         load.push_back(word1);
0039       }
0040 
0041       return {Block(95, load)};
0042     }
0043   }  // namespace stage1
0044 }  // namespace l1t
0045 
0046 DEFINE_L1T_PACKER(l1t::stage1::MissEtPacker);