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