CMS 3D CMS Logo

BMTFUnpackerInputs.cc
Go to the documentation of this file.
2 
3 #include "BMTFUnpackerInputs.h"
4 
7 
8 namespace l1t {
9  namespace stage2 {
10  void numWheelSectorTrTag_bmtf(int& wheelNo, int& tagSegID, int linkNo, int amcNo) {
11  if (linkNo >= 0 && linkNo < 6)
12  wheelNo = -2;
13  else if (linkNo >= 8 && linkNo < 14)
14  wheelNo = -1;
15  else if (linkNo >= 16 && linkNo < 22)
16  wheelNo = 0;
17  else if (linkNo >= 22 && linkNo < 28)
18  wheelNo = 1;
19  else if ((linkNo >= 28 && linkNo < 30) || (linkNo >= 32 && linkNo < 36))
20  wheelNo = 2;
21 
22  if (linkNo % 2 == 0)
23  tagSegID = 0;
24  else
25  tagSegID = 1;
26  }
27 
28  bool checkQual_bmtf(const unsigned int& value, const bool& isNewFw) {
29  if (isNewFw)
30  return (value == 7);
31  else
32  return (value == 0);
33  }
34 
35  bool unpacking_bmtf(const Block& block, UnpackerCollections* coll, qualityHits& linkAndQual_, const bool& isNewFw) {
36  unsigned int ownLinks[] = {4, 5, 12, 13, 20, 21, 22, 23, 28, 29};
37  bool ownFlag(false);
38 
39  //Checks if the given block coresponds to 1 of the OWN links
40  for (int i = 0; i < 10; i++) {
41  if (block.header().getID() / 2 == ownLinks[i])
42  ownFlag = true;
43  }
44  if (!ownFlag) //if not returns that the "job here done"
45  return true;
46 
47  //Get header ID and payload from the given Block
48  unsigned int blockId = block.header().getID();
49  LogDebug("L1T") << "Block ID: " << blockId << " size: " << block.header().getSize();
50 
51  //Make output CMSSW collections
52  L1MuDTChambPhContainer* resPhi = static_cast<BMTFCollections*>(coll)->getInMuonsPh();
53  L1MuDTChambThContainer* resThe = static_cast<BMTFCollections*>(coll)->getInMuonsTh();
54 
55  //Get input phi & eta Containers
58 
59  //ZeroSuppresion Handler
60  BxBlocks bxBlocks;
61  bool ZS_enabled =
62  (bool)((block.header().getFlags() >> 1) & 0x01); //getFlags() returns first 8-bits from the amc header
63  if (ZS_enabled)
64  bxBlocks =
65  block.getBxBlocks((unsigned int)6, true); //it returnes 7-32bit bxBlocks originated from the amc13 Block
66  else
67  bxBlocks =
68  block.getBxBlocks((unsigned int)6, false); //it returnes 6-32bit bxBlocks originated from the amc13 Block
69 
70  for (auto ibx : bxBlocks) //Bx iteration
71  {
72  int bxNum = ibx.header().getBx();
73  uint32_t inputWords[ibx.getSize()]; //array of 6 uint32_t payload-words (size of the payload in the BxBlock)
74 
75  //Note
76  /*In the non-ZS fashion, the expression "block.header().getSize()/nBX" was 6 in any case
77  the reason is that the size is 6 or 30, and these numbers are divided by 1 or 5 respectively.*/
78 
79  //Fill the above uint32_t array
80  for (unsigned int iw = 0; iw < ibx.getSize(); iw++)
81  inputWords[iw] = (ibx.payload())[iw];
82 
83  int wheel, sector, trTag; //Container information
84  numWheelSectorTrTag_bmtf(wheel, trTag, blockId / 2, block.amc().getAMCNumber()); //this returns wheel & tsTag
85  sector = block.amc().getBoardID() - 1;
86 
87  //Check if the sector is "out of range" - (trys then to use AMC13 information?)
88  if (sector < 0 || sector > 11) {
89  edm::LogInfo("l1t:stage2::BMTFUnpackerInputs::unpack")
90  << "Sector found out of range so it will be calculated by the slot number";
91  if (block.amc().getAMCNumber() % 2 != 0)
92  sector = block.amc().getAMCNumber() / 2;
93  else
94  sector = 6 + (block.amc().getAMCNumber() / 2 - 1);
95  }
96 
97  int mbPhi[4], mbPhiB[4], mbQual[4], mbBxC[4], mbRPC[4]; //Container information
98  //mbPhiB[2] = 0;
99 
100  for (int iw = 0; iw < 4; iw++) // 4 phi (32-bit) words
101  {
102  if (((inputWords[iw] & 0xfffffff) == 0) || (inputWords[iw] == 0x505050bc))
103  continue;
104  else if ((inputWords[iw] != 0x505050bc) && (inputWords[iw + 2] == 0x505050bc))
105  continue;
106 
107  if (((inputWords[iw] >> 11) & 0x1) == 1)
108  mbPhi[iw] = (inputWords[iw] & 0x7FF) - 2048;
109  else
110  mbPhi[iw] = (inputWords[iw] & 0xFFF);
111 
112  if (((inputWords[iw] >> 21) & 0x1) == 1)
113  mbPhiB[iw] = ((inputWords[iw] >> 12) & 0x1FF) - 512;
114  else
115  mbPhiB[iw] = (inputWords[iw] >> 12) & 0x3FF;
116 
117  mbQual[iw] = (inputWords[iw] >> 22) & 0x7;
118  mbRPC[iw] = (inputWords[iw] >> 26) & 0x1;
119  mbBxC[iw] = (inputWords[iw] >> 30) & 0x3;
120 
121  //if (mbQual[iw] == 0)
122  if (checkQual_bmtf(mbQual[iw], isNewFw))
123  continue;
124 
125  phiData.push_back(L1MuDTChambPhDigi(
126  bxNum, wheel, sector, iw + 1, mbPhi[iw], mbPhiB[iw], mbQual[iw], trTag, mbBxC[iw], mbRPC[iw]));
127 
128  } //4 phi words
129 
130  int etaHits[3][7]; //Container information
131  bool zeroFlag[3];
132  for (int i = 0; i < 3; i++) // 3 eta (7-bit) words
133  {
134  zeroFlag[i] = false;
135  for (int j = 0; j < 7; j++) {
136  etaHits[i][j] = (inputWords[4] >> (i * 7 + j)) & 0x1;
137  if (etaHits[i][j] != 0)
138  zeroFlag[i] = true;
139  }
140  } //3 eta words
141 
142  if (trTag == 1) {
143  for (int i = 0; i < 3; i++) {
144  if (zeroFlag[i])
145  theData.push_back(L1MuDTChambThDigi(bxNum, wheel, sector, i + 1, etaHits[i], linkAndQual_.hits[i]));
146  }
147 
148  } else {
149  /*
150  qualityHits temp;
151  temp.linkNo = blockId/2;
152  std::copy(&etaHits[0][0], &etaHits[0][0]+3*7,&temp.hits[0][0]);
153  linkAndQual_[blockId/2] = temp;
154  */
155  linkAndQual_.linkNo = blockId / 2;
156  std::copy(&etaHits[0][0], &etaHits[0][0] + 3 * 7, &linkAndQual_.hits[0][0]);
157  }
158 
159  } //iBxBlock
160 
161  //Fill Containers
162  resThe->setContainer(theData);
163  resPhi->setContainer(phiData);
164 
165  return true;
166  }
167 
169  return unpacking_bmtf(block, coll, linkAndQual_, false);
170  } //unpack old quality
171 
173  return unpacking_bmtf(block, coll, linkAndQual_, true);
174  } //unpack new quality
175  } // namespace stage2
176 } // namespace l1t
177 
l1t::stage2::checkQual_bmtf
bool checkQual_bmtf(const unsigned int &value, const bool &isNewFw)
Definition: BMTFUnpackerInputs.cc:28
BMTFUnpackerInputs.h
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
l1t::stage2::BMTFUnpackerInputsOldQual::linkAndQual_
qualityHits linkAndQual_
Definition: BMTFUnpackerInputs.h:17
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
edm::LogInfo
Definition: MessageLogger.h:254
l1t::stage2::qualityHits
Definition: BMTFUnpackerInputs.h:8
l1t::stage2::BMTFUnpackerInputsNewQual::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: BMTFUnpackerInputs.cc:172
L1MuDTChambThContainer.h
L1MuDTChambPhContainer
Definition: L1MuDTChambPhContainer.h:33
L1MuDTChambPhContainer::getContainer
Phi_Container const * getContainer() const
Definition: L1MuDTChambPhContainer.cc:41
l1t::stage2::qualityHits::hits
int hits[3][7]
Definition: BMTFUnpackerInputs.h:10
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
L1MuDTChambThContainer::setContainer
void setContainer(The_Container inputSegments)
Definition: L1MuDTChambThContainer.cc:39
L1MuDTChambPhContainer::setContainer
void setContainer(Phi_Container inputSegments)
Definition: L1MuDTChambPhContainer.cc:39
UnpackerFactory.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
l1t::stage2::unpacking_bmtf
bool unpacking_bmtf(const Block &block, UnpackerCollections *coll, qualityHits &linkAndQual_, const bool &isNewFw)
Definition: BMTFUnpackerInputs.cc:35
l1t
delete x;
Definition: CaloConfig.h:22
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
L1MuDTChambThContainer::getContainer
The_Container const * getContainer() const
Definition: L1MuDTChambThContainer.cc:41
value
Definition: value.py:1
l1t::stage2::BMTFUnpackerInputsNewQual::linkAndQual_
qualityHits linkAndQual_
Definition: BMTFUnpackerInputs.h:26
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
L1MuDTChambPhContainer.h
SiStripSourceConfigTier0_cff.stage2
stage2
Definition: SiStripSourceConfigTier0_cff.py:71
L1MuDTChambThContainer::The_Container
std::vector< L1MuDTChambThDigi > The_Container
Definition: L1MuDTChambThContainer.h:35
l1t::stage2::BMTFUnpackerInputsNewQual
Definition: BMTFUnpackerInputs.h:21
L1MuDTChambThDigi
Definition: L1MuDTChambThDigi.h:33
L1MuDTChambPhContainer::Phi_Container
std::vector< L1MuDTChambPhDigi > Phi_Container
Definition: L1MuDTChambPhContainer.h:35
l1t::stage2::BMTFUnpackerInputsOldQual::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: BMTFUnpackerInputs.cc:168
l1t::UnpackerCollections
Definition: UnpackerCollections.h:9
l1t::stage2::qualityHits::linkNo
int linkNo
Definition: BMTFUnpackerInputs.h:9
DEFINE_L1T_UNPACKER
#define DEFINE_L1T_UNPACKER(type)
Definition: UnpackerFactory.h:23
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
l1t::stage2::numWheelSectorTrTag_bmtf
void numWheelSectorTrTag_bmtf(int &wheelNo, int &tagSegID, int linkNo, int amcNo)
Definition: BMTFUnpackerInputs.cc:10
l1t::Block
Definition: Block.h:54
L1MuDTChambThContainer
Definition: L1MuDTChambThContainer.h:33
L1MuDTChambPhDigi
Definition: L1MuDTChambPhDigi.h:31
l1t::BxBlocks
std::vector< BxBlock > BxBlocks
Definition: BxBlock.h:79
l1t::stage2::BMTFUnpackerInputsOldQual
Definition: BMTFUnpackerInputs.h:12