test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JetUnpacker.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 JetUnpacker : 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() / (double) demux::nOutputFramePerBX )); // 6 frames per BX
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)->getJets();
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 jets filling jet collection
49  for (int bx=firstBX; bx<=lastBX; bx++){
50  for (unsigned iJet=0; iJet < demux::nJetPerLink && iJet < block.header().getSize(); iJet++){
51 
52  int iFrame = (bx-firstBX)*demux::nOutputFramePerBX + iJet;
53  uint32_t raw_data = block.payload().at(iFrame);
54 
55  if (raw_data == 0)
56  continue;
57 
58  l1t::Jet jet = l1t::Jet();
59 
60  jet.setHwPt(raw_data & 0x7FF);
61 
62  if (jet.hwPt()==0) continue;
63 
64  int abs_eta = (raw_data >> 11) & 0x7F;
65  if ((raw_data >> 18) & 0x1) {
66  jet.setHwEta(-1 * (128-abs_eta));
67  } else {
68  jet.setHwEta(abs_eta);
69  }
70 
71  jet.setHwPhi((raw_data >> 19) & 0xFF);
72  jet.setHwQual((raw_data >> 27) & 0x7); // Assume 3 bits for now? Leaves 2 bits spare
73 
74  LogDebug("L1T") << "Jet: eta " << jet.hwEta() << " phi " << jet.hwPhi() << " pT " << jet.hwPt() << " qual " << jet.hwQual() << " bx " << bx;
75 
76  jet.setP4( l1t::CaloTools::p4Demux(&jet) );
77 
78  res_->push_back(bx, jet);
79  }
80  }
81 
82  return true;
83  }
84 }
85 }
86 
#define LogDebug(id)
unsigned int getID() const
Definition: Block.h:22
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
Definition: Jet.h:16
int hwEta() const
Definition: L1Candidate.cc:74
int hwQual() const
Definition: L1Candidate.cc:89
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: JetUnpacker.cc:25
void setHwPhi(int phi)
Definition: L1Candidate.cc:54
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:256