CMS 3D CMS Logo

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