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