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  // FW version is computed as (Year - 2000)*2^9 + Month*2^5 + Day (see Block.cc and EMTFBlockTrailers.cc)
180  bool useNNBits_ = getAlgoVersion() >= 11098; // FW versions >= 26.10.2021
181  bool useHMTBits_ = getAlgoVersion() >= 11306; // FW versions >= 10.01.2022
182  bool reducedDAQWindow =
183  (getAlgoVersion() >=
184  11656); // Firmware from 08.12.22 which is used as a flag for new reduced readout window - EY 01.03.23
185 
186  static constexpr int nominalShower_ = 1;
187  static constexpr int tightShower_ = 3;
188 
189  // Check Format of Payload
190  l1t::emtf::SP SP_;
191  for (int err = 0; err < checkFormat(block); err++)
192  SP_.add_format_error();
193 
194  // Assign payload to 16-bit words
195  uint16_t SP1a = payload[0];
196  uint16_t SP1b = payload[1];
197  uint16_t SP1c = payload[2];
198  uint16_t SP1d = payload[3];
199  uint16_t SP2a = payload[4];
200  uint16_t SP2b = payload[5];
201  uint16_t SP2c = payload[6];
202  uint16_t SP2d = payload[7];
203 
204  // res is a pointer to a collection of EMTFDaqOut class objects
205  // There is one EMTFDaqOut for each MTF7 (60 deg. sector) in the event
207  res = static_cast<EMTFCollections*>(coll)->getEMTFDaqOuts();
208  int iOut = res->size() - 1;
209  std::vector<int> conv_vals_SP;
210  std::vector<int> conv_vals_pT_LUT;
211 
212  EMTFHitCollection* res_hit;
213  res_hit = static_cast<EMTFCollections*>(coll)->getEMTFHits();
214 
215  EMTFTrackCollection* res_track;
216  res_track = static_cast<EMTFCollections*>(coll)->getEMTFTracks();
217  EMTFTrack Track_;
218 
220  res_cand = static_cast<EMTFCollections*>(coll)->getRegionalMuonCands();
221  RegionalMuonCand mu_(0, 0, 0, 0, 0, 0, 0, tftype::emtf_pos);
222 
223  RegionalMuonShowerBxCollection* res_shower;
224  res_shower = static_cast<EMTFCollections*>(coll)->getRegionalMuonShowers();
225  RegionalMuonShower muShower_(false, false, false, false, false, false);
226 
228  // Unpack the SP Output Data Record
230 
231  SP_.set_phi_full(GetHexBits(SP1a, 0, 12));
232  SP_.set_c(GetHexBits(SP1a, 13, 13));
233  SP_.set_hl(GetHexBits(SP1a, 14, 14));
234 
235  SP_.set_phi_GMT(TwosCompl(8, GetHexBits(SP1b, 0, 7)));
236  SP_.set_quality_GMT(GetHexBits(SP1b, 8, 11));
237  SP_.set_bc0(GetHexBits(SP1b, 12, 12));
238  SP_.set_se(GetHexBits(SP1b, 13, 13));
239  SP_.set_vc(GetHexBits(SP1b, 14, 14));
240 
241  SP_.set_eta_GMT(TwosCompl(9, GetHexBits(SP1c, 0, 8)));
242  SP_.set_mode(GetHexBits(SP1c, 9, 12));
243 
244  if (useHMTBits_) {
245  SP_.set_hmt(GetHexBits(SP1c, 13, 14));
246  } else {
247  SP_.set_bx(GetHexBits(SP1c, 13, 14));
248  }
249 
250  SP_.set_pt_GMT(GetHexBits(SP1d, 0, 8));
251  SP_.set_me1_stub_num(GetHexBits(SP1d, 9, 9));
252  SP_.set_me1_CSC_ID(GetHexBits(SP1d, 10, 13));
253  SP_.set_me1_subsector(GetHexBits(SP1d, 14, 14));
254 
255  SP_.set_me2_stub_num(GetHexBits(SP2a, 0, 0));
256  SP_.set_me2_CSC_ID(GetHexBits(SP2a, 1, 4));
257  SP_.set_me3_stub_num(GetHexBits(SP2a, 5, 5));
258  SP_.set_me3_CSC_ID(GetHexBits(SP2a, 6, 9));
259  SP_.set_me4_stub_num(GetHexBits(SP2a, 10, 10));
260  SP_.set_me4_CSC_ID(GetHexBits(SP2a, 11, 14));
261 
262  SP_.set_me1_delay(GetHexBits(SP2b, 0, 2));
263  SP_.set_me2_delay(GetHexBits(SP2b, 3, 5));
264  SP_.set_me3_delay(GetHexBits(SP2b, 6, 8));
265  SP_.set_me4_delay(GetHexBits(SP2b, 9, 11));
266  if (reducedDAQWindow) // reduced DAQ window is used only after run3 DAQ format
267  SP_.set_tbin(GetHexBits(SP2b, 12, 14) + 1);
268  else
269  SP_.set_tbin(GetHexBits(SP2b, 12, 14));
270 
271  if (useNNBits_) {
272  SP_.set_pt_dxy_GMT(GetHexBits(SP2c, 0, 7));
273  SP_.set_dxy_GMT(GetHexBits(SP2c, 8, 10));
274  SP_.set_nn_pt_valid(GetHexBits(SP2c, 11, 11));
275  } else {
276  SP_.set_pt_LUT_addr(GetHexBits(SP2c, 0, 14, SP2d, 0, 14));
277  }
278 
279  // SP_.set_dataword ( uint64_t dataword );
280 
281  ImportSP(Track_, SP_, (res->at(iOut)).PtrEventHeader()->Endcap(), (res->at(iOut)).PtrEventHeader()->Sector());
282  // Track_.ImportPtLUT( Track_.Mode(), Track_.Pt_LUT_addr() ); // Deprecated ... replace? - AWB 15.03.17
283 
284  if (!(res->at(iOut)).PtrSPCollection()->empty())
285  if (SP_.TBIN() == (res->at(iOut)).PtrSPCollection()->at((res->at(iOut)).PtrSPCollection()->size() - 1).TBIN())
286  Track_.set_track_num((res->at(iOut)).PtrSPCollection()->size());
287  else
288  Track_.set_track_num(0);
289  else
290  Track_.set_track_num(0);
291 
292  // For single-LCT tracks, "Track_num" = 2 (last in collection)
293  if (SP_.Quality_GMT() == 0)
294  Track_.set_track_num(2);
295 
296  mu_.setHwSign(SP_.C());
297  mu_.setHwSignValid(SP_.VC());
298  mu_.setHwQual(SP_.Quality_GMT());
299  mu_.setHwEta(SP_.Eta_GMT());
300  mu_.setHwPhi(SP_.Phi_GMT());
301  mu_.setHwPt(SP_.Pt_GMT());
302  if (useNNBits_) {
303  mu_.setHwPtUnconstrained(SP_.Pt_dxy_GMT());
304  mu_.setHwDXY(SP_.Dxy_GMT());
305  }
306  mu_.setTFIdentifiers(Track_.Sector() - 1, (Track_.Endcap() == 1) ? emtf_pos : emtf_neg);
308  // Truncated to 11 bits and offset by 25 from global event BX in EMTF firmware
309  int EMTF_kBX = ((res->at(iOut)).PtrEventHeader()->L1A_BXN() % 2048) - 25 + Track_.BX();
310  if (EMTF_kBX < 0)
311  EMTF_kBX += 2048;
313  // mu_.set_dataword ( SP_.Dataword() );
314  // Track_.set_GMT(mu_);
315 
316  // Set Regional Muon Showers
317  if (useHMTBits_) {
318  muShower_.setTFIdentifiers(Track_.Sector() - 1, (Track_.Endcap() == 1) ? emtf_pos : emtf_neg);
319  muShower_.setOneNominalInTime(SP_.HMT() == nominalShower_ ? true : false);
320  muShower_.setOneTightInTime(SP_.HMT() == tightShower_ ? true : false);
321  }
322 
324  // Match hits to tracks
326 
327  // Find the track delay
328  int nDelay[3] = {0, 0, 0}; // Number of hits in the track with delay 0, 1, or 2
329  if (Track_.Mode() >= 8)
330  nDelay[SP_.ME1_delay()] += 1;
331  if ((Track_.Mode() % 8) >= 4)
332  nDelay[SP_.ME2_delay()] += 1;
333  if ((Track_.Mode() % 4) >= 2)
334  nDelay[SP_.ME3_delay()] += 1;
335  if ((Track_.Mode() % 2) == 1)
336  nDelay[SP_.ME4_delay()] += 1;
337 
338  int trk_delay = -99;
339  // Assume 2nd-earliest LCT configuration
340  if (nDelay[2] >= 2)
341  trk_delay = 2;
342  else if (nDelay[2] + nDelay[1] >= 2)
343  trk_delay = 1;
344  else if (nDelay[2] + nDelay[1] + nDelay[0] >= 2)
345  trk_delay = 0;
346 
347  // // For earliest LCT configuration
348  // if (nDelay[2] >= 1) trk_delay = 2;
349  // else if (nDelay[2] + nDelay[1] >= 1) trk_delay = 1;
350  // else if (nDelay[2] + nDelay[1] + nDelay[0] >= 1) trk_delay = 0;
351 
352  // Reverse 'rotate by 2' to get CPPF subsector number
353  auto get_subsector_rpc_cppf = [](int subsector_rpc) { return ((subsector_rpc + 3) % 6) + 1; };
354 
355  std::array<int, 4> St_hits{{0, 0, 0, 0}}; // Number of matched hits in each station
356 
357  for (auto const& Hit : *res_hit) {
358  if (Track_.Mode() == 1)
359  continue; // Special case dealt with later
360  if (Hit.Endcap() != Track_.Endcap())
361  continue;
362 
363  int hit_delay = -99;
364  if (Hit.Station() == 1)
365  hit_delay = SP_.ME1_delay();
366  else if (Hit.Station() == 2)
367  hit_delay = SP_.ME2_delay();
368  else if (Hit.Station() == 3)
369  hit_delay = SP_.ME3_delay();
370  else if (Hit.Station() == 4)
371  hit_delay = SP_.ME4_delay();
372 
373  // Require exact matching according to TBIN and delays
374  if (Hit.BX() + 3 + hit_delay != SP_.TBIN() + trk_delay)
375  continue;
376 
377  // Match hit in station 1
378  conv_vals_SP =
379  convert_SP_location(SP_.ME1_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), SP_.ME1_subsector(), 1);
380 
381  if (Hit.Station() == 1 && Hit.Sector() == conv_vals_SP.at(1) && Hit.Neighbor() == conv_vals_SP.at(3) &&
382  Hit.Stub_num() == SP_.ME1_stub_num()) {
383  if (Hit.Is_CSC() == 1 && (Hit.CSC_ID() != conv_vals_SP.at(0) || Hit.Subsector() != conv_vals_SP.at(2)))
384  continue;
385 
386  int tmp_subsector = get_subsector_rpc_cppf(Hit.Subsector_RPC());
387  int RPC_subsector = ((tmp_subsector - 1) / 3) + 1; // Map RPC subsector to equivalent CSC subsector
388  int RPC_CSC_ID = ((tmp_subsector - 1) % 3) + 4; // Map RPC subsector and ring to equivalent CSC ID
389 
390  if (Hit.Is_RPC() == 1 && (RPC_CSC_ID != conv_vals_SP.at(0) || RPC_subsector != conv_vals_SP.at(2)))
391  continue;
392 
393  if (St_hits.at(0) == 0) { // Only add the first matched hit to the track
394  Track_.push_Hit((Hit));
396  mu_.setTrackSubAddress(
398  L1TMuonEndCap::calc_uGMT_chamber(conv_vals_SP.at(0), conv_vals_SP.at(2), conv_vals_SP.at(3), 1));
399  }
400  St_hits.at(0) += 1; // Count the total number of matches for debugging purposes
401  } // End conditional: if ( Hit.Station() == 1
402 
403  // Match hit in station 2
404  conv_vals_SP = convert_SP_location(SP_.ME2_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 2);
405 
406  if (Hit.Station() == 2 && Hit.Sector() == conv_vals_SP.at(1) && Hit.Neighbor() == conv_vals_SP.at(3) &&
407  Hit.Stub_num() == SP_.ME2_stub_num()) {
408  if (Hit.Is_CSC() == 1 && Hit.CSC_ID() != conv_vals_SP.at(0))
409  continue;
410 
411  int tmp_subsector = get_subsector_rpc_cppf(Hit.Subsector_RPC());
412  if (Hit.Is_RPC() == 1 && tmp_subsector + 3 != conv_vals_SP.at(0))
413  continue;
414 
415  if (St_hits.at(1) == 0) {
416  Track_.push_Hit((Hit));
418  mu_.setTrackSubAddress(
420  L1TMuonEndCap::calc_uGMT_chamber(conv_vals_SP.at(0), conv_vals_SP.at(2), conv_vals_SP.at(3), 2));
421  }
422  St_hits.at(1) += 1;
423  } // End conditional: if ( Hit.Station() == 2
424 
425  // Match hit in station 3
426  conv_vals_SP = convert_SP_location(SP_.ME3_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 3);
427 
428  if (Hit.Station() == 3 && Hit.Sector() == conv_vals_SP.at(1) && Hit.Neighbor() == conv_vals_SP.at(3) &&
429  Hit.Stub_num() == SP_.ME3_stub_num()) {
430  if (Hit.Is_CSC() == 1 && Hit.CSC_ID() != conv_vals_SP.at(0))
431  continue;
432 
433  int tmp_subsector = get_subsector_rpc_cppf(Hit.Subsector_RPC());
434  if (Hit.Is_RPC() == 1 && tmp_subsector + 3 != conv_vals_SP.at(0))
435  continue;
436 
437  if (St_hits.at(2) == 0) {
438  Track_.push_Hit((Hit));
440  mu_.setTrackSubAddress(
442  L1TMuonEndCap::calc_uGMT_chamber(conv_vals_SP.at(0), conv_vals_SP.at(2), conv_vals_SP.at(3), 3));
443  }
444  St_hits.at(2) += 1;
445  } // End conditional: if ( Hit.Station() == 3
446 
447  // Match hit in station 4
448  conv_vals_SP = convert_SP_location(SP_.ME4_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 4);
449 
450  if (Hit.Station() == 4 && Hit.Sector() == conv_vals_SP.at(1) && Hit.Neighbor() == conv_vals_SP.at(3) &&
451  Hit.Stub_num() == SP_.ME4_stub_num()) {
452  if (Hit.Is_CSC() == 1 && Hit.CSC_ID() != conv_vals_SP.at(0))
453  continue;
454 
455  int tmp_subsector = get_subsector_rpc_cppf(Hit.Subsector_RPC());
456  if (Hit.Is_RPC() == 1 && tmp_subsector + 3 != conv_vals_SP.at(0))
457  continue;
458 
459  if (St_hits.at(3) == 0) {
460  Track_.push_Hit((Hit));
462  mu_.setTrackSubAddress(
464  L1TMuonEndCap::calc_uGMT_chamber(conv_vals_SP.at(0), conv_vals_SP.at(2), conv_vals_SP.at(3), 4));
465  }
466  St_hits.at(3) += 1;
467  } // End conditional: if ( Hit.Station() == 4
468 
469  } // End loop: for (auto const & Hit : *res_hit)
470 
471  // Special configuration for single-stub tracks from ME1/1
472  if (Track_.Mode() == 1) {
473  // Infer ME1/1 chamber based on track phi
474  int chamber_min = ((Track_.GMT_phi() - 17) / 16) + Track_.Sector() * 6 - 3;
475  int chamber_max = ((Track_.GMT_phi() + 1) / 16) + Track_.Sector() * 6 - 3;
476  for (int iChamb = chamber_max; iChamb >= chamber_min; iChamb--) {
477  int chamber = (iChamb < 37 ? iChamb : (iChamb % 36));
478 
479  for (auto const& Hit : *res_hit) {
480  if (Hit.Sector_idx() != Track_.Sector_idx())
481  continue;
482  if (Hit.BX() != Track_.BX())
483  continue;
484  if (Hit.Chamber() != chamber)
485  continue;
486  if (Hit.Is_CSC() != 1)
487  continue;
488  if (Hit.Station() != 1)
489  continue;
490  if ((Hit.Ring() % 3) != 1)
491  continue;
492  if (Hit.Neighbor() == 1)
493  continue;
494 
495  // Don't use LCTs that were already used in a multi-station track
496  bool hit_already_used = false;
497  for (auto const& Trk : *res_track) {
498  if (Trk.Sector_idx() != Track_.Sector_idx())
499  continue;
500  if (Trk.NumHits() < 1)
501  continue;
502 
503  if (Trk.Hits().at(0).Station() == 1 && Trk.Hits().at(0).Chamber() == chamber &&
504  Trk.Hits().at(0).BX() == Hit.BX() && Trk.Hits().at(0).Ring() == Hit.Ring() &&
505  Trk.Hits().at(0).Strip() == Hit.Strip() && Trk.Hits().at(0).Wire() == Hit.Wire()) {
506  hit_already_used = true;
507  break;
508  }
509  } // End loop: for (auto const & Trk : *res_track)
510 
511  if (!hit_already_used) {
512  Track_.push_Hit((Hit));
513  break;
514  }
515  } // End loop: for (auto const & Hit : *res_hit)
516  if (Track_.NumHits() > 0)
517  break;
518  } // End loop: for (int iChamb = chamber_max; iChamb >= chamber_min; iChamb--)
519 
520  // if (Track_.NumHits() != 1) {
521  // std::cout << "\n\n***********************************************************" << std::endl;
522  // std::cout << "Bug in unpacked EMTF event! Mode " << Track_.Mode() << " track in sector " << Track_.Sector()*Track_.Endcap()
523  // << ", BX " << Track_.BX() << ", GMT phi " << Track_.GMT_phi() << ", GMT eta " << Track_.GMT_eta()
524  // << " should have found an LCT between chamber " << chamber_min << " and " << chamber_max << std::endl;
525  // std::cout << "All available LCTs as follows:" << std::endl;
526  // for (auto const & Hit : *res_hit) {
527  // std::cout << "Hit: Is CSC = " << Hit.Is_CSC() << ", CSC ID = " << Hit.CSC_ID()
528  // << ", sector = " << Hit.Sector()*Hit.Endcap() << ", sub = " << Hit.Subsector()
529  // << ", neighbor = " << Hit.Neighbor() << ", station = " << Hit.Station()
530  // << ", ring = " << Hit.Ring() << ", chamber = " << Hit.Chamber()
531  // << ", stub = " << Hit.Stub_num() << ", BX = " << Hit.BX() << std::endl;
532  // std::cout << "All other tracks are as follows:" << std::endl;
533  // for (auto Trk = res_hit->begin(); Trk != res_hit->end(); ++Trk) {
534  // std::cout << "Track: mode " << Trk.Mode() << " track in sector " << Trk.Sector()*Trk.Endcap()
535  // << ", BX " << Trk.BX() << ", GMT phi " << Trk.GMT_phi() << ", GMT eta " << Trk.GMT_eta() << std::endl;
536  // }
537  // std::cout << "***********************************************************\n\n" << std::endl;
538  // } // End conditional: if (Track_.NumHits() != 1)
539 
540  } // End conditional: if (Track_.Mode() == 1)
541 
542  // 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) {
543  // std::cout << "\n\n***********************************************************" << std::endl;
544  // std::cout << "Bug in unpacked EMTF event! Mode " << Track_.Mode() << " track in sector " << Track_.Sector()*Track_.Endcap()
545  // << ", BX " << Track_.BX() << " (delay = " << trk_delay << ") with (" << St_hits.at(0) << ", " << St_hits.at(1)
546  // << ", " << St_hits.at(2) << ", " << St_hits.at(3) << ") hits in stations (1, 2, 3, 4)" << std::endl;
547 
548  // std::cout << "\nME1_stub_num = " << SP_.ME1_stub_num() << ", ME1_delay = " << SP_.ME1_delay()
549  // << ", ME1_CSC_ID = " << SP_.ME1_CSC_ID() << ", ME1_subsector = " << SP_.ME1_subsector() << std::endl;
550  // std::cout << "ME2_stub_num = " << SP_.ME2_stub_num() << ", ME2_delay = " << SP_.ME2_delay()
551  // << ", ME2_CSC_ID = " << SP_.ME2_CSC_ID() << std::endl;
552  // std::cout << "ME3_stub_num = " << SP_.ME3_stub_num() << ", ME3_delay = " << SP_.ME3_delay()
553  // << ", ME3_CSC_ID = " << SP_.ME3_CSC_ID() << std::endl;
554  // std::cout << "ME4_stub_num = " << SP_.ME4_stub_num() << ", ME4_delay = " << SP_.ME4_delay()
555  // << ", ME4_CSC_ID = " << SP_.ME4_CSC_ID() << std::endl;
556 
557  // conv_vals_SP = convert_SP_location( SP_.ME1_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), SP_.ME1_subsector(), 1 );
558  // std::cout << "\nConverted ME1 CSC ID = " << conv_vals_SP.at(0) << ", sector = " << conv_vals_SP.at(1)
559  // << ", subsector = " << conv_vals_SP.at(2) << ", neighbor = " << conv_vals_SP.at(3) << std::endl;
560  // conv_vals_SP = convert_SP_location( SP_.ME2_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 2 );
561  // std::cout << "Converted ME2 CSC ID = " << conv_vals_SP.at(0) << ", sector = " << conv_vals_SP.at(1)
562  // << ", subsector = " << conv_vals_SP.at(2) << ", neighbor = " << conv_vals_SP.at(3) << std::endl;
563  // conv_vals_SP = convert_SP_location( SP_.ME3_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 3 );
564  // std::cout << "Converted ME3 CSC ID = " << conv_vals_SP.at(0) << ", sector = " << conv_vals_SP.at(1)
565  // << ", subsector = " << conv_vals_SP.at(2) << ", neighbor = " << conv_vals_SP.at(3) << std::endl;
566  // conv_vals_SP = convert_SP_location( SP_.ME4_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 4 );
567  // std::cout << "Converted ME4 CSC ID = " << conv_vals_SP.at(0) << ", sector = " << conv_vals_SP.at(1)
568  // << ", subsector = " << conv_vals_SP.at(2) << ", neighbor = " << conv_vals_SP.at(3) << "\n" << std::endl;
569 
570  // for (auto const & Hit : *res_hit)
571  // std::cout << "Hit: Is CSC = " << Hit.Is_CSC() << ", CSC ID = " << Hit.CSC_ID()
572  // << ", sector = " << Hit.Sector() << ", sub = " << Hit.Subsector()
573  // << ", neighbor = " << Hit.Neighbor() << ", station = " << Hit.Station()
574  // << ", ring = " << Hit.Ring() << ", chamber = " << Hit.Chamber()
575  // << ", stub = " << Hit.Stub_num() << ", BX = " << Hit.BX() << std::endl;
576 
577  // // int iHit = 0;
578  // // for (auto const & Hit : *res_hit) {
579  // // if (iHit == 0) Hit.PrintSimulatorHeader();
580  // // Hit.PrintForSimulator();
581  // // iHit += 1;
582  // // }
583  // std::cout << "***********************************************************\n\n" << std::endl;
584  // }
585 
586  // Reject tracks with out-of-range BX values. This needs to be adjusted if we increase l1a_window parameter in EMTF config - EY 03.08.2022
587  if (Track_.BX() > 3 or Track_.BX() < -3) {
588  edm::LogWarning("L1T|EMTF") << "EMTF unpacked track with out-of-range BX! BX: " << Track_.BX()
589  << " endcap: " << (Track_.Endcap() == 1 ? 1 : 2) << " sector: " << Track_.Sector()
590  << " address: " << Track_.PtLUT().address << " mode: " << Track_.Mode()
591  << " eta: " << (Track_.GMT_eta() >= 0 ? Track_.GMT_eta() : Track_.GMT_eta() + 512)
592  << " phi: " << Track_.GMT_phi() << " charge: " << Track_.GMT_charge()
593  << " qual: " << Track_.GMT_quality() << " pt: " << Track_.Pt()
594  << " pt_dxy: " << Track_.Pt_dxy() << std::endl;
595  return true;
596  }
597 
598  (res->at(iOut)).push_SP(SP_);
599 
600  res_track->push_back(Track_);
601 
602  // TBIN_num can range from 0 through 7, i.e. BX = -3 through +4. - AWB 04.04.16
603  res_cand->setBXRange(-3, 4);
604  res_cand->push_back(SP_.TBIN() - 3, mu_);
605 
606  res_shower->setBXRange(-3, 4);
607  res_shower->push_back(SP_.TBIN() - 3, muShower_);
608 
609  // Finished with unpacking one SP Output Data Record
610  return true;
611 
612  } // End bool SPBlockUnpacker::unpack
613 
614  // bool SPBlockPacker::pack(const Block& block, UnpackerCollections *coll) {
615  // std::cout << "Inside SPBlockPacker::pack" << std::endl;
616  // return true;
617  // } // End bool SPBlockPacker::pack
618 
619  } // End namespace emtf
620  } // End namespace stage2
621 } // End namespace l1t
622 
624 // DEFINE_L1T_PACKER(l1t::stage2::SPBlockPacker);
int ME3_stub_num() const
Definition: SP.h:109
int Quality_GMT() const
Definition: SP.h:95
int Sector_idx() const
Definition: EMTFTrack.h:167
void set_me3_stub_num(int bits)
Definition: SP.h:75
void setOneTightInTime(const bool bit)
int HMT() const
Definition: SP.h:121
void setHwPhi(int bits)
Set compressed relative phi as transmitted by hardware LSB = 2*pi/576 (8 bits)
float Pt() const
Definition: EMTFTrack.h:180
void set_me2_stub_num(int bits)
Definition: SP.h:73
void set_pt_dxy_GMT(int bits)
Definition: SP.h:67
int ME4_stub_num() const
Definition: SP.h:111
float Pt_dxy() const
Definition: EMTFTrack.h:182
int ME1_CSC_ID() const
Definition: SP.h:104
int Sector() const
Definition: EMTFTrack.h:166
void set_me3_CSC_ID(int bits)
Definition: SP.h:74
unsigned int getAlgoVersion()
Definition: Unpacker.h:18
int ME1_stub_num() const
Definition: SP.h:105
virtual int checkFormat(const Block &block)
Definition: EMTFBlockSP.cc:34
int GMT_charge() const
Definition: EMTFTrack.h:199
void set_bx(int bits)
Definition: SP.h:62
int calc_uGMT_chamber(int csc_ID, int subsector, int neighbor, int station)
Definition: TrackTools.cc:53
int Pt_dxy_GMT() const
Definition: SP.h:101
Definition: Event.h:15
delete x;
Definition: CaloConfig.h:22
int ME2_delay() const
Definition: SP.h:114
Log< level::Error, false > LogError
int Mode() const
Definition: EMTFTrack.h:168
Definition: Electron.h:6
void set_se(int bits)
Definition: SP.h:58
void set_me2_CSC_ID(int bits)
Definition: SP.h:72
int Pt_GMT() const
Definition: SP.h:100
void set_me1_stub_num(int bits)
Definition: SP.h:71
void set_pt_GMT(int bits)
Definition: SP.h:66
void set_me4_delay(int bits)
Definition: SP.h:82
void set_phi_GMT(int bits)
Definition: SP.h:61
int VC() const
Definition: SP.h:91
int TwosCompl(int nBits, int bits)
void set_me1_delay(int bits)
Definition: SP.h:79
void set_me2_delay(int bits)
Definition: SP.h:80
void set_hl(int bits)
Definition: SP.h:53
void setTFIdentifiers(int processor, tftype trackFinder)
Set the processor ID, track-finder type. From these two, the link is set.
void set_tbin(int bits)
Definition: SP.h:78
int NumHits() const
Definition: EMTFTrack.h:124
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
int GMT_quality() const
Definition: EMTFTrack.h:198
int BX() const
Definition: EMTFTrack.h:177
int Eta_GMT() const
Definition: SP.h:99
int Endcap() const
Definition: EMTFTrack.h:165
std::vector< EMTFHit > EMTFHitCollection
Definition: EMTFHit.h:366
int Phi_GMT() const
Definition: SP.h:96
int ME4_CSC_ID() const
Definition: SP.h:110
std::vector< EMTFDaqOut > EMTFDaqOutCollection
Definition: EMTFDaqOut.h:179
void setTrackSubAddress(bmtfAddress subAddress, int value)
Set a part of the muon candidates track address; specialised for BMTF.
void set_bc0(int bits)
Definition: SP.h:59
void set_track_num(int bits)
Definition: EMTFTrack.h:163
void set_eta_GMT(int bits)
Definition: SP.h:65
int ME2_CSC_ID() const
Definition: SP.h:106
int C() const
Definition: SP.h:89
void set_c(int bits)
Definition: SP.h:54
void set_vc(int bits)
Definition: SP.h:56
void set_hmt(int bits)
Definition: SP.h:63
int GMT_eta() const
Definition: EMTFTrack.h:197
void setHwQual(int bits)
Set compressed quality code as transmitted by hardware (4 bits)
void setHwPt(int bits)
Set compressed pT as transmitted by hardware LSB = 0.5 (9 bits)
void set_me4_CSC_ID(int bits)
Definition: SP.h:76
void setHwEta(int bits)
Set compressed eta as transmitted by hardware LSB = 0.010875 (9 bits)
void setHwDXY(int bits)
Set compressed impact parameter with respect to beamspot (4 bits)
void setOneNominalInTime(const bool bit)
void set_me4_stub_num(int bits)
Definition: SP.h:77
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: EMTFBlockSP.cc:170
void set_me3_delay(int bits)
Definition: SP.h:81
void set_dxy_GMT(int bits)
Definition: SP.h:68
int ME3_delay() const
Definition: SP.h:115
int ME1_subsector() const
Definition: SP.h:103
void setBXRange(int bxFirst, int bxLast)
uint64_t address
Definition: EMTFTrack.h:25
int ME3_CSC_ID() const
Definition: SP.h:108
EMTFPtLUT PtLUT() const
Definition: EMTFTrack.h:129
void setTFIdentifiers(int processor, tftype trackFinder)
Set the processor ID, track-finder type. From these two, the link is set.
int ME1_delay() const
Definition: SP.h:113
void set_pt_LUT_addr(unsigned long bits)
Definition: SP.h:84
void ImportSP(EMTFTrack &_track, const l1t::emtf::SP _SP, const int _endcap, const int _evt_sector)
int ME4_delay() const
Definition: SP.h:116
int Track_num() const
Definition: EMTFTrack.h:201
void push_Hit(const EMTFHit &hit)
Definition: EMTFTrack.h:101
#define DEFINE_L1T_UNPACKER(type)
void set_me1_CSC_ID(int bits)
Definition: SP.h:70
void setHwSignValid(int bits)
Set whether charge measurement is valid (0 for high pT muons)
int TBIN() const
Definition: SP.h:112
std::vector< int > convert_SP_location(int _csc_ID, int _sector, int _subsector, int _station)
Definition: EMTFBlockSP.cc:99
Definition: errors.py:1
int ME2_stub_num() const
Definition: SP.h:107
std::vector< EMTFTrack > EMTFTrackCollection
Definition: EMTFTrack.h:251
uint16_t GetHexBits(uint16_t word, uint16_t lowBit, uint16_t highBit)
Log< level::Warning, false > LogWarning
int GMT_phi() const
Definition: EMTFTrack.h:196
void set_me1_subsector(int bits)
Definition: SP.h:69
void setHwPtUnconstrained(int bits)
Set compressed second displaced pT as transmitted by hardware LSB = 1.0 (8 bits)
void set_quality_GMT(int bits)
Definition: SP.h:60
void add_format_error()
Definition: SP.h:85
void push_back(int bx, T object)
void set_phi_full(int bits)
Definition: SP.h:55
void setHwSign(int bits)
Set charge sign bit (charge = (-1)^(sign))
void set_mode(int bits)
Definition: SP.h:64
int Dxy_GMT() const
Definition: SP.h:102
void set_nn_pt_valid(int bits)
Definition: SP.h:83