CMS 3D CMS Logo

RegionalMuonGMTUnpacker.cc
Go to the documentation of this file.
4 
7 
8 namespace l1t {
9  namespace stage2 {
11  unsigned int blockId = block.header().getID();
12  LogDebug("L1T") << "Block ID = " << blockId << " size = " << block.header().getSize();
13  // Process only if there is a payload.
14  // If all BX block were zero suppressed the block header size is 0.
15  if (block.header().getSize() < 1) {
16  return true;
17  }
18 
19  auto payload = block.payload();
20 
21  int nBX, firstBX, lastBX;
22  // Check if per BX zero suppression was enabled
23  bool bxZsEnabled = ((block.header().getFlags() >> bxzs_enable_shift_) & 0x1) == 1;
24  // Calculate the total number of BXs
25  if (bxZsEnabled) {
26  BxBlockHeader bxHeader(payload.at(0));
27  nBX = bxHeader.getTotalBx();
28  } else {
29  nBX = int(ceil(block.header().getSize() / nWords_));
30  }
31  getBXRange(nBX, firstBX, lastBX);
32 
33  // decide which collection to use according to the link ID
34  unsigned int linkId = blockId / 2;
35  int processor;
37  tftype trackFinder;
38  if (linkId > 47 && linkId < 60) {
39  res = static_cast<GMTCollections*>(coll)->getRegionalMuonCandsBMTF();
40  trackFinder = tftype::bmtf;
41  processor = linkId - 48;
42  } else if (linkId > 41 && linkId < 66) {
43  res = static_cast<GMTCollections*>(coll)->getRegionalMuonCandsOMTF();
44  if (linkId < 48) {
45  trackFinder = tftype::omtf_pos;
46  processor = linkId - 42;
47  } else {
48  trackFinder = tftype::omtf_neg;
49  processor = linkId - 60;
50  }
51  } else if (linkId > 35 && linkId < 72) {
52  res = static_cast<GMTCollections*>(coll)->getRegionalMuonCandsEMTF();
53  if (linkId < 42) {
54  trackFinder = tftype::emtf_pos;
55  processor = linkId - 36;
56  } else {
57  trackFinder = tftype::emtf_neg;
58  processor = linkId - 66;
59  }
60  } else {
61  edm::LogError("L1T") << "No TF muon expected for link " << linkId;
62  return false;
63  }
64  res->setBXRange(firstBX, lastBX);
65 
66  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
67 
68  // Get the BX blocks and unpack them
69  auto bxBlocks = block.getBxBlocks(nWords_, bxZsEnabled);
70  for (const auto& bxBlock : bxBlocks) {
71  // Throw an exception if finding a corrupt BX header with out of range BX numbers
72  const auto bx = bxBlock.header().getBx();
73  if (bx < firstBX || bx > lastBX) {
74  throw cms::Exception("CorruptData") << "Corrupt RAW data from AMC " << block.amc().getAMCNumber()
75  << ". BX number " << bx << " in BX header is outside of the BX range ["
76  << firstBX << "," << lastBX << "] defined in the block header.";
77  }
78  // Check if there are enough words left in the BX block payload
79  auto bxPayload = bxBlock.payload();
80  if (nWords_ <= bxPayload.size()) {
81  for (unsigned nWord = 0; nWord < nWords_; nWord += 2) {
82  uint32_t raw_data_00_31 = bxPayload[nWord];
83  uint32_t raw_data_32_63 = bxPayload[nWord + 1];
84  LogDebug("L1T") << "raw_data_00_31 = 0x" << hex << setw(8) << setfill('0') << raw_data_00_31
85  << " raw_data_32_63 = 0x" << setw(8) << setfill('0') << raw_data_32_63;
86  // skip empty muons (hwPt == 0)
87  if (((raw_data_00_31 >> l1t::RegionalMuonRawDigiTranslator::ptShift_) &
89  LogDebug("L1T") << "Muon hwPt zero. Skip.";
90  continue;
91  }
92  // Detect and ignore comma events
93  if (raw_data_00_31 == 0x505050bc || raw_data_32_63 == 0x505050bc) {
94  edm::LogWarning("L1T") << "Comma detected in raw data stream. Orbit number: "
95  << block.amc().getOrbitNumber() << ", BX ID: " << block.amc().getBX()
96  << ", BX: " << bx << ", linkId: " << linkId << ", Raw data: 0x" << hex << setw(8)
97  << setfill('0') << raw_data_32_63 << setw(8) << setfill('0') << raw_data_00_31
98  << dec << ". Skip.";
99  continue;
100  }
101 
103 
105  mu, raw_data_00_31, raw_data_32_63, processor, trackFinder);
106 
107  LogDebug("L1T") << "Mu" << nWord / 2 << ": eta " << mu.hwEta() << " phi " << mu.hwPhi() << " pT "
108  << mu.hwPt() << " qual " << mu.hwQual() << " sign " << mu.hwSign() << " sign valid "
109  << mu.hwSignValid();
110 
111  res->push_back(bx, mu);
112  }
113  } else {
114  unsigned int nWords =
115  nWords_; // This seems unnecessary but it prevents an 'undefined reference' linker error that occurs when using nWords_ directly with LogWarning.
116  edm::LogWarning("L1T") << "Only " << bxPayload.size() << " 32 bit words in this BX but " << nWords
117  << " are required. Not unpacking the data for BX " << bx << ".";
118  }
119  }
120  return true;
121  }
122  } // namespace stage2
123 } // namespace l1t
124 
l1t::bmtf
Definition: RegionalMuonCandFwd.h:8
l1t::emtf_neg
Definition: RegionalMuonCandFwd.h:8
RegionalMuonRawDigiTranslator.h
MessageLogger.h
RegionalMuonGMTUnpacker.h
l1t::omtf_pos
Definition: RegionalMuonCandFwd.h:8
l1t::tftype
tftype
Definition: RegionalMuonCandFwd.h:8
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
l1t::stage2::RegionalMuonGMTUnpacker::nWords_
static constexpr unsigned nWords_
Definition: RegionalMuonGMTUnpacker.h:15
RPCBxOrConfig_cff.firstBX
firstBX
Definition: RPCBxOrConfig_cff.py:5
BXVector< RegionalMuonCand >
l1t::stage2::RegionalMuonGMTUnpacker::bxzs_enable_shift_
static constexpr unsigned bxzs_enable_shift_
Definition: RegionalMuonGMTUnpacker.h:16
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
reco::ceil
constexpr int32_t ceil(float num)
Definition: constexpr_cmath.h:7
l1t::BxBlockHeader::getTotalBx
unsigned int getTotalBx() const
Definition: BxBlock.h:27
l1t::RegionalMuonRawDigiTranslator::ptMask_
static const unsigned ptMask_
Definition: RegionalMuonRawDigiTranslator.h:14
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
edm::LogError
Definition: MessageLogger.h:183
l1t
delete x;
Definition: CaloConfig.h:22
l1t::RegionalMuonRawDigiTranslator::fillRegionalMuonCand
static void fillRegionalMuonCand(RegionalMuonCand &, uint32_t, uint32_t, int, tftype)
Definition: RegionalMuonRawDigiTranslator.cc:4
createfilelist.int
int
Definition: createfilelist.py:10
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
l1t::RegionalMuonRawDigiTranslator::ptShift_
static const unsigned ptShift_
Definition: RegionalMuonRawDigiTranslator.h:15
res
Definition: Electron.h:6
SiStripSourceConfigTier0_cff.stage2
stage2
Definition: SiStripSourceConfigTier0_cff.py:71
l1t::stage2::RegionalMuonGMTUnpacker::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: RegionalMuonGMTUnpacker.cc:10
l1t::emtf_pos
Definition: RegionalMuonCandFwd.h:8
Exception
Definition: hltDiff.cc:246
l1t::UnpackerCollections
Definition: UnpackerCollections.h:9
Exception.h
l1t::stage2::RegionalMuonGMTUnpacker
Definition: RegionalMuonGMTUnpacker.h:10
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
l1t::BxBlockHeader
Definition: BxBlock.h:10
l1t::Block
Definition: Block.h:54
l1t::omtf_neg
Definition: RegionalMuonCandFwd.h:8
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
l1t::RegionalMuonCand
Definition: RegionalMuonCand.h:8