CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BMTFUnpackerOutput.cc
Go to the documentation of this file.
2 
3 #include "BMTFUnpackerOutput.h"
4 
5 namespace l1t
6 {
7  namespace stage2
8  {
10  {
11  unsigned int blockId = block.header().getID();
12  LogDebug("L1T") << "Block ID: " << blockId << " size: " << block.header().getSize();
13 
14  auto payload = block.payload();
15 
16  //int nwords(2); //two words per muon
17  int nBX, firstBX, lastBX;
18  nBX = int(ceil(block.header().getSize()/6));
19 
20  getBXRange(nBX, firstBX, lastBX);
21  //if we want to use central BX, uncommect the two lines below
22  //firstBX=0;
23  //lastBX=0;
24  //LogDebug("L1T") << "BX override. Set firstBX = lastBX = 0";
25 
27  res = static_cast<BMTFCollections*>(coll)->getBMTFMuons();
28  res->setBXRange(firstBX, lastBX);
29 
30  LogDebug("L1T") << "nBX = " << nBX << " firstBX = " << firstBX << " lastBX = " << lastBX;
31 
32  int processor = block.amc().getBoardID() - 1;
33  if ( processor < 0 || processor > 11 )
34  {
35  edm::LogInfo ("l1t:stage2::BMTFUnpackerOutput::unpack") << "Processor found out of range so it will be calculated by the old way";
36  if ( block.amc().getAMCNumber()%2 != 0 )
37  processor = block.amc().getAMCNumber()/2 ;
38  else
39  processor = 6 + (block.amc().getAMCNumber()/2 -1);
40  }
41 
42  for(int ibx = firstBX; ibx <= lastBX; ibx++)
43  {
44  int ip(0);
45  for(unsigned int iw = 0; iw < block.header().getSize()/nBX; iw += 2)
46  {
47  uint32_t raw_first = payload[ip+(ibx+lastBX)*6];
48  ip++;
49  uint32_t raw_secnd = payload[ip+(ibx+lastBX)*6];
50  ip++;
51  if ( raw_first == 0 )
52  {
53  LogDebug("L1T") << "Raw data is zero";
54  continue;
55  }
56 
58  RegionalMuonRawDigiTranslator::fillRegionalMuonCand(muCand, raw_first, raw_secnd, processor, tftype::bmtf);
59  muCand.setLink(blockId/2);
60 
61  LogDebug("L1T") << "Pt = " << muCand.hwPt() << " eta: " << muCand.hwEta() << " phi: " << muCand.hwPhi();
62  if ( muCand.hwQual() != 0 )
63  {
64  res->push_back(ibx, muCand);
65  }
66 
67  }//for iw
68  }//for ibx
69 
70  return true;
71  }//unpack
72  }//ns stage2
73 }//ns lt1
74 
#define LogDebug(id)
void setLink(int link)
unsigned int getID() const
Definition: Block.h:22
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
void getBXRange(int nbx, int &first, int &last)
Definition: Unpacker.cc:14
BlockHeader header() const
Definition: Block.h:56
std::vector< uint32_t > payload() const
Definition: Block.h:57
const int hwQual() const
Get quality code.
const int hwEta() const
Get compressed eta (returned int * 0.010875 = eta)
const int hwPhi() const
Get compressed local phi (returned int * 2*pi/576 = local phi in rad)
JetCorrectorParametersCollection coll
Definition: classes.h:10
static void fillRegionalMuonCand(RegionalMuonCand &, uint32_t, uint32_t, int, tftype)
void setBXRange(int bxFirst, int bxLast)
const int hwPt() const
Get compressed pT (returned int * 0.5 = pT (GeV))
unsigned int getSize() const
Definition: Block.h:23
void amc(const amc::Header &h)
Definition: Block.h:59
void push_back(int bx, T object)