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.
2 
4 
5 #include "CaloCollections.h"
6 
7 namespace l1t {
8  namespace stage1 {
9  namespace legacy {
10  class EtSumUnpacker : 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 res_ = static_cast<CaloCollections*>(coll)->getEtSums();
34  res_->setBXRange(firstBX, lastBX);
35 
36  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
37 
38  // Initialise index
39  int unsigned i = 0;
40 
41  // Loop over multiple BX and then number of jets filling jet collection
42  for (int bx=firstBX; bx<=lastBX; bx++){
43  uint32_t raw_data0 = block.payload()[i++];
44  uint32_t raw_data1 = block.payload()[i++];
45 
46  /* if (raw_data0 == 0 || raw_data1==0) continue; */
47 
48  uint16_t candbit[4];
49  candbit[0] = raw_data0 & 0xFFFF;
50  candbit[1] = (raw_data0 >> 16) & 0xFFFF;
51  candbit[2] = raw_data1 & 0xFFFF;
52  candbit[3] = (raw_data1 >> 16) & 0xFFFF;
53 
54  int totet=candbit[0] & 0xFFF;
55  int overflowtotet=(candbit[0]>>12) & 0x1;
56  int etmiss=candbit[1] & 0xFFF;
57  int overflowetmiss=(candbit[1]>>12) & 0x1;
58  int totht=candbit[2] & 0xFFF;
59  int overflowtotht=(candbit[2]>>12) & 0x1;
60  int etmissphi=candbit[3] & 0x7F;
61 
62  l1t::EtSum et = l1t::EtSum();
63  et.setHwPt(totet);
65  int flagtotet=et.hwQual();
66  flagtotet|= overflowtotet;
67  et.setHwQual(flagtotet);
68  LogDebug("L1T") << "ET: pT " << et.hwPt()<<"is overflow "<<overflowtotet<<std::endl;
69  res_->push_back(bx,et);
70 
71  l1t::EtSum ht = l1t::EtSum();
72  ht.setHwPt(totht);
74  int flagtotht=ht.hwQual();
75  flagtotht|= overflowtotht;
76  ht.setHwQual(flagtotht);
77  LogDebug("L1T") << "HT: pT " << ht.hwPt()<<"is overflow "<<overflowtotht<<std::endl;
78  res_->push_back(bx,ht);
79 
81  met.setHwPt(etmiss);
82  met.setHwPhi(etmissphi);
84  int flagetmiss=met.hwQual();
85  flagetmiss|= overflowetmiss;
86  met.setHwQual(flagetmiss);
87  LogDebug("L1T") << "MET: pT " << met.hwPt()<<"is overflow "<<overflowetmiss<<std::endl;
88  res_->push_back(bx,met);
89 
90  }
91 
92  return true;
93 
94  }
95  }
96  }
97 }
98 
#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)
Definition: Unpacker.cc:12
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
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