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