CMS 3D CMS Logo

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