CMS 3D CMS Logo

LegacyHFRingUnpacker.cc
Go to the documentation of this file.
3 
4 #include "CaloCollections.h"
5 #include "LegacyHFRingUnpacker.h"
6 
7 namespace l1t {
8  namespace stage1 {
9  namespace legacy {
11  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
12 
13  int nBX, firstBX, lastBX;
14  nBX = int(ceil(block.header().getSize() / 2.));
15  getBXRange(nBX, firstBX, lastBX);
16 
17  auto resHFBitCounts_ = static_cast<CaloCollections*>(coll)->getCaloSpareHFBitCounts();
18  resHFBitCounts_->setBXRange(firstBX, lastBX);
19 
20  auto resHFRingSums_ = static_cast<CaloCollections*>(coll)->getCaloSpareHFRingSums();
21  resHFRingSums_->setBXRange(firstBX, lastBX);
22 
23  auto reset_ = static_cast<CaloCollections*>(coll)->getEtSums();
24  reset_->setBXRange(firstBX, lastBX);
25 
26  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
27 
28  // Initialise index
29  int unsigned i = 0;
30 
31  // Loop over multiple BX and then number of jets filling jet collection
32  for (int bx = firstBX; bx <= lastBX; bx++) {
33  uint32_t raw_data0 = block.payload()[i++];
34  uint32_t raw_data1 = block.payload()[i++];
35 
36  /* if (raw_data0 == 0 || raw_data1==0) continue; */
37 
38  uint16_t candbit[4];
39  candbit[0] = raw_data0 & 0xFFFF;
40  candbit[1] = (raw_data0 >> 16) & 0xFFFF;
41  candbit[2] = raw_data1 & 0xFFFF;
42  candbit[3] = (raw_data1 >> 16) & 0xFFFF;
43 
44  int hfbitcount = candbit[0] & 0xFFF;
45  int hfringsum = ((candbit[0] >> 12) & 0x7) | ((candbit[2] & 0x1FF) << 3);
46  int htmissphi = candbit[1] & 0x1F;
47  int htmiss = (candbit[1] >> 5) & 0x7F;
48  int overflowhtmiss = (candbit[1] >> 12) & 0x1;
49 
51  hfbc.setHwPt(hfbitcount);
53  LogDebug("L1T") << "hfbc pT " << hfbc.hwPt();
54  resHFBitCounts_->push_back(bx, hfbc);
55 
57  hfrs.setHwPt(hfringsum);
59  LogDebug("L1T") << "hfrs pT " << hfrs.hwPt();
60  resHFRingSums_->push_back(bx, hfrs);
61 
62  l1t::EtSum mht = l1t::EtSum();
63  mht.setHwPt(htmiss);
64  mht.setHwPhi(htmissphi);
66  int flaghtmiss = mht.hwQual();
67  flaghtmiss |= overflowhtmiss;
68  mht.setHwQual(flaghtmiss);
69  LogDebug("L1T") << "MHT: pT " << mht.hwPt() << "is overflow " << overflowhtmiss << std::endl;
70  reset_->push_back(bx, mht);
71  }
72 
73  return true;
74  }
75  } // namespace legacy
76  } // namespace stage1
77 } // namespace l1t
78 
#define LogDebug(id)
const std::vector< uint32_t > & payload() const
Definition: Block.h:70
unsigned int getID() const
Definition: Block.h:27
void getBXRange(int nbx, int &first, int &last)
BlockHeader header() const
Definition: Block.h:69
void setHwQual(int qual)
Definition: L1Candidate.h:31
delete x;
Definition: CaloConfig.h:22
void setType(EtSumType type)
Definition: EtSum.cc:11
constexpr int32_t ceil(float num)
void setType(CaloSpareType type)
Definition: CaloSpare.cc:11
int hwQual() const
Definition: L1Candidate.h:38
void setHwPhi(int phi)
Definition: L1Candidate.h:30
JetCorrectorParametersCollection coll
Definition: classes.h:10
int hwPt() const
Definition: L1Candidate.h:35
void setHwPt(int pt)
Definition: L1Candidate.h:28
#define DEFINE_L1T_UNPACKER(type)
unsigned int getSize() const
Definition: Block.h:28
bool unpack(const Block &block, UnpackerCollections *coll) override