Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-02 23:59:50

0001 #include "BMTFPackerOutput.h"
0002 #include <vector>
0003 
0004 // Implementation
0005 namespace l1t {
0006   namespace stage2 {
0007     Blocks BMTFPackerOutput::pack(const edm::Event& event, const PackerTokens* toks) {
0008       int board_id = (int)board();
0009 
0010       auto muonToken = static_cast<const BMTFTokens*>(toks)->getOutputMuonToken();
0011 
0012       Blocks blocks;
0013       const int bmtfBlockID = 123;
0014       edm::LogInfo("L1T-BMTFPackerOutput") << "Will use setup:"
0015                                            << " isKalman->" << isKalman_;
0016 
0017       edm::Handle<RegionalMuonCandBxCollection> muons;
0018       event.getByToken(muonToken, muons);
0019 
0020       for (auto imu = muons->begin(); imu != muons->end(); imu++) {
0021         if (imu->processor() + 1 == board_id) {
0022           uint32_t firstWord(0), lastWord(0);
0023           RegionalMuonRawDigiTranslator::generatePackedDataWords(*imu, firstWord, lastWord, isKalman_, false);
0024           payloadMap_[bmtfBlockID].push_back(firstWord);  //imu->link()*2+1
0025           payloadMap_[bmtfBlockID].push_back(lastWord);   //imu->link()*2+1
0026         }
0027       }  //imu
0028 
0029       //in case less than 3 muons have been found by the processor
0030       if (payloadMap_[bmtfBlockID].size() < 6) {
0031         unsigned int initialSize = payloadMap_[bmtfBlockID].size();
0032 
0033         for (unsigned int j = 0; j < 3 - initialSize / 2; j++) {
0034           payloadMap_[bmtfBlockID].push_back(0);
0035           uint32_t nullMuon_word2 = 0 | ((65532 & 0xFFFF) << 3) | ((2 & 0x3) << 0);
0036           payloadMap_[bmtfBlockID].push_back(nullMuon_word2);
0037         }
0038       } else if (payloadMap_[bmtfBlockID].size() < 30 && payloadMap_[bmtfBlockID].size() > 6) {
0039         unsigned int initialSize = payloadMap_[bmtfBlockID].size();
0040 
0041         for (unsigned int j = 0; j < 15 - initialSize / 2; j++) {
0042           payloadMap_[bmtfBlockID].push_back(0);
0043           uint32_t nullMuon_word2 = 0 | ((65532 & 0xFFFF) << 3) | ((2 & 0x3) << 0);
0044           payloadMap_[bmtfBlockID].push_back(nullMuon_word2);
0045         }
0046       }
0047 
0048       Block block(bmtfBlockID, payloadMap_[bmtfBlockID]);
0049 
0050       blocks.push_back(block);
0051 
0052       return blocks;
0053     }
0054 
0055   }  // namespace stage2
0056 }  // namespace l1t
0057 DEFINE_L1T_PACKER(l1t::stage2::BMTFPackerOutput);