test
CMS 3D CMS Logo

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