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  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)
27 
28  // Find the central, first and last BXs
29  int firstBX = -(ceil((double)nBX/2.)-1);
30  int lastBX;
31  if (nBX % 2 == 0) {
32  lastBX = ceil((double)nBX/2.);
33  } else {
34  lastBX = ceil((double)nBX/2.)-1;
35  }
36 
37  auto res_ = static_cast<GTCollections*>(coll)->getExts();
38  res_->setBXRange(firstBX, lastBX);
39 
40  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
41 
42  // Loop over multiple BX and then number of EG cands filling collection
43  for (int bx=firstBX; bx<=lastBX; bx++){
44 
45  // If this is the first block, instantiate GlobalAlg so it is there to fill from mult. blocks
46  if(block.header().getID()==1) {
47 
48  LogDebug("L1T") << "Creating GT External Block for BX =" << bx;
49  GlobalExtBlk tExt = GlobalExtBlk();
50  res_->push_back(bx,tExt);
51 
52  }
53 
54  //fetch from collection
55  GlobalExtBlk ext = res_->at(bx,0);
56 
57  for(unsigned int wd=0; wd<block.header().getSize(); wd++) {
58  uint32_t raw_data = block.payload()[wd];
59  LogDebug("L1T") << " payload word " << wd << " 0x" << hex << raw_data;
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 
67  }
68 
69  return true;
70  }
71 }
72 }
73 
#define LogDebug(id)
unsigned int getID() const
Definition: Block.h:22
BlockHeader header() const
Definition: Block.h:56
std::vector< uint32_t > payload() const
Definition: Block.h:57
#define DEFINE_L1T_UNPACKER(type)
Definition: Unpacker.h:31
JetCorrectorParametersCollection coll
Definition: classes.h:10
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
unsigned int getSize() const
Definition: Block.h:23