CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
9  bool
11  {
12 
13  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
14 
15  unsigned int wdPerBX = 6; //should this be configured someplace else?
16  int nBX = int(ceil(block.header().getSize() / 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)
17 
18  // Find the central, first and last BXs
19  int firstBX = -(ceil((double)nBX/2.)-1);
20  int lastBX;
21  if (nBX % 2 == 0) {
22  lastBX = ceil((double)nBX/2.);
23  } else {
24  lastBX = ceil((double)nBX/2.)-1;
25  }
26 
27  auto res_ = static_cast<GTCollections*>(coll)->getExts();
28  res_->setBXRange(firstBX, lastBX);
29 
30  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
31 
32  // Loop over multiple BX and then number of EG cands filling collection
33  int numBX = 0; //positive int to count BX
34  for (int bx=firstBX; bx<=lastBX; bx++){
35 
36  // If this is the first block, instantiate GlobalExt so it is there to fill from mult. blocks
37  if(block.header().getID()==24) {
38 
39  LogDebug("L1T") << "Creating GT External Block for BX =" << bx;
40  GlobalExtBlk tExt = GlobalExtBlk();
41  res_->push_back(bx,tExt);
42 
43  }
44 
45  //fetch from collection
46  GlobalExtBlk ext = res_->at(bx,0);
47 
48  //Determine offset of algorithm bits based on block.ID
49  // ID=24 offset = 0; ID=26 offset=64; ID=28 offset=128=2*64; ID=30 offset=3*64=192
50  int extOffset = ((block.header().getID()-24)/2)*64;
51 
52  for(unsigned int wd=0; wd<wdPerBX; wd++) {
53  uint32_t raw_data = block.payload()[wd+numBX*wdPerBX];
54  LogDebug("L1T") << " payload word " << wd << " 0x" << hex << raw_data;
55 
56  if(wd < 2) {
57  for(unsigned int bt=0; bt<32; bt++) {
58  int val = ((raw_data >> bt) & 0x1);
59  int extBit = bt+wd*32+extOffset;
60  if(val==1) ext.setExternalDecision(extBit,true);
61  }
62  }
63 
64  }
65 
66  // Put the object back into place (Must be better way???)
67  res_->set(bx,0,ext);
68 
69  //ext.print(std::cout);
70  numBX++;
71  }
72 
73  return true;
74  }
75 }
76 }
77 
#define LogDebug(id)
unsigned int getID() const
Definition: Block.h:22
BlockHeader header() const
Definition: Block.h:56
static const unsigned int numBX
Definition: LumiConstants.h:9
std::vector< uint32_t > payload() const
Definition: Block.h:57
DEFINE_L1T_UNPACKER(l1t::stage2::MPUnpacker_0x10010033)
void setExternalDecision(unsigned int bit, bool val)
Set decision bits.
Definition: GlobalExtBlk.cc:52
JetCorrectorParametersCollection coll
Definition: classes.h:10
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
unsigned int getSize() const
Definition: Block.h:23