CMS 3D CMS Logo

EMTFBlockSP.cc
Go to the documentation of this file.
1 // Code to unpack the "SP Output Data Record"
2 
4 
5 #include "EMTFCollections.h"
6 #include "EMTFUnpackerTools.h"
7 
8 // This is the "header" - no EMTFBlockSP.h file is needed
9 namespace l1t {
10  namespace stage2 {
11  namespace emtf {
12 
13  class SPBlockUnpacker : public Unpacker { // "SPBlockUnpacker" inherits from "Unpacker"
14  public:
15  virtual int checkFormat(const Block& block);
16  bool unpack(const Block& block,
17  UnpackerCollections* coll) override; // Apparently it's always good to use override in C++
18  // virtual bool packBlock(const Block& block, UnpackerCollections *coll) override;
19  };
20 
21  // class SPBlockPacker : public Packer { // "SPBlockPacker" inherits from "Packer"
22  // public:
23  // virtual bool unpack(const Block& block, UnpackerCollections *coll) override; // Apparently it's always good to use override in C++
24  // };
25 
26  } // namespace emtf
27  } // namespace stage2
28 } // namespace l1t
29 
30 namespace l1t {
31  namespace stage2 {
32  namespace emtf {
33 
35  auto payload = block.payload();
36  int errors = 0;
37 
38  // Check the number of 16-bit words
39  if (payload.size() != 8) {
40  errors += 1;
41  edm::LogError("L1T|EMTF") << "Payload size in 'SP Output Data Record' is different than expected";
42  }
43 
44  // Check that each word is 16 bits
45  for (unsigned int i = 0; i < 8; i++) {
46  if (GetHexBits(payload[i], 16, 31) != 0) {
47  errors += 1;
48  edm::LogError("L1T|EMTF") << "Payload[" << i << "] has more than 16 bits in 'SP Output Data Record'";
49  }
50  }
51 
52  uint16_t SP1a = payload[0];
53  uint16_t SP1b = payload[1];
54  uint16_t SP1c = payload[2];
55  uint16_t SP1d = payload[3];
56  uint16_t SP2a = payload[4];
57  uint16_t SP2b = payload[5];
58  uint16_t SP2c = payload[6];
59  uint16_t SP2d = payload[7];
60 
61  // Check Format
62  if (GetHexBits(SP1a, 15, 15) != 1) {
63  errors += 1;
64  edm::LogError("L1T|EMTF") << "Format identifier bits in SP1a are incorrect";
65  }
66  if (GetHexBits(SP1b, 15, 15) != 0) {
67  errors += 1;
68  edm::LogError("L1T|EMTF") << "Format identifier bits in SP1b are incorrect";
69  }
70  if (GetHexBits(SP1c, 15, 15) != 1) {
71  errors += 1;
72  edm::LogError("L1T|EMTF") << "Format identifier bits in SP1c are incorrect";
73  }
74  if (GetHexBits(SP1d, 15, 15) != 0) {
75  errors += 1;
76  edm::LogError("L1T|EMTF") << "Format identifier bits in SP1d are incorrect";
77  }
78  if (GetHexBits(SP2a, 15, 15) != 0) {
79  errors += 1;
80  edm::LogError("L1T|EMTF") << "Format identifier bits in SP2a are incorrect";
81  }
82  if (GetHexBits(SP2b, 15, 15) != 1) {
83  errors += 1;
84  edm::LogError("L1T|EMTF") << "Format identifier bits in SP2b are incorrect";
85  }
86  if (GetHexBits(SP2c, 15, 15) != 1) {
87  errors += 1;
88  edm::LogError("L1T|EMTF") << "Format identifier bits in SP2c are incorrect";
89  }
90  if (GetHexBits(SP2d, 15, 15) != 0) {
91  errors += 1;
92  edm::LogError("L1T|EMTF") << "Format identifier bits in SP2d are incorrect";
93  }
94 
95  return errors;
96  }
97 
98  // Converts CSC_ID, sector, subsector, and neighbor
99  std::vector<int> convert_SP_location(int _csc_ID, int _sector, int _subsector, int _station) {
100  int new_sector = _sector;
101  if (_station == 1) {
102  if (_csc_ID < 0) {
103  int arr[] = {_csc_ID, -99, -99, -99};
104  std::vector<int> vec(arr, arr + 4);
105  return vec;
106  } else if (_csc_ID == 0) {
107  int arr[] = {-1, -1, -1, -1};
108  std::vector<int> vec(arr, arr + 4);
109  return vec;
110  } else if (_csc_ID <= 9) {
111  int arr[] = {_csc_ID, new_sector, _subsector + 1, 0};
112  std::vector<int> vec(arr, arr + 4);
113  return vec;
114  } else
115  new_sector = (_sector != 1) ? _sector - 1 : 6;
116 
117  if (_csc_ID == 10) {
118  int arr[] = {3, new_sector, 2, 1};
119  std::vector<int> vec(arr, arr + 4);
120  return vec;
121  } else if (_csc_ID == 11) {
122  int arr[] = {6, new_sector, 2, 1};
123  std::vector<int> vec(arr, arr + 4);
124  return vec;
125  } else if (_csc_ID == 12) {
126  int arr[] = {9, new_sector, 2, 1};
127  std::vector<int> vec(arr, arr + 4);
128  return vec;
129  } else {
130  int arr[] = {_csc_ID, -99, -99, -99};
131  std::vector<int> vec(arr, arr + 4);
132  return vec;
133  }
134  } else if (_station == 2 || _station == 3 || _station == 4) {
135  if (_csc_ID < 0) {
136  int arr[] = {_csc_ID, -99, -99, -99};
137  std::vector<int> vec(arr, arr + 4);
138  return vec;
139  } else if (_csc_ID == 0) {
140  int arr[] = {-1, -1, -1, -1};
141  std::vector<int> vec(arr, arr + 4);
142  return vec;
143  } else if (_csc_ID <= 9) {
144  int arr[] = {_csc_ID, new_sector, -1, 0};
145  std::vector<int> vec(arr, arr + 4);
146  return vec;
147  } else
148  new_sector = (_sector != 1) ? _sector - 1 : 6;
149 
150  if (_csc_ID == 10) {
151  int arr[] = {3, new_sector, -1, 1};
152  std::vector<int> vec(arr, arr + 4);
153  return vec;
154  } else if (_csc_ID == 11) {
155  int arr[] = {9, new_sector, -1, 1};
156  std::vector<int> vec(arr, arr + 4);
157  return vec;
158  } else {
159  int arr[] = {_csc_ID, -99, -99, -99};
160  std::vector<int> vec(arr, arr + 4);
161  return vec;
162  }
163  } else {
164  int arr[] = {-99, -99, -99, -99};
165  std::vector<int> vec(arr, arr + 4);
166  return vec;
167  }
168  }
169 
171  // std::cout << "Inside EMTFBlockSP.cc: unpack" << std::endl;
172  // LogDebug("L1T|EMTF") << "Inside EMTFBlockSP.cc: unpack"; // Why doesn't this work? - AWB 09.04.16
173 
174  // Get the payload for this block, made up of 16-bit words (0xffff)
175  // Format defined in MTF7Payload::getBlock() in src/Block.cc
176  // payload[0] = bits 0-15, payload[1] = 16-31, payload[3] = 32-47, etc.
177  auto payload = block.payload();
178 
179  // Check Format of Payload
180  l1t::emtf::SP SP_;
181  for (int err = 0; err < checkFormat(block); err++)
182  SP_.add_format_error();
183 
184  // Assign payload to 16-bit words
185  uint16_t SP1a = payload[0];
186  uint16_t SP1b = payload[1];
187  uint16_t SP1c = payload[2];
188  uint16_t SP1d = payload[3];
189  uint16_t SP2a = payload[4];
190  uint16_t SP2b = payload[5];
191  uint16_t SP2c = payload[6];
192  uint16_t SP2d = payload[7];
193 
194  // res is a pointer to a collection of EMTFDaqOut class objects
195  // There is one EMTFDaqOut for each MTF7 (60 deg. sector) in the event
197  res = static_cast<EMTFCollections*>(coll)->getEMTFDaqOuts();
198  int iOut = res->size() - 1;
199  std::vector<int> conv_vals_SP;
200  std::vector<int> conv_vals_pT_LUT;
201 
202  EMTFHitCollection* res_hit;
203  res_hit = static_cast<EMTFCollections*>(coll)->getEMTFHits();
204 
205  EMTFTrackCollection* res_track;
206  res_track = static_cast<EMTFCollections*>(coll)->getEMTFTracks();
207  EMTFTrack Track_;
208 
210  res_cand = static_cast<EMTFCollections*>(coll)->getRegionalMuonCands();
211  RegionalMuonCand mu_(0, 0, 0, 0, 0, 0, 0, tftype::emtf_pos);
212 
214  // Unpack the SP Output Data Record
216 
217  SP_.set_phi_full(GetHexBits(SP1a, 0, 12));
218  SP_.set_c(GetHexBits(SP1a, 13, 13));
219  SP_.set_hl(GetHexBits(SP1a, 14, 14));
220 
221  SP_.set_phi_GMT(TwosCompl(8, GetHexBits(SP1b, 0, 7)));
222  SP_.set_quality_GMT(GetHexBits(SP1b, 8, 11));
223  SP_.set_bc0(GetHexBits(SP1b, 12, 12));
224  SP_.set_se(GetHexBits(SP1b, 13, 13));
225  SP_.set_vc(GetHexBits(SP1b, 14, 14));
226 
227  SP_.set_eta_GMT(TwosCompl(9, GetHexBits(SP1c, 0, 8)));
228  SP_.set_mode(GetHexBits(SP1c, 9, 12));
229  SP_.set_bx(GetHexBits(SP1c, 13, 14));
230 
231  SP_.set_pt_GMT(GetHexBits(SP1d, 0, 8));
232  SP_.set_me1_stub_num(GetHexBits(SP1d, 9, 9));
233  SP_.set_me1_CSC_ID(GetHexBits(SP1d, 10, 13));
234  SP_.set_me1_subsector(GetHexBits(SP1d, 14, 14));
235 
236  SP_.set_me2_stub_num(GetHexBits(SP2a, 0, 0));
237  SP_.set_me2_CSC_ID(GetHexBits(SP2a, 1, 4));
238  SP_.set_me3_stub_num(GetHexBits(SP2a, 5, 5));
239  SP_.set_me3_CSC_ID(GetHexBits(SP2a, 6, 9));
240  SP_.set_me4_stub_num(GetHexBits(SP2a, 10, 10));
241  SP_.set_me4_CSC_ID(GetHexBits(SP2a, 11, 14));
242 
243  SP_.set_me1_delay(GetHexBits(SP2b, 0, 2));
244  SP_.set_me2_delay(GetHexBits(SP2b, 3, 5));
245  SP_.set_me3_delay(GetHexBits(SP2b, 6, 8));
246  SP_.set_me4_delay(GetHexBits(SP2b, 9, 11));
247  SP_.set_tbin(GetHexBits(SP2b, 12, 14));
248 
249  SP_.set_pt_LUT_addr(GetHexBits(SP2c, 0, 14, SP2d, 0, 14));
250 
251  // SP_.set_dataword ( uint64_t dataword );
252 
253  ImportSP(Track_, SP_, (res->at(iOut)).PtrEventHeader()->Endcap(), (res->at(iOut)).PtrEventHeader()->Sector());
254  // Track_.ImportPtLUT( Track_.Mode(), Track_.Pt_LUT_addr() ); // Deprecated ... replace? - AWB 15.03.17
255 
256  if (!(res->at(iOut)).PtrSPCollection()->empty())
257  if (SP_.TBIN() == (res->at(iOut)).PtrSPCollection()->at((res->at(iOut)).PtrSPCollection()->size() - 1).TBIN())
258  Track_.set_track_num((res->at(iOut)).PtrSPCollection()->size());
259  else
260  Track_.set_track_num(0);
261  else
262  Track_.set_track_num(0);
263 
264  // For single-LCT tracks, "Track_num" = 2 (last in collection)
265  if (SP_.Quality_GMT() == 0)
266  Track_.set_track_num(2);
267 
268  mu_.setHwSign(SP_.C());
269  mu_.setHwSignValid(SP_.VC());
270  mu_.setHwQual(SP_.Quality_GMT());
271  mu_.setHwEta(SP_.Eta_GMT());
272  mu_.setHwPhi(SP_.Phi_GMT());
273  mu_.setHwPt(SP_.Pt_GMT());
274  mu_.setTFIdentifiers(Track_.Sector() - 1, (Track_.Endcap() == 1) ? emtf_pos : emtf_neg);
276  // Truncated to 11 bits and offset by 25 from global event BX in EMTF firmware
277  int EMTF_kBX = ((res->at(iOut)).PtrEventHeader()->L1A_BXN() % 2048) - 25 + Track_.BX();
278  if (EMTF_kBX < 0)
279  EMTF_kBX += 2048;
281  // mu_.set_dataword ( SP_.Dataword() );
282  // Track_.set_GMT(mu_);
283 
285  // Match hits to tracks
287 
288  // Find the track delay
289  int nDelay[3] = {0, 0, 0}; // Number of hits in the track with delay 0, 1, or 2
290  if (Track_.Mode() >= 8)
291  nDelay[SP_.ME1_delay()] += 1;
292  if ((Track_.Mode() % 8) >= 4)
293  nDelay[SP_.ME2_delay()] += 1;
294  if ((Track_.Mode() % 4) >= 2)
295  nDelay[SP_.ME3_delay()] += 1;
296  if ((Track_.Mode() % 2) == 1)
297  nDelay[SP_.ME4_delay()] += 1;
298 
299  int trk_delay = -99;
300  // Assume 2nd-earliest LCT configuration
301  if (nDelay[2] >= 2)
302  trk_delay = 2;
303  else if (nDelay[2] + nDelay[1] >= 2)
304  trk_delay = 1;
305  else if (nDelay[2] + nDelay[1] + nDelay[0] >= 2)
306  trk_delay = 0;
307 
308  // // For earliest LCT configuration
309  // if (nDelay[2] >= 1) trk_delay = 2;
310  // else if (nDelay[2] + nDelay[1] >= 1) trk_delay = 1;
311  // else if (nDelay[2] + nDelay[1] + nDelay[0] >= 1) trk_delay = 0;
312 
313  // Reverse 'rotate by 2' to get CPPF subsector number
314  auto get_subsector_rpc_cppf = [](int subsector_rpc) { return ((subsector_rpc + 3) % 6) + 1; };
315 
316  std::array<int, 4> St_hits{{0, 0, 0, 0}}; // Number of matched hits in each station
317 
318  for (auto const& Hit : *res_hit) {
319  if (Track_.Mode() == 1)
320  continue; // Special case dealt with later
321  if (Hit.Endcap() != Track_.Endcap())
322  continue;
323 
324  int hit_delay = -99;
325  if (Hit.Station() == 1)
326  hit_delay = SP_.ME1_delay();
327  else if (Hit.Station() == 2)
328  hit_delay = SP_.ME2_delay();
329  else if (Hit.Station() == 3)
330  hit_delay = SP_.ME3_delay();
331  else if (Hit.Station() == 4)
332  hit_delay = SP_.ME4_delay();
333 
334  // Require exact matching according to TBIN and delays
335  if (Hit.BX() + 3 + hit_delay != SP_.TBIN() + trk_delay)
336  continue;
337 
338  // Match hit in station 1
339  conv_vals_SP =
340  convert_SP_location(SP_.ME1_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), SP_.ME1_subsector(), 1);
341 
342  if (Hit.Station() == 1 && Hit.Sector() == conv_vals_SP.at(1) && Hit.Neighbor() == conv_vals_SP.at(3) &&
343  Hit.Stub_num() == SP_.ME1_stub_num()) {
344  if (Hit.Is_CSC() == 1 && (Hit.CSC_ID() != conv_vals_SP.at(0) || Hit.Subsector() != conv_vals_SP.at(2)))
345  continue;
346 
347  int tmp_subsector = get_subsector_rpc_cppf(Hit.Subsector_RPC());
348  int RPC_subsector = ((tmp_subsector - 1) / 3) + 1; // Map RPC subsector to equivalent CSC subsector
349  int RPC_CSC_ID = ((tmp_subsector - 1) % 3) + 4; // Map RPC subsector and ring to equivalent CSC ID
350 
351  if (Hit.Is_RPC() == 1 && (RPC_CSC_ID != conv_vals_SP.at(0) || RPC_subsector != conv_vals_SP.at(2)))
352  continue;
353 
354  if (St_hits.at(0) == 0) { // Only add the first matched hit to the track
355  Track_.push_Hit((Hit));
357  mu_.setTrackSubAddress(
359  L1TMuonEndCap::calc_uGMT_chamber(conv_vals_SP.at(0), conv_vals_SP.at(2), conv_vals_SP.at(3), 1));
360  }
361  St_hits.at(0) += 1; // Count the total number of matches for debugging purposes
362  } // End conditional: if ( Hit.Station() == 1
363 
364  // Match hit in station 2
365  conv_vals_SP = convert_SP_location(SP_.ME2_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 2);
366 
367  if (Hit.Station() == 2 && Hit.Sector() == conv_vals_SP.at(1) && Hit.Neighbor() == conv_vals_SP.at(3) &&
368  Hit.Stub_num() == SP_.ME2_stub_num()) {
369  if (Hit.Is_CSC() == 1 && Hit.CSC_ID() != conv_vals_SP.at(0))
370  continue;
371 
372  int tmp_subsector = get_subsector_rpc_cppf(Hit.Subsector_RPC());
373  if (Hit.Is_RPC() == 1 && tmp_subsector + 3 != conv_vals_SP.at(0))
374  continue;
375 
376  if (St_hits.at(1) == 0) {
377  Track_.push_Hit((Hit));
379  mu_.setTrackSubAddress(
381  L1TMuonEndCap::calc_uGMT_chamber(conv_vals_SP.at(0), conv_vals_SP.at(2), conv_vals_SP.at(3), 2));
382  }
383  St_hits.at(1) += 1;
384  } // End conditional: if ( Hit.Station() == 2
385 
386  // Match hit in station 3
387  conv_vals_SP = convert_SP_location(SP_.ME3_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 3);
388 
389  if (Hit.Station() == 3 && Hit.Sector() == conv_vals_SP.at(1) && Hit.Neighbor() == conv_vals_SP.at(3) &&
390  Hit.Stub_num() == SP_.ME3_stub_num()) {
391  if (Hit.Is_CSC() == 1 && Hit.CSC_ID() != conv_vals_SP.at(0))
392  continue;
393 
394  int tmp_subsector = get_subsector_rpc_cppf(Hit.Subsector_RPC());
395  if (Hit.Is_RPC() == 1 && tmp_subsector + 3 != conv_vals_SP.at(0))
396  continue;
397 
398  if (St_hits.at(2) == 0) {
399  Track_.push_Hit((Hit));
401  mu_.setTrackSubAddress(
403  L1TMuonEndCap::calc_uGMT_chamber(conv_vals_SP.at(0), conv_vals_SP.at(2), conv_vals_SP.at(3), 3));
404  }
405  St_hits.at(2) += 1;
406  } // End conditional: if ( Hit.Station() == 3
407 
408  // Match hit in station 4
409  conv_vals_SP = convert_SP_location(SP_.ME4_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 4);
410 
411  if (Hit.Station() == 4 && Hit.Sector() == conv_vals_SP.at(1) && Hit.Neighbor() == conv_vals_SP.at(3) &&
412  Hit.Stub_num() == SP_.ME4_stub_num()) {
413  if (Hit.Is_CSC() == 1 && Hit.CSC_ID() != conv_vals_SP.at(0))
414  continue;
415 
416  int tmp_subsector = get_subsector_rpc_cppf(Hit.Subsector_RPC());
417  if (Hit.Is_RPC() == 1 && tmp_subsector + 3 != conv_vals_SP.at(0))
418  continue;
419 
420  if (St_hits.at(3) == 0) {
421  Track_.push_Hit((Hit));
423  mu_.setTrackSubAddress(
425  L1TMuonEndCap::calc_uGMT_chamber(conv_vals_SP.at(0), conv_vals_SP.at(2), conv_vals_SP.at(3), 4));
426  }
427  St_hits.at(3) += 1;
428  } // End conditional: if ( Hit.Station() == 4
429 
430  } // End loop: for (auto const & Hit : *res_hit)
431 
432  // Special configuration for single-stub tracks from ME1/1
433  if (Track_.Mode() == 1) {
434  // Infer ME1/1 chamber based on track phi
435  int chamber_min = ((Track_.GMT_phi() - 17) / 16) + Track_.Sector() * 6 - 3;
436  int chamber_max = ((Track_.GMT_phi() + 1) / 16) + Track_.Sector() * 6 - 3;
437  for (int iChamb = chamber_max; iChamb >= chamber_min; iChamb--) {
438  int chamber = (iChamb < 37 ? iChamb : (iChamb % 36));
439 
440  for (auto const& Hit : *res_hit) {
441  if (Hit.Sector_idx() != Track_.Sector_idx())
442  continue;
443  if (Hit.BX() != Track_.BX())
444  continue;
445  if (Hit.Chamber() != chamber)
446  continue;
447  if (Hit.Is_CSC() != 1)
448  continue;
449  if (Hit.Station() != 1)
450  continue;
451  if ((Hit.Ring() % 3) != 1)
452  continue;
453  if (Hit.Neighbor() == 1)
454  continue;
455 
456  // Don't use LCTs that were already used in a multi-station track
457  bool hit_already_used = false;
458  for (auto const& Trk : *res_track) {
459  if (Trk.Sector_idx() != Track_.Sector_idx())
460  continue;
461  if (Trk.NumHits() < 1)
462  continue;
463 
464  if (Trk.Hits().at(0).Station() == 1 && Trk.Hits().at(0).Chamber() == chamber &&
465  Trk.Hits().at(0).BX() == Hit.BX() && Trk.Hits().at(0).Ring() == Hit.Ring() &&
466  Trk.Hits().at(0).Strip() == Hit.Strip() && Trk.Hits().at(0).Wire() == Hit.Wire()) {
467  hit_already_used = true;
468  break;
469  }
470  } // End loop: for (auto const & Trk : *res_track)
471 
472  if (!hit_already_used) {
473  Track_.push_Hit((Hit));
474  break;
475  }
476  } // End loop: for (auto const & Hit : *res_hit)
477  if (Track_.NumHits() > 0)
478  break;
479  } // End loop: for (int iChamb = chamber_max; iChamb >= chamber_min; iChamb--)
480 
481  // if (Track_.NumHits() != 1) {
482  // std::cout << "\n\n***********************************************************" << std::endl;
483  // std::cout << "Bug in unpacked EMTF event! Mode " << Track_.Mode() << " track in sector " << Track_.Sector()*Track_.Endcap()
484  // << ", BX " << Track_.BX() << ", GMT phi " << Track_.GMT_phi() << ", GMT eta " << Track_.GMT_eta()
485  // << " should have found an LCT between chamber " << chamber_min << " and " << chamber_max << std::endl;
486  // std::cout << "All available LCTs as follows:" << std::endl;
487  // for (auto const & Hit : *res_hit) {
488  // std::cout << "Hit: Is CSC = " << Hit.Is_CSC() << ", CSC ID = " << Hit.CSC_ID()
489  // << ", sector = " << Hit.Sector()*Hit.Endcap() << ", sub = " << Hit.Subsector()
490  // << ", neighbor = " << Hit.Neighbor() << ", station = " << Hit.Station()
491  // << ", ring = " << Hit.Ring() << ", chamber = " << Hit.Chamber()
492  // << ", stub = " << Hit.Stub_num() << ", BX = " << Hit.BX() << std::endl;
493  // std::cout << "All other tracks are as follows:" << std::endl;
494  // for (auto Trk = res_hit->begin(); Trk != res_hit->end(); ++Trk) {
495  // std::cout << "Track: mode " << Trk.Mode() << " track in sector " << Trk.Sector()*Trk.Endcap()
496  // << ", BX " << Trk.BX() << ", GMT phi " << Trk.GMT_phi() << ", GMT eta " << Trk.GMT_eta() << std::endl;
497  // }
498  // std::cout << "***********************************************************\n\n" << std::endl;
499  // } // End conditional: if (Track_.NumHits() != 1)
500 
501  } // End conditional: if (Track_.Mode() == 1)
502 
503  // if ( Track_.Mode() != St_hits.at(0)*8 + St_hits.at(1)*4 + St_hits.at(2)*2 + St_hits.at(3) && Track_.BX() == 0) {
504  // std::cout << "\n\n***********************************************************" << std::endl;
505  // std::cout << "Bug in unpacked EMTF event! Mode " << Track_.Mode() << " track in sector " << Track_.Sector()*Track_.Endcap()
506  // << ", BX " << Track_.BX() << " (delay = " << trk_delay << ") with (" << St_hits.at(0) << ", " << St_hits.at(1)
507  // << ", " << St_hits.at(2) << ", " << St_hits.at(3) << ") hits in stations (1, 2, 3, 4)" << std::endl;
508 
509  // std::cout << "\nME1_stub_num = " << SP_.ME1_stub_num() << ", ME1_delay = " << SP_.ME1_delay()
510  // << ", ME1_CSC_ID = " << SP_.ME1_CSC_ID() << ", ME1_subsector = " << SP_.ME1_subsector() << std::endl;
511  // std::cout << "ME2_stub_num = " << SP_.ME2_stub_num() << ", ME2_delay = " << SP_.ME2_delay()
512  // << ", ME2_CSC_ID = " << SP_.ME2_CSC_ID() << std::endl;
513  // std::cout << "ME3_stub_num = " << SP_.ME3_stub_num() << ", ME3_delay = " << SP_.ME3_delay()
514  // << ", ME3_CSC_ID = " << SP_.ME3_CSC_ID() << std::endl;
515  // std::cout << "ME4_stub_num = " << SP_.ME4_stub_num() << ", ME4_delay = " << SP_.ME4_delay()
516  // << ", ME4_CSC_ID = " << SP_.ME4_CSC_ID() << std::endl;
517 
518  // conv_vals_SP = convert_SP_location( SP_.ME1_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), SP_.ME1_subsector(), 1 );
519  // std::cout << "\nConverted ME1 CSC ID = " << conv_vals_SP.at(0) << ", sector = " << conv_vals_SP.at(1)
520  // << ", subsector = " << conv_vals_SP.at(2) << ", neighbor = " << conv_vals_SP.at(3) << std::endl;
521  // conv_vals_SP = convert_SP_location( SP_.ME2_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 2 );
522  // std::cout << "Converted ME2 CSC ID = " << conv_vals_SP.at(0) << ", sector = " << conv_vals_SP.at(1)
523  // << ", subsector = " << conv_vals_SP.at(2) << ", neighbor = " << conv_vals_SP.at(3) << std::endl;
524  // conv_vals_SP = convert_SP_location( SP_.ME3_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 3 );
525  // std::cout << "Converted ME3 CSC ID = " << conv_vals_SP.at(0) << ", sector = " << conv_vals_SP.at(1)
526  // << ", subsector = " << conv_vals_SP.at(2) << ", neighbor = " << conv_vals_SP.at(3) << std::endl;
527  // conv_vals_SP = convert_SP_location( SP_.ME4_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 4 );
528  // std::cout << "Converted ME4 CSC ID = " << conv_vals_SP.at(0) << ", sector = " << conv_vals_SP.at(1)
529  // << ", subsector = " << conv_vals_SP.at(2) << ", neighbor = " << conv_vals_SP.at(3) << "\n" << std::endl;
530 
531  // for (auto const & Hit : *res_hit)
532  // std::cout << "Hit: Is CSC = " << Hit.Is_CSC() << ", CSC ID = " << Hit.CSC_ID()
533  // << ", sector = " << Hit.Sector() << ", sub = " << Hit.Subsector()
534  // << ", neighbor = " << Hit.Neighbor() << ", station = " << Hit.Station()
535  // << ", ring = " << Hit.Ring() << ", chamber = " << Hit.Chamber()
536  // << ", stub = " << Hit.Stub_num() << ", BX = " << Hit.BX() << std::endl;
537 
538  // // int iHit = 0;
539  // // for (auto const & Hit : *res_hit) {
540  // // if (iHit == 0) Hit.PrintSimulatorHeader();
541  // // Hit.PrintForSimulator();
542  // // iHit += 1;
543  // // }
544  // std::cout << "***********************************************************\n\n" << std::endl;
545  // }
546 
547  (res->at(iOut)).push_SP(SP_);
548 
549  res_track->push_back(Track_);
550 
551  // TBIN_num can range from 0 through 7, i.e. BX = -3 through +4. - AWB 04.04.16
552  res_cand->setBXRange(-3, 4);
553  res_cand->push_back(SP_.TBIN() - 3, mu_);
554 
555  // Finished with unpacking one SP Output Data Record
556  return true;
557 
558  } // End bool SPBlockUnpacker::unpack
559 
560  // bool SPBlockPacker::pack(const Block& block, UnpackerCollections *coll) {
561  // std::cout << "Inside SPBlockPacker::pack" << std::endl;
562  // return true;
563  // } // End bool SPBlockPacker::pack
564 
565  } // End namespace emtf
566  } // End namespace stage2
567 } // End namespace l1t
568 
570 // DEFINE_L1T_PACKER(l1t::stage2::SPBlockPacker);
l1t::EMTFDaqOutCollection
std::vector< EMTFDaqOut > EMTFDaqOutCollection
Definition: EMTFDaqOut.h:164
l1t::RegionalMuonCand::kME1Ch
Definition: RegionalMuonCand.h:32
l1t::RegionalMuonCand::kME3Seg
Definition: RegionalMuonCand.h:35
Hit
Definition: SiPixelLorentzAngle.h:57
l1t::emtf::SP::set_phi_full
void set_phi_full(int bits)
Definition: SP.h:51
l1t::emtf_neg
Definition: RegionalMuonCandFwd.h:8
mps_fire.i
i
Definition: mps_fire.py:355
l1t::emtf::SP::ME3_stub_num
int ME3_stub_num() const
Definition: SP.h:99
l1t::emtf::SP::set_bx
void set_bx(int bits)
Definition: SP.h:58
l1t::emtf::SP::set_me1_subsector
void set_me1_subsector(int bits)
Definition: SP.h:62
l1t::emtf::SP::Quality_GMT
int Quality_GMT() const
Definition: SP.h:87
l1t::stage2::emtf::SPBlockUnpacker
Definition: EMTFBlockSP.cc:13
l1t::emtf::SP::ME1_stub_num
int ME1_stub_num() const
Definition: SP.h:95
l1t::RegionalMuonCand::kME2Ch
Definition: RegionalMuonCand.h:34
l1t::emtf::SP::set_me2_stub_num
void set_me2_stub_num(int bits)
Definition: SP.h:66
l1t::RegionalMuonCand::setHwSign
void setHwSign(int bits)
Set charge sign bit (charge = (-1)^(sign))
Definition: RegionalMuonCand.h:136
l1t::RegionalMuonCand::kBX
Definition: RegionalMuonCand.h:40
l1t::emtf::SP::set_mode
void set_mode(int bits)
Definition: SP.h:59
emtf::calc_uGMT_chamber
int calc_uGMT_chamber(int csc_ID, int subsector, int neighbor, int station)
Definition: TrackTools.cc:53
l1t::emtf::SP::set_se
void set_se(int bits)
Definition: SP.h:54
l1t::emtf::SP::set_me2_CSC_ID
void set_me2_CSC_ID(int bits)
Definition: SP.h:65
l1t::emtf::SP::Pt_GMT
int Pt_GMT() const
Definition: SP.h:92
l1t::RegionalMuonCand::kME1Seg
Definition: RegionalMuonCand.h:31
MessageLogger_cfi.errors
errors
Definition: MessageLogger_cfi.py:18
EMTFCollections.h
l1t::emtf::SP::set_pt_GMT
void set_pt_GMT(int bits)
Definition: SP.h:61
l1t::EMTFTrack::Mode
int Mode() const
Definition: EMTFTrack.h:146
l1t::emtf::SP::set_phi_GMT
void set_phi_GMT(int bits)
Definition: SP.h:57
l1t::emtf::SP::set_me4_delay
void set_me4_delay(int bits)
Definition: SP.h:75
l1t::EMTFTrack::Sector
int Sector() const
Definition: EMTFTrack.h:144
l1t::stage2::emtf::TwosCompl
int TwosCompl(int nBits, int bits)
Definition: EMTFUnpackerTools.h:36
l1t::emtf::SP::set_me1_stub_num
void set_me1_stub_num(int bits)
Definition: SP.h:64
l1t::emtf::SP::ME2_delay
int ME2_delay() const
Definition: SP.h:104
BXVector< RegionalMuonCand >
l1t::EMTFTrack::NumHits
int NumHits() const
Definition: EMTFTrack.h:106
l1t::EMTFTrack::BX
int BX() const
Definition: EMTFTrack.h:154
l1t::EMTFTrackCollection
std::vector< EMTFTrack > EMTFTrackCollection
Definition: EMTFTrack.h:219
l1t::EMTFTrack::push_Hit
void push_Hit(const EMTFHit &hit)
Definition: EMTFTrack.h:85
l1t::emtf::SP
Definition: SP.h:11
errors
Definition: errors.py:1
l1t::emtf::SP::set_me2_delay
void set_me2_delay(int bits)
Definition: SP.h:73
l1t::RegionalMuonCand::setTFIdentifiers
void setTFIdentifiers(int processor, tftype trackFinder)
Set the processor ID, track-finder type. From these two, the link is set.
Definition: RegionalMuonCand.cc:5
emtf
Definition: Event.h:15
l1t::emtf::SP::set_c
void set_c(int bits)
Definition: SP.h:50
l1t::stage2::emtf::SPBlockUnpacker::checkFormat
virtual int checkFormat(const Block &block)
Definition: EMTFBlockSP.cc:34
l1t::emtf::SP::Phi_GMT
int Phi_GMT() const
Definition: SP.h:88
l1t::EMTFTrack::GMT_phi
int GMT_phi() const
Definition: EMTFTrack.h:169
l1t::EMTFTrack::Endcap
int Endcap() const
Definition: EMTFTrack.h:143
UnpackerFactory.h
jets_cff.payload
payload
Definition: jets_cff.py:34
l1t::emtf::SP::set_bc0
void set_bc0(int bits)
Definition: SP.h:55
l1t::RegionalMuonCand::setHwPt
void setHwPt(int bits)
Set compressed pT as transmitted by hardware LSB = 0.5 (9 bits)
Definition: RegionalMuonCand.h:126
l1t::Unpacker
Definition: Unpacker.h:11
l1t::emtf::SP::set_hl
void set_hl(int bits)
Definition: SP.h:49
l1t::EMTFTrack
Definition: EMTFTrack.h:34
l1t::emtf::SP::C
int C() const
Definition: SP.h:81
l1t::emtf::SP::Eta_GMT
int Eta_GMT() const
Definition: SP.h:91
edm::LogError
Definition: MessageLogger.h:183
l1t::emtf::SP::VC
int VC() const
Definition: SP.h:83
l1t::emtf::SP::set_me1_delay
void set_me1_delay(int bits)
Definition: SP.h:72
runTheMatrix.err
err
Definition: runTheMatrix.py:288
l1t::EMTFTrack::Sector_idx
int Sector_idx() const
Definition: EMTFTrack.h:145
l1t
delete x;
Definition: CaloConfig.h:22
l1t::emtf::SP::set_me4_CSC_ID
void set_me4_CSC_ID(int bits)
Definition: SP.h:69
l1t::EMTFTrack::set_track_num
void set_track_num(int bits)
Definition: EMTFTrack.h:141
l1t::RegionalMuonCand::setHwEta
void setHwEta(int bits)
Set compressed eta as transmitted by hardware LSB = 0.010875 (9 bits)
Definition: RegionalMuonCand.h:134
l1t::emtf::SP::ME2_CSC_ID
int ME2_CSC_ID() const
Definition: SP.h:96
l1t::emtf::SP::set_tbin
void set_tbin(int bits)
Definition: SP.h:71
l1t::emtf::SP::set_me4_stub_num
void set_me4_stub_num(int bits)
Definition: SP.h:70
l1t::emtf::SP::set_me3_delay
void set_me3_delay(int bits)
Definition: SP.h:74
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
l1t::emtf::SP::ME4_CSC_ID
int ME4_CSC_ID() const
Definition: SP.h:100
l1t::RegionalMuonCand::kME4Seg
Definition: RegionalMuonCand.h:37
l1t::RegionalMuonCand::setTrackSubAddress
void setTrackSubAddress(bmtfAddress subAddress, int value)
Set a part of the muon candidates track address; specialised for BMTF.
Definition: RegionalMuonCand.h:152
l1t::RegionalMuonCand::setHwQual
void setHwQual(int bits)
Set compressed quality code as transmitted by hardware (4 bits)
Definition: RegionalMuonCand.h:140
l1t::emtf::SP::set_me1_CSC_ID
void set_me1_CSC_ID(int bits)
Definition: SP.h:63
res
Definition: Electron.h:6
SiStripSourceConfigTier0_cff.stage2
stage2
Definition: SiStripSourceConfigTier0_cff.py:71
l1t::EMTFTrack::Track_num
int Track_num() const
Definition: EMTFTrack.h:174
l1t::emtf::SP::set_eta_GMT
void set_eta_GMT(int bits)
Definition: SP.h:60
l1t::RegionalMuonCand::setHwSignValid
void setHwSignValid(int bits)
Set whether charge measurement is valid (0 for high pT muons)
Definition: RegionalMuonCand.h:138
l1t::RegionalMuonCand::kTrkNum
Definition: RegionalMuonCand.h:39
l1t::stage2::emtf::ImportSP
void ImportSP(EMTFTrack &_track, const l1t::emtf::SP _SP, const int _endcap, const int _evt_sector)
Definition: EMTFUnpackerTools.cc:63
l1t::emtf::SP::ME2_stub_num
int ME2_stub_num() const
Definition: SP.h:97
l1t::emtf::SP::set_vc
void set_vc(int bits)
Definition: SP.h:52
l1t::stage2::emtf::convert_SP_location
std::vector< int > convert_SP_location(int _csc_ID, int _sector, int _subsector, int _station)
Definition: EMTFBlockSP.cc:99
l1t::emtf::SP::ME3_delay
int ME3_delay() const
Definition: SP.h:105
l1t::emtf_pos
Definition: RegionalMuonCandFwd.h:8
EMTFUnpackerTools.h
l1t::UnpackerCollections
Definition: UnpackerCollections.h:9
l1t::emtf::SP::ME3_CSC_ID
int ME3_CSC_ID() const
Definition: SP.h:98
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
DEFINE_L1T_UNPACKER
#define DEFINE_L1T_UNPACKER(type)
Definition: UnpackerFactory.h:23
l1t::RegionalMuonCand::kME2Seg
Definition: RegionalMuonCand.h:33
l1t::emtf::SP::ME1_subsector
int ME1_subsector() const
Definition: SP.h:93
l1t::RegionalMuonCand::kME3Ch
Definition: RegionalMuonCand.h:36
l1t::emtf::SP::set_quality_GMT
void set_quality_GMT(int bits)
Definition: SP.h:56
l1t::RegionalMuonCand::setHwPhi
void setHwPhi(int bits)
Set compressed relative phi as transmitted by hardware LSB = 2*pi/576 (8 bits)
Definition: RegionalMuonCand.h:132
l1t::emtf::SP::TBIN
int TBIN() const
Definition: SP.h:102
BXVector::setBXRange
void setBXRange(int bxFirst, int bxLast)
l1t::emtf::SP::add_format_error
void add_format_error()
Definition: SP.h:77
l1t::Block
Definition: Block.h:54
l1t::emtf::SP::ME4_stub_num
int ME4_stub_num() const
Definition: SP.h:101
BXVector::push_back
void push_back(int bx, T object)
l1t::emtf::SP::ME1_delay
int ME1_delay() const
Definition: SP.h:103
l1t::emtf::SP::set_pt_LUT_addr
void set_pt_LUT_addr(unsigned long bits)
Definition: SP.h:76
l1t::stage2::emtf::SPBlockUnpacker::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: EMTFBlockSP.cc:170
l1t::emtf::SP::ME1_CSC_ID
int ME1_CSC_ID() const
Definition: SP.h:94
l1t::emtf::SP::ME4_delay
int ME4_delay() const
Definition: SP.h:106
l1t::stage2::emtf::GetHexBits
uint16_t GetHexBits(uint16_t word, uint16_t lowBit, uint16_t highBit)
Definition: EMTFUnpackerTools.h:44
l1t::RegionalMuonCand
Definition: RegionalMuonCand.h:8
l1t::emtf::SP::set_me3_CSC_ID
void set_me3_CSC_ID(int bits)
Definition: SP.h:67
l1t::RegionalMuonCand::kME4Ch
Definition: RegionalMuonCand.h:38
l1t::emtf::SP::set_me3_stub_num
void set_me3_stub_num(int bits)
Definition: SP.h:68
l1t::EMTFHitCollection
std::vector< EMTFHit > EMTFHitCollection
Definition: EMTFHit.h:302