CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EtSumUnpacker_0x10010057.cc
Go to the documentation of this file.
3 
5 
6 #include "L1TObjectCollections.h"
7 
10 
11 namespace l1t {
12  namespace stage2 {
14 
16  using namespace l1t::stage2::layer2;
17 
18  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
19 
20  int nBX = int(
21  ceil(block.header().getSize() / demux::nOutputFramePerBX)); // Since there 6 frames per demux output event
22  // expect the first four frames to be the first 4 EtSum objects reported per event (see CMS IN-2013/005)
23 
24  // Find the central, first and last BXs
25  int firstBX = -(ceil((double)nBX / 2.) - 1);
26  int lastBX;
27  if (nBX % 2 == 0) {
28  lastBX = ceil((double)nBX / 2.);
29  } else {
30  lastBX = ceil((double)nBX / 2.) - 1;
31  }
32 
33  auto res_ = static_cast<L1TObjectCollections*>(coll)->getEtSums(EtSumCopy_);
34  res_->setBXRange(firstBX, lastBX);
35 
36  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
37 
38  // Loop over multiple BX and fill EtSums collection
39  for (int bx = firstBX; bx <= lastBX; bx++) {
40  // ET
41  int iFrame = (bx - firstBX) * demux::nOutputFramePerBX;
42 
43  uint32_t raw_data = block.payload().at(iFrame);
44 
45  l1t::EtSum et = l1t::EtSum();
46 
47  et.setHwPt(raw_data & 0xFFF);
50 
51  LogDebug("L1T") << "ET: pT " << et.hwPt() << " bx " << bx;
52 
53  res_->push_back(bx, et);
54 
55  // ET EM
56 
57  l1t::EtSum etem = l1t::EtSum();
58 
59  etem.setHwPt((raw_data >> 12) & 0xFFF);
61  etem.setP4(l1t::CaloTools::p4Demux(&etem));
62 
63  LogDebug("L1T") << "ETEM: pT " << etem.hwPt() << " bx " << bx;
64 
65  res_->push_back(bx, etem);
66 
67  // MBHFPT0
68 
69  l1t::EtSum mbp0 = l1t::EtSum();
70  mbp0.setHwPt((raw_data >> 28) & 0xf);
72 
73  res_->push_back(bx, mbp0);
74 
75  // HT
76 
77  raw_data = block.payload()[iFrame + 1];
78 
79  l1t::EtSum ht = l1t::EtSum();
80 
81  ht.setHwPt(raw_data & 0xFFF);
84 
85  LogDebug("L1T") << "HT: pT " << ht.hwPt();
86 
87  res_->push_back(bx, ht);
88 
89  //MBHFMT0
90 
91  l1t::EtSum mbm0 = l1t::EtSum();
92  mbm0.setHwPt((raw_data >> 28) & 0xf);
94 
95  res_->push_back(bx, mbm0);
96 
97  // MET (no HF)
98 
99  raw_data = block.payload()[iFrame + 2];
100 
102 
103  met.setHwPt(raw_data & 0xFFF);
104  met.setHwPhi((raw_data >> 12) & 0xFF);
106  met.setP4(l1t::CaloTools::p4Demux(&met));
107 
108  LogDebug("L1T") << "MET: phi " << met.hwPhi() << " pT " << met.hwPt() << " bx " << bx;
109 
110  res_->push_back(bx, met);
111 
112  // MBHFPT1
113 
114  l1t::EtSum mbp1 = l1t::EtSum();
115  mbp1.setHwPt((raw_data >> 28) & 0xf);
117 
118  res_->push_back(bx, mbp1);
119 
120  // ET ASYMM
121 
122  l1t::EtSum etAsym = l1t::EtSum();
123  etAsym.setHwPt((raw_data >> 20) & 0xFF);
125 
126  res_->push_back(bx, etAsym);
127 
128  // MHT
129 
130  raw_data = block.payload()[iFrame + 3];
131 
132  l1t::EtSum mht = l1t::EtSum();
133 
134  mht.setHwPt(raw_data & 0xFFF);
135  mht.setHwPhi((raw_data >> 12) & 0xFF);
137  mht.setP4(l1t::CaloTools::p4Demux(&mht));
138 
139  LogDebug("L1T") << "MHT: phi " << mht.hwPhi() << " pT " << mht.hwPt() << " bx " << bx;
140 
141  res_->push_back(bx, mht);
142 
143  // MBHFMT1
144 
145  l1t::EtSum mbm1 = l1t::EtSum();
146  mbm1.setHwPt((raw_data >> 28) & 0xf);
148 
149  res_->push_back(bx, mbm1);
150 
151  // HT ASYMM
152 
153  l1t::EtSum htAsym = l1t::EtSum();
154  htAsym.setHwPt((raw_data >> 20) & 0xFF);
156 
157  res_->push_back(bx, htAsym);
158 
159  // MET (with HF)
160 
161  raw_data = block.payload()[iFrame + 4];
162 
163  l1t::EtSum methf = l1t::EtSum();
164 
165  methf.setHwPt(raw_data & 0xFFF);
166  methf.setHwPhi((raw_data >> 12) & 0xFF);
168  methf.setP4(l1t::CaloTools::p4Demux(&methf));
169 
170  LogDebug("L1T") << "METHF: phi " << methf.hwPhi() << " pT " << methf.hwPt() << " bx " << bx;
171 
172  res_->push_back(bx, methf);
173 
174  // ETHF ASYMM
175 
176  l1t::EtSum etHFAsym = l1t::EtSum();
177  etHFAsym.setHwPt((raw_data >> 20) & 0xFF);
178  etHFAsym.setType(l1t::EtSum::kAsymEtHF);
179 
180  res_->push_back(bx, etHFAsym);
181 
182  // CENTRALITY LOWER NIB
183 
184  uint32_t centLN = ((raw_data >> 28) & 0xF);
185 
186  // MHT with HF
187 
188  raw_data = block.payload()[iFrame + 5];
189 
190  l1t::EtSum mhthf = l1t::EtSum();
191 
192  mhthf.setHwPt(raw_data & 0xFFF);
193  mhthf.setHwPhi((raw_data >> 12) & 0xFF);
195  mhthf.setP4(l1t::CaloTools::p4Demux(&mhthf));
196 
197  LogDebug("L1T") << "MHThf: phi " << mhthf.hwPhi() << " pT " << mhthf.hwPt() << " bx " << bx;
198 
199  res_->push_back(bx, mhthf);
200 
201  // HTHF ASYMM
202 
203  l1t::EtSum htHFAsym = l1t::EtSum();
204  htHFAsym.setHwPt((raw_data >> 20) & 0xFF);
205  htHFAsym.setType(l1t::EtSum::kAsymHtHF);
206 
207  res_->push_back(bx, htHFAsym);
208 
209  // CENTRALITY UPPER NIB
210 
211  uint32_t centUN = ((raw_data >> 28) & 0xF);
212 
213  l1t::EtSum cent = l1t::EtSum();
214  cent.setHwPt((centUN << 4) | centLN);
216 
217  res_->push_back(bx, cent);
218 
219  //HI-SUM
220 
221  raw_data = block.payload()[iFrame + 1];
222 
223  l1t::EtSum towCount = l1t::EtSum();
224  towCount.setHwPt((raw_data >> 12) & 0x1FFF);
225  towCount.setType((l1t::EtSum::kTowerCount));
226  towCount.setP4(l1t::CaloTools::p4Demux(&towCount));
227 
228  res_->push_back(bx, towCount);
229  }
230 
231  return true;
232  }
233  } // namespace stage2
234 } // namespace l1t
235 
constexpr int32_t ceil(float num)
const std::vector< uint32_t > & payload() const
Definition: Block.h:86
unsigned int getID() const
Definition: Block.h:43
const unsigned int nOutputFramePerBX
BlockHeader header() const
Definition: Block.h:85
int hwPhi() const
Definition: L1Candidate.h:37
void setType(EtSumType type)
Definition: EtSum.cc:11
void setHwPhi(int phi)
Definition: L1Candidate.h:30
int hwPt() const
Definition: L1Candidate.h:35
bool unpack(const Block &block, UnpackerCollections *coll) override
void setHwPt(int pt)
Definition: L1Candidate.h:28
#define DEFINE_L1T_UNPACKER(type)
unsigned int getSize() const
Definition: Block.h:44
static math::PtEtaPhiMLorentzVector p4Demux(l1t::L1Candidate *)
Definition: CaloTools.cc:317
void setP4(const LorentzVector &p4) final
set 4-momentum
#define LogDebug(id)