Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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 "JetPacker.h"
0008 
0009 namespace l1t {
0010   namespace stage2 {
0011     Blocks JetPacker::pack(const edm::Event& event, const PackerTokens* toks) {
0012       edm::Handle<JetBxCollection> jets;
0013       event.getByToken(static_cast<const CommonTokens*>(toks)->getJetToken(), jets);
0014 
0015       std::vector<uint32_t> load1, load2;
0016 
0017       // loop over BX
0018       int nBx = 0;
0019       for (int i = jets->getFirstBX(); i <= jets->getLastBX(); ++i) {
0020         // get jets from this BX
0021         for (auto j = jets->begin(i); j != jets->end(i); ++j) {
0022           uint32_t packed_eta = abs(j->hwEta()) & 0x7F;
0023           if (j->hwEta() < 0) {
0024             packed_eta = (128 - packed_eta) | 1 << 7;
0025           }
0026 
0027           uint32_t word =
0028               std::min(j->hwPt(), 0x7FF) | packed_eta << 11 | (j->hwPhi() & 0xFF) << 19 | (j->hwQual() & 0x7) << 27;
0029 
0030           // Depending on the number, push onto appropriate link
0031           if (load1.size() - nBx * l1t::stage2::layer2::demux::nJetPerLink < l1t::stage2::layer2::demux::nJetPerLink)
0032             load1.push_back(word);
0033           else
0034             load2.push_back(word);
0035         }
0036 
0037         // push zeroes if jets are missing must do this for each BX and each link
0038         while (load1.size() - nBx * l1t::stage2::layer2::demux::nOutputFramePerBX <
0039                l1t::stage2::layer2::demux::nOutputFramePerBX)
0040           load1.push_back(0);
0041         while (load2.size() - nBx * l1t::stage2::layer2::demux::nOutputFramePerBX <
0042                l1t::stage2::layer2::demux::nOutputFramePerBX)
0043           load2.push_back(0);
0044 
0045         nBx++;
0046       }
0047 
0048       return {Block(b1_, load1), Block(b2_, load2)};
0049     }
0050   }  // namespace stage2
0051 }  // namespace l1t
0052 
0053 DEFINE_L1T_PACKER(l1t::stage2::GTJetPacker);
0054 DEFINE_L1T_PACKER(l1t::stage2::CaloJetPacker);