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 "GTTokens.h"
0005 #include "GlobalAlgBlkPacker.h"
0006 
0007 namespace l1t {
0008   namespace stage2 {
0009     Blocks GlobalAlgBlkPacker::pack(const edm::Event& event, const PackerTokens* toks) {
0010       edm::Handle<GlobalAlgBlkBxCollection> algs;
0011       event.getByToken(static_cast<const GTTokens*>(toks)->getAlgToken(), algs);
0012 
0013       unsigned int wdPerBX = 6;  //should this be configured someplace else?
0014 
0015       Blocks res;
0016 
0017       for (int blk = 0; blk < 9; blk++) {
0018         unsigned int blkID = blk * 2 + 33;
0019 
0020         unsigned int algOffset = (2 * blk + 1) / 2;
0021         algOffset = (algOffset % 3) * 192;
0022 
0023         //vector of words
0024         std::vector<uint32_t> load;
0025 
0026         for (int i = algs->getFirstBX(); i <= algs->getLastBX(); ++i) {
0027           for (auto j = algs->begin(i); j != algs->end(i); ++j) {
0028             for (unsigned int wd = 0; wd < wdPerBX; wd++) {
0029               uint32_t word = 0;
0030 
0031               if ((blk + 1) % 3 > 0 || wd < 4) {
0032                 unsigned int startAlg = wd * 32 + algOffset;
0033                 for (unsigned bt = 0; bt < 32; bt++) {
0034                   if (blk < 3) {
0035                     if (j->getAlgoDecisionInitial(bt + startAlg))
0036                       word |= (0x1 << bt);
0037                   } else if (blk < 6) {
0038                     if (j->getAlgoDecisionInterm(bt + startAlg))
0039                       word |= (0x1 << bt);
0040                   } else {
0041                     if (j->getAlgoDecisionFinal(bt + startAlg))
0042                       word |= (0x1 << bt);
0043                   }
0044                 }
0045 
0046               } else if (blk == 2 && (wd == 4 || wd == 5)) {
0047                 //putting hashed values of the menu name and firmware uuid into record.
0048                 if (wd == 4)
0049                   word |= (j->getL1MenuUUID() & 0xFFFFFFFF);
0050                 if (wd == 5)
0051                   word |= (j->getL1FirmwareUUID() & 0xFFFFFFFF);
0052 
0053               } else if (blk == 8) {
0054                 if (wd == 4) {
0055                   if (j->getFinalOR())
0056                     word |= (0x1 << 16);
0057                   if (j->getFinalORVeto())
0058                     word |= (0x1 << 8);
0059                   if (j->getFinalORPreVeto())
0060                     word |= (0x1 << 0);
0061                 } else if (wd == 5) {
0062                   word |= (j->getPreScColumn() & 0xFF);
0063                 }
0064               }  //if on blk
0065 
0066               load.push_back(word);
0067             }  //loop over words
0068 
0069           }  //end loop over alg objects.(trivial one per BX)
0070 
0071         }  //end loop over bx
0072 
0073         res.push_back(Block(blkID, load));
0074 
0075       }  //loop over blks
0076 
0077       return res;
0078     }
0079   }  // namespace stage2
0080 }  // namespace l1t
0081 
0082 DEFINE_L1T_PACKER(l1t::stage2::GlobalAlgBlkPacker);