CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonUnpacker.cc
Go to the documentation of this file.
2 
4 
6 #include "GMTCollections.h"
7 
8 namespace l1t {
9  namespace stage2 {
10  class MuonUnpacker : public Unpacker {
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  LogDebug("L1T|Muon") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
24 
25  auto payload = block.payload();
26 
27  unsigned int nWords = 6; // every link transmits 6 words (3 muons) per bx
28  int nBX, firstBX, lastBX;
29  nBX = int(ceil(block.header().getSize() / nWords));
30  getBXRange(nBX, firstBX, lastBX);
31  // only use central BX for now
32  //firstBX = 0;
33  //lastBX = 0;
34  //LogDebug("L1T|Muon") << "BX override. Set first BX = lastBX = 0.";
35 
36  auto res = static_cast<GMTCollections*>(coll)->getMuons();
37  res->setBXRange(firstBX, lastBX);
38 
39  LogDebug("L1T|Muon") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
40 
41  // Initialise index
42  int unsigned i = 0;
43 
44  // Loop over multiple BX and then number of muons filling muon collection
45  for (int bx = firstBX; bx <= lastBX; ++bx) {
46  for (unsigned nWord = 0; nWord < nWords && i < block.header().getSize(); nWord += 2) {
47  uint32_t raw_data_00_31 = payload[i++];
48  uint32_t raw_data_32_63 = payload[i++];
49  LogDebug("L1T|Muon") << "raw_data_00_31 = 0x" << hex << raw_data_00_31 << " raw_data_32_63 = 0x" << raw_data_32_63;
50  // skip empty muons (hwPt == 0)
52  LogDebug("L1T|Muon") << "Muon hwPt zero. Skip.";
53  continue;
54  }
55 
56  Muon mu;
57 
58  MuonRawDigiTranslator::fillMuon(mu, raw_data_00_31, raw_data_32_63);
59 
60  LogDebug("L1T|Muon") << "Mu" << nWord/2 << ": eta " << mu.hwEta() << " phi " << mu.hwPhi() << " pT " << mu.hwPt() << " iso " << mu.hwIso() << " qual " << mu.hwQual() << " charge " << mu.hwCharge() << " charge valid " << mu.hwChargeValid();
61 
62  res->push_back(bx, mu);
63  }
64  }
65  return true;
66  }
67  }
68 }
69 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
unsigned int getID() const
Definition: Block.h:22
void getBXRange(int nbx, int &first, int &last)
Definition: Unpacker.cc:12
BlockHeader header() const
Definition: Block.h:56
static void fillMuon(Muon &, uint32_t, uint32_t)
int hwPhi() const
Definition: L1Candidate.cc:79
std::vector< uint32_t > payload() const
Definition: Block.h:57
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: MuonUnpacker.cc:21
#define DEFINE_L1T_UNPACKER(type)
Definition: Unpacker.h:31
int hwIso() const
Definition: L1Candidate.cc:84
const int mu
Definition: Constants.h:22
int hwEta() const
Definition: L1Candidate.cc:74
int hwQual() const
Definition: L1Candidate.cc:89
Definition: Muon.h:16
JetCorrectorParametersCollection coll
Definition: classes.h:10
int hwPt() const
Definition: L1Candidate.cc:69
static const unsigned ptShift_
unsigned int getSize() const
Definition: Block.h:23
int hwChargeValid() const
Definition: Muon.cc:142
int hwCharge() const
Definition: Muon.cc:136
static const unsigned ptMask_