CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
46  l1t::EtSum et = l1t::EtSum();
47  et.setHwPt(totet);
49  int flagtotet = et.hwQual();
50  flagtotet |= overflowtotet;
51  et.setHwQual(flagtotet);
52  LogDebug("L1T") << "ET: pT " << et.hwPt() << "is overflow " << overflowtotet << std::endl;
53  res_->push_back(bx, et);
54 
55  l1t::EtSum ht = l1t::EtSum();
56  ht.setHwPt(totht);
58  int flagtotht = ht.hwQual();
59  flagtotht |= overflowtotht;
60  ht.setHwQual(flagtotht);
61  LogDebug("L1T") << "HT: pT " << ht.hwPt() << "is overflow " << overflowtotht << std::endl;
62  res_->push_back(bx, ht);
63 
65  met.setHwPt(etmiss);
66  met.setHwPhi(etmissphi);
68  int flagetmiss = met.hwQual();
69  flagetmiss |= overflowetmiss;
70  met.setHwQual(flagetmiss);
71  LogDebug("L1T") << "MET: pT " << met.hwPt() << "is overflow " << overflowetmiss << std::endl;
72  res_->push_back(bx, met);
73  }
74 
75  return true;
76  }
77  } // namespace legacy
78  } // namespace stage1
79 } // namespace l1t
80 
constexpr int32_t ceil(float num)
bool unpack(const Block &block, UnpackerCollections *coll) override
const std::vector< uint32_t > & payload() const
Definition: Block.h:86
unsigned int getID() const
Definition: Block.h:43
void getBXRange(int nbx, int &first, int &last)
BlockHeader header() const
Definition: Block.h:85
void setHwQual(int qual)
Definition: L1Candidate.h:31
void setType(EtSumType type)
Definition: EtSum.cc:11
int hwQual() const
Definition: L1Candidate.h:38
void setHwPhi(int phi)
Definition: L1Candidate.h:30
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:44
#define LogDebug(id)