test
CMS 3D CMS Logo

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