CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EtSumUnpacker.cc
Go to the documentation of this file.
2 
4 
5 #include "L1TObjectCollections.h"
6 
7 namespace l1t {
8  namespace stage2 {
9  class EtSumUnpacker : 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 stage2 {
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() / 6.)); // Since there 6 frames per demux output event
27  // expect the first four frames to be the first 4 EtSum objects reported per event (see CMS IN-2013/005)
28 
29  // Find the central, first and last BXs
30  int firstBX = -(ceil((double)nBX/2.)-1);
31  int lastBX;
32  if (nBX % 2 == 0) {
33  lastBX = ceil((double)nBX/2.);
34  } else {
35  lastBX = ceil((double)nBX/2.)-1;
36  }
37 
38  auto res_ = static_cast<L1TObjectCollections*>(coll)->getEtSums();
39  res_->setBXRange(firstBX, lastBX);
40 
41  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
42 
43  // Initialise index
44  int unsigned i = 0;
45 
46  // Loop over multiple BX and fill EtSums collection
47  for (int bx=firstBX; bx<=lastBX; bx++){
48 
49  // ET
50 
51  uint32_t raw_data = block.payload()[i++];
52 
53  l1t::EtSum et = l1t::EtSum();
54 
55  et.setHwPt(raw_data & 0xFFF);
57 
58  LogDebug("L1T") << "ET: pT " << et.hwPt() << " bx " << bx;
59 
60  res_->push_back(bx,et);
61 
62 
63  // HT
64 
65  raw_data = block.payload()[i++];
66 
67  l1t::EtSum ht = l1t::EtSum();
68 
69  ht.setHwPt(raw_data & 0xFFF);
71 
72  LogDebug("L1T") << "HT: pT " << ht.hwPt();
73 
74  res_->push_back(bx,ht);
75 
76 
77  // MET
78 
79  raw_data = block.payload()[i++];
80 
82 
83  met.setHwPt(raw_data & 0xFFF);
84  met.setHwPhi((raw_data >> 12) & 0xFF);
86 
87  LogDebug("L1T") << "MET: phi " << met.hwPhi() << " pT " << met.hwPt() << " bx " << bx;
88 
89  res_->push_back(bx,met);
90 
91 
92  // MHT
93 
94  raw_data = block.payload()[i++];
95 
96  l1t::EtSum mht = l1t::EtSum();
97 
98  mht.setHwPt(raw_data & 0xFFF);
99  mht.setHwPhi((raw_data >> 12) & 0xFF);
101 
102  LogDebug("L1T") << "MHT: phi " << mht.hwPhi() << " pT " << mht.hwPt() << " bx " << bx;
103 
104  res_->push_back(bx,mht);
105 
106  }
107 
108  return true;
109  }
110 }
111 }
112 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
unsigned int getID() const
Definition: Block.h:22
BlockHeader header() const
Definition: Block.h:56
int hwPhi() const
Definition: L1Candidate.cc:79
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
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
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