CMS 3D CMS Logo

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 
46 
47  et.setHwPt(raw_data & 0xFFF);
48  et.setP4(l1t::CaloTools::p4Demux(&et));
49 
50  LogDebug("L1T") << "ET: pT " << et.hwPt() << " bx " << bx;
51 
52  res_->push_back(bx, et);
53 
54  // ET EM
55 
57 
58  etem.setHwPt((raw_data >> 12) & 0xFFF);
59  etem.setP4(l1t::CaloTools::p4Demux(&etem));
60 
61  LogDebug("L1T") << "ETEM: pT " << etem.hwPt() << " bx " << bx;
62 
63  res_->push_back(bx, etem);
64 
65  // MBHFPT0
66 
68  mbp0.setHwPt((raw_data >> 28) & 0xf);
69 
70  res_->push_back(bx, mbp0);
71 
72  // HT
73 
74  raw_data = block.payload()[iFrame + 1];
75 
77 
78  ht.setHwPt(raw_data & 0xFFF);
79  ht.setP4(l1t::CaloTools::p4Demux(&ht));
80 
81  LogDebug("L1T") << "HT: pT " << ht.hwPt();
82 
83  res_->push_back(bx, ht);
84 
85  //MBHFMT0
86 
88  mbm0.setHwPt((raw_data >> 28) & 0xf);
89 
90  res_->push_back(bx, mbm0);
91 
92  // MET (no HF)
93 
94  raw_data = block.payload()[iFrame + 2];
95 
97 
98  met.setHwPt(raw_data & 0xFFF);
99  met.setHwPhi((raw_data >> 12) & 0xFF);
101 
102  LogDebug("L1T") << "MET: phi " << met.hwPhi() << " pT " << met.hwPt() << " bx " << bx;
103 
104  res_->push_back(bx, met);
105 
106  // MBHFPT1
107 
109  mbp1.setHwPt((raw_data >> 28) & 0xf);
110 
111  res_->push_back(bx, mbp1);
112 
113  // ET ASYMM
114 
116  etAsym.setHwPt((raw_data >> 20) & 0xFF);
117 
118  res_->push_back(bx, etAsym);
119 
120  // MHT
121 
122  raw_data = block.payload()[iFrame + 3];
123 
125 
126  mht.setHwPt(raw_data & 0xFFF);
127  mht.setHwPhi((raw_data >> 12) & 0xFF);
128  mht.setP4(l1t::CaloTools::p4Demux(&mht));
129 
130  LogDebug("L1T") << "MHT: phi " << mht.hwPhi() << " pT " << mht.hwPt() << " bx " << bx;
131 
132  res_->push_back(bx, mht);
133 
134  // MBHFMT1
135 
137  mbm1.setHwPt((raw_data >> 28) & 0xf);
138 
139  res_->push_back(bx, mbm1);
140 
141  // HT ASYMM
142 
144  htAsym.setHwPt((raw_data >> 20) & 0xFF);
145 
146  res_->push_back(bx, htAsym);
147 
148  // MET (with HF)
149 
150  raw_data = block.payload()[iFrame + 4];
151 
153 
154  methf.setHwPt(raw_data & 0xFFF);
155  methf.setHwPhi((raw_data >> 12) & 0xFF);
156  methf.setP4(l1t::CaloTools::p4Demux(&methf));
157 
158  LogDebug("L1T") << "METHF: phi " << methf.hwPhi() << " pT " << methf.hwPt() << " bx " << bx;
159 
160  res_->push_back(bx, methf);
161 
162  // ETHF ASYMM
163 
165  etHFAsym.setHwPt((raw_data >> 20) & 0xFF);
166 
167  res_->push_back(bx, etHFAsym);
168 
169  // CENTRALITY LOWER NIB
170 
171  uint32_t centLN = ((raw_data >> 28) & 0xF);
172 
173  // MHT with HF
174 
175  raw_data = block.payload()[iFrame + 5];
176 
178 
179  mhthf.setHwPt(raw_data & 0xFFF);
180  mhthf.setHwPhi((raw_data >> 12) & 0xFF);
181  mhthf.setP4(l1t::CaloTools::p4Demux(&mhthf));
182 
183  LogDebug("L1T") << "MHThf: phi " << mhthf.hwPhi() << " pT " << mhthf.hwPt() << " bx " << bx;
184 
185  res_->push_back(bx, mhthf);
186 
187  // HTHF ASYMM
188 
190  htHFAsym.setHwPt((raw_data >> 20) & 0xFF);
191 
192  res_->push_back(bx, htHFAsym);
193 
194  // CENTRALITY UPPER NIB
195 
196  uint32_t centUN = ((raw_data >> 28) & 0xF);
197 
199  cent.setHwPt((centUN << 4) | centLN);
200 
201  res_->push_back(bx, cent);
202 
203  //HI-SUM
204 
205  raw_data = block.payload()[iFrame + 1];
206 
208  towCount.setHwPt((raw_data >> 12) & 0x1FFF);
209  towCount.setP4(l1t::CaloTools::p4Demux(&towCount));
210 
211  res_->push_back(bx, towCount);
212  }
213 
214  return true;
215  }
216  } // namespace stage2
217 } // namespace l1t
218 
constexpr int32_t ceil(float num)
delete x;
Definition: CaloConfig.h:22
const unsigned int nOutputFramePerBX
Definition: GTSetup.cc:15
bool unpack(const Block &block, UnpackerCollections *coll) override
#define DEFINE_L1T_UNPACKER(type)
static math::PtEtaPhiMLorentzVector p4Demux(l1t::L1Candidate *)
Definition: CaloTools.cc:317
#define LogDebug(id)