CMS 3D CMS Logo

RegionalMuonGMTUnpacker.cc
Go to the documentation of this file.
3 
6 
7 namespace l1t {
8  namespace stage2 {
9  bool
11  {
12  unsigned int blockId = block.header().getID();
13  LogDebug("L1T") << "Block ID = " << blockId << " size = " << block.header().getSize();
14  // Process only if there is a payload.
15  // If all BX block were zero suppressed the block header size is 0.
16  if (block.header().getSize() < 1) {
17  return true;
18  }
19 
20  auto payload = block.payload();
21 
22  int nBX, firstBX, lastBX;
23  // Check if per BX zero suppression was enabled
24  bool bxZsEnabled = ((block.header().getFlags() >> bxzs_enable_shift_) & 0x1) == 1;
25  // Calculate the total number of BXs
26  if (bxZsEnabled) {
27  BxBlockHeader bxHeader(payload.at(0));
28  nBX = bxHeader.getTotalBx();
29  } else {
30  nBX = int(ceil(block.header().getSize() / nWords_));
31  }
32  getBXRange(nBX, firstBX, lastBX);
33 
34  // decide which collection to use according to the link ID
35  unsigned int linkId = blockId / 2;
36  int processor;
38  tftype trackFinder;
39  if (linkId > 47 && linkId < 60) {
40  res = static_cast<GMTCollections*>(coll)->getRegionalMuonCandsBMTF();
41  trackFinder = tftype::bmtf;
42  processor = linkId - 48;
43  } else if (linkId > 41 && linkId < 66) {
44  res = static_cast<GMTCollections*>(coll)->getRegionalMuonCandsOMTF();
45  if (linkId < 48) {
46  trackFinder = tftype::omtf_pos;
47  processor = linkId - 42;
48  } else {
49  trackFinder = tftype::omtf_neg;
50  processor = linkId - 60;
51  }
52  } else if (linkId > 35 && linkId < 72) {
53  res = static_cast<GMTCollections*>(coll)->getRegionalMuonCandsEMTF();
54  if (linkId < 42) {
55  trackFinder = tftype::emtf_pos;
56  processor = linkId - 36;
57  } else {
58  trackFinder = tftype::emtf_neg;
59  processor = linkId - 66;
60  }
61  } else {
62  edm::LogError("L1T") << "No TF muon expected for link " << linkId;
63  return false;
64  }
65  res->setBXRange(firstBX, lastBX);
66 
67  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
68 
69  // Get the BX blocks and unpack them
70  auto bxBlocks = block.getBxBlocks(nWords_, bxZsEnabled);
71  for (const auto& bxBlock : bxBlocks) {
72  // Check if there are enough words left in the BX block payload
73  auto bxPayload = bxBlock.payload();
74  if (nWords_ <= bxPayload.size()) {
75  for (unsigned nWord = 0; nWord < nWords_; nWord += 2) {
76  uint32_t raw_data_00_31 = bxPayload[nWord];
77  uint32_t raw_data_32_63 = bxPayload[nWord+1];
78  LogDebug("L1T") << "raw_data_00_31 = 0x" << hex << setw(8) << setfill('0') << raw_data_00_31 << " raw_data_32_63 = 0x" << setw(8) << setfill('0') << raw_data_32_63;
79  // skip empty muons (hwPt == 0)
81  LogDebug("L1T") << "Muon hwPt zero. Skip.";
82  continue;
83  }
84  // Detect and ignore comma events
85  if (raw_data_00_31 == 0x505050bc || raw_data_32_63 == 0x505050bc) {
86  edm::LogWarning("L1T") << "Comma detected in raw data stream. Orbit number: " << block.amc().getOrbitNumber() << ", BX ID: " << block.amc().getBX() << ", BX: " << bxBlock.header().getBx() << ", linkId: " << linkId << ", Raw data: 0x" << hex << setw(8) << setfill('0') << raw_data_32_63 << setw(8) << setfill('0') << raw_data_00_31 << dec << ". Skip.";
87  continue;
88  }
89 
91 
92  RegionalMuonRawDigiTranslator::fillRegionalMuonCand(mu, raw_data_00_31, raw_data_32_63, processor, trackFinder);
93 
94  LogDebug("L1T") << "Mu" << nWord/2 << ": eta " << mu.hwEta() << " phi " << mu.hwPhi() << " pT " << mu.hwPt() << " qual " << mu.hwQual() << " sign " << mu.hwSign() << " sign valid " << mu.hwSignValid();
95 
96  res->push_back(bxBlock.header().getBx(), mu);
97  }
98  } else {
99  unsigned int nWords = nWords_; // This seems unnecessary but it prevents an 'undefined reference' linker error that occurs when using nWords_ directly with LogWarning.
100  edm::LogWarning("L1T") << "Only " << bxPayload.size() << " 32 bit words in this BX but " << nWords << " are required. Not unpacking the data for BX " << bxBlock.header().getBx() << ".";
101  }
102  }
103  return true;
104  }
105  }
106 }
107 
#define LogDebug(id)
const int hwSignValid() const
Get charge sign valid bit (0 - not valid (high pT muon); 1 - valid)
unsigned int getID() const
Definition: Block.h:21
void getBXRange(int nbx, int &first, int &last)
BlockHeader header() const
Definition: Block.h:59
delete x;
Definition: CaloConfig.h:22
std::vector< uint32_t > payload() const
Definition: Block.h:60
Definition: Electron.h:4
const int hwQual() const
Get quality code.
payload
payload postfix for testing
bool unpack(const Block &block, UnpackerCollections *coll) override
unsigned int getTotalBx() const
Definition: BxBlock.h:22
const int hwEta() const
Get compressed eta (returned int * 0.010875 = eta)
const int mu
Definition: Constants.h:22
const int hwPhi() const
Get compressed local phi (returned int * 2*pi/576 = local phi in rad)
JetCorrectorParametersCollection coll
Definition: classes.h:10
static void fillRegionalMuonCand(RegionalMuonCand &, uint32_t, uint32_t, int, tftype)
void setBXRange(int bxFirst, int bxLast)
BxBlocks getBxBlocks(unsigned int payloadWordsPerBx, bool bxHeader) const
Definition: Block.cc:47
const int hwPt() const
Get compressed pT (returned int * 0.5 = pT (GeV))
#define DEFINE_L1T_UNPACKER(type)
unsigned int getSize() const
Definition: Block.h:22
const int hwSign() const
Get charge sign bit (charge = (-1)^(sign))
void amc(const amc::Header &h)
Definition: Block.h:62
unsigned int getFlags() const
Definition: Block.h:24
void push_back(int bx, T object)