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;
33  if ( block.amc().getAMCNumber()%2 != 0 )
34  processor = block.amc().getAMCNumber()/2;
35  else
36  processor = 6 + ( block.amc().getAMCNumber()/2 -1);
37 
38 
39  for(int ibx = firstBX; ibx <= lastBX; ibx++)
40  {
41  int ip(0);
42  for(unsigned int iw = 0; iw < block.header().getSize()/nBX; iw += 2)
43  {
44  uint32_t raw_first = payload[ip+(ibx+lastBX)*6];
45  ip++;
46  uint32_t raw_secnd = payload[ip+(ibx+lastBX)*6];
47  ip++;
48  if ( raw_first == 0 )
49  {
50  LogDebug("L1T") << "Raw data is zero";
51  continue;
52  }
53 
55  RegionalMuonRawDigiTranslator::fillRegionalMuonCand(muCand, raw_first, raw_secnd, processor, tftype::bmtf);
56  muCand.setLink(blockId/2);
57 
58  LogDebug("L1T") << "Pt = " << muCand.hwPt() << " eta: " << muCand.hwEta() << " phi: " << muCand.hwPhi();
59  if ( muCand.hwQual() != 0 )
60  {
61  if ( muCand.hwPt() < 6 )
62  std::cout << "Output is: " << std::hex << raw_first <<"\t" << raw_secnd << std::dec << "\tPt: " << muCand.hwPt() << "\teta: " << muCand.hwEta() << "\tphi: " << muCand.hwPhi() <<"\tQual: " << muCand.hwQual() << std::endl << "Wheel is: " << (int) ((raw_secnd >> 20) & 0x3) << std::endl;
63  res->push_back(ibx, muCand);
64  }
65 
66  }//for iw
67  }//for ibx
68 
69  return true;
70  }//unpack
71  }//ns stage2
72 }//ns lt1
73 
#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
tuple cout
Definition: gather_cfg.py:145
void amc(const amc::Header &h)
Definition: Block.h:59
void push_back(int bx, T object)