Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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 "TauPacker.h"
0008 
0009 namespace l1t {
0010   namespace stage2 {
0011     Blocks TauPacker::pack(const edm::Event& event, const PackerTokens* toks) {
0012       edm::Handle<TauBxCollection> taus;
0013       event.getByToken(static_cast<const CommonTokens*>(toks)->getTauToken(), taus);
0014 
0015       std::vector<uint32_t> load1, load2;
0016 
0017       int nBx = 0;
0018       for (int i = taus->getFirstBX(); i <= taus->getLastBX(); ++i) {
0019         for (auto j = taus->begin(i); j != taus->end(i); ++j) {
0020           uint32_t packed_eta = abs(j->hwEta()) & 0x7F;
0021           if (j->hwEta() < 0) {
0022             packed_eta = (128 - packed_eta) | 1 << 7;
0023           }
0024 
0025           uint32_t word = std::min(j->hwPt(), 0x1FF) | packed_eta << 9 | (j->hwPhi() & 0xFF) << 17 |
0026                           (j->hwIso() & 0x3) << 25 |  //two bits for tau isolation
0027                           (j->hwQual() & 0x7) << 27;
0028 
0029           // Depending on the number, push onto appropriate link
0030           if (load1.size() - nBx * l1t::stage2::layer2::demux::nTauPerLink < l1t::stage2::layer2::demux::nTauPerLink)
0031             load1.push_back(word);
0032           else
0033             load2.push_back(word);
0034         }
0035 
0036         // push zeroes if not enough taus must do this for each BX and each link
0037         while (load1.size() - nBx * l1t::stage2::layer2::demux::nOutputFramePerBX <
0038                l1t::stage2::layer2::demux::nOutputFramePerBX)
0039           load1.push_back(0);
0040         while (load2.size() - nBx * l1t::stage2::layer2::demux::nOutputFramePerBX <
0041                l1t::stage2::layer2::demux::nOutputFramePerBX)
0042           load2.push_back(0);
0043 
0044         nBx++;
0045       }
0046 
0047       return {Block(b1_, load1), Block(b2_, load2)};
0048     }
0049   }  // namespace stage2
0050 }  // namespace l1t
0051 
0052 DEFINE_L1T_PACKER(l1t::stage2::GTTauPacker);
0053 DEFINE_L1T_PACKER(l1t::stage2::CaloTauPacker);