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  MuonUnpacker::MuonUnpacker() : algoVersion_(0), muonCopy_(0)
13  {
14  }
15 
16  bool
18  {
19  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
20 
21  auto payload = block.payload();
22 
23  unsigned int nWords = 6; // every link transmits 6 words (3 muons) per bx
24  int nBX, firstBX, lastBX;
25  nBX = int(ceil(block.header().getSize() / nWords));
26  getBXRange(nBX, firstBX, lastBX);
27  // only use central BX for now
28  //firstBX = 0;
29  //lastBX = 0;
30  //LogDebug("L1T") << "BX override. Set first BX = lastBX = 0.";
31 
32  auto res = static_cast<L1TObjectCollections*>(coll)->getMuons(muonCopy_);
33  res->setBXRange(firstBX, lastBX);
34 
35  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
36 
37  // Initialise index
38  int unsigned i = 0;
39 
40  // Loop over multiple BX and then number of muons filling muon collection
41  for (int bx = firstBX; bx <= lastBX; ++bx) {
42  for (unsigned nWord = 0; nWord < nWords && i < block.header().getSize(); nWord += 2) {
43  uint32_t raw_data_00_31 = payload[i++];
44  uint32_t raw_data_32_63 = payload[i++];
45  LogDebug("L1T") << "raw_data_00_31 = 0x" << hex << raw_data_00_31 << " raw_data_32_63 = 0x" << raw_data_32_63;
46  // skip empty muons (hwPt == 0)
48  LogDebug("L1T") << "Muon hwPt zero. Skip.";
49  continue;
50  }
51 
52  Muon mu;
53 
54  MuonRawDigiTranslator::fillMuon(mu, raw_data_00_31, raw_data_32_63, fed_, algoVersion_);
55 
56  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();
57 
58  res->push_back(bx, mu);
59  }
60  }
61  return true;
62  }
63  }
64 }
65 
#define LogDebug(id)
unsigned int getID() const
Definition: Block.h:22
void getBXRange(int nbx, int &first, int &last)
BlockHeader header() const
Definition: Block.h:60
int hwPhi() const
Definition: L1Candidate.h:50
delete x;
Definition: CaloConfig.h:22
std::vector< uint32_t > payload() const
Definition: Block.h:61
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: MuonUnpacker.cc:17
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.h:83
int hwCharge() const
Definition: Muon.h:82
static const unsigned ptMask_
static void fillMuon(Muon &, uint32_t, uint32_t, int, unsigned int)