test
CMS 3D CMS Logo

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