File indexing completed on 2024-09-07 04:36:14
0001 #include "EventFilter/L1TRawToDigi/plugins/UnpackerFactory.h"
0002 #include "L1Trigger/L1TMuon/interface/RegionalMuonRawDigiTranslator.h"
0003 #include "BMTFUnpackerOutput.h"
0004
0005 namespace l1t {
0006 namespace stage2 {
0007
0008 bool BMTFUnpackerOutput::unpack(const Block &block, UnpackerCollections *coll) {
0009 unsigned int blockId = block.header().getID();
0010 LogDebug("L1T") << "Block ID: " << blockId << " size: " << block.header().getSize();
0011
0012
0013 BxBlocks bxBlocks;
0014 bool ZS_enabled =
0015 (bool)((block.header().getFlags() >> 1) & 0x01);
0016 if (ZS_enabled)
0017 bxBlocks =
0018 block.getBxBlocks((unsigned int)6, true);
0019 else
0020 bxBlocks =
0021 block.getBxBlocks((unsigned int)6, false);
0022
0023 edm::LogInfo("L1T") << "Will use the setup:"
0024 << " ZS_enabled->" << ZS_enabled << " isTriggeringAlgo->" << isTriggeringAlgo << " isKalman->"
0025 << isKalman;
0026
0027 RegionalMuonCandBxCollection *res;
0028 if (isTriggeringAlgo)
0029 res = static_cast<BMTFCollections *>(coll)->getBMTFMuons();
0030 else
0031 res = static_cast<BMTFCollections *>(coll)->getBMTF2Muons();
0032
0033
0034 int firstBX = 0, lastBX = 0;
0035 int nBX = 0;
0036 if (!bxBlocks.empty()) {
0037 nBX = bxBlocks[0].header().getTotalBx();
0038 getBXRange(nBX, firstBX, lastBX);
0039 res->setBXRange(firstBX, lastBX);
0040 } else {
0041 res->setBXRange(-2, 2);
0042 LogDebug("L1T") << "No BXs included in the given Block. Set the BXRange to be (-2,2).";
0043 return true;
0044 }
0045
0046 LogDebug("L1T") << "nBX = " << nBX << " firstBX = " << firstBX << " lastBX = " << lastBX;
0047
0048 int processor = block.amc().getBoardID() - 1;
0049 if (processor < 0 || processor > 11) {
0050 edm::LogInfo("L1T") << "Processor found out of range, it will be calculated by the old way";
0051 if (block.amc().getAMCNumber() % 2 != 0)
0052 processor = block.amc().getAMCNumber() / 2;
0053 else
0054 processor = 6 + (block.amc().getAMCNumber() / 2 - 1);
0055 }
0056
0057 for (const auto &bxBlock : bxBlocks) {
0058 int ibx = bxBlock.header().getBx();
0059
0060 for (auto iw = 0; iw < 6; iw += 2) {
0061 uint32_t raw_first = bxBlock.payload()[iw];
0062 uint32_t raw_secnd = bxBlock.payload()[iw + 1];
0063 if (raw_first == 0) {
0064 LogDebug("L1T") << "Raw data is zero";
0065 continue;
0066 }
0067
0068 RegionalMuonCand muCand;
0069 RegionalMuonRawDigiTranslator::fillRegionalMuonCand(
0070 muCand, raw_first, raw_secnd, processor, tftype::bmtf, isKalman, false, false);
0071
0072 if (muCand.hwPt() == 0) {
0073 continue;
0074 }
0075
0076 if (isKalman) {
0077 LogDebug("L1T") << "Pt = " << muCand.hwPt() << " eta: " << muCand.hwEta() << " phi: " << muCand.hwPhi()
0078 << " diplacedPt = " << muCand.hwPtUnconstrained();
0079 } else {
0080 LogDebug("L1T") << "Pt = " << muCand.hwPt() << " eta: " << muCand.hwEta() << " phi: " << muCand.hwPhi();
0081 }
0082
0083 res->push_back(ibx, muCand);
0084
0085 }
0086 }
0087
0088 return true;
0089 }
0090
0091 }
0092 }
0093
0094 DEFINE_L1T_UNPACKER(l1t::stage2::BMTFUnpackerOutput);