CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TauUnpacker.cc
Go to the documentation of this file.
3 
5 
6 #include "L1TObjectCollections.h"
7 
9 #include "TauUnpacker.h"
10 
11 namespace l1t {
12  namespace stage2 {
13  TauUnpacker::TauUnpacker() : TauCopy_(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() / demux::nOutputFramePerBX));
21 
22  // Find the 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)->getTaus(TauCopy_);
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 Tau cands filling collection
37  for (int bx = firstBX; bx <= lastBX; bx++) {
38  for (unsigned iTau = 0; iTau < demux::nTauPerLink && iTau < block.header().getSize(); iTau++) {
39  int iFrame = (bx - firstBX) * demux::nOutputFramePerBX + iTau;
40 
41  uint32_t raw_data = block.payload().at(iFrame);
42 
43  if (raw_data == 0)
44  continue;
45 
46  l1t::Tau tau = l1t::Tau();
47 
48  tau.setHwPt(raw_data & 0x1FF);
49 
50  if (tau.hwPt() == 0)
51  continue;
52 
53  int abs_eta = (raw_data >> 9) & 0x7F;
54  if ((raw_data >> 16) & 0x1) {
55  tau.setHwEta(-1 * (128 - abs_eta));
56  } else {
57  tau.setHwEta(abs_eta);
58  }
59 
60  tau.setHwPhi((raw_data >> 17) & 0xFF);
61  tau.setHwIso((raw_data >> 25) & 0x3); // 2 bits
62  tau.setHwQual((raw_data >> 27) & 0x7); // Assume 3 bits for now? leaves 3 spare bits
63  // tau.setHwQual((raw_data >> 26) & 0x7); // Assume 3 bits for now? leaves 3 spare bits
64 
65  LogDebug("L1T") << "Tau: eta " << tau.hwEta() << " phi " << tau.hwPhi() << " pT " << tau.hwPt() << " iso "
66  << tau.hwIso() << " qual " << tau.hwQual();
67 
68  tau.setP4(l1t::CaloTools::p4Demux(&tau));
69 
70  res_->push_back(bx, tau);
71  }
72  }
73 
74  return true;
75  }
76  } // namespace stage2
77 } // namespace l1t
78 
constexpr int32_t ceil(float num)
const std::vector< uint32_t > & payload() const
Definition: Block.h:86
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: TauUnpacker.cc:15
unsigned int getID() const
Definition: Block.h:43
const unsigned int nOutputFramePerBX
Definition: Tau.h:20
BlockHeader header() const
Definition: Block.h:85
void setHwQual(int qual)
Definition: L1Candidate.h:31
int hwPhi() const
Definition: L1Candidate.h:37
int hwIso() const
Definition: L1Candidate.h:39
int hwEta() const
Definition: L1Candidate.h:36
int hwQual() const
Definition: L1Candidate.h:38
void setHwPhi(int phi)
Definition: L1Candidate.h:30
void setHwIso(int iso)
Definition: L1Candidate.h:32
int hwPt() const
Definition: L1Candidate.h:35
void setHwPt(int pt)
Definition: L1Candidate.h:28
#define DEFINE_L1T_UNPACKER(type)
unsigned int getSize() const
Definition: Block.h:44
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
#define LogDebug(id)