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,0);
31  res2_->setBXRange(0,0);
32 
33  // Initialise frame indices for each data type
34  int unsigned fet = 0;
35  int unsigned fht = 1;
36  int unsigned fjet = 2;
37 
38  // ET / MET(x) / MET (y)
39 
40  uint32_t raw_data = block.payload()[fet];
41 
42  l1t::EtSum et = l1t::EtSum();
43 
44  et.setHwPt( static_cast<int32_t>( uint32_t(raw_data & 0xFFFFFF) << 16 ) >> 16 );
45  //et.setHwPt(raw_data & 0xFFFFF);
46  switch(block.header().getID()){
47  case 1: et.setType(l1t::EtSum::kTotalEt); break;
48  case 3: et.setType(l1t::EtSum::kTotalEtx); break;
49  case 5: et.setType(l1t::EtSum::kTotalEty); break;
50  case 7: et.setType(l1t::EtSum::kTotalEt); break;
51  case 9: et.setType(l1t::EtSum::kTotalEtx); break;
52  case 11: et.setType(l1t::EtSum::kTotalEty); break;
53  default: break;
54  }
55 
56 
57  LogDebug("L1T") << "ET/METx/METy: pT " << et.hwPt();
58 
59  res2_->push_back(0,et);
60 
61 
62  // HT / MHT(x)/ MHT (y)
63 
64  raw_data = block.payload()[fht];
65 
66  l1t::EtSum ht = l1t::EtSum();
67 
68  //ht.setHwPt(raw_data & 0xFFFFF);
69  ht.setHwPt( static_cast<int32_t>( uint32_t(raw_data & 0xFFFFFF) << 16 ) >> 16 );
70  switch(block.header().getID()){
71  case 1: ht.setType(l1t::EtSum::kTotalHt); break;
72  case 3: ht.setType(l1t::EtSum::kTotalHtx); break;
73  case 5: ht.setType(l1t::EtSum::kTotalHty); break;
74  case 7: ht.setType(l1t::EtSum::kTotalHt); break;
75  case 9: ht.setType(l1t::EtSum::kTotalHtx); break;
76  case 11: ht.setType(l1t::EtSum::kTotalHty); break;
77  default: break;
78  }
79 
80  LogDebug("L1T") << "HT/MHTx/MHTy: pT " << ht.hwPt();
81 
82  res2_->push_back(0,ht);
83 
84  // Two jets
85  for (unsigned nJet=0; nJet < 2; nJet++){
86 
87  raw_data = block.payload()[fjet+nJet];
88 
89  if (raw_data == 0)
90  continue;
91 
92  l1t::Jet jet = l1t::Jet();
93 
94  int etasign = 1;
95  if ((block.header().getID() == 7) ||
96  (block.header().getID() == 9) ||
97  (block.header().getID() == 11)) {
98  etasign = -1;
99  }
100 
101  LogDebug("L1") << "block ID=" << block.header().getID() << " etasign=" << etasign;
102 
103  jet.setHwEta(etasign*(raw_data & 0x3F));
104  jet.setHwPhi((raw_data >> 6) & 0x7F);
105  jet.setHwPt((raw_data >> 13) & 0xFFFF);
106 
107  LogDebug("L1T") << "Jet: eta " << jet.hwEta() << " phi " << jet.hwPhi() << " pT " << jet.hwPt() << " qual " << jet.hwQual();
108 
109  //res1_->push_back(0,jet);
110 
111  // Push them back in the right place (for checking sorting)
112 
113  int blockID = block.header().getID();
114  int nPos=0, nNeg=0;
115  for (unsigned i=0; i<res1_->size(0); i++)
116  res1_->at(0,i).hwEta()>0 ? nPos++ : nNeg++;
117 
118  if (nJet==1) res1_->push_back(0,jet);
119  else if (nJet==0) {
120  if (blockID==1) {
121  res1_->push_back(0,jet);
122  }
123  if (blockID==3) {
124  if (nPos==1) res1_->push_back(0,jet);
125  else if (nPos==2) res1_->insert(0,1,jet);
126  }
127  if (blockID==5) {
128  if (nPos==2) res1_->push_back(0,jet);
129  else if (nPos>2) res1_->insert(0,2,jet);
130  }
131  if (blockID==7) {
132  res1_->push_back(0,jet);
133  }
134  if (blockID==9) {
135  if (nNeg==1) res1_->push_back(0,jet);
136  else if (nNeg==2) res1_->insert(0,nPos+1,jet);
137  }
138  if (blockID==11) {
139  if (nNeg==2) res1_->push_back(0,jet);
140  else if (nNeg>2) res1_->insert(0,nPos+2,jet);
141  }
142  }
143 
144  }
145 
146  return true;
147  }
148 }
149 }
150 
#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:22
BlockHeader header() const
Definition: Block.h:56
int hwPhi() const
Definition: L1Candidate.cc:79
std::vector< uint32_t > payload() const
Definition: Block.h:57
void setType(EtSumType type)
Definition: EtSum.cc:32
#define DEFINE_L1T_UNPACKER(type)
Definition: Unpacker.h:31
Definition: Jet.h:13
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:23
void setHwEta(int eta)
Definition: L1Candidate.cc:49