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 
7 #include "L1TObjectCollections.h"
8 //#include "GMTCollections.h"
9 
10 namespace l1t {
11  namespace stage2 {
12  class MuonUnpacker : public Unpacker {
13  public:
14  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
15  };
16  }
17 }
18 
19 // Implementation
20 namespace l1t {
21  namespace stage2 {
22  bool
24  {
25  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
26 
27  auto payload = block.payload();
28 
29  unsigned int nWords = 6; // every link transmits 6 words (3 muons) per bx
30  int nBX, firstBX, lastBX;
31  nBX = int(ceil(block.header().getSize() / nWords));
32  getBXRange(nBX, firstBX, lastBX);
33  // only use central BX for now
34  //firstBX = 0;
35  //lastBX = 0;
36  //LogDebug("L1T") << "BX override. Set first BX = lastBX = 0.";
37 
38  auto res = static_cast<L1TObjectCollections*>(coll)->getMuons();
39  res->setBXRange(firstBX, lastBX);
40 
41  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
42 
43  // Initialise index
44  int unsigned i = 0;
45 
46  // Loop over multiple BX and then number of muons filling muon collection
47  for (int bx = firstBX; bx <= lastBX; ++bx) {
48  for (unsigned nWord = 0; nWord < nWords && i < block.header().getSize(); nWord += 2) {
49  uint32_t raw_data_00_31 = payload[i++];
50  uint32_t raw_data_32_63 = payload[i++];
51  LogDebug("L1T") << "raw_data_00_31 = 0x" << hex << raw_data_00_31 << " raw_data_32_63 = 0x" << raw_data_32_63;
52  // skip empty muons (hwPt == 0)
54  LogDebug("L1T") << "Muon hwPt zero. Skip.";
55  continue;
56  }
57 
58  Muon mu;
59 
60  MuonRawDigiTranslator::fillMuon(mu, raw_data_00_31, raw_data_32_63);
61 
62  LogDebug("L1T") << "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();
63 
64  res->push_back(bx, mu);
65  }
66  }
67  return true;
68  }
69  }
70 }
71 
#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:14
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:23
#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_