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