CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BMTFUnpackerInputs.cc
Go to the documentation of this file.
1 #include "BMTFUnpackerInputs.h"
2 
5 
6 namespace l1t
7 {
8  namespace stage2
9  {
10  void numWheelSectorTrTag(int& wheelNo, int& sectorNo, int& tagSegID, int linkNo, int amcNo)
11  {
12  if (linkNo >= 0 && linkNo < 6)
13  wheelNo = -2;
14  else if (linkNo >= 8 && linkNo < 14)
15  wheelNo = -1;
16  else if (linkNo >= 16 && linkNo < 22)
17  wheelNo = 0;
18  else if (linkNo >= 22 && linkNo < 28)
19  wheelNo = 1;
20  else if ( (linkNo >= 28 && linkNo < 29) || (linkNo >= 32 && linkNo < 36))
21  wheelNo = 2;
22 
23  sectorNo = amcNo;
24 
25  if ( linkNo%2 == 0 )
26  tagSegID = 0;
27  else
28  tagSegID = 1;
29  }
30 
32  {
33  unsigned int blockId = block.header().getID();
34  LogDebug("L1T") << "Block ID: " << blockId << " size: " << block.header().getSize();
35  auto payload = block.payload();
36  int nBX, firstBX, lastBX;
37 
38  nBX = int(ceil(block.header().getSize()/6));
39  getBXRange(nBX, firstBX, lastBX);
40 
41  LogDebug("L1T") << "BX override. Set firstBX = lastBX = 0";
42 
43  L1MuDTChambPhContainer *resPhi;
44  L1MuDTChambThContainer *resThe;
45  resPhi = static_cast<BMTFCollections*>(coll)->getInMuonsPh();
46  resThe = static_cast<BMTFCollections*>(coll)->getInMuonsTh();
47 
50 
51  for(int ibx = firstBX; ibx <= lastBX; ibx++)
52  {
53  uint32_t inputWords[block.header().getSize()/nBX];
54 
55  for(unsigned int iw = 0; iw < block.header().getSize()/nBX; iw++)
56  inputWords[iw] = payload[iw+(ibx+lastBX)*6];
57 
58  int wheel, sector, trTag;
59  numWheelSectorTrTag(wheel, sector, trTag, blockId/2, block.amc().getAMCNumber());
60 
61  int mbPhi[4], mbPhiB[4], mbQual[4], mbBxC[4], mbRPC[4];
62  mbPhiB[2] = 0;
63 
64  for (int iw = 0; iw < 4; iw++)
65  {
66  if ( ((inputWords[iw] & 0x3fffffff) == 0) || (inputWords[iw] == 0x505050bc) )
67  continue;
68  else if ( (inputWords[iw] != 0x505050bc) && (inputWords[iw+2] == 0x505050bc) )
69  continue;
70 
71 
72  if ( ((inputWords[iw] >> 11) & 0x1) == 1 )
73  mbPhi[iw] = ( inputWords[iw] & 0x7FF ) - 2048;
74  else
75  mbPhi[iw] = inputWords[iw] & 0xFFF;
76 
77  if ( iw != 2)
78  {
79  if ( ((inputWords[iw] >> 21) & 0x1) == 1 )
80  mbPhiB[iw] = ( (inputWords[iw] >> 12) & 0x1FF ) - 512;
81  else
82  mbPhiB[iw] = (inputWords[iw] >> 12) & 0x3FF;
83  }
84 
85  mbQual[iw] = (inputWords[iw] >> 22) & 0xF;
86  mbBxC[iw] = (inputWords[iw] >> 30) & 0x3;
87 
88  if (mbQual[iw] == 0)
89  continue;
90 
91  mbRPC[iw] = (inputWords[iw] >> 26) & 0x1;
92  phi_data.push_back( L1MuDTChambPhDigi( ibx, wheel, sector, iw+1, mbPhi[iw], mbPhiB[iw], mbQual[iw], trTag, mbBxC[iw], mbRPC[iw] ) );
93 
94  }//iw
95  int mbEta[3];//, mbEtaBxC;
96  for (int i = 0; i < 3; i++)
97  mbEta[i] = (inputWords[4] >> (i*7 + 1)) & 0xFF;
98 
99  the_data.push_back(L1MuDTChambThDigi( ibx, wheel, sector, 3, mbEta) );
100 
101  resPhi->setContainer(phi_data);
102  resThe->setContainer(the_data);
103 
104  }//ibx
105 
106 
107  return true;
108  }//unpack
109  }//ns2
110 }//ns l1t;
111 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
unsigned int getID() const
Definition: Block.h:22
void getBXRange(int nbx, int &first, int &last)
Definition: Unpacker.cc:12
BlockHeader header() const
Definition: Block.h:56
std::vector< uint32_t > payload() const
Definition: Block.h:57
void numWheelSectorTrTag(int &wheelNo, int &sectorNo, int &tagSegID, int linkNo, int amcNo)
std::vector< L1MuDTChambPhDigi > Phi_Container
std::vector< L1MuDTChambThDigi > The_Container
void setContainer(const The_Container &inputSegments)
JetCorrectorParametersCollection coll
Definition: classes.h:10
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
void setContainer(const Phi_Container &inputSegments)
unsigned int getSize() const
Definition: Block.h:23
void amc(const amc::Header &h)
Definition: Block.h:59