CMS 3D CMS Logo

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 
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)
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: TauUnpacker.cc:15
Definition: Tau.h:20
delete x;
Definition: CaloConfig.h:22
const unsigned int nOutputFramePerBX
Definition: GTSetup.cc:16
#define DEFINE_L1T_UNPACKER(type)
static math::PtEtaPhiMLorentzVector p4Demux(l1t::L1Candidate *)
Definition: CaloTools.cc:317
#define LogDebug(id)