CMS 3D CMS Logo

GlobalExtBlkUnpacker.cc
Go to the documentation of this file.
3 
4 #include "GTCollections.h"
5 #include "GlobalExtBlkUnpacker.h"
6 
7 namespace l1t {
8  namespace stage2 {
10  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
11 
12  unsigned int wdPerBX = 6; //should this be configured someplace else?
13  int nBX = int(ceil(
14  block.header().getSize() /
15  6.)); // FOR GT Not sure what we have here...put at 6 because of 6 frames. Since there are 12 EGamma objects reported per event (see CMS IN-2013/005)
16 
17  // Find the central, first and last BXs
18  int firstBX = -(ceil((double)nBX / 2.) - 1);
19  int lastBX;
20  if (nBX % 2 == 0) {
21  lastBX = ceil((double)nBX / 2.);
22  } else {
23  lastBX = ceil((double)nBX / 2.) - 1;
24  }
25 
26  auto res_ = static_cast<GTCollections*>(coll)->getExts();
27  res_->setBXRange(firstBX, lastBX);
28 
29  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
30 
31  // Loop over multiple BX and then number of EG cands filling collection
32  int numBX = 0; //positive int to count BX
33  for (int bx = firstBX; bx <= lastBX; bx++) {
34  // If this is the first block, instantiate GlobalExt so it is there to fill from mult. blocks
35  if (block.header().getID() == 24) {
36  LogDebug("L1T") << "Creating GT External Block for BX =" << bx;
37  GlobalExtBlk tExt = GlobalExtBlk();
38  res_->push_back(bx, tExt);
39  }
40 
41  //fetch from collection
42  GlobalExtBlk ext = res_->at(bx, 0);
43 
44  //Determine offset of algorithm bits based on block.ID
45  // ID=24 offset = 0; ID=26 offset=64; ID=28 offset=128=2*64; ID=30 offset=3*64=192
46  int extOffset = ((block.header().getID() - 24) / 2) * 64;
47 
48  for (unsigned int wd = 0; wd < wdPerBX; wd++) {
49  uint32_t raw_data = block.payload()[wd + numBX * wdPerBX];
50  LogDebug("L1T") << " payload word " << wd << " 0x" << hex << raw_data;
51 
52  if (wd < 2) {
53  for (unsigned int bt = 0; bt < 32; bt++) {
54  int val = ((raw_data >> bt) & 0x1);
55  int extBit = bt + wd * 32 + extOffset;
56  if (val == 1)
57  ext.setExternalDecision(extBit, true);
58  }
59  }
60  }
61 
62  // Put the object back into place (Must be better way???)
63  res_->set(bx, 0, ext);
64 
65  //ext.print(std::cout);
66  numBX++;
67  }
68 
69  return true;
70  }
71  } // namespace stage2
72 } // namespace l1t
73 
#define LogDebug(id)
const std::vector< uint32_t > & payload() const
Definition: Block.h:70
unsigned int getID() const
Definition: Block.h:27
BlockHeader header() const
Definition: Block.h:69
static const unsigned int numBX
Definition: LumiConstants.h:8
delete x;
Definition: CaloConfig.h:22
constexpr int32_t ceil(float num)
void setExternalDecision(unsigned int bit, bool val)
Set decision bits.
Definition: GlobalExtBlk.cc:40
JetCorrectorParametersCollection coll
Definition: classes.h:10
bool unpack(const Block &block, UnpackerCollections *coll) override
#define DEFINE_L1T_UNPACKER(type)
unsigned int getSize() const
Definition: Block.h:28
Definition: memstream.h:15