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