CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
l1t::stage2::EGammaUnpacker Class Reference
Inheritance diagram for l1t::stage2::EGammaUnpacker:
l1t::Unpacker

Public Member Functions

virtual bool unpack (const Block &block, UnpackerCollections *coll) override
 

Detailed Description

Definition at line 9 of file EGammaUnpacker.cc.

Member Function Documentation

bool l1t::stage2::EGammaUnpacker::unpack ( const Block block,
UnpackerCollections coll 
)
overridevirtual

Implements l1t::Unpacker.

Definition at line 21 of file EGammaUnpacker.cc.

References coll, l1t::BlockHeader::getID(), l1t::BlockHeader::getSize(), l1t::Block::header(), l1t::L1Candidate::hwEta(), l1t::L1Candidate::hwIso(), l1t::L1Candidate::hwPhi(), l1t::L1Candidate::hwPt(), l1t::L1Candidate::hwQual(), i, LogDebug, l1t::Block::payload(), l1t::L1Candidate::setHwEta(), l1t::L1Candidate::setHwIso(), l1t::L1Candidate::setHwPhi(), l1t::L1Candidate::setHwPt(), and l1t::L1Candidate::setHwQual().

22  {
23 
24  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
25 
26  int nBX = int(ceil(block.header().getSize() / 12.)); // Since there are 12 EGamma objects reported per event (see CMS IN-2013/005)
27 
28  // Find the central, first and last BXs
29  int firstBX = -(ceil((double)nBX/2.)-1);
30  int lastBX;
31  if (nBX % 2 == 0) {
32  lastBX = ceil((double)nBX/2.);
33  } else {
34  lastBX = ceil((double)nBX/2.)-1;
35  }
36 
37  auto res_ = static_cast<L1TObjectCollections*>(coll)->getEGammas();
38  res_->setBXRange(firstBX, lastBX);
39 
40  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
41 
42  // Initialise index
43  int unsigned i = 0;
44 
45  // Loop over multiple BX and then number of EG cands filling collection
46  for (int bx=firstBX; bx<=lastBX; bx++){
47 
48  for (unsigned nEG=0; nEG < 12 && nEG < block.header().getSize(); nEG++){
49 
50  uint32_t raw_data = block.payload()[i++];
51 
52  // skip padding to bring EG candidates up to 12 pre BX
53  if (raw_data == 0)
54  continue;
55 
56  l1t::EGamma eg = l1t::EGamma();
57 
58  eg.setHwPt(raw_data & 0x1FF);
59 
60  int abs_eta = (raw_data >> 9) & 0x7F;
61  if ((raw_data >> 16) & 0x1) {
62  eg.setHwEta(-1*abs_eta);
63  } else {
64  eg.setHwEta(abs_eta);
65  }
66 
67  eg.setHwPhi((raw_data >> 17) & 0xFF);
68  eg.setHwIso((raw_data >> 25) & 0x1); // Assume one bit for now?
69  eg.setHwQual((raw_data >> 26) & 0x7); // Assume 3 bits for now? leaves 3 spare bits
70 
71  LogDebug("L1T") << "EG: eta " << eg.hwEta() << " phi " << eg.hwPhi() << " pT " << eg.hwPt() << " iso " << eg.hwIso() << " qual " << eg.hwQual();
72 
73  res_->push_back(bx,eg);
74  }
75 
76  }
77 
78  return true;
79  }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
void setHwQual(int qual)
Definition: L1Candidate.cc:64
int hwPhi() const
Definition: L1Candidate.cc:79
int hwIso() const
Definition: L1Candidate.cc:84
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
void setHwPt(int pt)
Definition: L1Candidate.cc:44
void setHwEta(int eta)
Definition: L1Candidate.cc:49