CMS 3D CMS Logo

MPUnpacker_0x10010010.cc
Go to the documentation of this file.
1 #define EDM_ML_DEBUG 1
2 
4 
6 
8 
9 #include "CaloCollections.h"
11 #include "MPUnpacker_0x10010010.h"
12 
13 namespace l1t {
14  namespace stage2 {
16  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize()
17  << " AMC = " << block.amc().getAMCNumber();
18 
19  // check this is the correct MP
20  const unsigned int tmt = block.amc().getBoardID() - l1t::stage2::layer2::mp::offsetBoardId + 1;
21  const unsigned int bxid = block.amc().getBX();
22 
23  // handle offset between BC0 marker and actual BC0...
24  //if( (tmt-1) != ((bxid-1+3)%9) ) return true;
25  LogDebug("L1T") << "Unpacking TMT # " << tmt << " for BX " << bxid;
26 
27  auto res1_ = static_cast<CaloCollections*>(coll)->getMPJets();
28  auto res2_ = static_cast<CaloCollections*>(coll)->getMPEtSums();
29  auto res3_ = static_cast<CaloCollections*>(coll)->getMPEGammas();
30  auto res4_ = static_cast<CaloCollections*>(coll)->getMPTaus();
31 
32  res1_->setBXRange(0, 0);
33  res2_->setBXRange(0, 0);
34  res3_->setBXRange(0, 0);
35  res4_->setBXRange(0, 0);
36 
37  // Initialise frame indices for each data type
38  const int unsigned fet = 0;
39  const int unsigned fht = 2;
40  const int unsigned feg = 4;
41  const int unsigned ftau = 6;
42  const int unsigned fjet = 8;
43  const int unsigned faux = 10;
44 
45  // ===== Jets and Sums =====
46 
47  // ET / MET(x) / MET (y) with HF (configurable)
48 
49  uint32_t raw_data = block.payload()[fet];
50 
51  l1t::EtSum ethf = l1t::EtSum();
52 
53  switch (block.header().getID()) {
54  case 123: // 61
56  ethf.setHwPt(static_cast<int32_t>(uint32_t(raw_data & 0xFFFF)));
57  break;
58  case 121: // 60
60  ethf.setHwPt(static_cast<int32_t>(uint32_t(raw_data)));
61  break;
62  case 127: // 63
64  ethf.setHwPt(static_cast<int32_t>(uint32_t(raw_data)));
65  break;
66  case 125: // 62
68  ethf.setHwPt(static_cast<int32_t>(uint32_t(raw_data & 0xFFFF)));
69  break;
70  case 131: // 65
72  ethf.setHwPt(static_cast<int32_t>(uint32_t(raw_data)));
73  break;
74  case 129: // 64
76  ethf.setHwPt(static_cast<int32_t>(uint32_t(raw_data)));
77  break;
78  default:
79  break;
80  }
81 
82  LogDebug("L1T") << "ET/METx/METy: pT " << ethf.hwPt();
83 
84  res2_->push_back(0, ethf);
85 
86  // ET / MET(x) / MET (y) without HF
87 
88  raw_data = block.payload()[fet + 1];
89 
90  l1t::EtSum etNoHF = l1t::EtSum();
91 
92  switch (block.header().getID()) {
93  case 123: // 61
95  etNoHF.setHwPt(static_cast<int32_t>(uint32_t(raw_data & 0xFFFF)));
96  break;
97  case 121: // 60
99  etNoHF.setHwPt(static_cast<int32_t>(uint32_t(raw_data)));
100  break;
101  case 127: // 63
103  etNoHF.setHwPt(static_cast<int32_t>(uint32_t(raw_data)));
104  break;
105  case 125: // 62
107  etNoHF.setHwPt(static_cast<int32_t>(uint32_t(raw_data & 0xFFFF)));
108  break;
109  case 131: // 65
111  etNoHF.setHwPt(static_cast<int32_t>(uint32_t(raw_data)));
112  break;
113  case 129: // 64
115  etNoHF.setHwPt(static_cast<int32_t>(uint32_t(raw_data)));
116  break;
117  default:
118  break;
119  }
120 
121  LogDebug("L1T") << "ET/METx/METy (no HF): pT " << etNoHF.hwPt();
122 
123  res2_->push_back(0, etNoHF);
124 
125  // HT / MHT(x)/ MHT (y) with HF
126 
127  raw_data = block.payload()[fht];
128 
129  l1t::EtSum hthf = l1t::EtSum();
130 
131  switch (block.header().getID()) {
132  case 123: // 61
134  hthf.setHwPt(static_cast<int32_t>(uint32_t(raw_data & 0xFFFF)));
135  break;
136  case 121: // 60
138  hthf.setHwPt(static_cast<int32_t>(uint32_t(raw_data)));
139  break;
140  case 127: // 63
142  hthf.setHwPt(static_cast<int32_t>(uint32_t(raw_data)));
143  break;
144  case 125: // 62
146  hthf.setHwPt(static_cast<int32_t>(uint32_t(raw_data & 0xFFFF)));
147  break;
148  case 131: // 65
150  hthf.setHwPt(static_cast<int32_t>(uint32_t(raw_data)));
151  break;
152  case 129: // 64
154  hthf.setHwPt(static_cast<int32_t>(uint32_t(raw_data)));
155  break;
156  default:
157  break;
158  }
159 
160  LogDebug("L1T") << "HTHF/MHTHFx/MHTHFy: pT " << hthf.hwPt();
161 
162  res2_->push_back(0, hthf);
163 
164  // HT / MHT(x)/ MHT (y) no HF
165 
166  raw_data = block.payload()[fht + 1];
167 
168  l1t::EtSum htNoHF = l1t::EtSum();
169 
170  switch (block.header().getID()) {
171  case 123: // 61
173  htNoHF.setHwPt(static_cast<int32_t>(uint32_t(raw_data & 0xFFFF)));
174  break;
175  case 121: // 60
177  htNoHF.setHwPt(static_cast<int32_t>(uint32_t(raw_data)));
178  break;
179  case 127: // 63
181  htNoHF.setHwPt(static_cast<int32_t>(uint32_t(raw_data)));
182  break;
183  case 125: // 62
185  htNoHF.setHwPt(static_cast<int32_t>(uint32_t(raw_data & 0xFFFF)));
186  break;
187  case 131: // 65
189  htNoHF.setHwPt(static_cast<int32_t>(uint32_t(raw_data)));
190  break;
191  case 129: // 64
193  htNoHF.setHwPt(static_cast<int32_t>(uint32_t(raw_data)));
194  break;
195  default:
196  break;
197  }
198 
199  LogDebug("L1T") << "HTNOHF/MHTNOHFx/MHTNOHFy: pT " << htNoHF.hwPt();
200 
201  res2_->push_back(0, htNoHF);
202 
203  // Two jets
204  for (unsigned nJet = 0; nJet < 2; nJet++) {
205  raw_data = block.payload()[fjet + nJet];
206 
207  if (raw_data == 0)
208  continue;
209 
210  l1t::Jet jet = l1t::Jet();
211 
212  int etasign = 1;
213  if ((block.header().getID() == 125) || (block.header().getID() == 131) || (block.header().getID() == 129)) {
214  etasign = -1;
215  }
216 
217  LogDebug("L1") << "block ID=" << block.header().getID() << " etasign=" << etasign;
218 
219  int mpEta = etasign * (raw_data & 0x3F);
220  jet.setHwEta(CaloTools::caloEta(mpEta));
221  jet.setHwPhi((raw_data >> 6) & 0x7F);
222  jet.setHwPt((raw_data >> 13) & 0xFFFF);
223  jet.setHwQual((raw_data >> 29) & 0x1);
224 
225  if (jet.hwPt() == 0)
226  continue;
227 
228  LogDebug("L1T") << "Jet: eta " << jet.hwEta() << " phi " << jet.hwPhi() << " pT " << jet.hwPt() << " qual "
229  << jet.hwQual();
230 
231  jet.setP4(l1t::CaloTools::p4MP(&jet));
232  res1_->push_back(0, jet);
233  }
234 
235  // ===== EGammas =====
236 
237  // Two EGammas
238 
239  for (unsigned nEG = 0; nEG < 2; nEG++) {
240  raw_data = block.payload()[feg + nEG];
241 
242  if (raw_data == 0)
243  continue;
244 
245  l1t::EGamma eg = l1t::EGamma();
246 
247  int etasign = 1;
248  if ((block.header().getID() == 125) || (block.header().getID() == 131) || (block.header().getID() == 129)) {
249  etasign = -1;
250  }
251 
252  LogDebug("L1") << "block ID=" << block.header().getID() << " etasign=" << etasign;
253 
254  eg.setHwEta(etasign * ((raw_data >> 3) & 0x3F));
255  eg.setHwPhi((raw_data >> 9) & 0x7F);
256  eg.setHwPt((raw_data >> 20) & 0xFFF);
257  eg.setHwIso((raw_data >> 1) & 0x3);
258  eg.setHwQual((raw_data >> 16) & 0xf);
259 
260  if (eg.hwPt() == 0)
261  continue;
262 
263  LogDebug("L1T") << "Egamma: eta " << eg.hwEta() << " phi " << eg.hwPhi() << " pT " << eg.hwPt() << " qual "
264  << eg.hwQual();
265 
266  eg.setP4(l1t::CaloTools::p4MP(&eg));
267  res3_->push_back(0, eg);
268  }
269 
270  // ===== Taus =====
271 
272  // Two taus
273 
274  for (unsigned nTau = 0; nTau < 2; nTau++) {
275  raw_data = block.payload()[ftau + nTau];
276 
277  if (raw_data == 0)
278  continue;
279 
280  l1t::Tau tau = l1t::Tau();
281 
282  int etasign = 1;
283  if ((block.header().getID() == 125) || (block.header().getID() == 131) || (block.header().getID() == 129)) {
284  etasign = -1;
285  }
286 
287  LogDebug("L1") << "block ID=" << block.header().getID() << " etasign=" << etasign;
288 
289  tau.setHwEta(etasign * ((raw_data >> 3) & 0x3F));
290  tau.setHwPhi((raw_data >> 9) & 0x7F);
291  tau.setHwPt((raw_data >> 20) & 0xFFF);
292  tau.setHwIso((raw_data >> 1) & 0x3);
293  tau.setHwQual((raw_data >> 16) & 0xf);
294 
295  if (tau.hwPt() == 0)
296  continue;
297 
298  LogDebug("L1T") << "Tau: eta " << tau.hwEta() << " phi " << tau.hwPhi() << " pT " << tau.hwPt() << " qual "
299  << tau.hwQual();
300 
301  tau.setP4(l1t::CaloTools::p4MP(&tau));
302  res4_->push_back(0, tau);
303  }
304 
305  // check block size to avoid problems with test run 272133
306  // which used wrong fw version and doesn't have aux output
307 
308  if (block.header().getSize() > faux) {
309  // ===== Aux =====
310  raw_data = block.payload()[faux];
311 
312  // create a sum object for each type of HF sum
313  l1t::EtSum mbp0 = l1t::EtSum();
314  l1t::EtSum mbm0 = l1t::EtSum();
315  l1t::EtSum mbm1 = l1t::EtSum();
316  l1t::EtSum mbp1 = l1t::EtSum();
317 
318  // readout the sums only if the correct block is being processed (first frame of AUX)
319  switch (block.header().getID()) {
320  case 121: // this should correspond to the first link
321  // read 4 bits starting at position 24 (24 -> 28)
322  mbp0.setHwPt((raw_data >> 24) & 0xF);
324 
325  // read 4 bits starting at position 16 (16 -> 20)
326  mbm0.setHwPt((raw_data >> 16) & 0xF);
328 
329  // read 4 bits starting at position 8 (8 -> 12)
330  mbp1.setHwPt((raw_data >> 8) & 0xF);
332 
333  // read the first 4 bits by masking with 0xF
334  mbm1.setHwPt(raw_data & 0xF);
336 
337  LogDebug("L1T") << "mbp0 HF sum: " << mbp0.hwPt();
338  LogDebug("L1T") << "mbm0 HF sum: " << mbm0.hwPt();
339  LogDebug("L1T") << "mbp1 HF sum: " << mbp1.hwPt();
340  LogDebug("L1T") << "mbm1 HF sum: " << mbm1.hwPt();
341 
342  res2_->push_back(0, mbp0);
343  res2_->push_back(0, mbm0);
344  res2_->push_back(0, mbp1);
345  res2_->push_back(0, mbm1);
346  break;
347  default:
348  break;
349  }
350  }
351 
352  return true;
353  }
354  } // namespace stage2
355 } // namespace l1t
356 
l1t::EtSum::kTotalHty
Definition: EtSum.h:30
l1t::EtSum::kMinBiasHFP0
Definition: EtSum.h:34
l1t::CaloTools::caloEta
static int caloEta(int ietaMP)
Definition: CaloTools.cc:234
l1t::EtSum::setType
void setType(EtSumType type)
Definition: EtSum.cc:11
l1t::EtSum::kTotalEtx
Definition: EtSum.h:27
CaloTools.h
l1t::L1Candidate::hwPhi
int hwPhi() const
Definition: L1Candidate.h:37
MPUnpacker_0x10010010.h
MessageLogger.h
L1TStage2Layer2Constants.h
metsig::tau
Definition: SignAlgoResolutions.h:49
l1t::EtSum::kMinBiasHFM1
Definition: EtSum.h:37
L1TRate_Offline_cfi.Tau
Tau
Definition: L1TRate_Offline_cfi.py:43
l1t::L1Candidate::hwQual
int hwQual() const
Definition: L1Candidate.h:38
l1t::EtSum::kTotalEty
Definition: EtSum.h:28
l1t::EtSum::kTotalHt
Definition: EtSum.h:24
l1t::Tau
Definition: Tau.h:20
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
l1t::L1Candidate::hwEta
int hwEta() const
Definition: L1Candidate.h:36
l1t::L1Candidate::setHwQual
void setHwQual(int qual)
Definition: L1Candidate.h:31
L1TRate_cfi.Jet
Jet
Definition: L1TRate_cfi.py:43
UnpackerFactory.h
l1t::Jet
Definition: Jet.h:20
l1t::EtSum::kMinBiasHFP1
Definition: EtSum.h:36
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
l1t
delete x;
Definition: CaloConfig.h:22
l1t::EtSum
Definition: EtSum.h:20
l1t::EtSum::kTotalHtHF
Definition: EtSum.h:40
l1t::EtSum::kTotalHtxHF
Definition: EtSum.h:41
l1t::EGamma
Definition: EGamma.h:20
l1t::L1Candidate::setHwPt
void setHwPt(int pt)
Definition: L1Candidate.h:28
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
l1t::L1Candidate::setHwEta
void setHwEta(int eta)
Definition: L1Candidate.h:29
l1t::EtSum::kTotalEtyHF
Definition: EtSum.h:33
SiStripSourceConfigTier0_cff.stage2
stage2
Definition: SiStripSourceConfigTier0_cff.py:71
reco::LeafCandidate::setP4
void setP4(const LorentzVector &p4) final
set 4-momentum
Definition: LeafCandidate.h:158
l1t::stage2::MPUnpacker_0x10010010
Definition: MPUnpacker_0x10010010.h:8
metsig::jet
Definition: SignAlgoResolutions.h:47
l1t::UnpackerCollections
Definition: UnpackerCollections.h:9
HLT_FULL_cff.EGamma
EGamma
Definition: HLT_FULL_cff.py:3928
l1t::L1Candidate::setHwIso
void setHwIso(int iso)
Definition: L1Candidate.h:32
l1t::EtSum::kTotalEtxHF
Definition: EtSum.h:32
l1t::EtSum::kTotalHtyHF
Definition: EtSum.h:42
l1t::L1Candidate::hwPt
int hwPt() const
Definition: L1Candidate.h:35
l1t::EtSum::kTotalHtx
Definition: EtSum.h:29
DEFINE_L1T_UNPACKER
#define DEFINE_L1T_UNPACKER(type)
Definition: UnpackerFactory.h:23
l1t::L1Candidate::setHwPhi
void setHwPhi(int phi)
Definition: L1Candidate.h:30
l1t::stage2::layer2::mp::offsetBoardId
const unsigned int offsetBoardId
Definition: L1TStage2Layer2Constants.cc:6
l1t::EtSum::kMinBiasHFM0
Definition: EtSum.h:35
CaloCollections.h
l1t::stage2::MPUnpacker_0x10010010::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: MPUnpacker_0x10010010.cc:15
l1t::Block
Definition: Block.h:70
l1t::EtSum::kTotalEt
Definition: EtSum.h:23
l1t::CaloTools::p4MP
static math::PtEtaPhiMLorentzVector p4MP(l1t::L1Candidate *)
Definition: CaloTools.cc:369
l1t::EtSum::kTotalEtHF
Definition: EtSum.h:38