CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
l1t::stage2::GlobalAlgBlkUnpacker Class Reference
Inheritance diagram for l1t::stage2::GlobalAlgBlkUnpacker:
l1t::Unpacker

Public Member Functions

virtual bool unpack (const Block &block, UnpackerCollections *coll) override
 

Detailed Description

Definition at line 9 of file GlobalAlgBlkUnpacker.cc.

Member Function Documentation

bool l1t::stage2::GlobalAlgBlkUnpacker::unpack ( const Block block,
UnpackerCollections coll 
)
overridevirtual

Implements l1t::Unpacker.

Definition at line 21 of file GlobalAlgBlkUnpacker.cc.

References coll, l1t::BlockHeader::getID(), l1t::BlockHeader::getSize(), l1t::Block::header(), LogDebug, l1t::Block::payload(), GlobalAlgBlk::setAlgoDecisionFinal(), and GlobalAlgBlk::setFinalOR().

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)->getAlgs();
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 Algorithm Block for BX =" << bx;
49  GlobalAlgBlk talg = GlobalAlgBlk();
50  res_->push_back(bx,talg);
51 
52  }
53 
54  //fetch
55  GlobalAlgBlk alg = res_->at(bx,0);
56 
57  //Determine offset of algorithm bits based on block.ID
58  // ID=0 offset = 0; ID=3 offset=192; ID=5 offset=384=2*192;
59  int algOffset = (block.header().getID()/2)*192;
60 
61  for(unsigned int wd=0; wd<block.header().getSize(); wd++) {
62  uint32_t raw_data = block.payload()[wd];
63  LogDebug("L1T") << " payload word " << wd << " 0x" << hex << raw_data << " offset=" << algOffset;
64 
65  //parse these 32 bits into algorithm bits (perhaps needs a more efficient way of doing this?
66  if(block.header().getID()!=5 || wd<4) {
67  for(unsigned int bt=0; bt<32; bt++) {
68  int val = ((raw_data >> bt) & 0x1);
69  if(val==1) alg.setAlgoDecisionFinal(bt+wd*32+algOffset,true);
70  }
71  } else if(block.header().getID()==5 && wd==4) {
72  //This is the FINOR
73  alg.setFinalOR(raw_data);
74  LogDebug("L1T") << " Packing the FinalOR " << wd << " 0x" << hex << raw_data;
75  }
76  }
77 
78  // Put the object back into place (Must be better way)
79  res_->set(bx,0,alg);
80 
81  //alg.print(std::cout);
82 
83  }
84 
85  return true;
86  }
#define LogDebug(id)
void setFinalOR(int fOR)
Definition: GlobalAlgBlk.h:57
JetCorrectorParametersCollection coll
Definition: classes.h:10
void setAlgoDecisionFinal(int bit, bool val)
Definition: GlobalAlgBlk.cc:98