CMS 3D CMS Logo

MuonUnpacker.cc
Go to the documentation of this file.
3 
5 
6 #include "L1TObjectCollections.h"
7 //#include "GMTCollections.h"
8 #include "MuonUnpacker.h"
9 
10 namespace l1t {
11  namespace stage2 {
12  bool
14  {
15  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
16 
17  auto payload = block.payload();
18 
19  unsigned int nWords = 6; // every link transmits 6 words (3 muons) per bx
20  int nBX, firstBX, lastBX;
21  nBX = int(ceil(block.header().getSize() / nWords));
22  getBXRange(nBX, firstBX, lastBX);
23  // only use central BX for now
24  //firstBX = 0;
25  //lastBX = 0;
26  //LogDebug("L1T") << "BX override. Set first BX = lastBX = 0.";
27 
28  auto res = static_cast<L1TObjectCollections*>(coll)->getMuons();
29  res->setBXRange(firstBX, lastBX);
30 
31  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
32 
33  // Initialise index
34  int unsigned i = 0;
35 
36  // Loop over multiple BX and then number of muons filling muon collection
37  for (int bx = firstBX; bx <= lastBX; ++bx) {
38  for (unsigned nWord = 0; nWord < nWords && i < block.header().getSize(); nWord += 2) {
39  uint32_t raw_data_00_31 = payload[i++];
40  uint32_t raw_data_32_63 = payload[i++];
41  LogDebug("L1T") << "raw_data_00_31 = 0x" << hex << raw_data_00_31 << " raw_data_32_63 = 0x" << raw_data_32_63;
42  // skip empty muons (hwPt == 0)
44  LogDebug("L1T") << "Muon hwPt zero. Skip.";
45  continue;
46  }
47 
48  Muon mu;
49 
50  MuonRawDigiTranslator::fillMuon(mu, raw_data_00_31, raw_data_32_63);
51 
52  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();
53 
54  res->push_back(bx, mu);
55  }
56  }
57  return true;
58  }
59  }
60 }
61 
#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)
BlockHeader header() const
Definition: Block.h:56
static void fillMuon(Muon &, uint32_t, uint32_t)
int hwPhi() const
Definition: L1Candidate.h:50
delete x;
Definition: CaloConfig.h:22
std::vector< uint32_t > payload() const
Definition: Block.h:57
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: MuonUnpacker.cc:13
Definition: Electron.h:4
int hwIso() const
Definition: L1Candidate.h:52
payload
payload postfix for testing
Definition: Muon.py:1
const int mu
Definition: Constants.h:22
int hwEta() const
Definition: L1Candidate.h:49
int hwQual() const
Definition: L1Candidate.h:51
JetCorrectorParametersCollection coll
Definition: classes.h:10
int hwPt() const
Definition: L1Candidate.h:48
static const unsigned ptShift_
#define DEFINE_L1T_UNPACKER(type)
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_