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::fillMuon(mu, raw_data_00_31, raw_data_32_63, 1402, 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 
mps_fire.i
i
Definition: mps_fire.py:355
l1t::stage2::IntermediateMuonUnpacker::coll1Cnt_
unsigned int coll1Cnt_
Definition: IntermediateMuonUnpacker.h:23
MessageLogger.h
l1t::stage2::IntermediateMuonUnpacker::res2_
MuonBxCollection * res2_
Definition: IntermediateMuonUnpacker.h:22
MuonRawDigiTranslator.h
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
GMTCollections.h
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
l1t::MuonRawDigiTranslator::ptShift_
static const unsigned ptShift_
Definition: MuonRawDigiTranslator.h:16
l1t::stage2::IntermediateMuonUnpacker
Definition: IntermediateMuonUnpacker.h:10
RPCBxOrConfig_cff.firstBX
firstBX
Definition: RPCBxOrConfig_cff.py:5
Muon
Definition: Muon.py:1
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
l1t::MuonRawDigiTranslator::fillMuon
static void fillMuon(Muon &, uint32_t, uint32_t, int, unsigned int)
Definition: MuonRawDigiTranslator.cc:4
l1t::stage2::IntermediateMuonUnpacker::res1_
MuonBxCollection * res1_
Definition: IntermediateMuonUnpacker.h:21
reco::ceil
constexpr int32_t ceil(float num)
Definition: constexpr_cmath.h:7
l1t::BxBlockHeader::getTotalBx
unsigned int getTotalBx() const
Definition: BxBlock.h:27
UnpackerFactory.h
jets_cff.payload
payload
Definition: jets_cff.py:34
l1t::stage2::IntermediateMuonUnpacker::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: IntermediateMuonUnpacker.cc:14
edm::LogWarning
Definition: MessageLogger.h:141
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
Event.h
l1t
delete x;
Definition: CaloConfig.h:22
createfilelist.int
int
Definition: createfilelist.py:10
l1t::MuonRawDigiTranslator::ptMask_
static const unsigned ptMask_
Definition: MuonRawDigiTranslator.h:15
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
SiStripSourceConfigTier0_cff.stage2
stage2
Definition: SiStripSourceConfigTier0_cff.py:71
l1t::stage2::IntermediateMuonUnpacker::nWords_
static constexpr unsigned nWords_
Definition: IntermediateMuonUnpacker.h:18
l1t::stage2::IntermediateMuonUnpacker::IntermediateMuonUnpacker
IntermediateMuonUnpacker()
Definition: IntermediateMuonUnpacker.cc:12
l1t::UnpackerCollections
Definition: UnpackerCollections.h:9
RPCBxOrConfig_cff.lastBX
lastBX
Definition: RPCBxOrConfig_cff.py:4
DEFINE_L1T_UNPACKER
#define DEFINE_L1T_UNPACKER(type)
Definition: UnpackerFactory.h:23
l1t::getBXRange
void getBXRange(int nbx, int &first, int &last)
Definition: UnpackerFactory.cc:12
BXVector::setBXRange
void setBXRange(int bxFirst, int bxLast)
l1t::BxBlockHeader
Definition: BxBlock.h:10
l1t::Block
Definition: Block.h:54
BXVector::push_back
void push_back(int bx, T object)
IntermediateMuonUnpacker.h
l1t::Unpacker::getAlgoVersion
unsigned int getAlgoVersion()
Definition: Unpacker.h:18
l1t::stage2::IntermediateMuonUnpacker::unpackBx
void unpackBx(int bx, const std::vector< uint32_t > &payload, unsigned int startIdx=0)
Definition: IntermediateMuonUnpacker.cc:103
l1t::stage2::IntermediateMuonUnpacker::bxzs_enable_shift_
static constexpr unsigned bxzs_enable_shift_
Definition: IntermediateMuonUnpacker.h:19