Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "FWCore/Framework/interface/Event.h"
0002 #include "EventFilter/L1TRawToDigi/plugins/PackerFactory.h"
0003 
0004 #include "CaloTokens.h"
0005 
0006 #include "L1TStage2Layer2Constants.h"
0007 #include "EtSumPacker.h"
0008 
0009 namespace l1t {
0010   namespace stage2 {
0011     Blocks EtSumPacker::pack(const edm::Event& event, const PackerTokens* toks) {
0012       edm::Handle<EtSumBxCollection> etSums;
0013       event.getByToken(static_cast<const CommonTokens*>(toks)->getEtSumToken(), etSums);
0014 
0015       std::vector<uint32_t> load;
0016       int nBx = 0;
0017 
0018       for (int i = etSums->getFirstBX(); i <= etSums->getLastBX(); ++i) {
0019         uint32_t et_word = 0;
0020         uint32_t ht_word = 0;
0021         uint32_t met_word = 0;
0022         uint32_t mht_word = 0;
0023         uint32_t methf_word = 0;
0024         uint32_t mhthf_word = 0;
0025 
0026         for (auto j = etSums->begin(i); j != etSums->end(i); ++j) {
0027           uint32_t word = std::min(j->hwPt(), 0xFFF);
0028           if ((j->getType() == l1t::EtSum::kMissingEt) || (j->getType() == l1t::EtSum::kMissingHt) ||
0029               (j->getType() == l1t::EtSum::kMissingEtHF) || (j->getType() == l1t::EtSum::kMissingHtHF))
0030             word = word | ((j->hwPhi() & 0xFF) << 12);
0031 
0032           if (j->getType() == l1t::EtSum::kTotalEt)
0033             et_word |= word;
0034           if (j->getType() == l1t::EtSum::kTotalEtEm)
0035             et_word |= (word << 12);
0036           if (j->getType() == l1t::EtSum::kMinBiasHFP0)
0037             et_word |= (word << 28);
0038           if (j->getType() == l1t::EtSum::kTotalHt)
0039             ht_word |= word;
0040           if (j->getType() == l1t::EtSum::kMinBiasHFM0)
0041             ht_word |= (word << 28);
0042           if (j->getType() == l1t::EtSum::kMissingEt)
0043             met_word |= word;
0044           if (j->getType() == l1t::EtSum::kMinBiasHFP1)
0045             met_word |= (word << 28);
0046           if (j->getType() == l1t::EtSum::kMissingHt)
0047             mht_word |= word;
0048           if (j->getType() == l1t::EtSum::kMinBiasHFM1)
0049             mht_word |= (word << 28);
0050           if (j->getType() == l1t::EtSum::kMissingEtHF)
0051             methf_word |= word;
0052           if (j->getType() == l1t::EtSum::kMissingHtHF)
0053             mhthf_word |= word;
0054           if (j->getType() == l1t::EtSum::kTowerCount)
0055             ht_word |= (word << 12);
0056           if (j->getType() == l1t::EtSum::kAsymEt)
0057             met_word |= (word << 20);
0058           if (j->getType() == l1t::EtSum::kAsymHt)
0059             mht_word |= (word << 20);
0060           if (j->getType() == l1t::EtSum::kAsymEtHF)
0061             methf_word |= (word << 20);
0062           if (j->getType() == l1t::EtSum::kAsymHtHF)
0063             mhthf_word |= (word << 20);
0064           if (j->getType() == l1t::EtSum::kCentrality) {
0065             methf_word |= ((word & 0xF) << 28);
0066             mhthf_word |= (((word >> 4) & 0xF) << 28);
0067           }
0068         }
0069 
0070         load.push_back(et_word);
0071         load.push_back(ht_word);
0072         load.push_back(met_word);
0073         load.push_back(mht_word);
0074         load.push_back(methf_word);
0075         load.push_back(mhthf_word);
0076 
0077         //pad with zeros to fill out block; must do this for each BX
0078         while (load.size() - nBx * l1t::stage2::layer2::demux::nOutputFramePerBX <
0079                l1t::stage2::layer2::demux::nOutputFramePerBX)
0080           load.push_back(0);
0081         nBx++;
0082       }
0083 
0084       return {Block(b1_, load)};
0085     }
0086   }  // namespace stage2
0087 }  // namespace l1t
0088 
0089 DEFINE_L1T_PACKER(l1t::stage2::CaloEtSumPacker);
0090 DEFINE_L1T_PACKER(l1t::stage2::GTEtSumPacker);