Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:39

0001 
0002 #include "L1Trigger/DemonstratorTools/interface/codecs/vertices.h"
0003 
0004 namespace l1t::demo::codecs {
0005 
0006   ap_uint<64> encodeVertex(const l1t::VertexWord& v) { return v.vertexWord(); }
0007 
0008   // Encodes vertex collection onto 1 output link
0009   std::array<std::vector<ap_uint<64>>, 1> encodeVertices(const edm::View<l1t::VertexWord>& vertices) {
0010     std::vector<ap_uint<64>> vertexWords;
0011 
0012     for (const auto& vertex : vertices)
0013       vertexWords.push_back(encodeVertex(vertex));
0014 
0015     std::array<std::vector<ap_uint<64>>, 1> linkData;
0016 
0017     for (size_t i = 0; i < linkData.size(); i++) {
0018       // Pad vertex vectors -> full packet length (48 frames, but only 10 vertices max)
0019       vertexWords.resize(10, 0);
0020       linkData.at(i) = vertexWords;
0021     }
0022 
0023     return linkData;
0024   }
0025 
0026   std::vector<l1t::VertexWord> decodeVertices(const std::vector<ap_uint<64>>& frames) {
0027     std::vector<l1t::VertexWord> vertices;
0028 
0029     for (const auto& x : frames) {
0030       if (not x.test(VertexWord::kValidLSB))
0031         break;
0032       VertexWord::vtxvalid_t validWord;
0033       VertexWord::vtxz0_t z0Word;
0034       VertexWord::vtxmultiplicity_t multWord;
0035       VertexWord::vtxsumpt_t sumPtWord;
0036       VertexWord::vtxquality_t qualityWord;
0037       VertexWord::vtxinversemult_t inverseMultWord;
0038       VertexWord::vtxunassigned_t unassignedWord;
0039 
0040       validWord.V = x(VertexWord::kValidMSB, VertexWord::kValidLSB);
0041       z0Word.V = x(VertexWord::kZ0MSB, VertexWord::kZ0LSB);
0042       multWord.V = x(VertexWord::kNTrackInPVMSB, VertexWord::kNTrackInPVLSB);
0043       sumPtWord.V = x(VertexWord::kSumPtMSB, VertexWord::kSumPtLSB);
0044       qualityWord.V = x(VertexWord::kQualityMSB, VertexWord::kQualityLSB);
0045       inverseMultWord.V = x(VertexWord::kNTrackOutPVMSB, VertexWord::kNTrackOutPVLSB);
0046       unassignedWord.V = x(VertexWord::kUnassignedMSB, VertexWord::kUnassignedLSB);
0047 
0048       VertexWord v(validWord, z0Word, multWord, sumPtWord, qualityWord, qualityWord, unassignedWord);
0049       vertices.push_back(v);
0050     }
0051 
0052     return vertices;
0053   }
0054 
0055 }  // namespace l1t::demo::codecs