Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "FWCore/Framework/interface/Event.h"
0002 #include "EventFilter/L1TRawToDigi/plugins/PackerFactory.h"
0003 
0004 #include "GTTokens.h"
0005 #include "GlobalExtBlkPacker.h"
0006 
0007 namespace l1t {
0008   namespace stage2 {
0009     Blocks GlobalExtBlkPacker::pack(const edm::Event& event, const PackerTokens* toks) {
0010       edm::Handle<GlobalExtBlkBxCollection> exts;
0011       event.getByToken(static_cast<const GTTokens*>(toks)->getExtToken(), exts);
0012 
0013       unsigned int wdPerBX = 6;  //should this be configured someplace else?
0014 
0015       Blocks res;
0016 
0017       for (int blk = 0; blk < 4; blk++) {
0018         unsigned int blkID = blk * 2 + 24;
0019 
0020         unsigned int extOffset = blk * 64;
0021 
0022         //vector of words
0023         std::vector<uint32_t> load;
0024 
0025         for (int i = exts->getFirstBX(); i <= exts->getLastBX(); ++i) {
0026           for (auto j = exts->begin(i); j != exts->end(i); ++j) {
0027             for (unsigned int wd = 0; wd < wdPerBX; wd++) {
0028               uint32_t word = 0;
0029 
0030               if (wd < 2) {
0031                 unsigned int startExt = wd * 32 + extOffset;
0032                 for (unsigned bt = 0; bt < 32; bt++) {
0033                   if (j->getExternalDecision(bt + startExt))
0034                     word |= (0x1 << bt);
0035 
0036                 }  //end loop over bits
0037               }    //endif wrd < 2
0038 
0039               load.push_back(word);
0040             }  //loop over words
0041 
0042           }  //end loop over alg objects.(trivial one per BX)
0043 
0044         }  //end loop over bx
0045 
0046         res.push_back(Block(blkID, load));
0047 
0048       }  //loop over blks
0049 
0050       return res;
0051     }
0052   }  // namespace stage2
0053 }  // namespace l1t
0054 
0055 DEFINE_L1T_PACKER(l1t::stage2::GlobalExtBlkPacker);