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