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