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 
l1t::stage2::EGammaUnpacker::EGammaCopy_
unsigned int EGammaCopy_
Definition: EGammaUnpacker.h:15
CaloTools.h
l1t::L1Candidate::hwPhi
int hwPhi() const
Definition: L1Candidate.h:37
MessageLogger.h
L1TStage2Layer2Constants.h
l1t::CaloTools::p4Demux
static math::PtEtaPhiMLorentzVector p4Demux(l1t::L1Candidate *)
Definition: CaloTools.cc:317
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
l1t::L1Candidate::hwQual
int hwQual() const
Definition: L1Candidate.h:38
RPCBxOrConfig_cff.firstBX
firstBX
Definition: RPCBxOrConfig_cff.py:5
l1t::stage2::layer2::demux::nEGPerLink
const unsigned int nEGPerLink
Definition: L1TStage2Layer2Constants.cc:12
l1t::L1Candidate::hwEta
int hwEta() const
Definition: L1Candidate.h:36
reco::ceil
constexpr int32_t ceil(float num)
Definition: constexpr_cmath.h:7
l1t::L1Candidate::setHwQual
void setHwQual(int qual)
Definition: L1Candidate.h:31
l1t::stage2::EGammaUnpacker::EGammaUnpacker
EGammaUnpacker()
Definition: EGammaUnpacker.cc:13
l1t::stage2::EGammaUnpacker
Definition: EGammaUnpacker.h:8
UnpackerFactory.h
l1t::stage2::EGammaUnpacker::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: EGammaUnpacker.cc:15
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
l1t
delete x;
Definition: CaloConfig.h:22
l1t::stage2::layer2
Definition: L1TStage2Layer2Constants.h:8
createfilelist.int
int
Definition: createfilelist.py:10
l1t::EGamma
Definition: EGamma.h:20
EGammaUnpacker.h
l1t::L1Candidate::setHwPt
void setHwPt(int pt)
Definition: L1Candidate.h:28
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
l1t::L1Candidate::setHwEta
void setHwEta(int eta)
Definition: L1Candidate.h:29
l1t::stage2::layer2::mp::nOutputFramePerBX
const unsigned int nOutputFramePerBX
Definition: L1TStage2Layer2Constants.cc:9
SiStripSourceConfigTier0_cff.stage2
stage2
Definition: SiStripSourceConfigTier0_cff.py:71
reco::LeafCandidate::setP4
void setP4(const LorentzVector &p4) final
set 4-momentum
Definition: LeafCandidate.h:158
l1t::UnpackerCollections
Definition: UnpackerCollections.h:9
HLT_FULL_cff.EGamma
EGamma
Definition: HLT_FULL_cff.py:3928
l1t::L1Candidate::setHwIso
void setHwIso(int iso)
Definition: L1Candidate.h:32
L1TObjectCollections.h
l1t::L1Candidate::hwPt
int hwPt() const
Definition: L1Candidate.h:35
RPCBxOrConfig_cff.lastBX
lastBX
Definition: RPCBxOrConfig_cff.py:4
DEFINE_L1T_UNPACKER
#define DEFINE_L1T_UNPACKER(type)
Definition: UnpackerFactory.h:23
l1t::L1Candidate::setHwPhi
void setHwPhi(int phi)
Definition: L1Candidate.h:30
l1t::Block
Definition: Block.h:70
l1t::L1Candidate::hwIso
int hwIso() const
Definition: L1Candidate.h:39