CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RegionalMuonGMTUnpacker.cc
Go to the documentation of this file.
2 
4 
6 #include "GMTCollections.h"
7 
8 namespace l1t {
9  namespace stage2 {
11  public:
12  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
13  };
14  }
15 }
16 
17 // Implementation
18 namespace l1t {
19  namespace stage2 {
20  bool
22  {
23  unsigned int blockId = block.header().getID();
24  LogDebug("L1T") << "Block ID = " << blockId << " size = " << block.header().getSize();
25 
26  auto payload = block.payload();
27 
28  unsigned int nWords = 6; // every link transmits 6 words (3 muons) per bx
29  int nBX, firstBX, lastBX;
30  nBX = int(ceil(block.header().getSize() / nWords));
31  getBXRange(nBX, firstBX, lastBX);
32  // only use central BX for now
33  //firstBX = 0;
34  //lastBX = 0;
35  //LogDebug("L1T") << "BX override. Set first BX = lastBX = 0.";
36 
37  // decide which collection to use according to the link ID
38  unsigned int linkId = blockId / 2;
39  int processor;
41  tftype trackFinder;
42  if (linkId > 47 && linkId < 60) {
43  res = static_cast<GMTCollections*>(coll)->getRegionalMuonCandsBMTF();
44  trackFinder = tftype::bmtf;
45  processor = linkId - 48;
46  } else if (linkId > 41 && linkId < 66) {
47  res = static_cast<GMTCollections*>(coll)->getRegionalMuonCandsOMTF();
48  if (linkId < 48) {
49  trackFinder = tftype::omtf_pos;
50  processor = linkId - 42;
51  } else {
52  trackFinder = tftype::omtf_neg;
53  processor = linkId - 60;
54  }
55  } else if (linkId > 35 && linkId < 72) {
56  res = static_cast<GMTCollections*>(coll)->getRegionalMuonCandsEMTF();
57  if (linkId < 42) {
58  trackFinder = tftype::emtf_pos;
59  processor = linkId - 36;
60  } else {
61  trackFinder = tftype::emtf_neg;
62  processor = linkId - 66;
63  }
64  } else {
65  edm::LogError("L1T") << "No TF muon expected for link " << linkId;
66  return false;
67  }
68  res->setBXRange(firstBX, lastBX);
69 
70  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
71 
72  // Initialise index
73  int unsigned i = 0;
74 
75  // Loop over multiple BX and then number of muons filling muon collection
76  for (int bx = firstBX; bx <= lastBX; ++bx) {
77  for (unsigned nWord = 0; nWord < nWords && i < block.header().getSize(); nWord += 2) {
78  uint32_t raw_data_00_31 = payload[i++];
79  uint32_t raw_data_32_63 = payload[i++];
80  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;
81  // skip empty muons (hwPt == 0)
83  //if ((raw_data_00_31 & 0x7FFFFFFF) == 0 && (raw_data_32_63 & 0x7FFFFFFF) == 0) {
85  LogDebug("L1T") << "Muon hwPt zero. Skip.";
86  continue;
87  }
88  // Detect and ignore comma events
89  if (raw_data_00_31 == 0x505050bc || raw_data_32_63 == 0x505050bc) {
90  edm::LogWarning("L1T") << "Comma detected in raw data stream. Orbit number: " << block.amc().getOrbitNumber() << ", BX ID: " << block.amc().getBX() << ", BX: " << bx << ", linkId: " << linkId << ", Raw data: 0x" << hex << setw(8) << setfill('0') << raw_data_32_63 << setw(8) << setfill('0') << raw_data_00_31 << dec << ". Skip.";
91  continue;
92  }
93 
95 
96  RegionalMuonRawDigiTranslator::fillRegionalMuonCand(mu, raw_data_00_31, raw_data_32_63, processor, trackFinder);
97 
98  LogDebug("L1T") << "Mu" << nWord/2 << ": eta " << mu.hwEta() << " phi " << mu.hwPhi() << " pT " << mu.hwPt() << " qual " << mu.hwQual() << " sign " << mu.hwSign() << " sign valid " << mu.hwSignValid();
99 
100  res->push_back(bx, mu);
101  }
102  }
103  return true;
104  }
105  }
106 }
107 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
const int hwSignValid() const
Get charge sign valid bit (0 - not valid (high pT muon); 1 - valid)
unsigned int getID() const
Definition: Block.h:22
void getBXRange(int nbx, int &first, int &last)
Definition: Unpacker.cc:14
BlockHeader header() const
Definition: Block.h:56
std::vector< uint32_t > payload() const
Definition: Block.h:57
#define DEFINE_L1T_UNPACKER(type)
Definition: Unpacker.h:31
const int hwQual() const
Get quality code.
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
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)
const int hwPt() const
Get compressed pT (returned int * 0.5 = pT (GeV))
unsigned int getSize() const
Definition: Block.h:23
const int hwSign() const
Get charge sign bit (charge = (-1)^(sign))
void amc(const amc::Header &h)
Definition: Block.h:59
void push_back(int bx, T object)