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