CMS 3D CMS Logo

MPUnpacker_0x1001000b.cc
Go to the documentation of this file.
3 
5 
6 #include "CaloCollections.h"
8 
9 namespace l1t {
10  namespace stage2 {
11 
13  if ((blkId == BLK_TOT_NEG) || (blkId == BLK_X_NEG) || (blkId == BLK_Y_NEG)) {
14  return -1;
15  }
16  return 1;
17  }
18 
20  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize()
21  << " AMC = " << block.amc().getAMCNumber();
22 
23  // check this is the correct MP
24  unsigned int amc = block.amc().getAMCNumber();
25  unsigned int bxid = block.amc().getBX();
26  LogDebug("L1T") << "Unpacking AMC " << amc << " for BX " << bxid;
27 
28  auto res1_ = static_cast<CaloCollections*>(coll)->getMPJets();
29  auto res2_ = static_cast<CaloCollections*>(coll)->getMPEtSums();
30  auto res3_ = static_cast<CaloCollections*>(coll)->getMPEGammas();
31  auto res4_ = static_cast<CaloCollections*>(coll)->getMPTaus();
32 
33  res1_->setBXRange(0, 0);
34  res2_->setBXRange(0, 0);
35  res3_->setBXRange(0, 0);
36  res4_->setBXRange(0, 0);
37 
38  // Initialise frame indices for each data type
39  int unsigned fet = 0;
40  int unsigned fht = 2;
41  int unsigned feg = 3;
42  int unsigned ftau = 5;
43  int unsigned fjet = 7;
44 
45  // ===== Jets and Sums =====
46 
47  // ET / MET(x) / MET (y)
48 
49  uint32_t raw_data = block.payload()[fet];
50 
52 
53  switch (block.header().getID()) {
54  case BLK_TOT_POS:
55  et.setType(l1t::EtSum::kTotalEt);
56  et.setHwPt((uint32_t(raw_data & 0xFFFFFF) << 16) >> 16);
57  break;
58  case BLK_X_POS:
59  et.setType(l1t::EtSum::kTotalEtx);
60  et.setHwPt((uint32_t(raw_data)));
61  break;
62  case BLK_Y_POS:
63  et.setType(l1t::EtSum::kTotalEty);
64  et.setHwPt((uint32_t(raw_data)));
65  break;
66  case BLK_TOT_NEG:
67  et.setType(l1t::EtSum::kTotalEt);
68  et.setHwPt((uint32_t(raw_data & 0xFFFFFF) << 16) >> 16);
69  break;
70  case BLK_X_NEG:
71  et.setType(l1t::EtSum::kTotalEtx);
72  et.setHwPt((uint32_t(raw_data)));
73  break;
74  case BLK_Y_NEG:
75  et.setType(l1t::EtSum::kTotalEty);
76  et.setHwPt((uint32_t(raw_data)));
77  break;
78  default:
79  break;
80  }
81 
82  LogDebug("L1T") << "ET/METx/METy: pT " << et.hwPt();
83 
84  res2_->push_back(0, et);
85 
86  // HT / MHT(x)/ MHT (y)
87 
88  raw_data = block.payload()[fht];
89 
90  l1t::EtSum ht = l1t::EtSum();
91 
92  //ht.setHwPt(raw_data & 0xFFFFF);
93  ht.setHwPt((uint32_t(raw_data & 0xFFFFFF) << 16) >> 16);
94  switch (block.header().getID()) {
95  case BLK_TOT_POS:
96  ht.setType(l1t::EtSum::kTotalHt);
97  break;
98  case BLK_X_POS:
99  ht.setType(l1t::EtSum::kTotalHtx);
100  break;
101  case BLK_Y_POS:
102  ht.setType(l1t::EtSum::kTotalHty);
103  break;
104  case BLK_TOT_NEG:
105  ht.setType(l1t::EtSum::kTotalHt);
106  break;
107  case BLK_X_NEG:
108  ht.setType(l1t::EtSum::kTotalHtx);
109  break;
110  case BLK_Y_NEG:
111  ht.setType(l1t::EtSum::kTotalHty);
112  break;
113  default:
114  break;
115  }
116 
117  LogDebug("L1T") << "HT/MHTx/MHTy: pT " << ht.hwPt();
118 
119  res2_->push_back(0, ht);
120 
121  // Two jets
122  for (unsigned nJet = 0; nJet < 2; nJet++) {
123  raw_data = block.payload()[fjet + nJet];
124 
125  if (raw_data == 0)
126  continue;
127 
128  l1t::Jet jet = l1t::Jet();
129 
130  int etasign = etaSign(block.header().getID());
131 
132  LogDebug("L1") << "block ID=" << block.header().getID() << " etasign=" << etasign;
133 
134  int mpEta = etasign * (raw_data & 0x3F);
135  jet.setHwEta(CaloTools::caloEta(mpEta));
136  jet.setHwPhi((raw_data >> 6) & 0x7F);
137  jet.setHwPt((raw_data >> 13) & 0xFFFF);
138  jet.setHwQual((raw_data >> 29) & 0x1);
139 
140  LogDebug("L1T") << "Jet: eta " << jet.hwEta() << " phi " << jet.hwPhi() << " pT " << jet.hwPt() << " qual "
141  << jet.hwQual();
142 
143  jet.setP4(l1t::CaloTools::p4MP(&jet));
144  res1_->push_back(0, jet);
145  }
146 
147  // ===== EGammas =====
148 
149  // Two EGammas
150 
151  for (unsigned nEG = 0; nEG < 2; nEG++) {
152  raw_data = block.payload()[feg + nEG];
153 
154  if (raw_data == 0)
155  continue;
156 
157  l1t::EGamma eg = l1t::EGamma();
158 
159  int etasign = etaSign(block.header().getID());
160 
161  LogDebug("L1") << "block ID=" << block.header().getID() << " etasign=" << etasign;
162 
163  eg.setHwEta(etasign * ((raw_data >> 3) & 0x3F));
164  eg.setHwPhi((raw_data >> 9) & 0x7F);
165  eg.setHwPt((raw_data >> 20) & 0xFFF);
166  eg.setHwIso((raw_data >> 1) & 0x3);
167  eg.setHwQual((raw_data >> 16) & 0xf);
168 
169  LogDebug("L1T") << "Egamma: eta " << eg.hwEta() << " phi " << eg.hwPhi() << " pT " << eg.hwPt() << " qual "
170  << eg.hwQual();
171 
172  eg.setP4(l1t::CaloTools::p4MP(&eg));
173  res3_->push_back(0, eg);
174  }
175 
176  // ===== Taus =====
177 
178  // Two taus
179 
180  for (unsigned nTau = 0; nTau < 2; nTau++) {
181  raw_data = block.payload()[ftau + nTau];
182 
183  if (raw_data == 0)
184  continue;
185 
186  l1t::Tau tau = l1t::Tau();
187 
188  int etasign = etaSign(block.header().getID());
189 
190  LogDebug("L1") << "block ID=" << block.header().getID() << " etasign=" << etasign;
191 
192  tau.setHwEta(etasign * ((raw_data >> 3) & 0x3F));
193  tau.setHwPhi((raw_data >> 9) & 0x7F);
194  tau.setHwPt((raw_data >> 20) & 0xFFF);
195  tau.setHwIso((raw_data >> 1) & 0x3);
196  tau.setHwQual((raw_data >> 16) & 0xf);
197 
198  LogDebug("L1T") << "Tau: eta " << tau.hwEta() << " phi " << tau.hwPhi() << " pT " << tau.hwPt() << " qual "
199  << tau.hwQual();
200 
201  tau.setP4(l1t::CaloTools::p4MP(&tau));
202  res4_->push_back(0, tau);
203  }
204 
205  return true;
206  }
207  } // namespace stage2
208 } // namespace l1t
209 
Definition: Tau.h:20
int hwPhi() const
Definition: L1Candidate.h:37
static math::PtEtaPhiMLorentzVector p4MP(l1t::L1Candidate *)
Definition: CaloTools.cc:369
void setHwQual(int qual)
Definition: L1Candidate.h:31
delete x;
Definition: CaloConfig.h:22
int hwQual() const
Definition: L1Candidate.h:38
Definition: Jet.h:20
int hwEta() const
Definition: L1Candidate.h:36
void setHwPhi(int phi)
Definition: L1Candidate.h:30
void setHwIso(int iso)
Definition: L1Candidate.h:32
int hwPt() const
Definition: L1Candidate.h:35
static int caloEta(int ietaMP)
Definition: CaloTools.cc:234
void setHwPt(int pt)
Definition: L1Candidate.h:28
#define DEFINE_L1T_UNPACKER(type)
void setHwEta(int eta)
Definition: L1Candidate.h:29
Definition: AMCSpec.h:8
void setP4(const LorentzVector &p4) final
set 4-momentum
#define LogDebug(id)
bool unpack(const Block &block, UnpackerCollections *coll) override