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_;
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  mu_.setHwSign ( SP_.C() );
201  mu_.setHwSignValid ( SP_.VC() );
202  mu_.setHwQual ( SP_.Quality_GMT() );
203  mu_.setHwEta ( SP_.Eta_GMT() );
204  mu_.setHwPhi ( SP_.Phi_GMT() );
205  mu_.setHwPt ( SP_.Pt_GMT() );
206  mu_.setTFIdentifiers ( Track_.Sector() - 1, (Track_.Endcap() == 1) ? emtf_pos : emtf_neg );
208  // mu_.set_dataword ( SP_.Dataword() );
209  // Track_.set_GMT(mu_);
210 
212  // Match hits to tracks
214 
215  // Find the track delay
216  int nDelay[3] = {0, 0, 0}; // Number of hits in the track with delay 0, 1, or 2
217  if ( Track_.Mode() >= 8) nDelay[SP_.ME1_delay()] += 1;
218  if ((Track_.Mode() % 8) >= 4) nDelay[SP_.ME2_delay()] += 1;
219  if ((Track_.Mode() % 4) >= 2) nDelay[SP_.ME3_delay()] += 1;
220  if ((Track_.Mode() % 2) == 1) nDelay[SP_.ME4_delay()] += 1;
221 
222  int trk_delay = -99;
223  // Assume 2nd-earliest LCT configuration
224  if (nDelay[2] >= 2) trk_delay = 2;
225  else if (nDelay[2] + nDelay[1] >= 2) trk_delay = 1;
226  else if (nDelay[2] + nDelay[1] + nDelay[0] >= 2) trk_delay = 0;
227 
228  // // For earliest LCT configuration
229  // if (nDelay[2] >= 1) trk_delay = 2;
230  // else if (nDelay[2] + nDelay[1] >= 1) trk_delay = 1;
231  // else if (nDelay[2] + nDelay[1] + nDelay[0] >= 1) trk_delay = 0;
232 
233  std::array<int, 4> St_hits{{0, 0, 0, 0}}; // Number of matched hits in each station
234 
235  for (auto const & Hit : *res_hit) {
236 
237  if ( Track_.Mode() == 1 ) continue; // Special case dealt with later
238  if ( Hit.Endcap() != Track_.Endcap() ) continue;
239 
240  int hit_delay = -99;
241  if ( Hit.Station() == 1 ) hit_delay = SP_.ME1_delay();
242  else if ( Hit.Station() == 2 ) hit_delay = SP_.ME2_delay();
243  else if ( Hit.Station() == 3 ) hit_delay = SP_.ME3_delay();
244  else if ( Hit.Station() == 4 ) hit_delay = SP_.ME4_delay();
245 
246  // Require exact matching according to TBIN and delays
247  if ( Hit.BX() + 3 + hit_delay != SP_.TBIN() + trk_delay ) continue;
248 
249  // Match hit in station 1
250  conv_vals_SP = convert_SP_location( SP_.ME1_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), SP_.ME1_subsector(), 1 );
251 
252  if ( Hit.Station() == 1 &&
253  Hit.Sector() == conv_vals_SP.at(1) &&
254  Hit.Neighbor() == conv_vals_SP.at(3) &&
255  Hit.Stub_num() == SP_.ME1_stub_num() ) {
256 
257  if ( Hit.Is_CSC() == 1 &&
258  ( Hit.CSC_ID() != conv_vals_SP.at(0) ||
259  Hit.Subsector() != conv_vals_SP.at(2) ) ) continue;
260 
261  int RPC_subsector = ((Hit.Subsector() - 1) / 3) + 1; // Map RPC subsector to equivalent CSC subsector
262  int RPC_CSC_ID = ((Hit.Subsector() - 1) % 3) + 4; // Map RPC subsector and ring to equivalent CSC ID
263 
264  if ( Hit.Is_RPC() == 1 &&
265  ( RPC_CSC_ID != conv_vals_SP.at(0) ||
266  RPC_subsector != conv_vals_SP.at(2) ) ) continue;
267 
268  if (St_hits.at(0) == 0 ) { // Only add the first matched hit to the track
269  Track_.push_Hit( (Hit) );
272  L1TMuonEndCap::calc_uGMT_chamber( conv_vals_SP.at(0),
273  conv_vals_SP.at(2),
274  conv_vals_SP.at(3), 1) );
275  }
276  St_hits.at(0) += 1; // Count the total number of matches for debugging purposes
277  } // End conditional: if ( Hit.Station() == 1
278 
279 
280  // Match hit in station 2
281  conv_vals_SP = convert_SP_location( SP_.ME2_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 2 );
282 
283  if ( Hit.Station() == 2 &&
284  Hit.Sector() == conv_vals_SP.at(1) &&
285  Hit.Neighbor() == conv_vals_SP.at(3) &&
286  Hit.Stub_num() == SP_.ME2_stub_num() ) {
287 
288  if ( Hit.Is_CSC() == 1 &&
289  Hit.CSC_ID() != conv_vals_SP.at(0) ) continue;
290 
291  if ( Hit.Is_RPC() == 1 &&
292  Hit.Subsector() + 3 != conv_vals_SP.at(0) ) continue;
293 
294  if (St_hits.at(1) == 0 ) {
295  Track_.push_Hit( (Hit) );
298  L1TMuonEndCap::calc_uGMT_chamber( conv_vals_SP.at(0),
299  conv_vals_SP.at(2),
300  conv_vals_SP.at(3), 2) );
301  }
302  St_hits.at(1) += 1;
303  } // End conditional: if ( Hit.Station() == 2
304 
305 
306  // Match hit in station 3
307  conv_vals_SP = convert_SP_location( SP_.ME3_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 3 );
308 
309  if ( Hit.Station() == 3 &&
310  Hit.Sector() == conv_vals_SP.at(1) &&
311  Hit.Neighbor() == conv_vals_SP.at(3) &&
312  Hit.Stub_num() == SP_.ME3_stub_num() ) {
313 
314  if ( Hit.Is_CSC() == 1 &&
315  Hit.CSC_ID() != conv_vals_SP.at(0) ) continue;
316 
317  if ( Hit.Is_RPC() == 1 &&
318  Hit.Subsector() + 3 != conv_vals_SP.at(0) ) continue;
319 
320  if (St_hits.at(2) == 0 ) {
321  Track_.push_Hit( (Hit) );
324  L1TMuonEndCap::calc_uGMT_chamber( conv_vals_SP.at(0),
325  conv_vals_SP.at(2),
326  conv_vals_SP.at(3), 3) );
327  }
328  St_hits.at(2) += 1;
329  } // End conditional: if ( Hit.Station() == 3
330 
331 
332  // Match hit in station 4
333  conv_vals_SP = convert_SP_location( SP_.ME4_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 4 );
334 
335  if ( Hit.Station() == 4 &&
336  Hit.Sector() == conv_vals_SP.at(1) &&
337  Hit.Neighbor() == conv_vals_SP.at(3) &&
338  Hit.Stub_num() == SP_.ME4_stub_num() ) {
339 
340  if ( Hit.Is_CSC() == 1 &&
341  Hit.CSC_ID() != conv_vals_SP.at(0) ) continue;
342 
343  if ( Hit.Is_RPC() == 1 &&
344  Hit.Subsector() + 3 != conv_vals_SP.at(0) ) continue;
345 
346  if (St_hits.at(3) == 0 ) {
347  Track_.push_Hit( (Hit) );
350  L1TMuonEndCap::calc_uGMT_chamber( conv_vals_SP.at(0),
351  conv_vals_SP.at(2),
352  conv_vals_SP.at(3), 4) );
353  }
354  St_hits.at(3) += 1;
355  } // End conditional: if ( Hit.Station() == 4
356 
357  } // End loop: for (auto const & Hit : *res_hit)
358 
359 
360  // Special configuration for single-stub tracks from ME1/1
361  if (Track_.Mode() == 1) {
362 
363  // Infer ME1/1 chamber based on track phi
364  int chamber_min = ((Track_.GMT_phi() - 17) / 16) + Track_.Sector()*6 - 3;
365  int chamber_max = ((Track_.GMT_phi() + 1) / 16) + Track_.Sector()*6 - 3;
366  for (int iChamb = chamber_max; iChamb >= chamber_min; iChamb--) {
367  int chamber = (iChamb < 37 ? iChamb : (iChamb % 36));
368 
369  for (auto const & Hit : *res_hit) {
370  if ( Hit.Sector_idx() != Track_.Sector_idx() ) continue;
371  if ( Hit.BX() != Track_.BX() ) continue;
372  if ( Hit.Chamber() != chamber ) continue;
373  if ( Hit.Is_CSC() != 1 ) continue;
374  if ( Hit.Station() != 1 ) continue;
375  if ( ( Hit.Ring() % 3 ) != 1 ) continue;
376  if ( Hit.Neighbor() == 1 ) continue;
377 
378  // Don't use LCTs that were already used in a multi-station track
379  bool hit_already_used = false;
380  for (auto const & Trk : *res_track) {
381  if ( Trk.Sector_idx() != Track_.Sector_idx() ) continue;
382  if ( Trk.NumHits() < 1 ) continue;
383 
384  if ( Trk.Hits().at(0).Station() == 1 &&
385  Trk.Hits().at(0).Chamber() == chamber &&
386  Trk.Hits().at(0).BX() == Hit.BX() &&
387  Trk.Hits().at(0).Ring() == Hit.Ring() &&
388  Trk.Hits().at(0).Strip() == Hit.Strip() &&
389  Trk.Hits().at(0).Wire() == Hit.Wire() ) {
390  hit_already_used = true;
391  break;
392  }
393  } // End loop: for (auto const & Trk : *res_track)
394 
395  if (!hit_already_used) {
396  Track_.push_Hit( (Hit) );
397  break;
398  }
399  } // End loop: for (auto const & Hit : *res_hit)
400  if (Track_.NumHits() > 0) break;
401  } // End loop: for (int iChamb = chamber_max; iChamb >= chamber_min; iChamb--)
402 
403  // if (Track_.NumHits() != 1) {
404  // std::cout << "\n\n***********************************************************" << std::endl;
405  // std::cout << "Bug in unpacked EMTF event! Mode " << Track_.Mode() << " track in sector " << Track_.Sector()*Track_.Endcap()
406  // << ", BX " << Track_.BX() << ", GMT phi " << Track_.GMT_phi() << ", GMT eta " << Track_.GMT_eta()
407  // << " should have found an LCT between chamber " << chamber_min << " and " << chamber_max << std::endl;
408  // std::cout << "All available LCTs as follows:" << std::endl;
409  // for (auto const & Hit : *res_hit) {
410  // std::cout << "Hit: Is CSC = " << Hit.Is_CSC() << ", CSC ID = " << Hit.CSC_ID()
411  // << ", sector = " << Hit.Sector()*Hit.Endcap() << ", sub = " << Hit.Subsector()
412  // << ", neighbor = " << Hit.Neighbor() << ", station = " << Hit.Station()
413  // << ", ring = " << Hit.Ring() << ", chamber = " << Hit.Chamber()
414  // << ", stub = " << Hit.Stub_num() << ", BX = " << Hit.BX() << std::endl;
415  // std::cout << "All other tracks are as follows:" << std::endl;
416  // for (auto Trk = res_hit->begin(); Trk != res_hit->end(); ++Trk) {
417  // std::cout << "Track: mode " << Trk.Mode() << " track in sector " << Trk.Sector()*Trk.Endcap()
418  // << ", BX " << Trk.BX() << ", GMT phi " << Trk.GMT_phi() << ", GMT eta " << Trk.GMT_eta() << std::endl;
419  // }
420  // std::cout << "***********************************************************\n\n" << std::endl;
421  // } // End conditional: if (Track_.NumHits() != 1)
422 
423  } // End conditional: if (Track_.Mode() == 1)
424 
425 
426  // 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) {
427  // std::cout << "\n\n***********************************************************" << std::endl;
428  // std::cout << "Bug in unpacked EMTF event! Mode " << Track_.Mode() << " track in sector " << Track_.Sector()*Track_.Endcap()
429  // << ", BX " << Track_.BX() << " (delay = " << trk_delay << ") with (" << St_hits.at(0) << ", " << St_hits.at(1)
430  // << ", " << St_hits.at(2) << ", " << St_hits.at(3) << ") hits in stations (1, 2, 3, 4)" << std::endl;
431 
432  // std::cout << "\nME1_stub_num = " << SP_.ME1_stub_num() << ", ME1_delay = " << SP_.ME1_delay()
433  // << ", ME1_CSC_ID = " << SP_.ME1_CSC_ID() << ", ME1_subsector = " << SP_.ME1_subsector() << std::endl;
434  // std::cout << "ME2_stub_num = " << SP_.ME2_stub_num() << ", ME2_delay = " << SP_.ME2_delay()
435  // << ", ME2_CSC_ID = " << SP_.ME2_CSC_ID() << std::endl;
436  // std::cout << "ME3_stub_num = " << SP_.ME3_stub_num() << ", ME3_delay = " << SP_.ME3_delay()
437  // << ", ME3_CSC_ID = " << SP_.ME3_CSC_ID() << std::endl;
438  // std::cout << "ME4_stub_num = " << SP_.ME4_stub_num() << ", ME4_delay = " << SP_.ME4_delay()
439  // << ", ME4_CSC_ID = " << SP_.ME4_CSC_ID() << std::endl;
440 
441  // conv_vals_SP = convert_SP_location( SP_.ME1_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), SP_.ME1_subsector(), 1 );
442  // std::cout << "\nConverted ME1 CSC ID = " << conv_vals_SP.at(0) << ", sector = " << conv_vals_SP.at(1)
443  // << ", subsector = " << conv_vals_SP.at(2) << ", neighbor = " << conv_vals_SP.at(3) << std::endl;
444  // conv_vals_SP = convert_SP_location( SP_.ME2_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 2 );
445  // std::cout << "Converted ME2 CSC ID = " << conv_vals_SP.at(0) << ", sector = " << conv_vals_SP.at(1)
446  // << ", subsector = " << conv_vals_SP.at(2) << ", neighbor = " << conv_vals_SP.at(3) << std::endl;
447  // conv_vals_SP = convert_SP_location( SP_.ME3_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 3 );
448  // std::cout << "Converted ME3 CSC ID = " << conv_vals_SP.at(0) << ", sector = " << conv_vals_SP.at(1)
449  // << ", subsector = " << conv_vals_SP.at(2) << ", neighbor = " << conv_vals_SP.at(3) << std::endl;
450  // conv_vals_SP = convert_SP_location( SP_.ME4_CSC_ID(), (res->at(iOut)).PtrEventHeader()->Sector(), -99, 4 );
451  // std::cout << "Converted ME4 CSC ID = " << conv_vals_SP.at(0) << ", sector = " << conv_vals_SP.at(1)
452  // << ", subsector = " << conv_vals_SP.at(2) << ", neighbor = " << conv_vals_SP.at(3) << "\n" << std::endl;
453 
454 
455  // for (auto const & Hit : *res_hit)
456  // std::cout << "Hit: Is CSC = " << Hit.Is_CSC() << ", CSC ID = " << Hit.CSC_ID()
457  // << ", sector = " << Hit.Sector() << ", sub = " << Hit.Subsector()
458  // << ", neighbor = " << Hit.Neighbor() << ", station = " << Hit.Station()
459  // << ", ring = " << Hit.Ring() << ", chamber = " << Hit.Chamber()
460  // << ", stub = " << Hit.Stub_num() << ", BX = " << Hit.BX() << std::endl;
461 
462  // // int iHit = 0;
463  // // for (auto const & Hit : *res_hit) {
464  // // if (iHit == 0) Hit.PrintSimulatorHeader();
465  // // Hit.PrintForSimulator();
466  // // iHit += 1;
467  // // }
468  // std::cout << "***********************************************************\n\n" << std::endl;
469  // }
470 
471  (res->at(iOut)).push_SP(SP_);
472 
473  res_track->push_back( Track_ );
474 
475  // TBIN_num can range from 0 through 7, i.e. BX = -3 through +4. - AWB 04.04.16
476  res_cand->setBXRange(-3, 4);
477  res_cand->push_back(SP_.TBIN() - 3, mu_);
478 
479  // Finished with unpacking one SP Output Data Record
480  return true;
481 
482  } // End bool SPBlockUnpacker::unpack
483 
484  // bool SPBlockPacker::pack(const Block& block, UnpackerCollections *coll) {
485  // std::cout << "Inside SPBlockPacker::pack" << std::endl;
486  // return true;
487  // } // End bool SPBlockPacker::pack
488 
489  } // End namespace emtf
490  } // End namespace stage2
491 } // End namespace l1t
492 
494 // DEFINE_L1T_PACKER(l1t::stage2::SPBlockPacker);
int ME3_stub_num() const
Definition: SP.h:76
void set_me3_stub_num(int bits)
Definition: SP.h:45
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:43
int ME4_delay() const
Definition: SP.h:83
int Endcap() const
Definition: EMTFTrack.h:119
void set_me3_CSC_ID(int bits)
Definition: SP.h:44
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:35
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:79
delete x;
Definition: CaloConfig.h:22
std::vector< uint32_t > payload() const
Definition: Block.h:60
int ME3_CSC_ID() const
Definition: SP.h:75
Definition: Electron.h:4
void set_se(int bits)
Definition: SP.h:31
void set_me2_CSC_ID(int bits)
Definition: SP.h:42
int ME1_delay() const
Definition: SP.h:80
void set_me1_stub_num(int bits)
Definition: SP.h:41
int Sector_idx() const
Definition: EMTFTrack.h:121
void set_pt_GMT(int bits)
Definition: SP.h:38
void set_me4_delay(int bits)
Definition: SP.h:52
int ME3_delay() const
Definition: SP.h:82
void set_phi_GMT(int bits)
Definition: SP.h:34
int TwosCompl(int nBits, int bits)
void set_me1_delay(int bits)
Definition: SP.h:49
int Phi_GMT() const
Definition: SP.h:65
int ME1_subsector() const
Definition: SP.h:70
void set_me2_delay(int bits)
Definition: SP.h:50
void set_hl(int bits)
Definition: SP.h:26
int VC() const
Definition: SP.h:60
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:48
int ME2_CSC_ID() const
Definition: SP.h:73
std::vector< EMTFHit > EMTFHitCollection
Definition: EMTFHit.h:241
int ME1_CSC_ID() const
Definition: SP.h:71
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:32
void set_track_num(int bits)
Definition: EMTFTrack.h:116
void set_eta_GMT(int bits)
Definition: SP.h:37
void set_c(int bits)
Definition: SP.h:27
void set_vc(int bits)
Definition: SP.h:29
int ME1_stub_num() const
Definition: SP.h:72
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:77
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:46
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:47
int Pt_GMT() const
Definition: SP.h:69
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: EMTFBlockSP.cc:108
void set_me3_delay(int bits)
Definition: SP.h:51
int ME4_stub_num() const
Definition: SP.h:78
int ME2_delay() const
Definition: SP.h:81
void setBXRange(int bxFirst, int bxLast)
int Eta_GMT() const
Definition: SP.h:68
int BX() const
Definition: EMTFTrack.h:130
void set_pt_LUT_addr(unsigned long bits)
Definition: SP.h:53
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:58
#define DEFINE_L1T_UNPACKER(type)
void set_me1_CSC_ID(int bits)
Definition: SP.h:40
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:74
void set_me1_subsector(int bits)
Definition: SP.h:39
int Quality_GMT() const
Definition: SP.h:64
void set_quality_GMT(int bits)
Definition: SP.h:33
void add_format_error()
Definition: SP.h:54
void push_back(int bx, T object)
void set_phi_full(int bits)
Definition: SP.h:28
void setHwSign(int bits)
Set charge sign bit (charge = (-1)^(sign))
void set_mode(int bits)
Definition: SP.h:36