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 + 2; // Only words 2-5 are "standard" muon words.
58  // Check if there are enough words left in the payload
59  if (startIdx + nWords_ <= payload.size()) {
60  for (unsigned nWord = 2; nWord < nWords_; nWord += 2) { // Only words 2-5 are "standard" muon words.
61  uint32_t raw_data_spare = payload[startIdx + 1];
62  uint32_t raw_data_00_31 = payload[i++];
63  uint32_t raw_data_32_63 = payload[i++];
64  LogDebug("L1T") << "raw_data_spare = 0x" << hex << raw_data_spare << " raw_data_00_31 = 0x" << raw_data_00_31
65  << " raw_data_32_63 = 0x" << raw_data_32_63;
66  // skip empty muons (hwPt == 0)
68  LogDebug("L1T") << "Muon hwPt zero. Skip.";
69  continue;
70  }
71 
72  Muon mu;
73 
75  mu, raw_data_spare, raw_data_00_31, raw_data_32_63, fed_, getAlgoVersion(), nWord / 2);
76 
77  LogDebug("L1T") << "Mu" << nWord / 2 << ": eta " << mu.hwEta() << " phi " << mu.hwPhi() << " pT " << mu.hwPt()
78  << " iso " << mu.hwIso() << " qual " << mu.hwQual() << " charge " << mu.hwCharge()
79  << " charge valid " << mu.hwChargeValid();
80 
81  res_->push_back(bx, mu);
82  }
83  } else {
84  edm::LogWarning("L1T") << "Only " << payload.size() - i << " 32 bit words in this BX but " << nWords_
85  << " are required. Not unpacking the data for BX " << bx << ".";
86  }
87  }
88  } // namespace stage2
89 } // namespace l1t
90 
mps_fire.i
i
Definition: mps_fire.py:428
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
l1t::MuonRawDigiTranslator::ptShift_
static constexpr unsigned ptShift_
Definition: MuonRawDigiTranslator.h:30
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
RPCBxOrConfig_cff.firstBX
firstBX
Definition: RPCBxOrConfig_cff.py:5
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
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 &mu, uint32_t raw_data_spare, uint32_t raw_data_00_31, uint32_t raw_data_32_63, int fed, unsigned int fw, int muInBx)
Definition: MuonRawDigiTranslator.cc:5
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:32
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
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
l1t::MuonRawDigiTranslator::ptMask_
static constexpr unsigned ptMask_
Definition: MuonRawDigiTranslator.h:29
createfilelist.int
int
Definition: createfilelist.py:10
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
MuonUnpacker.h
SiStripSourceConfigTier0_cff.stage2
stage2
Definition: SiStripSourceConfigTier0_cff.py:71
Exception
Definition: hltDiff.cc:245
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:70
BXVector::push_back
void push_back(int bx, T object)
l1t::Unpacker::getAlgoVersion
unsigned int getAlgoVersion()
Definition: Unpacker.h:18