CMS 3D CMS Logo

LegacyEtSumUnpacker.cc
Go to the documentation of this file.
3 
4 #include "CaloCollections.h"
5 #include "LegacyEtSumUnpacker.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 res_ = static_cast<CaloCollections*>(coll)->getEtSums();
18  res_->setBXRange(firstBX, lastBX);
19 
20  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
21 
22  // Initialise index
23  int unsigned i = 0;
24 
25  // Loop over multiple BX and then number of jets filling jet collection
26  for (int bx = firstBX; bx <= lastBX; bx++) {
27  uint32_t raw_data0 = block.payload()[i++];
28  uint32_t raw_data1 = block.payload()[i++];
29 
30  /* if (raw_data0 == 0 || raw_data1==0) continue; */
31 
32  uint16_t candbit[4];
33  candbit[0] = raw_data0 & 0xFFFF;
34  candbit[1] = (raw_data0 >> 16) & 0xFFFF;
35  candbit[2] = raw_data1 & 0xFFFF;
36  candbit[3] = (raw_data1 >> 16) & 0xFFFF;
37 
38  int totet = candbit[0] & 0xFFF;
39  int overflowtotet = (candbit[0] >> 12) & 0x1;
40  int etmiss = candbit[1] & 0xFFF;
41  int overflowetmiss = (candbit[1] >> 12) & 0x1;
42  int totht = candbit[2] & 0xFFF;
43  int overflowtotht = (candbit[2] >> 12) & 0x1;
44  int etmissphi = candbit[3] & 0x7F;
45 
47  et.setHwPt(totet);
48  int flagtotet = et.hwQual();
49  flagtotet |= overflowtotet;
50  et.setHwQual(flagtotet);
51  LogDebug("L1T") << "ET: pT " << et.hwPt() << "is overflow " << overflowtotet << std::endl;
52  res_->push_back(bx, et);
53 
55  ht.setHwPt(totht);
56  int flagtotht = ht.hwQual();
57  flagtotht |= overflowtotht;
58  ht.setHwQual(flagtotht);
59  LogDebug("L1T") << "HT: pT " << ht.hwPt() << "is overflow " << overflowtotht << std::endl;
60  res_->push_back(bx, ht);
61 
63  met.setHwPt(etmiss);
64  met.setHwPhi(etmissphi);
65  int flagetmiss = met.hwQual();
66  flagetmiss |= overflowetmiss;
67  met.setHwQual(flagetmiss);
68  LogDebug("L1T") << "MET: pT " << met.hwPt() << "is overflow " << overflowetmiss << std::endl;
69  res_->push_back(bx, met);
70  }
71 
72  return true;
73  }
74  } // namespace legacy
75  } // namespace stage1
76 } // namespace l1t
77 
constexpr int32_t ceil(float num)
bool unpack(const Block &block, UnpackerCollections *coll) override
void getBXRange(int nbx, int &first, int &last)
delete x;
Definition: CaloConfig.h:22
#define DEFINE_L1T_UNPACKER(type)
#define LogDebug(id)