CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MPUnpacker.cc
Go to the documentation of this file.
1 #define EDM_ML_DEBUG 1
2 
4 
6 
7 #include "CaloCollections.h"
8 
9 namespace l1t {
10  namespace stage2 {
11  class MPUnpacker : public Unpacker {
12  public:
13  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
14  };
15  }
16 }
17 
18 // Implementation
19 
20 namespace l1t {
21 namespace stage2 {
22  bool
24  {
25 
26  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
27 
28  auto res1_ = static_cast<CaloCollections*>(coll)->getMPJets();
29  auto res2_ = static_cast<CaloCollections*>(coll)->getMPEtSums();
30  res1_->setBXRange(0,1);
31  res2_->setBXRange(0,1);
32 
33  // Initialise index
34  int unsigned i = 0;
35 
36  // ET / MET(x) / MET (y)
37 
38  uint32_t raw_data = block.payload()[i++];
39 
40  l1t::EtSum et = l1t::EtSum();
41 
42  et.setHwPt(raw_data & 0xFFFFF);
44 
45  LogDebug("L1T") << "ET/METx/METy: pT " << et.hwPt();
46 
47  res2_->push_back(0,et);
48 
49  // Skip 9 empty frames
50  for (int j=0; j<9; j++) raw_data=block.payload()[i++];
51 
52  // HT / MHT(x)/ MHT (y)
53 
54  raw_data = block.payload()[i++];
55 
56  l1t::EtSum ht = l1t::EtSum();
57 
58  ht.setHwPt(raw_data & 0xFFFFF);
60 
61  LogDebug("L1T") << "HT/MHTx/MHTy: pT " << ht.hwPt();
62 
63  res2_->push_back(0,ht);
64 
65  // Skip 26 empty frames
66  for (int j=0; j<26; j++) raw_data=block.payload()[i++];
67 
68  // Two jets
69  for (unsigned nJet=0; nJet < 2; nJet++){
70  raw_data = block.payload()[i++];
71 
72  if (raw_data == 0)
73  continue;
74 
75  l1t::Jet jet = l1t::Jet();
76 
77  int etasign = 1;
78  if ((block.header().getID() == 7) ||
79  (block.header().getID() == 9) ||
80  (block.header().getID() == 11)) {
81  etasign = -1;
82  }
83 
84  LogDebug("L1") << "block ID=" << block.header().getID() << " etasign=" << block.header().getSize();
85 
86  jet.setHwEta(etasign*(raw_data & 0x3F));
87  jet.setHwPhi((raw_data >> 6) & 0x7F);
88  jet.setHwPt((raw_data >> 13) & 0xFFFF);
89 
90  LogDebug("L1T") << "Jet: eta " << jet.hwEta() << " phi " << jet.hwPhi() << " pT " << jet.hwPt() << " qual " << jet.hwQual();
91 
92  res1_->push_back(0,jet);
93  }
94 
95  return true;
96  }
97 }
98 }
99 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: MPUnpacker.cc:23
unsigned int getID() const
Definition: Block.h:14
BlockHeader header() const
Definition: Block.h:37
int hwPhi() const
Definition: L1Candidate.cc:79
std::vector< uint32_t > payload() const
Definition: Block.h:38
void setType(EtSumType type)
Definition: EtSum.cc:32
#define DEFINE_L1T_UNPACKER(type)
Definition: Unpacker.h:29
Definition: Jet.h:13
int j
Definition: DBlmapReader.cc:9
int hwEta() const
Definition: L1Candidate.cc:74
int hwQual() const
Definition: L1Candidate.cc:89
void setHwPhi(int phi)
Definition: L1Candidate.cc:54
JetCorrectorParametersCollection coll
Definition: classes.h:10
int hwPt() const
Definition: L1Candidate.cc:69
void setHwPt(int pt)
Definition: L1Candidate.cc:44
unsigned int getSize() const
Definition: Block.h:15
void setHwEta(int eta)
Definition: L1Candidate.cc:49