CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LegacyHFRingUnpacker.cc
Go to the documentation of this file.
2 
4 
5 #include "CaloCollections.h"
6 
7 namespace l1t {
8  namespace stage1 {
9  namespace legacy {
10  class HFRingUnpacker : public Unpacker {
11  public:
12  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
13  };
14  }
15  }
16 }
17 
18 // Implementation
19 
20 namespace l1t {
21  namespace stage1 {
22  namespace legacy {
23  bool
25  {
26 
27  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
28 
29  int nBX, firstBX, lastBX;
30  nBX = int(ceil(block.header().getSize() / 2.));
31  getBXRange(nBX, firstBX, lastBX);
32 
33  auto resHFBitCounts_ = static_cast<CaloCollections*>(coll)->getCaloSpareHFBitCounts();
34  resHFBitCounts_->setBXRange(firstBX, lastBX);
35 
36  auto resHFRingSums_ = static_cast<CaloCollections*>(coll)->getCaloSpareHFRingSums();
37  resHFRingSums_->setBXRange(firstBX, lastBX);
38 
39  auto reset_ = static_cast<CaloCollections*>(coll)->getEtSums();
40  reset_->setBXRange(firstBX, lastBX);
41 
42  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
43 
44  // Initialise index
45  int unsigned i = 0;
46 
47  // Loop over multiple BX and then number of jets filling jet collection
48  for (int bx=firstBX; bx<=lastBX; bx++){
49  uint32_t raw_data0 = block.payload()[i++];
50  uint32_t raw_data1 = block.payload()[i++];
51 
52  /* if (raw_data0 == 0 || raw_data1==0) continue; */
53 
54  uint16_t candbit[4];
55  candbit[0] = raw_data0 & 0xFFFF;
56  candbit[1] = (raw_data0 >> 16) & 0xFFFF;
57  candbit[2] = raw_data1 & 0xFFFF;
58  candbit[3] = (raw_data1 >> 16) & 0xFFFF;
59 
60  int hfbitcount=candbit[0] & 0xFFF;
61  int hfringsum=((candbit[0]>>12) & 0x7) | ((candbit[2] & 0x1FF) << 3);
62  int htmissphi=candbit[1] & 0x1F;
63  int htmiss=(candbit[1]>>5) & 0x7F;
64  int overflowhtmiss=(candbit[1]>>12) & 0x1;
65 
67  hfbc.setHwPt(hfbitcount);
69  LogDebug("L1T") << "hfbc pT " << hfbc.hwPt();
70  resHFBitCounts_->push_back(bx,hfbc);
71 
73  hfrs.setHwPt(hfringsum);
75  LogDebug("L1T") << "hfrs pT " << hfrs.hwPt();
76  resHFRingSums_->push_back(bx,hfrs);
77 
78  l1t::EtSum mht = l1t::EtSum();
79  mht.setHwPt(htmiss);
80  mht.setHwPhi(htmissphi);
82  int flaghtmiss=mht.hwQual();
83  flaghtmiss|= overflowhtmiss;
84  mht.setHwQual(flaghtmiss);
85  LogDebug("L1T") << "MHT: pT " << mht.hwPt()<<"is overflow "<<overflowhtmiss<<std::endl;
86  reset_->push_back(bx,mht);
87 
88  }
89 
90  return true;
91 
92  }
93  }
94  }
95 }
96 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
unsigned int getID() const
Definition: Block.h:22
void getBXRange(int nbx, int &first, int &last)
Definition: Unpacker.cc:14
BlockHeader header() const
Definition: Block.h:56
void setHwQual(int qual)
Definition: L1Candidate.cc:64
std::vector< uint32_t > payload() const
Definition: Block.h:57
void setType(EtSumType type)
Definition: EtSum.cc:32
#define DEFINE_L1T_UNPACKER(type)
Definition: Unpacker.h:31
void setType(CaloSpareType type)
Definition: CaloSpare.cc:32
int hwQual() const
Definition: L1Candidate.cc:89
void setHwPhi(int phi)
Definition: L1Candidate.cc:54
JetCorrectorParametersCollection coll
Definition: classes.h:10
int hwPt() const
Definition: L1Candidate.cc:69
void setHwPt(int pt)
Definition: L1Candidate.cc:44
unsigned int getSize() const
Definition: Block.h:23
virtual bool unpack(const Block &block, UnpackerCollections *coll) override