CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 {
10  bool
12  {
13 
14  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
15 
16  int nBX, firstBX, lastBX;
17  nBX = int(ceil(block.header().getSize() / 2.));
18  getBXRange(nBX, firstBX, lastBX);
19 
20  auto res_ = static_cast<CaloCollections*>(coll)->getEtSums();
21  res_->setBXRange(firstBX, lastBX);
22 
23  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
24 
25  // Initialise index
26  int unsigned i = 0;
27 
28  // Loop over multiple BX and then number of jets filling jet collection
29  for (int bx=firstBX; bx<=lastBX; bx++){
30  uint32_t raw_data0 = block.payload()[i++];
31  uint32_t raw_data1 = block.payload()[i++];
32 
33  /* if (raw_data0 == 0 || raw_data1==0) continue; */
34 
35  uint16_t candbit[4];
36  candbit[0] = raw_data0 & 0xFFFF;
37  candbit[1] = (raw_data0 >> 16) & 0xFFFF;
38  candbit[2] = raw_data1 & 0xFFFF;
39  candbit[3] = (raw_data1 >> 16) & 0xFFFF;
40 
41  int totet=candbit[0] & 0xFFF;
42  int overflowtotet=(candbit[0]>>12) & 0x1;
43  int etmiss=candbit[1] & 0xFFF;
44  int overflowetmiss=(candbit[1]>>12) & 0x1;
45  int totht=candbit[2] & 0xFFF;
46  int overflowtotht=(candbit[2]>>12) & 0x1;
47  int etmissphi=candbit[3] & 0x7F;
48 
49  l1t::EtSum et = l1t::EtSum();
50  et.setHwPt(totet);
52  int flagtotet=et.hwQual();
53  flagtotet|= overflowtotet;
54  et.setHwQual(flagtotet);
55  LogDebug("L1T") << "ET: pT " << et.hwPt()<<"is overflow "<<overflowtotet<<std::endl;
56  res_->push_back(bx,et);
57 
58  l1t::EtSum ht = l1t::EtSum();
59  ht.setHwPt(totht);
61  int flagtotht=ht.hwQual();
62  flagtotht|= overflowtotht;
63  ht.setHwQual(flagtotht);
64  LogDebug("L1T") << "HT: pT " << ht.hwPt()<<"is overflow "<<overflowtotht<<std::endl;
65  res_->push_back(bx,ht);
66 
68  met.setHwPt(etmiss);
69  met.setHwPhi(etmissphi);
71  int flagetmiss=met.hwQual();
72  flagetmiss|= overflowetmiss;
73  met.setHwQual(flagetmiss);
74  LogDebug("L1T") << "MET: pT " << met.hwPt()<<"is overflow "<<overflowetmiss<<std::endl;
75  res_->push_back(bx,met);
76 
77  }
78 
79  return true;
80 
81  }
82  }
83  }
84 }
85 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
unsigned int getID() const
Definition: Block.h:22
void getBXRange(int nbx, int &first, int &last)
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
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:23