CMS 3D CMS Logo

EGammaUnpacker.cc
Go to the documentation of this file.
3 
5 
6 #include "L1TObjectCollections.h"
7 
9 #include "EGammaUnpacker.h"
10 
11 namespace l1t {
12  namespace stage2 {
13  EGammaUnpacker::EGammaUnpacker() : EGammaCopy_(0) {}
14 
16  using namespace l1t::stage2::layer2;
17 
18  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
19 
20  int nBX = int(ceil(block.header().getSize() / (double)demux::nOutputFramePerBX)); // 6 link frames per BX
21 
22  // Find the central, first and last BXs
23  int firstBX = -(ceil((double)nBX / 2.) - 1);
24  int lastBX;
25  if (nBX % 2 == 0) {
26  lastBX = ceil((double)nBX / 2.);
27  } else {
28  lastBX = ceil((double)nBX / 2.) - 1;
29  }
30 
31  auto res_ = static_cast<L1TObjectCollections*>(coll)->getEGammas(EGammaCopy_);
32  res_->setBXRange(firstBX, lastBX);
33 
34  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
35 
36  // Loop over multiple BX and then number of EG cands filling collection
37  for (int bx = firstBX; bx <= lastBX; bx++) {
38  for (unsigned iEG = 0; iEG < demux::nEGPerLink && iEG < block.header().getSize(); iEG++) {
39  int iFrame = (bx - firstBX) * demux::nOutputFramePerBX + iEG;
40  uint32_t raw_data = block.payload().at(iFrame);
41 
42  // skip padding to bring EG candidates up to 12 pre BX
43  if (raw_data == 0)
44  continue;
45 
46  l1t::EGamma eg = l1t::EGamma();
47 
48  eg.setHwPt(raw_data & 0x1FF);
49 
50  if (eg.hwPt() == 0)
51  continue;
52 
53  int abs_eta = (raw_data >> 9) & 0x7F;
54  if ((raw_data >> 16) & 0x1) {
55  eg.setHwEta(-1 * (128 - abs_eta));
56  } else {
57  eg.setHwEta(abs_eta);
58  }
59 
60  eg.setHwPhi((raw_data >> 17) & 0xFF);
61  eg.setHwIso((raw_data >> 25) & 0x3);
62  eg.setHwQual((raw_data >> 27) & 0x7); // Assume 3 bits for now? leaves 2 spare bits
63 
64  LogDebug("L1T") << "EG: eta " << eg.hwEta() << " phi " << eg.hwPhi() << " pT " << eg.hwPt() << " iso "
65  << eg.hwIso() << " qual " << eg.hwQual();
66 
68 
69  res_->push_back(bx, eg);
70  }
71  }
72 
73  return true;
74  }
75  } // namespace stage2
76 } // namespace l1t
77 
constexpr int32_t ceil(float num)
const unsigned int nOutputFramePerBX
int hwPhi() const
Definition: L1Candidate.h:37
void setHwQual(int qual)
Definition: L1Candidate.h:31
delete x;
Definition: CaloConfig.h:22
int hwQual() const
Definition: L1Candidate.h:38
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
int hwIso() const
Definition: L1Candidate.h:39
void setHwPt(int pt)
Definition: L1Candidate.h:28
#define DEFINE_L1T_UNPACKER(type)
void setHwEta(int eta)
Definition: L1Candidate.h:29
static math::PtEtaPhiMLorentzVector p4Demux(l1t::L1Candidate *)
Definition: CaloTools.cc:317
void setP4(const LorentzVector &p4) final
set 4-momentum
bool unpack(const Block &block, UnpackerCollections *coll) override
#define LogDebug(id)