CMS 3D CMS Logo

MuonUnpacker.cc
Go to the documentation of this file.
4 
6 
7 #include "MuonUnpacker.h"
8 
9 namespace l1t {
10  namespace stage2 {
11  MuonUnpacker::MuonUnpacker() : res_(nullptr), muonCopy_(0) {}
12 
14  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
15  // process only if there is a payload
16  // If all BX block were zero suppressed the block header size is 0.
17  if (block.header().getSize() < 1) {
18  return true;
19  }
20 
21  auto payload = block.payload();
22 
23  int nBX, firstBX, lastBX;
24  // Check if per BX zero suppression was enabled
25  bool bxZsEnabled = ((block.header().getFlags() >> bxzs_enable_shift_) & 0x1) == 1;
26  // Calculate the total number of BXs
27  if (bxZsEnabled) {
28  BxBlockHeader bxHeader(payload.at(0));
29  nBX = bxHeader.getTotalBx();
30  } else {
31  nBX = int(ceil(block.header().getSize() / nWords_));
32  }
33  getBXRange(nBX, firstBX, lastBX);
34 
35  // Set the muon collection and the BX range
36  res_ = static_cast<L1TObjectCollections*>(coll)->getMuons(muonCopy_);
38  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
39 
40  // Get the BX blocks and unpack them
41  auto bxBlocks = block.getBxBlocks(nWords_, bxZsEnabled);
42  for (const auto& bxBlock : bxBlocks) {
43  // Throw an exception if finding a corrupt BX header with out of range BX numbers
44  const auto bx = bxBlock.header().getBx();
45  if (bx < firstBX || bx > lastBX) {
46  throw cms::Exception("CorruptData")
47  << "Corrupt RAW data from FED " << fed_ << ", AMC " << block.amc().getAMCNumber() << ". BX number " << bx
48  << " in BX header is outside of the BX range [" << firstBX << "," << lastBX
49  << "] defined in the block header.";
50  }
51  unpackBx(bx, bxBlock.payload());
52  }
53  return true;
54  }
55 
56  void MuonUnpacker::unpackBx(int bx, const std::vector<uint32_t>& payload, unsigned int startIdx) {
57  unsigned int i = startIdx;
58  // Check if there are enough words left in the payload
59  if (i + nWords_ <= payload.size()) {
60  for (unsigned nWord = 0; nWord < nWords_; nWord += 2) {
61  uint32_t raw_data_00_31 = payload[i++];
62  uint32_t raw_data_32_63 = payload[i++];
63  LogDebug("L1T") << "raw_data_00_31 = 0x" << hex << raw_data_00_31 << " raw_data_32_63 = 0x" << raw_data_32_63;
64  // skip empty muons (hwPt == 0)
66  LogDebug("L1T") << "Muon hwPt zero. Skip.";
67  continue;
68  }
69 
70  Muon mu;
71 
72  MuonRawDigiTranslator::fillMuon(mu, raw_data_00_31, raw_data_32_63, fed_, getAlgoVersion());
73 
74  LogDebug("L1T") << "Mu" << nWord / 2 << ": eta " << mu.hwEta() << " phi " << mu.hwPhi() << " pT " << mu.hwPt()
75  << " iso " << mu.hwIso() << " qual " << mu.hwQual() << " charge " << mu.hwCharge()
76  << " charge valid " << mu.hwChargeValid();
77 
78  res_->push_back(bx, mu);
79  }
80  } else {
81  edm::LogWarning("L1T") << "Only " << payload.size() - i << " 32 bit words in this BX but " << nWords_
82  << " are required. Not unpacking the data for BX " << bx << ".";
83  }
84  }
85  } // namespace stage2
86 } // namespace l1t
87 
mps_fire.i
i
Definition: mps_fire.py:355
l1t::stage2::MuonUnpacker::nWords_
static constexpr unsigned nWords_
Definition: MuonUnpacker.h:24
MessageLogger.h
l1t::stage2::MuonUnpacker::bxzs_enable_shift_
static constexpr unsigned bxzs_enable_shift_
Definition: MuonUnpacker.h:25
MuonRawDigiTranslator.h
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
l1t::stage2::MuonUnpacker::MuonUnpacker
MuonUnpacker()
Definition: MuonUnpacker.cc:11
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
l1t::MuonRawDigiTranslator::ptShift_
static const unsigned ptShift_
Definition: MuonRawDigiTranslator.h:16
RPCBxOrConfig_cff.firstBX
firstBX
Definition: RPCBxOrConfig_cff.py:5
Muon
Definition: Muon.py:1
l1t::stage2::MuonUnpacker
Definition: MuonUnpacker.h:10
l1t::stage2::MuonUnpacker::res_
MuonBxCollection * res_
Definition: MuonUnpacker.h:27
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
reco::ceil
constexpr int32_t ceil(float num)
Definition: constexpr_cmath.h:7
l1t::stage2::MuonUnpacker::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: MuonUnpacker.cc:13
l1t::BxBlockHeader::getTotalBx
unsigned int getTotalBx() const
Definition: BxBlock.h:27
l1t::stage2::MuonUnpacker::muonCopy_
unsigned int muonCopy_
Definition: MuonUnpacker.h:29
UnpackerFactory.h
jets_cff.payload
payload
Definition: jets_cff.py:34
edm::LogWarning
Definition: MessageLogger.h:141
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
l1t
delete x;
Definition: CaloConfig.h:22
l1t::stage2::MuonUnpacker::unpackBx
void unpackBx(int bx, const std::vector< uint32_t > &payload, unsigned int startIdx=0)
Definition: MuonUnpacker.cc:56
l1t::stage2::MuonUnpacker::fed_
int fed_
Definition: MuonUnpacker.h:28
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
MuonUnpacker.h
SiStripSourceConfigTier0_cff.stage2
stage2
Definition: SiStripSourceConfigTier0_cff.py:71
Exception
Definition: hltDiff.cc:246
l1t::UnpackerCollections
Definition: UnpackerCollections.h:9
Exception.h
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)
l1t::Unpacker::getAlgoVersion
unsigned int getAlgoVersion()
Definition: Unpacker.h:18