CMS 3D CMS Logo

IntermediateMuonUnpacker.cc
Go to the documentation of this file.
4 
6 
7 #include "GMTCollections.h"
9 
10 namespace l1t {
11  namespace stage2 {
13  {
14  }
15 
16  bool
18  {
19  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
20 
21  auto payload = block.payload();
22 
23  const unsigned int nWords = 6; // every link transmits 6 words (3 muons) per bx
24  int nBX, firstBX, lastBX;
25  nBX = int(ceil(block.header().getSize() / nWords));
26  getBXRange(nBX, firstBX, lastBX);
27 
28  // decide which collections to use according to the link ID
29  unsigned int linkId = (block.header().getID() - 1) / 2;
30  unsigned int coll1Cnt = 0;
31  MuonBxCollection* res1;
32  MuonBxCollection* res2;
33  // Intermediate muons come on uGMT output links 24-31.
34  // Each link can transmit 3 muons and we receive 4 intermediate muons from
35  // EMTF/OMTF on each detector side and 8 intermediate muons from BMTF.
36  // Therefore, the muon at a certain position on a link has to be filled
37  // in a specific collection. The order is from links 24-31:
38  // 4 muons from EMTF pos, 4 from OMTF pos, 8 from BMTF, 4 from OMTF neg,
39  // and 4 from EMTF neg.
40  switch (linkId) {
41  case 24:
42  res1 = static_cast<GMTCollections*>(coll)->getImdMuonsEMTFPos();
43  res2 = static_cast<GMTCollections*>(coll)->getImdMuonsEMTFPos();
44  coll1Cnt = 3;
45  break;
46  case 25:
47  res1 = static_cast<GMTCollections*>(coll)->getImdMuonsEMTFPos();
48  res2 = static_cast<GMTCollections*>(coll)->getImdMuonsOMTFPos();
49  coll1Cnt = 1;
50  break;
51  case 26:
52  res1 = static_cast<GMTCollections*>(coll)->getImdMuonsOMTFPos();
53  res2 = static_cast<GMTCollections*>(coll)->getImdMuonsBMTF();
54  coll1Cnt = 2;
55  break;
56  case 27:
57  res1 = static_cast<GMTCollections*>(coll)->getImdMuonsBMTF();
58  res2 = static_cast<GMTCollections*>(coll)->getImdMuonsBMTF();
59  coll1Cnt = 3;
60  break;
61  case 28:
62  res1 = static_cast<GMTCollections*>(coll)->getImdMuonsBMTF();
63  res2 = static_cast<GMTCollections*>(coll)->getImdMuonsBMTF();
64  coll1Cnt = 3;
65  break;
66  case 29:
67  res1 = static_cast<GMTCollections*>(coll)->getImdMuonsBMTF();
68  res2 = static_cast<GMTCollections*>(coll)->getImdMuonsOMTFNeg();
69  coll1Cnt = 1;
70  break;
71  case 30:
72  res1 = static_cast<GMTCollections*>(coll)->getImdMuonsOMTFNeg();
73  res2 = static_cast<GMTCollections*>(coll)->getImdMuonsEMTFNeg();
74  coll1Cnt = 2;
75  break;
76  case 31:
77  res1 = static_cast<GMTCollections*>(coll)->getImdMuonsEMTFNeg();
78  res2 = static_cast<GMTCollections*>(coll)->getImdMuonsEMTFNeg();
79  coll1Cnt = 3;
80  break;
81  default:
82  edm::LogWarning("L1T") << "Block ID " << block.header().getID() << " not associated with intermediate muons. Skip.";
83  return false;
84  }
85  res1->setBXRange(firstBX, lastBX);
86  res2->setBXRange(firstBX, lastBX);
87 
88  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
89 
90  // Initialise indices
91  unsigned int i = 0;
92 
93  // Loop over multiple BX and then number of muons filling muon collection
94  for (int bx = firstBX; bx <= lastBX; ++bx) {
95  unsigned int muonCnt = 0;
96  for (unsigned nWord = 0; nWord < nWords && i < block.header().getSize(); nWord += 2, ++muonCnt) {
97  uint32_t raw_data_00_31 = payload[i++];
98  uint32_t raw_data_32_63 = payload[i++];
99  LogDebug("L1T") << "raw_data_00_31 = 0x" << hex << raw_data_00_31 << " raw_data_32_63 = 0x" << raw_data_32_63;
100  // skip empty muons (hwPt == 0)
102  LogDebug("L1T") << "Muon hwPt zero. Skip.";
103  continue;
104  }
105 
106  Muon mu;
107 
108  // The intermediate muons do not have coordinates estimated at the vertex in the RAW data
109  // The corresponding bits are set to zero
110  MuonRawDigiTranslator::fillMuon(mu, raw_data_00_31, raw_data_32_63, 1402, algoVersion_);
111 
112  LogDebug("L1T") << "Mu" << nWord/2 << ": eta " << mu.hwEta() << " phi " << mu.hwPhi() << " pT " << mu.hwPt() << " iso " << mu.hwIso() << " qual " << mu.hwQual() << " charge " << mu.hwCharge() << " charge valid " << mu.hwChargeValid();
113 
114  if (muonCnt < coll1Cnt) {
115  res1->push_back(bx, mu);
116  } else {
117  res2->push_back(bx, mu);
118  }
119  }
120  }
121  return true;
122  }
123  }
124 }
125 
#define LogDebug(id)
unsigned int getID() const
Definition: Block.h:22
void getBXRange(int nbx, int &first, int &last)
BlockHeader header() const
Definition: Block.h:60
int hwPhi() const
Definition: L1Candidate.h:50
delete x;
Definition: CaloConfig.h:22
std::vector< uint32_t > payload() const
Definition: Block.h:61
int hwIso() const
Definition: L1Candidate.h:52
payload
payload postfix for testing
Definition: Muon.py:1
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
const int mu
Definition: Constants.h:22
int hwEta() const
Definition: L1Candidate.h:49
int hwQual() const
Definition: L1Candidate.h:51
JetCorrectorParametersCollection coll
Definition: classes.h:10
int hwPt() const
Definition: L1Candidate.h:48
static const unsigned ptShift_
void setBXRange(int bxFirst, int bxLast)
#define DEFINE_L1T_UNPACKER(type)
unsigned int getSize() const
Definition: Block.h:23
int hwChargeValid() const
Definition: Muon.h:83
void push_back(int bx, T object)
int hwCharge() const
Definition: Muon.h:82
static const unsigned ptMask_
static void fillMuon(Muon &, uint32_t, uint32_t, int, unsigned int)