test
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.
3 
5 #include "GMTCollections.h"
7 
8 namespace l1t {
9  namespace stage2 {
10  bool
12  {
13  unsigned int blockId = block.header().getID();
14  LogDebug("L1T") << "Block ID = " << blockId << " size = " << block.header().getSize();
15 
16  auto payload = block.payload();
17 
18  unsigned int nWords = 6; // every link transmits 6 words (3 muons) per bx
19  int nBX, firstBX, lastBX;
20  nBX = int(ceil(block.header().getSize() / nWords));
21  getBXRange(nBX, firstBX, lastBX);
22  // only use central BX for now
23  //firstBX = 0;
24  //lastBX = 0;
25  //LogDebug("L1T") << "BX override. Set first BX = lastBX = 0.";
26 
27  // decide which collection to use according to the link ID
28  unsigned int linkId = blockId / 2;
29  int processor;
31  tftype trackFinder;
32  if (linkId > 47 && linkId < 60) {
33  res = static_cast<GMTCollections*>(coll)->getRegionalMuonCandsBMTF();
34  trackFinder = tftype::bmtf;
35  processor = linkId - 48;
36  } else if (linkId > 41 && linkId < 66) {
37  res = static_cast<GMTCollections*>(coll)->getRegionalMuonCandsOMTF();
38  if (linkId < 48) {
39  trackFinder = tftype::omtf_pos;
40  processor = linkId - 42;
41  } else {
42  trackFinder = tftype::omtf_neg;
43  processor = linkId - 60;
44  }
45  } else if (linkId > 35 && linkId < 72) {
46  res = static_cast<GMTCollections*>(coll)->getRegionalMuonCandsEMTF();
47  if (linkId < 42) {
48  trackFinder = tftype::emtf_pos;
49  processor = linkId - 36;
50  } else {
51  trackFinder = tftype::emtf_neg;
52  processor = linkId - 66;
53  }
54  } else {
55  edm::LogError("L1T") << "No TF muon expected for link " << linkId;
56  return false;
57  }
58  res->setBXRange(firstBX, lastBX);
59 
60  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
61 
62  // Initialise index
63  int unsigned i = 0;
64 
65  // Loop over multiple BX and then number of muons filling muon collection
66  for (int bx = firstBX; bx <= lastBX; ++bx) {
67  for (unsigned nWord = 0; nWord < nWords && i < block.header().getSize(); nWord += 2) {
68  uint32_t raw_data_00_31 = payload[i++];
69  uint32_t raw_data_32_63 = payload[i++];
70  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;
71  // skip empty muons (hwPt == 0)
73  //if ((raw_data_00_31 & 0x7FFFFFFF) == 0 && (raw_data_32_63 & 0x7FFFFFFF) == 0) {
75  LogDebug("L1T") << "Muon hwPt zero. Skip.";
76  continue;
77  }
78  // Detect and ignore comma events
79  if (raw_data_00_31 == 0x505050bc || raw_data_32_63 == 0x505050bc) {
80  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.";
81  continue;
82  }
83 
85 
86  RegionalMuonRawDigiTranslator::fillRegionalMuonCand(mu, raw_data_00_31, raw_data_32_63, processor, trackFinder);
87 
88  LogDebug("L1T") << "Mu" << nWord/2 << ": eta " << mu.hwEta() << " phi " << mu.hwPhi() << " pT " << mu.hwPt() << " qual " << mu.hwQual() << " sign " << mu.hwSign() << " sign valid " << mu.hwSignValid();
89 
90  res->push_back(bx, mu);
91  }
92  }
93  return true;
94  }
95  }
96 }
97 
#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)
BlockHeader header() const
Definition: Block.h:56
std::vector< uint32_t > payload() const
Definition: Block.h:57
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))
#define DEFINE_L1T_UNPACKER(type)
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)