CMS 3D CMS Logo

IntermediateMuonUnpacker.cc
Go to the documentation of this file.
4 
6 
7 #include "GMTCollections.h"
9 
10 namespace l1t {
11  namespace stage2 {
12  IntermediateMuonUnpacker::IntermediateMuonUnpacker() : res1_(nullptr), res2_(nullptr), coll1Cnt_(0) {}
13 
15  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
16  // process only if there is a payload
17  // If all BX block were zero suppressed the block header size is 0.
18  if (block.header().getSize() < 1) {
19  return true;
20  }
21 
22  auto payload = block.payload();
23 
24  int nBX, firstBX, lastBX;
25  // Check if per BX zero suppression was enabled
26  bool bxZsEnabled = ((block.header().getFlags() >> bxzs_enable_shift_) & 0x1) == 1;
27  // Calculate the total number of BXs
28  if (bxZsEnabled) {
29  BxBlockHeader bxHeader(payload.at(0));
30  nBX = bxHeader.getTotalBx();
31  } else {
32  nBX = int(ceil(block.header().getSize() / nWords_));
33  }
34  getBXRange(nBX, firstBX, lastBX);
35 
36  // decide which collections to use according to the link ID
37  unsigned int linkId = (block.header().getID() - 1) / 2;
38  // Intermediate muons come on uGMT output links 24-31.
39  // Each link can transmit 3 muons and we receive 4 intermediate muons from
40  // EMTF/OMTF on each detector side and 8 intermediate muons from BMTF.
41  // Therefore, the muon at a certain position on a link has to be filled
42  // in a specific collection. The order is from links 24-31:
43  // 4 muons from EMTF pos, 4 from OMTF pos, 8 from BMTF, 4 from OMTF neg,
44  // and 4 from EMTF neg.
45  switch (linkId) {
46  case 24:
47  res1_ = static_cast<GMTCollections*>(coll)->getImdMuonsEMTFPos();
48  res2_ = static_cast<GMTCollections*>(coll)->getImdMuonsEMTFPos();
49  coll1Cnt_ = 3;
50  break;
51  case 25:
52  res1_ = static_cast<GMTCollections*>(coll)->getImdMuonsEMTFPos();
53  res2_ = static_cast<GMTCollections*>(coll)->getImdMuonsOMTFPos();
54  coll1Cnt_ = 1;
55  break;
56  case 26:
57  res1_ = static_cast<GMTCollections*>(coll)->getImdMuonsOMTFPos();
58  res2_ = static_cast<GMTCollections*>(coll)->getImdMuonsBMTF();
59  coll1Cnt_ = 2;
60  break;
61  case 27:
62  res1_ = static_cast<GMTCollections*>(coll)->getImdMuonsBMTF();
63  res2_ = static_cast<GMTCollections*>(coll)->getImdMuonsBMTF();
64  coll1Cnt_ = 3;
65  break;
66  case 28:
67  res1_ = static_cast<GMTCollections*>(coll)->getImdMuonsBMTF();
68  res2_ = static_cast<GMTCollections*>(coll)->getImdMuonsBMTF();
69  coll1Cnt_ = 3;
70  break;
71  case 29:
72  res1_ = static_cast<GMTCollections*>(coll)->getImdMuonsBMTF();
73  res2_ = static_cast<GMTCollections*>(coll)->getImdMuonsOMTFNeg();
74  coll1Cnt_ = 1;
75  break;
76  case 30:
77  res1_ = static_cast<GMTCollections*>(coll)->getImdMuonsOMTFNeg();
78  res2_ = static_cast<GMTCollections*>(coll)->getImdMuonsEMTFNeg();
79  coll1Cnt_ = 2;
80  break;
81  case 31:
82  res1_ = static_cast<GMTCollections*>(coll)->getImdMuonsEMTFNeg();
83  res2_ = static_cast<GMTCollections*>(coll)->getImdMuonsEMTFNeg();
84  coll1Cnt_ = 3;
85  break;
86  default:
87  edm::LogWarning("L1T") << "Block ID " << block.header().getID()
88  << " not associated with intermediate muons. Skip.";
89  return false;
90  }
93  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
94 
95  // Get the BX blocks and unpack them
96  auto bxBlocks = block.getBxBlocks(nWords_, bxZsEnabled);
97  for (const auto& bxBlock : bxBlocks) {
98  unpackBx(bxBlock.header().getBx(), bxBlock.payload());
99  }
100  return true;
101  }
102 
103  void IntermediateMuonUnpacker::unpackBx(int bx, const std::vector<uint32_t>& payload, unsigned int startIdx) {
104  unsigned int i = startIdx;
105  // Check if there are enough words left in the payload
106  if (i + nWords_ <= payload.size()) {
107  unsigned int muonCnt = 0;
108  for (unsigned nWord = 0; nWord < nWords_; nWord += 2, ++muonCnt) {
109  uint32_t raw_data_00_31 = payload[i++];
110  uint32_t raw_data_32_63 = payload[i++];
111  LogDebug("L1T") << "raw_data_00_31 = 0x" << hex << raw_data_00_31 << " raw_data_32_63 = 0x" << raw_data_32_63;
112  // skip empty muons (hwPt == 0)
114  LogDebug("L1T") << "Muon hwPt zero. Skip.";
115  continue;
116  }
117 
118  Muon mu;
119 
120  // The intermediate muons of the uGMT (FED number 1402) do not
121  // have coordinates estimated at the vertex in the RAW data.
122  // The corresponding bits are set to zero.
123  MuonRawDigiTranslator::fillIntermediateMuon(mu, raw_data_00_31, raw_data_32_63, getAlgoVersion());
124 
125  LogDebug("L1T") << "Mu" << nWord / 2 << ": eta " << mu.hwEta() << " phi " << mu.hwPhi() << " pT " << mu.hwPt()
126  << " iso " << mu.hwIso() << " qual " << mu.hwQual() << " charge " << mu.hwCharge()
127  << " charge valid " << mu.hwChargeValid();
128 
129  if (muonCnt < coll1Cnt_) {
130  res1_->push_back(bx, mu);
131  } else {
132  res2_->push_back(bx, mu);
133  }
134  }
135  } else {
136  edm::LogWarning("L1T") << "Only " << payload.size() - i << " 32 bit words in this BX but " << nWords_
137  << " are required. Not unpacking the data for BX " << bx << ".";
138  }
139  }
140 
141  } // namespace stage2
142 } // namespace l1t
143 
constexpr int32_t ceil(float num)
void unpackBx(int bx, const std::vector< uint32_t > &payload, unsigned int startIdx=0)
unsigned int getAlgoVersion()
Definition: Unpacker.h:18
void getBXRange(int nbx, int &first, int &last)
delete x;
Definition: CaloConfig.h:22
static void fillIntermediateMuon(Muon &mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63, unsigned int fw)
Definition: Muon.py:1
bool unpack(const Block &block, UnpackerCollections *coll) override
unsigned int getTotalBx() const
Definition: BxBlock.h:27
static constexpr unsigned ptShift_
void setBXRange(int bxFirst, int bxLast)
#define DEFINE_L1T_UNPACKER(type)
Log< level::Warning, false > LogWarning
static constexpr unsigned ptMask_
void push_back(int bx, T object)
#define LogDebug(id)