CMS 3D CMS Logo

PrimitiveConversion.cc
Go to the documentation of this file.
4 
5 #include "Geometry/RPCGeometry/interface/RPCGeometry.h" // for special treatments for iRPC
6 
8  const SectorProcessorLUT* pc_lut,
9  int verbose,
10  int endcap,
11  int sector,
12  int bx,
13  int bxShiftCSC,
14  int bxShiftRPC,
15  int bxShiftGEM,
16  int bxShiftME0,
17  const std::vector<int>& zoneBoundaries,
18  int zoneOverlap,
19  bool duplicateTheta,
20  bool fixZonePhi,
21  bool useNewZones,
22  bool fixME11Edges,
23  bool bugME11Dupes,
24  bool useRun3CCLUT) {
25  emtf_assert(tp_geom != nullptr);
26  emtf_assert(pc_lut != nullptr);
27 
28  tp_geom_ = tp_geom;
29  pc_lut_ = pc_lut;
30 
31  verbose_ = verbose;
32  endcap_ = endcap; // 1 for ME+, 2 for ME-
33  sector_ = sector;
34  bx_ = bx;
35 
36  bxShiftCSC_ = bxShiftCSC;
37  bxShiftRPC_ = bxShiftRPC;
38  bxShiftGEM_ = bxShiftGEM;
39  bxShiftME0_ = bxShiftME0;
40 
41  zoneBoundaries_ = zoneBoundaries;
42  zoneOverlap_ = zoneOverlap;
43  duplicateTheta_ = duplicateTheta;
44  fixZonePhi_ = fixZonePhi;
45  useNewZones_ = useNewZones;
46  fixME11Edges_ = fixME11Edges;
47  bugME11Dupes_ = bugME11Dupes;
48 
49  // Run 3 CCLUT algorithm
50  useRun3CCLUT_ = useRun3CCLUT;
51 }
52 
53 void PrimitiveConversion::process(const std::map<int, TriggerPrimitiveCollection>& selected_prim_map,
54  EMTFHitCollection& conv_hits) const {
55  std::map<int, TriggerPrimitiveCollection>::const_iterator map_tp_it = selected_prim_map.begin();
56  std::map<int, TriggerPrimitiveCollection>::const_iterator map_tp_end = selected_prim_map.end();
57 
58  for (; map_tp_it != map_tp_end; ++map_tp_it) {
59  // Unique chamber ID in FW, {0, 53} as defined in get_index_csc in src/PrimitiveSelection.cc
60  int selected = map_tp_it->first;
61  // "Primitive Conversion" sector/station/chamber ID scheme used in FW
62  int pc_sector = sector_;
63  int pc_station = selected / 9; // {0, 5} = {ME1 sub 1, ME1 sub 2, ME2, ME3, ME4, neighbor}
64  int pc_chamber = selected % 9; // Equals CSC ID - 1 for all except neighbor chambers
65  int pc_segment = 0; // Counts hits in a single chamber
66 
67  TriggerPrimitiveCollection::const_iterator tp_it = map_tp_it->second.begin();
68  TriggerPrimitiveCollection::const_iterator tp_end = map_tp_it->second.end();
69 
70  for (; tp_it != tp_end; ++tp_it) {
71  EMTFHit conv_hit;
72  if (tp_it->subsystem() == L1TMuon::kCSC) {
73  convert_csc(pc_sector, pc_station, pc_chamber, pc_segment, *tp_it, conv_hit);
74  } else if (tp_it->subsystem() == L1TMuon::kRPC) {
75  convert_rpc(pc_sector, pc_station, pc_chamber, pc_segment, *tp_it, conv_hit);
76  } else if (tp_it->subsystem() == L1TMuon::kGEM) {
77  convert_gem(pc_sector, 0, selected, pc_segment, *tp_it, conv_hit); // pc_station and pc_chamber are meaningless
78  } else if (tp_it->subsystem() == L1TMuon::kME0) {
79  convert_me0(pc_sector, 0, selected, pc_segment, *tp_it, conv_hit); // pc_station and pc_chamber are meaningless
80  } else if (tp_it->subsystem() == L1TMuon::kDT) {
81  convert_dt(pc_sector, 0, selected, pc_segment, *tp_it, conv_hit); // pc_station and pc_chamber are meaningless
82  } else {
83  emtf_assert(false && "Incorrect subsystem type");
84  }
85  conv_hits.push_back(conv_hit);
86  pc_segment += 1;
87  }
88  }
89 }
90 
91 // _____________________________________________________________________________
92 // CSC functions
94  int pc_station,
95  int pc_chamber,
96  int pc_segment,
97  const TriggerPrimitive& muon_primitive,
98  EMTFHit& conv_hit) const {
99  const CSCDetId& tp_detId = muon_primitive.detId<CSCDetId>();
100  const CSCData& tp_data = muon_primitive.getCSCData();
101 
102  int tp_endcap = tp_detId.endcap();
103  int tp_sector = tp_detId.triggerSector();
104  int tp_station = tp_detId.station();
105  int tp_ring = tp_detId.ring();
106  int tp_chamber = tp_detId.chamber();
107 
108  int tp_bx = tp_data.bx;
109  int tp_csc_ID = tp_data.cscID;
110 
111  // station 1 --> subsector 1 or 2
112  // station 2,3,4 --> subsector 0
113  int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber % 6 > 2) ? 1 : 2);
114 
115  const bool is_neighbor = (pc_station == 5);
116 
117  int csc_nID = tp_csc_ID; // modify csc_ID if coming from neighbor sector
118  if (is_neighbor) {
119  // station 1 has 3 neighbor chambers: 13,14,15 in rings 1,2,3
120  // (where are chambers 10,11,12 in station 1? they were used to label ME1/1a, but not anymore)
121  // station 2,3,4 have 2 neighbor chambers: 10,11 in rings 1,2
122  csc_nID = (pc_chamber < 3) ? (pc_chamber + 12) : (((pc_chamber - 1) % 2) + 9);
123  csc_nID += 1;
124 
125  if (tp_station == 1) { // neighbor ME1
126  emtf_assert(tp_subsector == 2);
127  }
128  }
129 
130  // Set properties
131  conv_hit.SetCSCDetId(tp_detId);
132 
133  conv_hit.set_bx(tp_bx + bxShiftCSC_);
134  conv_hit.set_subsystem(L1TMuon::kCSC);
135  conv_hit.set_endcap((tp_endcap == 2) ? -1 : tp_endcap);
136  conv_hit.set_station(tp_station);
137  conv_hit.set_ring(tp_ring);
138  //conv_hit.set_roll ( tp_roll );
139  conv_hit.set_chamber(tp_chamber);
140  conv_hit.set_sector(tp_sector);
141  conv_hit.set_subsector(tp_subsector);
142  conv_hit.set_csc_ID(tp_csc_ID);
143  conv_hit.set_csc_nID(csc_nID);
144  conv_hit.set_track_num(tp_data.trknmb);
145  conv_hit.set_sync_err(tp_data.syncErr);
146  //conv_hit.set_sector_RPC ( tp_sector );
147  //conv_hit.set_subsector_RPC ( tp_subsector );
148 
149  conv_hit.set_pc_sector(pc_sector);
150  conv_hit.set_pc_station(pc_station);
151  conv_hit.set_pc_chamber(pc_chamber);
152  conv_hit.set_pc_segment(pc_segment);
153 
154  conv_hit.set_valid(tp_data.valid);
155  conv_hit.set_strip(tp_data.strip);
156  //conv_hit.set_strip_low ( tp_data.strip_low );
157  //conv_hit.set_strip_hi ( tp_data.strip_hi );
158  conv_hit.set_wire(tp_data.keywire);
159  conv_hit.set_quality(tp_data.quality);
160  conv_hit.set_pattern(tp_data.pattern);
161  conv_hit.set_bend(tp_data.bend);
162  conv_hit.set_time(0.); // No fine resolution timing
163  conv_hit.set_alct_quality(tp_data.alct_quality);
164  conv_hit.set_clct_quality(tp_data.clct_quality);
165  // Run-3
166  conv_hit.set_strip_quart(tp_data.strip_quart);
167  conv_hit.set_strip_eighth(tp_data.strip_eighth);
168  conv_hit.set_strip_quart_bit(tp_data.strip_quart_bit);
169  conv_hit.set_strip_eighth_bit(tp_data.strip_eighth_bit);
170  conv_hit.set_pattern_run3(tp_data.pattern_run3);
171  conv_hit.set_slope(tp_data.slope);
172 
173  conv_hit.set_neighbor(is_neighbor);
174  conv_hit.set_sector_idx((endcap_ == 1) ? sector_ - 1 : sector_ + 5);
175 
176  convert_csc_details(conv_hit);
177 
178  // Add coordinates from fullsim
179  {
180  const GlobalPoint& gp = tp_geom_->getGlobalPoint(muon_primitive);
181  double glob_phi = emtf::rad_to_deg(gp.phi().value());
182  double glob_theta = emtf::rad_to_deg(gp.theta());
183  double glob_eta = gp.eta();
184  double glob_rho = gp.perp();
185  double glob_z = gp.z();
186 
187  conv_hit.set_phi_sim(glob_phi);
188  conv_hit.set_theta_sim(glob_theta);
189  conv_hit.set_eta_sim(glob_eta);
190  conv_hit.set_rho_sim(glob_rho);
191  conv_hit.set_z_sim(glob_z);
192  }
193 }
194 
196  const bool is_neighbor = conv_hit.Neighbor();
197 
198  // Defined as in firmware
199  // endcap : 0-1 for ME+,ME-
200  // sector : 0-5
201  // station: 0-4 for st1 sub1 or st1 sub2 from neighbor, st1 sub2, st2, st3, st4
202  // cscid : 0-14 (excluding 11), including neighbors
203  const int fw_endcap = (endcap_ - 1);
204  const int fw_sector = (sector_ - 1);
205  const int fw_station =
206  (conv_hit.Station() == 1) ? (is_neighbor ? 0 : (conv_hit.Subsector() - 1)) : conv_hit.Station();
207  const int fw_cscid = (conv_hit.CSC_nID() - 1);
208  const int fw_strip = conv_hit.Strip(); // it is half-strip, despite the name
209  const int fw_wire = conv_hit.Wire(); // it is wiregroup, despite the name
210 
211  // Primitive converter unit
212  // station: 0-5 for st1 sub1, st1 sub2, st2, st3, st4, neigh all st*
213  // chamber: 0-8
214  const int pc_station = conv_hit.PC_station();
215  const int pc_chamber = conv_hit.PC_chamber();
216  const int pc_segment = conv_hit.PC_segment();
217 
218  const bool is_me11a = (conv_hit.Station() == 1 && conv_hit.Ring() == 4);
219  const bool is_me11b = (conv_hit.Station() == 1 && conv_hit.Ring() == 1);
220  const bool is_me13 = (conv_hit.Station() == 1 && conv_hit.Ring() == 3);
221 
222  // Is this chamber mounted in reverse direction?
223  // (i.e., phi vs. strip number is reversed)
224  bool ph_reverse = false;
225  if ((fw_endcap == 0 && fw_station >= 3) || (fw_endcap == 1 && fw_station < 3)) // ME+3, ME+4, ME-1, ME-2
226  ph_reverse = true;
227 
228  // Chamber coverage if phi_reverse = true
229  int ph_coverage = 0; // Offset for coordinate conversion
230  if (ph_reverse) {
231  if (fw_station <= 1 && ((fw_cscid >= 6 && fw_cscid <= 8) || fw_cscid == 14)) // ME1/3
232  ph_coverage = 15;
233  else if (fw_station >= 2 && (fw_cscid <= 2 || fw_cscid == 9)) // ME2,3,4/1
234  ph_coverage = 40;
235  else // all others
236  ph_coverage = 20;
237  }
238 
239  // Is this 10-deg or 20-deg chamber?
240  bool is_10degree = false;
241  if ((fw_station <= 1) || // ME1
242  (fw_station >= 2 && ((fw_cscid >= 3 && fw_cscid <= 8) || fw_cscid == 10)) // ME2,3,4/2
243  ) {
244  is_10degree = true;
245  }
246 
247  // LUT index
248  // There are 54 CSC chambers including the neighbors in a sector, but 61 LUT indices
249  // This comes from dividing the 6 chambers + 1 neighbor in ME1/1 into ME1/1a and ME1/1b
250  int pc_lut_id = pc_chamber;
251  if (pc_station == 0) { // ME1 sub 1: 0 - 11
252  pc_lut_id = is_me11a ? pc_lut_id + 9 : pc_lut_id;
253  } else if (pc_station == 1) { // ME1 sub 2: 16 - 27
254  pc_lut_id += 16;
255  pc_lut_id = is_me11a ? pc_lut_id + 9 : pc_lut_id;
256  } else if (pc_station == 2) { // ME2: 28 - 36
257  pc_lut_id += 28;
258  } else if (pc_station == 3) { // ME3: 39 - 47
259  pc_lut_id += 39;
260  } else if (pc_station == 4) { // ME4 : 50 - 58
261  pc_lut_id += 50;
262  } else if (pc_station == 5 && pc_chamber < 3) { // neighbor ME1: 12 - 15
263  pc_lut_id = is_me11a ? pc_lut_id + 15 : pc_lut_id + 12;
264  } else if (pc_station == 5 && pc_chamber < 5) { // neighbor ME2: 37 - 38
265  pc_lut_id += 28 + 9 - 3;
266  } else if (pc_station == 5 && pc_chamber < 7) { // neighbor ME3: 48 - 49
267  pc_lut_id += 39 + 9 - 5;
268  } else if (pc_station == 5 && pc_chamber < 9) { // neighbor ME4: 59 - 60
269  pc_lut_id += 50 + 9 - 7;
270  }
271  emtf_assert(pc_lut_id < 61);
272 
273  if (verbose_ > 1) { // debug
274  std::cout << "pc_station: " << pc_station << " pc_chamber: " << pc_chamber << " fw_station: " << fw_station
275  << " fw_cscid: " << fw_cscid << " lut_id: " << pc_lut_id
276  << " ph_init: " << pc_lut().get_ph_init(fw_endcap, fw_sector, pc_lut_id)
277  << " ph_disp: " << pc_lut().get_ph_disp(fw_endcap, fw_sector, pc_lut_id)
278  << " th_init: " << pc_lut().get_th_init(fw_endcap, fw_sector, pc_lut_id)
279  << " th_disp: " << pc_lut().get_th_disp(fw_endcap, fw_sector, pc_lut_id)
280  << " ph_init_hard: " << pc_lut().get_ph_init_hard(fw_station, fw_cscid) << std::endl;
281  }
282 
283  // ___________________________________________________________________________
284  // phi conversion
285 
286  // Convert half-strip into 1/8-strip
287  int eighth_strip = 0;
288 
289  // Apply phi correction from CLCT pattern number (from src/SectorProcessorLUT.cc)
290  int clct_pat_corr = pc_lut().get_ph_patt_corr(conv_hit.Pattern());
291  int clct_pat_corr_sign = (pc_lut().get_ph_patt_corr_sign(conv_hit.Pattern()) == 0) ? 1 : -1;
292 
293  // At strip number 0, protect against negative correction
294  bool bugStrip0BeforeFW48200 = false;
295  if (bugStrip0BeforeFW48200 == false && fw_strip == 0 && clct_pat_corr_sign == -1)
296  clct_pat_corr = 0;
297 
298  if (is_10degree) {
299  eighth_strip = fw_strip << 2; // full precision, uses only 2 bits of pattern correction
300  if (useRun3CCLUT_) {
301  eighth_strip += (conv_hit.Strip_quart_bit() << 1 | conv_hit.Strip_eighth_bit() << 0); // Run 3 CCLUT variables
302  } else {
303  eighth_strip += clct_pat_corr_sign * (clct_pat_corr >> 1);
304  }
305  } else {
306  eighth_strip = fw_strip << 3; // multiply by 2, uses all 3 bits of pattern correction
307  if (useRun3CCLUT_) {
308  eighth_strip += (conv_hit.Strip_quart_bit() << 2 | conv_hit.Strip_eighth_bit() << 1); // Run 3 CCLUT variables
309  } else {
310  eighth_strip += clct_pat_corr_sign * (clct_pat_corr >> 0);
311  }
312  }
313  emtf_assert(bugStrip0BeforeFW48200 == true || eighth_strip >= 0);
314 
315  // Multiplicative factor for eighth_strip
316  // +----------------------------+-------------+------------------+
317  // | Chamber type | Strip angle | Mult factor |
318  // | | (deg) | |
319  // +----------------------------+-------------+------------------+
320  // | ME1/2, ME2/2, ME3/2, ME4/2 | 0.1333 | 1/2 (remove LSB) |
321  // | ME2/1, ME3/1, ME4/1 | 0.2666 | 1 (no op) |
322  // | ME1/1a | 0.2222 | 0.8335 |
323  // | ME1/1b | 0.1695 | 0.636 |
324  // | ME1/3 | 0.1233 | 0.4625 |
325  // +----------------------------+-------------+------------------+
326 
327  int factor = 1024;
328  if (is_me11a)
329  factor = 1707; // ME1/1a
330  else if (is_me11b)
331  factor = 1301; // ME1/1b
332  else if (is_me13)
333  factor = 947; // ME1/3
334 
335  // ph_tmp is full-precision phi, but local to chamber (counted from strip 0)
336  // full phi precision: ( 1/60) deg (1/8-strip)
337  // zone phi precision: (32/60) deg (4-strip, 32 times coarser than full phi precision)
338  int ph_tmp = (eighth_strip * factor) >> 10;
339  int ph_tmp_sign = (ph_reverse == 0) ? 1 : -1;
340 
341  int fph = pc_lut().get_ph_init(fw_endcap, fw_sector, pc_lut_id);
342  fph = fph + ph_tmp_sign * ph_tmp;
343 
344  int ph_hit = pc_lut().get_ph_disp(fw_endcap, fw_sector, pc_lut_id);
345  ph_hit = (ph_hit >> 1) + ph_tmp_sign * (ph_tmp >> 5) + ph_coverage;
346 
347  // Full phi +16 to put the rounded value into the middle of error range
348  // Divide full phi by 32, subtract chamber start
349  int ph_hit_fixed = -1 * pc_lut().get_ph_init_hard(fw_station, fw_cscid);
350  ph_hit_fixed = ph_hit_fixed + ((fph + (1 << 4)) >> 5);
351 
352  if (fixZonePhi_)
353  ph_hit = ph_hit_fixed;
354 
355  // Zone phi
356  int zone_hit = pc_lut().get_ph_zone_offset(pc_station, pc_chamber);
357  zone_hit += ph_hit;
358 
359  int zone_hit_fixed = pc_lut().get_ph_init_hard(fw_station, fw_cscid);
360  zone_hit_fixed += ph_hit_fixed;
361  // Since ph_hit_fixed = ((fph + (1<<4)) >> 5) - pc_lut().get_ph_init_hard(), the following is equivalent:
362  //zone_hit_fixed = ((fph + (1<<4)) >> 5);
363 
364  if (fixZonePhi_)
365  zone_hit = zone_hit_fixed;
366 
367  emtf_assert(0 <= fph && fph < 5000);
368  emtf_assert(0 <= zone_hit && zone_hit < 192);
369 
370  // ___________________________________________________________________________
371  // theta conversion
372 
373  // th_tmp is theta local to chamber
374  int pc_wire_id = (fw_wire & 0x7f); // 7-bit
375  int th_tmp = pc_lut().get_th_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_id);
376 
377  // For ME1/1 with tilted wires, add theta correction as a function of (wire,strip) index
378  if (!fixME11Edges_ && (is_me11a || is_me11b)) {
379  int pc_wire_strip_id =
380  (((fw_wire >> 4) & 0x3) << 5) | ((eighth_strip >> 4) & 0x1f); // 2-bit from wire, 5-bit from 2-strip
381 
382  // Only affect runs before FW changeset 47114 is applied
383  // e.g. Run 281707 and earlier
384  if (bugME11Dupes_) {
385  bool bugME11DupesBeforeFW47114 = false;
386  if (bugME11DupesBeforeFW47114) {
387  if (pc_segment == 1) {
388  pc_wire_strip_id = (((fw_wire >> 4) & 0x3) << 5) | (0); // 2-bit from wire, 5-bit from 2-strip
389  }
390  }
391  }
392 
393  int th_corr = pc_lut().get_th_corr_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_strip_id);
394  int th_corr_sign = (ph_reverse == 0) ? 1 : -1;
395 
396  th_tmp = th_tmp + th_corr_sign * th_corr;
397 
398  // Check that correction did not make invalid value outside chamber coverage
399  const int th_negative = 50;
400  const int th_coverage = 45;
401  if (th_tmp > th_negative || th_tmp < 0 || fw_wire == 0)
402  th_tmp = 0; // limit at the bottom
403  if (th_tmp > th_coverage)
404  th_tmp = th_coverage; // limit at the top
405 
406  } else if (fixME11Edges_ && (is_me11a || is_me11b)) {
407  int pc_wire_strip_id =
408  (((fw_wire >> 4) & 0x3) << 5) | ((eighth_strip >> 4) & 0x1f); // 2-bit from wire, 5-bit from 2-strip
409  if (is_me11a)
410  pc_wire_strip_id = (((fw_wire >> 4) & 0x3) << 5) | ((((eighth_strip * 341) >> 8) >> 4) &
411  0x1f); // correct for ME1/1a strip number (341/256 =~ 1.333)
412  int th_corr = pc_lut().get_th_corr_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_strip_id);
413 
414  th_tmp = th_tmp + th_corr;
415 
416  // Check that correction did not make invalid value outside chamber coverage
417  const int th_coverage = 46; // max coverage for front chamber is 47, max coverage for rear chamber is 45
418  if (fw_wire == 0)
419  th_tmp = 0; // limit at the bottom
420  if (th_tmp > th_coverage)
421  th_tmp = th_coverage; // limit at the top
422  }
423 
424  // theta precision: (36.5/128) deg
425  // theta starts at 8.5 deg: {1, 127} <--> {8.785, 44.715}
426  int th = pc_lut().get_th_init(fw_endcap, fw_sector, pc_lut_id);
427  th = th + th_tmp;
428 
429  emtf_assert(0 <= th && th < 128);
430  th = (th == 0) ? 1 : th; // protect against invalid value
431 
432  // ___________________________________________________________________________
433  // Zone codes and other segment IDs
434 
435  //int zone_hit = ((fph + (1<<4)) >> 5);
436  int zone_code = get_zone_code(conv_hit, th);
437  //int phzvl = get_phzvl(conv_hit, zone_code);
438 
439  int fs_zone_code = get_fs_zone_code(conv_hit);
440  int fs_segment = get_fs_segment(conv_hit, fw_station, fw_cscid, pc_segment);
441 
442  int bt_station = get_bt_station(conv_hit, fw_station, fw_cscid, pc_segment);
443  int bt_segment = get_bt_segment(conv_hit, fw_station, fw_cscid, pc_segment);
444 
445  // ___________________________________________________________________________
446  // Output
447 
448  conv_hit.set_phi_fp(fph); // Full-precision integer phi
449  conv_hit.set_theta_fp(th); // Full-precision integer theta
450  //conv_hit.set_phzvl ( phzvl ); // Local zone word: (1*low) + (2*mid) + (4*low) - used in FW debugging
451  //conv_hit.set_ph_hit ( ph_hit ); // Intermediate quantity in phi calculation - used in FW debugging
452  conv_hit.set_zone_hit(zone_hit); // Phi value for building patterns (0.53333 deg precision)
453  conv_hit.set_zone_code(zone_code); // Full zone word: 1*(zone 0) + 2*(zone 1) + 4*(zone 2) + 8*(zone 3)
454 
455  conv_hit.set_fs_segment(fs_segment); // Segment number used in primitive matching
456  conv_hit.set_fs_zone_code(fs_zone_code); // Zone word used in primitive matching
457 
458  conv_hit.set_bt_station(bt_station);
459  conv_hit.set_bt_segment(bt_segment);
460 
461  conv_hit.set_phi_loc(emtf::calc_phi_loc_deg(fph));
462  conv_hit.set_phi_glob(emtf::calc_phi_glob_deg(conv_hit.Phi_loc(), conv_hit.PC_sector()));
464  conv_hit.set_eta(emtf::calc_eta_from_theta_deg(conv_hit.Theta(), conv_hit.Endcap()));
465 }
466 
467 // _____________________________________________________________________________
468 // RPC functions
470  int pc_station,
471  int pc_chamber,
472  int pc_segment,
473  const TriggerPrimitive& muon_primitive,
474  EMTFHit& conv_hit) const {
475  const RPCDetId& tp_detId = muon_primitive.detId<RPCDetId>();
476  const RPCData& tp_data = muon_primitive.getRPCData();
477 
478  int tp_region = tp_detId.region(); // 0 for Barrel, +/-1 for +/- Endcap
479  int tp_endcap = (tp_region == -1) ? 2 : tp_region;
480  int tp_sector = tp_detId.sector(); // 1 - 6 (60 degrees in phi, sector 1 begins at -5 deg)
481  int tp_subsector = tp_detId.subsector(); // 1 - 6 (10 degrees in phi; staggered in z)
482  int tp_station = tp_detId.station(); // 1 - 4
483  int tp_ring = tp_detId.ring(); // 2 - 3 (increasing theta)
484  int tp_roll = tp_detId.roll(); // 1 - 3 (decreasing theta; aka A - C; space between rolls is 9 - 15 in theta_fp)
485  //int tp_layer = tp_detId.layer(); // Always 1 in the Endcap, 1 or 2 in the Barrel
486 
487  int tp_bx = tp_data.bx;
488  int tp_strip = ((tp_data.strip_low + tp_data.strip_hi) / 2); // in full-strip unit
489 
490  const bool is_neighbor = (pc_station == 5);
491 
492  // CSC-like sector, subsector and chamber numbers
493  int csc_tp_chamber = (tp_sector - 1) * 6 + tp_subsector;
494  int csc_tp_sector = (tp_subsector > 2) ? tp_sector : ((tp_sector + 4) % 6) + 1; // Rotate by 20 deg
495  int csc_tp_subsector = (tp_station != 1) ? 0 : ((csc_tp_chamber % 6 > 2) ? 1 : 2);
496 
497  const bool is_irpc = (tp_station == 3 || tp_station == 4) && (tp_ring == 1);
498  if (is_irpc) {
499  csc_tp_chamber = (tp_sector - 1) * 3 + tp_subsector;
500  csc_tp_sector = (tp_subsector > 1) ? tp_sector : ((tp_sector + 4) % 6) + 1; // Rotate by 20 deg
501  csc_tp_subsector = (tp_station != 1) ? 0 : ((csc_tp_chamber % 6 > 2) ? 1 : 2);
502  }
503  int tp_csc_ID = emtf::get_trigger_csc_ID(tp_ring, tp_station, csc_tp_chamber);
504 
505  int csc_nID = tp_csc_ID; // modify csc_ID if coming from neighbor sector
506  if (is_neighbor) {
507  // station 1 has 3 neighbor chambers: 13,14,15 in rings 1,2,3
508  // (where are chambers 10,11,12 in station 1? they were used to label ME1/1a, but not anymore)
509  // station 2,3,4 have 2 neighbor chambers: 10,11 in rings 1,2
510  csc_nID = (pc_chamber < 3) ? (pc_chamber + 12) : (((pc_chamber - 1) % 2) + 9);
511  csc_nID += 1;
512  }
513 
514  // Use cluster width as 'quality'
515  int tp_quality = (tp_data.strip_hi - tp_data.strip_low + 1);
516  if (!is_irpc) {
517  tp_quality *= 3; // old RPC strip pitch is 1.5 times the new iRPC
518  tp_quality /= 2;
519  }
520 
521  // Set properties
522  conv_hit.SetRPCDetId(tp_detId);
523 
524  conv_hit.set_bx(tp_bx + bxShiftRPC_);
525  conv_hit.set_subsystem(L1TMuon::kRPC);
526  conv_hit.set_endcap((tp_endcap == 2) ? -1 : tp_endcap);
527  conv_hit.set_station(tp_station);
528  conv_hit.set_ring(tp_ring);
529  conv_hit.set_roll(tp_roll);
530  conv_hit.set_chamber(csc_tp_chamber);
531  conv_hit.set_sector(csc_tp_sector);
532  conv_hit.set_subsector(csc_tp_subsector);
533  conv_hit.set_csc_ID(tp_csc_ID);
534  conv_hit.set_csc_nID(csc_nID);
535  //conv_hit.set_track_num ( tp_data.trknmb );
536  //conv_hit.set_sync_err ( tp_data.syncErr );
537  conv_hit.set_sector_RPC(tp_sector); // In RPC convention in CMSSW (RPCDetId.h), sector 1 starts at -5 deg
538  conv_hit.set_subsector_RPC(tp_subsector);
539 
540  conv_hit.set_pc_sector(pc_sector);
541  conv_hit.set_pc_station(pc_station);
542  conv_hit.set_pc_chamber(pc_chamber);
543  conv_hit.set_pc_segment(pc_segment);
544 
545  conv_hit.set_valid(tp_data.valid);
546  conv_hit.set_strip(tp_strip);
547  conv_hit.set_strip_low(tp_data.strip_low);
548  conv_hit.set_strip_hi(tp_data.strip_hi);
549  //conv_hit.set_wire ( tp_data.keywire );
550  conv_hit.set_quality(tp_quality);
551  conv_hit.set_pattern(0); // In firmware, this marks RPC stub
552  //conv_hit.set_bend ( tp_data.bend );
553  conv_hit.set_time(tp_data.time);
554  //conv_hit.set_alct_quality ( tp_data.alct_quality );
555  //conv_hit.set_clct_quality ( tp_data.clct_quality );
556 
557  conv_hit.set_neighbor(is_neighbor);
558  conv_hit.set_sector_idx((endcap_ == 1) ? sector_ - 1 : sector_ + 5);
559 
560  // Get coordinates from fullsim
561  bool use_fullsim_coords = true;
562 
563  if (tp_data.isCPPF) { // CPPF digis from EMTF unpacker or CPPF emulator
564  conv_hit.set_phi_fp(tp_data.phi_int * 4); // Full-precision integer phi
565  conv_hit.set_theta_fp(tp_data.theta_int * 4); // Full-precision integer theta
566  } else if (use_fullsim_coords) {
567  const GlobalPoint& gp = tp_geom_->getGlobalPoint(muon_primitive);
568  double glob_phi = emtf::rad_to_deg(gp.phi().value());
569  double glob_theta = emtf::rad_to_deg(gp.theta());
570  double glob_eta = gp.eta();
571  double glob_rho = gp.perp();
572  double glob_z = gp.z();
573 
574  // Use RPC-specific convention in docs/CPPF-EMTF-format_2016_11_01.docx
575  // Phi precision is 1/15 degrees (11 bits), 4x larger than CSC precision of 1/60 degrees (13 bits)
576  // Theta precision is 36.5/32 degrees (5 bits), 4x larger than CSC precision of 36.5/128 degrees (7 bits)
577  //
578  // NOTE: fph and th are recalculated using CPPF LUTs in the convert_rpc_details() function,
579  // this part is still kept because it is needed for Phase 2 iRPC hits.
580  //
581  int fph = emtf::calc_phi_loc_int_rpc(glob_phi, conv_hit.PC_sector());
582  int th = emtf::calc_theta_int_rpc(glob_theta, conv_hit.Endcap());
583 
584  //emtf_assert(0 <= fph && fph < 1024);
585  emtf_assert(0 <= fph && fph < 1250);
586  emtf_assert(0 <= th && th < 32);
587  emtf_assert(th != 0b11111); // RPC hit valid when data is not all ones
588  fph <<= 2; // upgrade to full CSC precision by adding 2 zeros
589  th <<= 2; // upgrade to full CSC precision by adding 2 zeros
590  th = (th == 0) ? 1 : th; // protect against invalid value
591 
592  if (is_irpc) {
593  const RPCRoll* roll = dynamic_cast<const RPCRoll*>(tp_geom_->getRPCGeometry().roll(tp_detId));
594  emtf_assert(roll != nullptr); // failed to get RPC roll
595  const GlobalPoint& new_gp = roll->surface().toGlobal(LocalPoint(tp_data.x, tp_data.y, 0));
596  glob_phi = emtf::rad_to_deg(gp.phi().value()); // using 'gp' instead of 'new_gp' for phi
597  glob_theta = emtf::rad_to_deg(new_gp.theta());
598  glob_eta = new_gp.eta();
599  glob_rho = new_gp.perp();
600  glob_z = new_gp.z();
601 
602  fph = emtf::calc_phi_loc_int(glob_phi, conv_hit.PC_sector());
603  th = emtf::calc_theta_int(glob_theta, conv_hit.Endcap());
604 
605  emtf_assert(0 <= fph && fph < 5000);
606  emtf_assert(0 <= th && th < 128);
607  th = (th == 0) ? 1 : th; // protect against invalid value
608  }
609 
610  // _________________________________________________________________________
611  // Output
612 
613  conv_hit.set_phi_sim(glob_phi);
614  conv_hit.set_theta_sim(glob_theta);
615  conv_hit.set_eta_sim(glob_eta);
616  conv_hit.set_rho_sim(glob_rho);
617  conv_hit.set_z_sim(glob_z);
618 
619  conv_hit.set_phi_fp(fph); // Full-precision integer phi
620  conv_hit.set_theta_fp(th); // Full-precision integer theta
621  }
622 
623  convert_rpc_details(conv_hit, tp_data.isCPPF);
624 }
625 
626 void PrimitiveConversion::convert_rpc_details(EMTFHit& conv_hit, bool isCPPF) const {
627  const bool is_neighbor = conv_hit.Neighbor();
628 
629  const int pc_station = conv_hit.PC_station();
630  const int pc_chamber = conv_hit.PC_chamber();
631  const int pc_segment = conv_hit.PC_segment();
632 
633  //const int fw_endcap = (endcap_-1);
634  //const int fw_sector = (sector_-1);
635  const int fw_station = (conv_hit.Station() == 1) ? (is_neighbor ? 0 : pc_station) : conv_hit.Station();
636  const int fw_cscid = (conv_hit.CSC_nID() - 1);
637 
638  int fph = conv_hit.Phi_fp();
639  int th = conv_hit.Theta_fp();
640 
641  // Do coordinate conversion using the CPPF LUTs. Not needed if the received digis are CPPF digis.
642  bool use_cppf_lut = !isCPPF;
643 
644  if (use_cppf_lut) {
645  int halfstrip = (conv_hit.Strip_low() + conv_hit.Strip_hi() - 1);
646  emtf_assert(1 <= halfstrip && halfstrip <= 64);
647 
648  int fph2 = pc_lut().get_cppf_ph_lut(conv_hit.Endcap(),
649  conv_hit.Sector_RPC(),
650  conv_hit.Station(),
651  conv_hit.Ring(),
652  conv_hit.Subsector_RPC(),
653  conv_hit.Roll(),
654  halfstrip,
655  is_neighbor);
656  int th2 = pc_lut().get_cppf_th_lut(conv_hit.Endcap(),
657  conv_hit.Sector_RPC(),
658  conv_hit.Station(),
659  conv_hit.Ring(),
660  conv_hit.Subsector_RPC(),
661  conv_hit.Roll());
662  //emtf_assert(abs((fph>>2) - fph2) <= 4); // arbitrary tolerance
663  //emtf_assert(abs((th>>2) - th2) <= 1); // arbitrary tolerance
664  fph = fph2;
665  th = th2;
666 
667  //emtf_assert(0 <= fph && fph < 1024);
668  emtf_assert(0 <= fph && fph < 1250);
669  emtf_assert(0 <= th && th < 32);
670  emtf_assert(th != 0b11111); // RPC hit valid when data is not all ones
671  fph <<= 2; // upgrade to full CSC precision by adding 2 zeros
672  th <<= 2; // upgrade to full CSC precision by adding 2 zeros
673  th = (th == 0) ? 1 : th; // protect against invalid value
674  }
675 
676  if (verbose_ > 1) { // debug
677  std::cout << "RPC hit pc_station: " << pc_station << " pc_chamber: " << pc_chamber << " fw_station: " << fw_station
678  << " fw_cscid: " << fw_cscid << " tp_station: " << conv_hit.Station() << " tp_ring: " << conv_hit.Ring()
679  << " tp_sector: " << conv_hit.Sector_RPC() << " tp_subsector: " << conv_hit.Subsector_RPC()
680  << " fph: " << fph << " th: " << th << std::endl;
681  }
682 
683  // ___________________________________________________________________________
684  // Zone codes and other segment IDs
685 
686  int zone_hit = ((fph + (1 << 4)) >> 5);
687  int zone_code = get_zone_code(conv_hit, th);
688  //int phzvl = get_phzvl(conv_hit, zone_code);
689 
690  int fs_zone_code = get_fs_zone_code(conv_hit);
691  int fs_segment = get_fs_segment(conv_hit, fw_station, fw_cscid, pc_segment);
692 
693  int bt_station = get_bt_station(conv_hit, fw_station, fw_cscid, pc_segment);
694  int bt_segment = get_bt_segment(conv_hit, fw_station, fw_cscid, pc_segment);
695 
696  // ___________________________________________________________________________
697  // Output
698 
699  conv_hit.set_phi_fp(fph); // Full-precision integer phi
700  conv_hit.set_theta_fp(th); // Full-precision integer theta
701  //conv_hit.set_phzvl ( phzvl ); // Local zone word: (1*low) + (2*mid) + (4*low) - used in FW debugging
702  //conv_hit.set_ph_hit ( ph_hit ); // Intermediate quantity in phi calculation - used in FW debugging
703  conv_hit.set_zone_hit(zone_hit); // Phi value for building patterns (0.53333 deg precision)
704  conv_hit.set_zone_code(zone_code); // Full zone word: 1*(zone 0) + 2*(zone 1) + 4*(zone 2) + 8*(zone 3)
705 
706  conv_hit.set_fs_segment(fs_segment); // Segment number used in primitive matching
707  conv_hit.set_fs_zone_code(fs_zone_code); // Zone word used in primitive matching
708 
709  conv_hit.set_bt_station(bt_station);
710  conv_hit.set_bt_segment(bt_segment);
711 
712  conv_hit.set_phi_loc(emtf::calc_phi_loc_deg(fph));
713  conv_hit.set_phi_glob(emtf::calc_phi_glob_deg(conv_hit.Phi_loc(), conv_hit.PC_sector()));
715  conv_hit.set_eta(emtf::calc_eta_from_theta_deg(conv_hit.Theta(), conv_hit.Endcap()));
716 }
717 
718 // _____________________________________________________________________________
719 // GEM functions
721  int pc_station,
722  int pc_chamber,
723  int pc_segment,
724  const TriggerPrimitive& muon_primitive,
725  EMTFHit& conv_hit) const {
726  const GEMDetId& tp_detId = muon_primitive.detId<GEMDetId>();
727  const GEMData& tp_data = muon_primitive.getGEMData();
728 
729  int tp_region = tp_detId.region(); // 0 for Barrel, +/-1 for +/- Endcap
730  int tp_endcap = (tp_region == -1) ? 2 : tp_region;
731  int tp_station = tp_detId.station();
732  int tp_ring = tp_detId.ring();
733  int tp_roll = tp_detId.roll();
734  //int tp_layer = tp_detId.layer();
735  int tp_chamber = tp_detId.chamber();
736 
737  int tp_bx = tp_data.bx;
738  int tp_pad = ((tp_data.pad_low + tp_data.pad_hi) / 2);
739 
740  int tp_sector = emtf::get_trigger_sector(tp_ring, tp_station, tp_chamber);
741  int tp_csc_ID = emtf::get_trigger_csc_ID(tp_ring, tp_station, tp_chamber);
742 
743  // station 1 --> subsector 1 or 2
744  // station 2,3,4 --> subsector 0
745  int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber % 6 > 2) ? 1 : 2);
746 
747  const bool is_neighbor = (pc_chamber == 12 || pc_chamber == 13);
748 
749  int csc_nID = tp_csc_ID; // modify csc_ID if coming from neighbor sector
750  if (is_neighbor) {
751  // station 1 has 3 neighbor chambers: 13,14,15 in rings 1,2,3
752  // (where are chambers 10,11,12 in station 1? they were used to label ME1/1a, but not anymore)
753  // station 2,3,4 have 2 neighbor chambers: 10,11 in rings 1,2
754  if (tp_station == 1) {
755  csc_nID = 13;
756  } else {
757  csc_nID = 10;
758  }
759  }
760 
761  // Use cluster width as 'quality'
762  int tp_quality = (tp_data.pad_hi - tp_data.pad_low + 1);
763 
764  // Set properties
765  conv_hit.SetGEMDetId(tp_detId);
766 
767  conv_hit.set_bx(tp_bx + bxShiftGEM_);
768  conv_hit.set_subsystem(L1TMuon::kGEM);
769  conv_hit.set_endcap((tp_endcap == 2) ? -1 : tp_endcap);
770  conv_hit.set_station(tp_station);
771  conv_hit.set_ring(tp_ring);
772  conv_hit.set_roll(tp_roll);
773  conv_hit.set_chamber(tp_chamber);
774  conv_hit.set_sector(tp_sector);
775  conv_hit.set_subsector(tp_subsector);
776  conv_hit.set_csc_ID(tp_csc_ID);
777  conv_hit.set_csc_nID(csc_nID);
778  //conv_hit.set_track_num ( tp_data.trknmb );
779  //conv_hit.set_sync_err ( tp_data.syncErr );
780  //conv_hit.set_sector_RPC ( tp_sector );
781  //conv_hit.set_subsector_RPC ( tp_subsector );
782 
783  conv_hit.set_pc_sector(pc_sector);
784  conv_hit.set_pc_station(pc_station);
785  conv_hit.set_pc_chamber(pc_chamber);
786  conv_hit.set_pc_segment(pc_segment);
787 
788  conv_hit.set_valid(true);
789  conv_hit.set_strip(tp_pad);
790  conv_hit.set_strip_low(tp_data.pad_low);
791  conv_hit.set_strip_hi(tp_data.pad_hi);
792  //conv_hit.set_wire ( tp_data.keywire );
793  conv_hit.set_quality(tp_quality);
794  conv_hit.set_pattern(0); // arbitrary
795  //conv_hit.set_bend ( tp_data.bend );
796  conv_hit.set_time(0.); // No fine resolution timing
797  //conv_hit.set_alct_quality ( tp_data.alct_quality );
798  //conv_hit.set_clct_quality ( tp_data.clct_quality );
799 
800  conv_hit.set_neighbor(is_neighbor);
801  conv_hit.set_sector_idx((endcap_ == 1) ? sector_ - 1 : sector_ + 5);
802 
803  // Get coordinates from fullsim since LUTs do not exist yet
804  bool use_fullsim_coords = true;
805  if (use_fullsim_coords) {
806  const GlobalPoint& gp = tp_geom_->getGlobalPoint(muon_primitive);
807  double glob_phi = emtf::rad_to_deg(gp.phi().value());
808  double glob_theta = emtf::rad_to_deg(gp.theta());
809  double glob_eta = gp.eta();
810  double glob_rho = gp.perp();
811  double glob_z = gp.z();
812 
813  // Use the CSC precision (unconfirmed!)
814  int fph = emtf::calc_phi_loc_int(glob_phi, conv_hit.PC_sector());
815  int th = emtf::calc_theta_int(glob_theta, conv_hit.Endcap());
816 
817  emtf_assert(0 <= fph && fph < 5000);
818  emtf_assert(0 <= th && th < 128);
819  th = (th == 0) ? 1 : th; // protect against invalid value
820 
821  // _________________________________________________________________________
822  // Output
823 
824  conv_hit.set_phi_sim(glob_phi);
825  conv_hit.set_theta_sim(glob_theta);
826  conv_hit.set_eta_sim(glob_eta);
827  conv_hit.set_rho_sim(glob_rho);
828  conv_hit.set_z_sim(glob_z);
829 
830  conv_hit.set_phi_fp(fph); // Full-precision integer phi
831  conv_hit.set_theta_fp(th); // Full-precision integer theta
832  }
833 
834  convert_other_details(conv_hit);
835 }
836 
838  const bool is_neighbor = conv_hit.Neighbor();
839 
840  const int pc_station = conv_hit.PC_station();
841  const int pc_chamber = conv_hit.PC_chamber();
842  const int pc_segment = conv_hit.PC_segment();
843 
844  //const int fw_endcap = (endcap_-1);
845  //const int fw_sector = (sector_-1);
846  const int fw_station =
847  (conv_hit.Station() == 1) ? (is_neighbor ? 0 : (conv_hit.Subsector() - 1)) : conv_hit.Station();
848  const int fw_cscid = (conv_hit.CSC_nID() - 1);
849 
850  int fph = conv_hit.Phi_fp();
851  int th = conv_hit.Theta_fp();
852 
853  if (verbose_ > 1) { // debug
854  std::cout << "GEM hit pc_station: " << pc_station << " pc_chamber: " << pc_chamber << " fw_station: " << fw_station
855  << " fw_cscid: " << fw_cscid << " tp_station: " << conv_hit.Station() << " tp_ring: " << conv_hit.Ring()
856  << " tp_sector: " << conv_hit.Sector() << " tp_subsector: " << conv_hit.Subsector() << " fph: " << fph
857  << " th: " << th << std::endl;
858  }
859 
860  // ___________________________________________________________________________
861  // Zone codes and other segment IDs
862 
863  int zone_hit = ((fph + (1 << 4)) >> 5);
864  int zone_code = get_zone_code(conv_hit, th);
865  //int phzvl = get_phzvl(conv_hit, zone_code);
866 
867  int fs_zone_code = get_fs_zone_code(conv_hit);
868  int fs_segment = get_fs_segment(conv_hit, fw_station, fw_cscid, pc_segment);
869 
870  int bt_station = get_bt_station(conv_hit, fw_station, fw_cscid, pc_segment);
871  int bt_segment = get_bt_segment(conv_hit, fw_station, fw_cscid, pc_segment);
872 
873  // ___________________________________________________________________________
874  // Output
875 
876  conv_hit.set_phi_fp(fph); // Full-precision integer phi
877  conv_hit.set_theta_fp(th); // Full-precision integer theta
878  //conv_hit.set_phzvl ( phzvl ); // Local zone word: (1*low) + (2*mid) + (4*low) - used in FW debugging
879  //conv_hit.set_ph_hit ( ph_hit ); // Intermediate quantity in phi calculation - used in FW debugging
880  conv_hit.set_zone_hit(zone_hit); // Phi value for building patterns (0.53333 deg precision)
881  conv_hit.set_zone_code(zone_code); // Full zone word: 1*(zone 0) + 2*(zone 1) + 4*(zone 2) + 8*(zone 3)
882 
883  conv_hit.set_fs_segment(fs_segment); // Segment number used in primitive matching
884  conv_hit.set_fs_zone_code(fs_zone_code); // Zone word used in primitive matching
885 
886  conv_hit.set_bt_station(bt_station);
887  conv_hit.set_bt_segment(bt_segment);
888 
889  conv_hit.set_phi_loc(emtf::calc_phi_loc_deg(fph));
890  conv_hit.set_phi_glob(emtf::calc_phi_glob_deg(conv_hit.Phi_loc(), conv_hit.PC_sector()));
892  conv_hit.set_eta(emtf::calc_eta_from_theta_deg(conv_hit.Theta(), conv_hit.Endcap()));
893 }
894 
895 // _____________________________________________________________________________
896 // ME0 functions
898  int pc_station,
899  int pc_chamber,
900  int pc_segment,
901  const TriggerPrimitive& muon_primitive,
902  EMTFHit& conv_hit) const {
903  const ME0DetId& tp_detId = muon_primitive.detId<ME0DetId>();
904  const ME0Data& tp_data = muon_primitive.getME0Data();
905 
906  int tp_region = tp_detId.region(); // 0 for Barrel, +/-1 for +/- Endcap
907  int tp_endcap = (tp_region == -1) ? 2 : tp_region;
908  int tp_station = tp_detId.station();
909  int tp_ring = 1; // tp_detId.ring() does not exist
910  //int tp_roll = tp_detId.roll();
911  //int tp_layer = tp_detId.layer();
912  int tp_chamber = tp_detId.chamber();
913 
914  int tp_bx = tp_data.bx;
915  int tp_pad = tp_data.phiposition;
916  int tp_partition = tp_data.partition;
917 
918  // The ME0 geometry is similar to ME2/1, so I use tp_station = 2, tp_ring = 1
919  // when calling get_trigger_sector() and get_trigger_csc_ID()
920  int tp_sector = emtf::get_trigger_sector(1, 2, tp_chamber);
921  int tp_csc_ID = emtf::get_trigger_csc_ID(1, 2, tp_chamber);
922  int tp_subsector = 0;
923 
924  const bool is_neighbor = (pc_chamber == 14);
925 
926  int csc_nID = tp_csc_ID; // modify csc_ID if coming from neighbor sector
927  if (is_neighbor) {
928  // station 1 has 3 neighbor chambers: 13,14,15 in rings 1,2,3
929  // (where are chambers 10,11,12 in station 1? they were used to label ME1/1a, but not anymore)
930  // station 2,3,4 have 2 neighbor chambers: 10,11 in rings 1,2
931  csc_nID = 10;
932  }
933 
934  // Set properties
935  conv_hit.SetME0DetId(tp_detId);
936 
937  conv_hit.set_bx(tp_bx + bxShiftME0_);
938  conv_hit.set_subsystem(L1TMuon::kME0);
939  conv_hit.set_endcap((tp_endcap == 2) ? -1 : tp_endcap);
940  conv_hit.set_station(tp_station);
941  conv_hit.set_ring(tp_ring);
942  conv_hit.set_roll(tp_partition);
943  conv_hit.set_chamber(tp_chamber);
944  conv_hit.set_sector(tp_sector);
945  conv_hit.set_subsector(tp_subsector);
946  conv_hit.set_csc_ID(tp_csc_ID);
947  conv_hit.set_csc_nID(csc_nID);
948  //conv_hit.set_track_num ( tp_data.trknmb );
949  //conv_hit.set_sync_err ( tp_data.syncErr );
950  //conv_hit.set_sector_RPC ( tp_sector );
951  //conv_hit.set_subsector_RPC ( tp_subsector );
952 
953  conv_hit.set_pc_sector(pc_sector);
954  conv_hit.set_pc_station(pc_station);
955  conv_hit.set_pc_chamber(pc_chamber);
956  conv_hit.set_pc_segment(pc_segment);
957 
958  conv_hit.set_valid(true);
959  conv_hit.set_strip(tp_pad);
960  //conv_hit.set_strip_low ( tp_strip );
961  //conv_hit.set_strip_hi ( tp_strip );
962  //conv_hit.set_wire ( tp_data.keywire );
963  conv_hit.set_quality(tp_data.quality);
964  conv_hit.set_pattern(0); // arbitrary
965  conv_hit.set_bend(tp_data.deltaphi * (tp_data.bend == 0 ? 1 : -1));
966  conv_hit.set_time(0.); // No fine resolution timing
967  //conv_hit.set_alct_quality ( tp_data.alct_quality );
968  //conv_hit.set_clct_quality ( tp_data.clct_quality );
969 
970  conv_hit.set_neighbor(is_neighbor);
971  conv_hit.set_sector_idx((endcap_ == 1) ? sector_ - 1 : sector_ + 5);
972 
973  // Get coordinates from fullsim since LUTs do not exist yet
974  bool use_fullsim_coords = true;
975  if (use_fullsim_coords) {
976  const GlobalPoint& gp = tp_geom_->getGlobalPoint(muon_primitive);
977  double glob_phi = emtf::rad_to_deg(gp.phi().value());
978  double glob_theta = emtf::rad_to_deg(gp.theta());
979  double glob_eta = gp.eta();
980  double glob_rho = gp.perp();
981  double glob_z = gp.z();
982 
983  // Use the CSC precision (unconfirmed!)
984  int fph = emtf::calc_phi_loc_int(glob_phi, conv_hit.PC_sector());
985  int th = emtf::calc_theta_int(glob_theta, conv_hit.Endcap());
986 
987  bool fix_me0_theta_edge = true;
988  if (fix_me0_theta_edge) {
989  // The ME0 extends to eta of 2.8 or theta of 7.0 deg. But integer theta
990  // only starts at theta of 8.5 deg.
991  if (th < 0)
992  th = 0;
993  }
994 
995  emtf_assert(0 <= fph && fph < 5000);
996  emtf_assert(0 <= th && th < 128);
997  th = (th == 0) ? 1 : th; // protect against invalid value
998 
999  // _________________________________________________________________________
1000  // Output
1001 
1002  conv_hit.set_phi_sim(glob_phi);
1003  conv_hit.set_theta_sim(glob_theta);
1004  conv_hit.set_eta_sim(glob_eta);
1005  conv_hit.set_rho_sim(glob_rho);
1006  conv_hit.set_z_sim(glob_z);
1007 
1008  conv_hit.set_phi_fp(fph); // Full-precision integer phi
1009  conv_hit.set_theta_fp(th); // Full-precision integer theta
1010  }
1011 
1012  convert_other_details(conv_hit);
1013 }
1014 
1015 // _____________________________________________________________________________
1016 // DT functions
1018  int pc_station,
1019  int pc_chamber,
1020  int pc_segment,
1021  const TriggerPrimitive& muon_primitive,
1022  EMTFHit& conv_hit) const {
1023  const DTChamberId& tp_detId = muon_primitive.detId<DTChamberId>();
1024  const DTData& tp_data = muon_primitive.getDTData();
1025 
1026  int tp_wheel = tp_detId.wheel();
1027  int tp_station = tp_detId.station();
1028  int tp_sector = tp_detId.sector(); // sectors are 1-12, starting at phi=0 and increasing with phi
1029 
1030  // In station 4, where the top and bottom setcors are made of two chambers,
1031  // two additional sector numbers are used, 13 (after sector 4, top)
1032  // and 14 (after sector 10, bottom).
1033  if (tp_station == 4) {
1034  if (tp_sector == 13)
1035  tp_sector = 4;
1036  else if (tp_sector == 14)
1037  tp_sector = 10;
1038  }
1039 
1040  int tp_bx = tp_data.bx;
1041  int tp_phi = tp_data.radialAngle;
1042  int tp_phiB = tp_data.bendingAngle;
1043 
1044  // Mimic 10 deg CSC chamber. I use tp_station = 2, tp_ring = 2
1045  // when calling get_trigger_sector() and get_trigger_csc_ID()
1046  int tp_chamber =
1047  tp_sector * 3 - 1; // DT chambers are 30 deg. Multiply sector number by 3 to mimic 10 deg CSC chamber number
1048  int tp_endcap = (tp_wheel > 0) ? +1 : ((tp_wheel < 0) ? 2 : 0);
1049  int csc_tp_sector = emtf::get_trigger_sector(2, 2, tp_chamber);
1050  int tp_csc_ID = emtf::get_trigger_csc_ID(2, 2, tp_chamber);
1051  int tp_subsector = 0;
1052 
1053  const bool is_neighbor = (pc_chamber >= 8);
1054 
1055  int csc_nID = tp_csc_ID; // modify csc_ID if coming from neighbor sector
1056  if (is_neighbor) {
1057  // station 1 has 3 neighbor chambers: 13,14,15 in rings 1,2,3
1058  // (where are chambers 10,11,12 in station 1? they were used to label ME1/1a, but not anymore)
1059  // station 2,3,4 have 2 neighbor chambers: 10,11 in rings 1,2
1060  csc_nID = 10;
1061  }
1062 
1063  // Set properties
1064  conv_hit.SetDTDetId(tp_detId);
1065 
1066  conv_hit.set_bx(tp_bx);
1067  conv_hit.set_subsystem(L1TMuon::kDT);
1068  conv_hit.set_endcap((tp_endcap == 2) ? -1 : tp_endcap);
1069  conv_hit.set_station(tp_station);
1070  conv_hit.set_ring(1); // set to ring 1?
1071  conv_hit.set_roll(tp_wheel); // used as wheel
1072  conv_hit.set_chamber(tp_chamber);
1073  conv_hit.set_sector(csc_tp_sector);
1074  conv_hit.set_subsector(tp_subsector);
1075  conv_hit.set_csc_ID(tp_csc_ID);
1076  conv_hit.set_csc_nID(csc_nID);
1077  conv_hit.set_track_num(tp_data.segment_number);
1078  conv_hit.set_sync_err(tp_data.RpcBit); // hacked to store rpc bit
1079  //conv_hit.set_sector_RPC ( tp_sector );
1080  //conv_hit.set_subsector_RPC ( tp_subsector );
1081 
1082  conv_hit.set_pc_sector(pc_sector);
1083  conv_hit.set_pc_station(pc_station);
1084  conv_hit.set_pc_chamber(pc_chamber);
1085  conv_hit.set_pc_segment(pc_segment);
1086 
1087  conv_hit.set_valid(true);
1088  conv_hit.set_strip(tp_phi);
1089  //conv_hit.set_strip_low ( tp_data.strip_low );
1090  //conv_hit.set_strip_hi ( tp_data.strip_hi );
1091  conv_hit.set_wire(tp_data.theta_bti_group);
1092  conv_hit.set_quality(tp_data.qualityCode);
1093  conv_hit.set_pattern(0); // arbitrary
1094  conv_hit.set_bend(tp_phiB);
1095  conv_hit.set_time(0.); // No fine resolution timing
1096  //conv_hit.set_alct_quality ( tp_data.alct_quality );
1097  //conv_hit.set_clct_quality ( tp_data.clct_quality );
1098 
1099  conv_hit.set_neighbor(is_neighbor);
1100  conv_hit.set_sector_idx((endcap_ == 1) ? sector_ - 1 : sector_ + 5);
1101 
1102  // Get coordinates from fullsim since LUTs do not exist yet
1103  bool use_fullsim_coords = true;
1104  if (use_fullsim_coords) {
1105  const GlobalPoint& gp = tp_geom_->getGlobalPoint(muon_primitive);
1106  double glob_phi = emtf::rad_to_deg(gp.phi().value());
1107  double glob_theta = emtf::rad_to_deg(gp.theta());
1108  double glob_eta = gp.eta();
1109  double glob_rho = gp.perp();
1110  double glob_z = gp.z();
1111 
1112  // Use the CSC precision (unconfirmed!)
1113  int fph = emtf::calc_phi_loc_int(glob_phi, conv_hit.PC_sector());
1114  int th = emtf::calc_theta_int(glob_theta, conv_hit.Endcap());
1115 
1116  bool fix_dt_phi_edge = true;
1117  if (fix_dt_phi_edge) {
1118  // The DT chamber edges are not always aligned at 0,30,60,etc. The local
1119  // phi 0 is set to the CSC chamber edge minus 22 deg. But it is possible
1120  // for the DT neighbor chamber to go as far as the CSC chamber edge minus
1121  // 32 deg.
1122  double loc = emtf::calc_phi_loc_deg_from_glob(glob_phi, conv_hit.PC_sector());
1123  if ((loc + 22.) < 0. && (loc + 32.) > 0.)
1124  fph = 0;
1125  else if ((loc + 360. + 22.) < 0. && (loc + 360. + 32.) > 0.)
1126  fph = 0;
1127  }
1128 
1129  emtf_assert(0 <= fph && fph < 5400);
1130  emtf_assert(0 <= th && th < 180); // Note: eta = 0.73 -> theta_int = 150
1131  th = (th == 0) ? 1 : th; // protect against invalid value
1132 
1133  // _________________________________________________________________________
1134  // Output
1135 
1136  conv_hit.set_phi_sim(glob_phi);
1137  conv_hit.set_theta_sim(glob_theta);
1138  conv_hit.set_eta_sim(glob_eta);
1139  conv_hit.set_rho_sim(glob_rho);
1140  conv_hit.set_z_sim(glob_z);
1141 
1142  conv_hit.set_phi_fp(fph); // Full-precision integer phi
1143  conv_hit.set_theta_fp(th); // Full-precision integer theta
1144  }
1145 
1146  convert_other_details(conv_hit);
1147 }
1148 
1149 // _____________________________________________________________________________
1150 // Aux functions
1151 int PrimitiveConversion::get_zone_code(const EMTFHit& conv_hit, int th) const {
1152  // ph zone boundaries for chambers that cover more than one zone
1153  // bnd1 is the lower boundary, bnd2 the upper boundary
1154  int zone_code = 0;
1155 
1156  bool is_csc = (conv_hit.Subsystem() == L1TMuon::kCSC);
1157  bool is_me13 = (is_csc && conv_hit.Station() == 1 && conv_hit.Ring() == 3);
1158 
1159  if (th >= 127)
1160  th = 127;
1161 
1162  for (int izone = 0; izone < emtf::NUM_ZONES; ++izone) {
1163  int zone_code_tmp = get_fs_zone_code(conv_hit);
1164  if (zone_code_tmp & (1 << izone)) {
1165  bool no_use_bnd1 =
1166  ((izone == 0) || ((zone_code_tmp & (1 << (izone - 1))) == 0) || is_me13); // first possible zone for this hit
1167  bool no_use_bnd2 = (((zone_code_tmp & (1 << (izone + 1))) == 0) || is_me13); // last possible zone for this hit
1168 
1169  int ph_zone_bnd1 = no_use_bnd1 ? zoneBoundaries_.at(0) : zoneBoundaries_.at(izone);
1170  int ph_zone_bnd2 = no_use_bnd2 ? zoneBoundaries_.at(emtf::NUM_ZONES) : zoneBoundaries_.at(izone + 1);
1171 
1172  if ((th > (ph_zone_bnd1 - zoneOverlap_)) && (th <= (ph_zone_bnd2 + zoneOverlap_))) {
1173  zone_code |= (1 << izone);
1174  }
1175  }
1176  }
1177  emtf_assert(zone_code > 0);
1178  return zone_code;
1179 }
1180 
1181 int PrimitiveConversion::get_phzvl(const EMTFHit& conv_hit, int zone_code) const {
1182  // For backward compatibility, no longer needed (only explicitly used in FW)
1183  // phzvl: each chamber overlaps with at most 3 zones, so this "local" zone word says
1184  // which of the possible zones contain the hit: 1 for lower, 2 for middle, 4 for upper
1185  int phzvl = 0;
1186  if (conv_hit.Ring() == 1 || conv_hit.Ring() == 4) {
1187  phzvl = (zone_code >> 0);
1188  } else if (conv_hit.Ring() == 2) {
1189  if (conv_hit.Station() == 3 || conv_hit.Station() == 4) {
1190  phzvl = (zone_code >> 1);
1191  } else if (conv_hit.Station() == 1 || conv_hit.Station() == 2) {
1192  phzvl = (zone_code >> 2);
1193  }
1194  } else if (conv_hit.Ring() == 3) {
1195  phzvl = (zone_code >> 3);
1196  }
1197  return phzvl;
1198 }
1199 
1201  static const unsigned int zone_code_table[4][3] = {
1202  // map (station,ring) to zone_code
1203  {0b0011, 0b0100, 0b1000}, // st1 r1: [z0,z1], r2: [z2], r3: [z3]
1204  {0b0011, 0b1100, 0b1100}, // st2 r1: [z0,z1], r2: [z2,z3], r3 = r2
1205  {0b0001, 0b1110, 0b1110}, // st3 r1: [z0], r2: [z1,z2,z3], r3 = r2
1206  {0b0001, 0b0110, 0b0110} // st4 r1: [z0], r2: [z1,z2], r3 = r2
1207  };
1208 
1209  static const unsigned int zone_code_table_new[4][3] = {
1210  // map (station,ring) to zone_code
1211  {0b0011, 0b0110, 0b1000}, // st1 r1: [z0,z1], r2: [z1,z2], r3: [z3]
1212  {0b0011, 0b1110, 0b1110}, // st2 r1: [z0,z1], r2: [z1,z2,z3], r3 = r2
1213  {0b0011, 0b1110, 0b1110}, // st3 r1: [z0,z1], r2: [z1,z2,z3], r3 = r2
1214  {0b0001, 0b0110, 0b0110} // st4 r1: [z0], r2: [z1,z2], r3 = r2
1215  };
1216 
1217  unsigned int istation = (conv_hit.Station() - 1);
1218  unsigned int iring = (conv_hit.Ring() == 4) ? 0 : (conv_hit.Ring() - 1);
1219  emtf_assert(istation < 4 && iring < 3);
1220  unsigned int zone_code = useNewZones_ ? zone_code_table_new[istation][iring] : zone_code_table[istation][iring];
1221  return zone_code;
1222 }
1223 
1224 int PrimitiveConversion::get_fs_segment(const EMTFHit& conv_hit, int fw_station, int fw_cscid, int pc_segment) const {
1225  // For later use in primitive matching
1226  // (in the firmware, this happens in the find_segment module)
1227  int fs_history = 0; // history id: not set here, to be set in primitive matching
1228  int fs_chamber = -1; // chamber id
1229  int fs_segment = pc_segment % 2; // segment id
1230 
1231  // For ME1
1232  // j = 0 is neighbor sector chamber
1233  // j = 1,2,3 are native subsector 1 chambers
1234  // j = 4,5,6 are native subsector 2 chambers
1235  // For ME2,3,4:
1236  // j = 0 is neighbor sector chamber
1237  // j = 1,2,3,4,5,6 are native sector chambers
1238  const bool is_neighbor = conv_hit.Neighbor();
1239  if (fw_station <= 1) { // ME1
1240  int n = fw_cscid % 3;
1241  fs_chamber = is_neighbor ? 0 : ((fw_station == 0) ? 1 + n : 4 + n);
1242  } else { // ME2,3,4
1243  int n = (conv_hit.Ring() == 1) ? fw_cscid : (fw_cscid - 3);
1244  fs_chamber = is_neighbor ? 0 : 1 + n;
1245  }
1246 
1247  emtf_assert(fs_history == 0 && (0 <= fs_chamber && fs_chamber < 7) && (0 <= fs_segment && fs_segment < 2));
1248  // fs_segment is a 6-bit word, HHCCCS, encoding the segment number S in the chamber (1 or 2),
1249  // the chamber number CCC ("j" above: uniquely identifies chamber within station and ring),
1250  // and the history HH (0 for current BX, 1 for previous BX, 2 for BX before that)
1251  fs_segment = ((fs_history & 0x3) << 4) | ((fs_chamber & 0x7) << 1) | (fs_segment & 0x1);
1252  return fs_segment;
1253 }
1254 
1255 int PrimitiveConversion::get_bt_station(const EMTFHit& conv_hit, int fw_station, int fw_cscid, int pc_segment) const {
1256  int bt_station = fw_station;
1257  return bt_station;
1258 }
1259 
1260 int PrimitiveConversion::get_bt_segment(const EMTFHit& conv_hit, int fw_station, int fw_cscid, int pc_segment) const {
1261  // For later use in angle calculation and best track selection
1262  // (in the firmware, this happens in the best_tracks module)
1263  int bt_history = 0; // history id: not set here, to be set in primitive matching
1264  int bt_chamber = -1; // chamber id
1265  int bt_segment = pc_segment % 2; // segment id
1266 
1267  // For ME1
1268  // j = 0 is No valid LCT
1269  // j = 1 .. 9 are native sector chambers
1270  // j = 10 .. 12 are neighbor sector chambers
1271  // For ME2,3,4
1272  // j = 0 is No valid LCT
1273  // j = 1 .. 9 are native sector chambers
1274  // j = 10 .. 11 are neighbor sector chambers
1275  bt_chamber = fw_cscid + 1;
1276  if (fw_station == 0 && bt_chamber >= 13) // ME1 neighbor chambers 13,14,15 -> 10,11,12
1277  bt_chamber -= 3;
1278 
1279  emtf_assert(bt_history == 0 && (0 <= bt_chamber && bt_chamber < 13) && (0 <= bt_segment && bt_segment < 2));
1280  // bt_segment is a 7-bit word, HHCCCCS, encoding the segment number S in the chamber (1 or 2),
1281  // the chamber number CCCC ("j" above: uniquely identifies chamber within station and ring),
1282  // and the history HH (0 for current BX, 1 for previous BX, 2 for BX before that)
1283  bt_segment = ((bt_history & 0x3) << 5) | ((bt_chamber & 0xf) << 1) | (bt_segment & 0x1);
1284  return bt_segment;
1285 }
1286 
1288  bool is_csc = conv_hit.Is_CSC();
1289  bool is_rpc = conv_hit.Is_RPC();
1290  bool is_irpc = conv_hit.Is_RPC() && ((conv_hit.Station() == 3 || conv_hit.Station() == 4) && (conv_hit.Ring() == 1));
1291  bool is_omtf = conv_hit.Is_RPC() && ((conv_hit.Station() == 1 || conv_hit.Station() == 2) &&
1292  (conv_hit.Ring() == 3)); // RPC in the overlap region
1293  return (is_csc || (is_rpc && !is_irpc && !is_omtf));
1294 }
l1t::EMTFHit::set_strip_hi
void set_strip_hi(int bits)
Definition: EMTFHit.h:155
l1t::EMTFHit::set_subsystem
void set_subsystem(int bits)
Definition: EMTFHit.h:134
RPCRoll
Definition: RPCRoll.h:12
l1t::EMTFHit::set_eta
void set_eta(float val)
Definition: EMTFHit.h:192
PrimitiveConversion::endcap_
int endcap_
Definition: PrimitiveConversion.h:99
SectorProcessorLUT::get_th_lut
uint32_t get_th_lut(int fw_endcap, int fw_sector, int pc_lut_id, int pc_wire_id) const
Definition: SectorProcessorLUT.cc:192
RPCData
Definition: RPCData.h:42
SectorProcessorLUT::get_th_init
uint32_t get_th_init(int fw_endcap, int fw_sector, int pc_lut_id) const
Definition: SectorProcessorLUT.cc:166
RPCDetId::station
int station() const
Definition: RPCDetId.h:78
l1t::EMTFHit::Strip_eighth_bit
int Strip_eighth_bit() const
Definition: EMTFHit.h:228
RPCDetId::region
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
GEMDetId::ring
constexpr int ring() const
Definition: GEMDetId.h:176
RPCDetId::subsector
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel,...
Definition: RPCDetId.h:88
emtf::calc_theta_int
int calc_theta_int(double theta, int endcap)
Definition: TrackTools.h:143
PrimitiveConversion::zoneOverlap_
int zoneOverlap_
Definition: PrimitiveConversion.h:104
SectorProcessorLUT.h
PrimitiveConversion::get_fs_zone_code
int get_fs_zone_code(const EMTFHit &conv_hit) const
Definition: PrimitiveConversion.cc:1200
SectorProcessorLUT::get_ph_zone_offset
uint32_t get_ph_zone_offset(int pc_station, int pc_chamber) const
Definition: SectorProcessorLUT.cc:272
PrimitiveConversion::get_fs_segment
int get_fs_segment(const EMTFHit &conv_hit, int fw_station, int fw_cscid, int pc_segment) const
Definition: PrimitiveConversion.cc:1224
PrimitiveConversion::get_bt_segment
int get_bt_segment(const EMTFHit &conv_hit, int fw_station, int fw_cscid, int pc_segment) const
Definition: PrimitiveConversion.cc:1260
GEMDetId::region
constexpr int region() const
Definition: GEMDetId.h:171
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
l1t::EMTFHit::set_pc_sector
void set_pc_sector(int bits)
Definition: EMTFHit.h:149
PV3DBase::theta
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
l1t::EMTFHit::PC_sector
int PC_sector() const
Definition: EMTFHit.h:217
RPCDetId
Definition: RPCDetId.h:16
gather_cfg.cout
cout
Definition: gather_cfg.py:144
l1t::EMTFHit::SetGEMDetId
void SetGEMDetId(const GEMDetId &id)
Definition: EMTFHit.h:117
emtf::get_trigger_csc_ID
int get_trigger_csc_ID(int ring, int station, int chamber)
Definition: TrackTools.cc:100
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
L1TMuon::TriggerPrimitive::getRPCData
RPCData getRPCData() const
Definition: MuonTriggerPrimitive.h:267
l1t::EMTFHit::SetDTDetId
void SetDTDetId(const DTChamberId &id)
Definition: EMTFHit.h:119
L1TMuon::TriggerPrimitive::getCSCData
CSCData getCSCData() const
Definition: MuonTriggerPrimitive.h:266
L1TMuon::GeometryTranslator::getGlobalPoint
GlobalPoint getGlobalPoint(const TriggerPrimitive &) const
Definition: GeometryTranslator.cc:106
l1t::EMTFHit::PC_segment
int PC_segment() const
Definition: EMTFHit.h:220
PrimitiveConversion::fixZonePhi_
bool fixZonePhi_
Definition: PrimitiveConversion.h:105
l1t::EMTFHit::Sector
int Sector() const
Definition: EMTFHit.h:206
l1t::EMTFHit::set_clct_quality
void set_clct_quality(int bits)
Definition: EMTFHit.h:200
l1t::EMTFHit::Endcap
int Endcap() const
Definition: EMTFHit.h:203
l1t::EMTFHit::Strip_hi
int Strip_hi() const
Definition: EMTFHit.h:223
l1t::EMTFHit::set_phi_loc
void set_phi_loc(float val)
Definition: EMTFHit.h:189
RPCGeometry::roll
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
Definition: RPCGeometry.cc:50
l1t::EMTFHit::Theta
float Theta() const
Definition: EMTFHit.h:274
l1t::EMTFHit::set_pc_segment
void set_pc_segment(int bits)
Definition: EMTFHit.h:152
PrimitiveConversion::process
void process(const std::map< int, TriggerPrimitiveCollection > &selected_prim_map, EMTFHitCollection &conv_hits) const
Definition: PrimitiveConversion.cc:53
l1t::EMTFHit::set_pc_chamber
void set_pc_chamber(int bits)
Definition: EMTFHit.h:151
SectorProcessorLUT::get_ph_disp
uint32_t get_ph_disp(int fw_endcap, int fw_sector, int pc_lut_id) const
Definition: SectorProcessorLUT.cc:153
l1t::EMTFHit::set_fs_segment
void set_fs_segment(int bits)
Definition: EMTFHit.h:185
l1t::EMTFHit::set_fs_zone_code
void set_fs_zone_code(int bits)
Definition: EMTFHit.h:186
align::LocalPoint
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
PrimitiveConversion::useNewZones_
bool useNewZones_
Definition: PrimitiveConversion.h:105
l1t::EMTFHit::set_strip_eighth
void set_strip_eighth(int bits)
Definition: EMTFHit.h:158
emtf::calc_eta_from_theta_deg
double calc_eta_from_theta_deg(double theta_deg, int endcap)
Definition: TrackTools.h:113
PrimitiveConversion::sector_
int sector_
Definition: PrimitiveConversion.h:99
l1t::EMTFHit::set_eta_sim
void set_eta_sim(float val)
Definition: EMTFHit.h:196
SectorProcessorLUT::get_ph_init
uint32_t get_ph_init(int fw_endcap, int fw_sector, int pc_lut_id) const
Definition: SectorProcessorLUT.cc:140
PrimitiveConversion::convert_rpc
void convert_rpc(int pc_sector, int pc_station, int pc_chamber, int pc_segment, const TriggerPrimitive &muon_primitive, EMTFHit &conv_hit) const
Definition: PrimitiveConversion.cc:469
l1t::EMTFHit::set_theta
void set_theta(float val)
Definition: EMTFHit.h:191
emtf::rad_to_deg
double rad_to_deg(double rad)
Definition: TrackTools.h:73
l1t::EMTFHit::set_chamber
void set_chamber(int bits)
Definition: EMTFHit.h:143
emtf::calc_theta_deg_from_int
double calc_theta_deg_from_int(int theta_int)
Definition: TrackTools.h:128
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
l1t::EMTFHit::set_subsector
void set_subsector(int bits)
Definition: EMTFHit.h:141
l1t::EMTFHit::set_phi_sim
void set_phi_sim(float val)
Definition: EMTFHit.h:194
PrimitiveConversion::convert_gem
void convert_gem(int pc_sector, int pc_station, int pc_chamber, int pc_segment, const TriggerPrimitive &muon_primitive, EMTFHit &conv_hit) const
Definition: PrimitiveConversion.cc:720
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
l1t::EMTFHit::set_slope
void set_slope(int bits)
Definition: EMTFHit.h:166
L1TMuon::kRPC
Definition: L1TMuonSubsystems.h:5
PrimitiveConversion::is_valid_for_run2
bool is_valid_for_run2(const EMTFHit &conv_hit) const
Definition: PrimitiveConversion.cc:1287
l1t::EMTFHit::set_time
void set_time(float val)
Definition: EMTFHit.h:193
l1t::EMTFHit::set_strip_eighth_bit
void set_strip_eighth_bit(int bits)
Definition: EMTFHit.h:160
L1TMuon::kME0
Definition: L1TMuonSubsystems.h:5
l1t::EMTFHit::Strip_quart_bit
int Strip_quart_bit() const
Definition: EMTFHit.h:227
l1t::EMTFHit::Strip_low
int Strip_low() const
Definition: EMTFHit.h:224
l1t::EMTFHit::Neighbor
int Neighbor() const
Definition: EMTFHit.h:215
l1t::EMTFHit::Subsector
int Subsector() const
Definition: EMTFHit.h:209
PrimitiveConversion::pc_lut_
const SectorProcessorLUT * pc_lut_
Definition: PrimitiveConversion.h:97
SectorProcessorLUT::get_th_corr_lut
uint32_t get_th_corr_lut(int fw_endcap, int fw_sector, int pc_lut_id, int pc_wire_strip_id) const
Definition: SectorProcessorLUT.cc:215
l1t::EMTFHit::Subsector_RPC
int Subsector_RPC() const
Definition: EMTFHit.h:210
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
l1t::EMTFHit::Roll
int Roll() const
Definition: EMTFHit.h:214
l1t::EMTFHit::set_zone_code
void set_zone_code(int bits)
Definition: EMTFHit.h:184
emtf::calc_phi_loc_deg
double calc_phi_loc_deg(int bits)
Definition: TrackTools.h:176
EMTFHitCollection
l1t::EMTFHitCollection EMTFHitCollection
Definition: Common.h:23
emtf::calc_phi_loc_int_rpc
int calc_phi_loc_int_rpc(double glob, int sector)
Definition: TrackTools.h:209
l1t::EMTFHit::Theta_fp
int Theta_fp() const
Definition: EMTFHit.h:265
l1t::EMTFHit::PC_station
int PC_station() const
Definition: EMTFHit.h:218
l1t::EMTFHit::set_valid
void set_valid(int bits)
Definition: EMTFHit.h:167
L1TMuon::GeometryTranslator::getRPCGeometry
const RPCGeometry & getRPCGeometry() const
Definition: GeometryTranslator.h:59
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
DQMScaleToClient_cfi.factor
factor
Definition: DQMScaleToClient_cfi.py:8
l1t::EMTFHit::set_station
void set_station(int bits)
Definition: EMTFHit.h:136
L1TMuon::TriggerPrimitive
Definition: MuonTriggerPrimitive.h:57
l1t::EMTFHit::set_csc_ID
void set_csc_ID(int bits)
Definition: EMTFHit.h:144
PrimitiveConversion::bugME11Dupes_
bool bugME11Dupes_
Definition: PrimitiveConversion.h:106
Point3DBase< float, GlobalTag >
l1t::EMTFHit::set_strip
void set_strip(int bits)
Definition: EMTFHit.h:154
l1t::EMTFHit::set_sync_err
void set_sync_err(int bits)
Definition: EMTFHit.h:168
emtf::calc_phi_glob_deg
double calc_phi_glob_deg(double loc, int sector)
Definition: TrackTools.h:166
PrimitiveConversion::fixME11Edges_
bool fixME11Edges_
Definition: PrimitiveConversion.h:105
PrimitiveConversion::bx_
int bx_
Definition: PrimitiveConversion.h:99
L1TMuon::TriggerPrimitive::ME0Data
Definition: MuonTriggerPrimitive.h:188
SectorProcessorLUT::get_ph_patt_corr
uint32_t get_ph_patt_corr(int pattern) const
Definition: SectorProcessorLUT.cc:248
PrimitiveConversion::verbose_
int verbose_
Definition: PrimitiveConversion.h:99
CSCDetId::triggerSector
int triggerSector() const
Definition: CSCDetId.cc:3
PrimitiveConversion::convert_rpc_details
void convert_rpc_details(EMTFHit &conv_hit, bool isCPPF) const
Definition: PrimitiveConversion.cc:626
runTauDisplay.gp
gp
Definition: runTauDisplay.py:431
RPCDetId::roll
int roll() const
Definition: RPCDetId.h:92
l1t::EMTFHit::set_strip_quart
void set_strip_quart(int bits)
Definition: EMTFHit.h:157
l1t::EMTFHit::set_sector_RPC
void set_sector_RPC(int bits)
Definition: EMTFHit.h:139
L1TMuon::kCSC
Definition: L1TMuonSubsystems.h:5
PrimitiveConversion::duplicateTheta_
bool duplicateTheta_
Definition: PrimitiveConversion.h:105
L1TMuon::kDT
Definition: L1TMuonSubsystems.h:5
GEMDetId::chamber
constexpr int chamber() const
Definition: GEMDetId.h:183
l1t::EMTFHit::Wire
int Wire() const
Definition: EMTFHit.h:221
l1t::EMTFHit::PC_chamber
int PC_chamber() const
Definition: EMTFHit.h:219
PrimitiveConversion::convert_csc_details
void convert_csc_details(EMTFHit &conv_hit) const
Definition: PrimitiveConversion.cc:195
SectorProcessorLUT::get_th_disp
uint32_t get_th_disp(int fw_endcap, int fw_sector, int pc_lut_id) const
Definition: SectorProcessorLUT.cc:179
l1t::EMTFHit
Definition: EMTFHit.h:25
l1t::EMTFHit::SetCSCDetId
void SetCSCDetId(const CSCDetId &id)
Definition: EMTFHit.h:115
L1TMuon::TriggerPrimitive::DTData
Definition: MuonTriggerPrimitive.h:139
l1t::EMTFHit::set_quality
void set_quality(int bits)
Definition: EMTFHit.h:162
PrimitiveConversion::bxShiftGEM_
int bxShiftGEM_
Definition: PrimitiveConversion.h:101
PrimitiveConversion::get_phzvl
int get_phzvl(const EMTFHit &conv_hit, int zone_code) const
Definition: PrimitiveConversion.cc:1181
GEMDetId::roll
constexpr int roll() const
Definition: GEMDetId.h:194
l1t::EMTFHit::set_phi_glob
void set_phi_glob(float val)
Definition: EMTFHit.h:190
l1t::EMTFHit::set_pattern_run3
void set_pattern_run3(int bits)
Definition: EMTFHit.h:164
PrimitiveConversion::convert_me0
void convert_me0(int pc_sector, int pc_station, int pc_chamber, int pc_segment, const TriggerPrimitive &muon_primitive, EMTFHit &conv_hit) const
Definition: PrimitiveConversion.cc:897
GEMDetId
Definition: GEMDetId.h:18
CSCDetId
Definition: CSCDetId.h:26
l1t::EMTFHit::set_sector_idx
void set_sector_idx(int bits)
Definition: EMTFHit.h:140
L1TMuon::kGEM
Definition: L1TMuonSubsystems.h:5
l1t::EMTFHit::set_theta_fp
void set_theta_fp(int bits)
Definition: EMTFHit.h:182
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
l1t::EMTFHit::Is_RPC
bool Is_RPC() const
Definition: EMTFHit.h:287
l1t::EMTFHit::set_wire
void set_wire(int bits)
Definition: EMTFHit.h:153
L1TMuonSubsystems.h
ME0DetId::station
int station() const
Definition: ME0DetId.h:58
L1TMuon::TriggerPrimitive::detId
IDType detId() const
Definition: MuonTriggerPrimitive.h:254
SectorProcessorLUT::get_ph_init_hard
uint32_t get_ph_init_hard(int fw_station, int fw_cscid) const
Definition: SectorProcessorLUT.cc:285
l1t::EMTFHit::set_csc_nID
void set_csc_nID(int bits)
Definition: EMTFHit.h:145
PrimitiveConversion::tp_geom_
const GeometryTranslator * tp_geom_
Definition: PrimitiveConversion.h:95
l1t::EMTFHit::Subsystem
int Subsystem() const
Definition: EMTFHit.h:202
emtf::get_trigger_sector
int get_trigger_sector(int ring, int station, int chamber)
Definition: TrackTools.cc:85
PrimitiveConversion::convert_other_details
void convert_other_details(EMTFHit &conv_hit) const
Definition: PrimitiveConversion.cc:837
L1TMuon::TriggerPrimitive::getDTData
DTData getDTData() const
Definition: MuonTriggerPrimitive.h:265
l1t::EMTFHit::set_z_sim
void set_z_sim(float val)
Definition: EMTFHit.h:198
l1t::EMTFHit::set_zone_hit
void set_zone_hit(int bits)
Definition: EMTFHit.h:183
CSCDetId::chamber
int chamber() const
Definition: CSCDetId.h:62
PrimitiveConversion::configure
void configure(const GeometryTranslator *tp_geom, const SectorProcessorLUT *pc_lut, int verbose, int endcap, int sector, int bx, int bxShiftCSC, int bxShiftRPC, int bxShiftGEM, int bxShiftME0, const std::vector< int > &zoneBoundaries, int zoneOverlap, bool duplicateTheta, bool fixZonePhi, bool useNewZones, bool fixME11Edges, bool bugME11Dupes, bool useRun3CCLUT)
Definition: PrimitiveConversion.cc:7
ME0DetId
Definition: ME0DetId.h:16
l1t::EMTFHit::set_pattern
void set_pattern(int bits)
Definition: EMTFHit.h:163
emtf::calc_phi_loc_deg_from_glob
double calc_phi_loc_deg_from_glob(double glob, int sector)
Definition: TrackTools.h:195
PrimitiveConversion::bxShiftME0_
int bxShiftME0_
Definition: PrimitiveConversion.h:101
l1t::EMTFHit::Phi_loc
float Phi_loc() const
Definition: EMTFHit.h:272
PrimitiveConversion::get_bt_station
int get_bt_station(const EMTFHit &conv_hit, int fw_station, int fw_cscid, int pc_segment) const
Definition: PrimitiveConversion.cc:1255
l1t::EMTFHit::set_endcap
void set_endcap(int bits)
Definition: EMTFHit.h:135
l1t::EMTFHit::set_bt_station
void set_bt_station(int bits)
Definition: EMTFHit.h:187
l1t::EMTFHit::set_neighbor
void set_neighbor(int bits)
Definition: EMTFHit.h:147
l1t::EMTFHit::Sector_RPC
int Sector_RPC() const
Definition: EMTFHit.h:207
RPCDetId::ring
int ring() const
Definition: RPCDetId.h:59
l1t::EMTFHit::set_strip_quart_bit
void set_strip_quart_bit(int bits)
Definition: EMTFHit.h:159
l1t::EMTFHit::set_bx
void set_bx(int bits)
Definition: EMTFHit.h:179
SectorProcessorLUT::get_cppf_th_lut
uint32_t get_cppf_th_lut(int rpc_region, int rpc_sector, int rpc_station, int rpc_ring, int rpc_subsector, int rpc_roll) const
Definition: SectorProcessorLUT.cc:335
SectorProcessorLUT
Definition: SectorProcessorLUT.h:8
L1TMuon::TriggerPrimitive::getGEMData
GEMData getGEMData() const
Definition: MuonTriggerPrimitive.h:268
L1TMuon::GeometryTranslator
Definition: GeometryTranslator.h:44
l1t::EMTFHit::set_sector
void set_sector(int bits)
Definition: EMTFHit.h:138
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
emtf::calc_phi_loc_int
int calc_phi_loc_int(double glob, int sector)
Definition: TrackTools.h:201
PrimitiveConversion::convert_dt
void convert_dt(int pc_sector, int pc_station, int pc_chamber, int pc_segment, const TriggerPrimitive &muon_primitive, EMTFHit &conv_hit) const
Definition: PrimitiveConversion.cc:1017
PrimitiveConversion.h
l1t::EMTFHit::Ring
int Ring() const
Definition: EMTFHit.h:205
CSCDetId::endcap
int endcap() const
Definition: CSCDetId.h:85
emtf::calc_theta_int_rpc
int calc_theta_int_rpc(double theta, int endcap)
Definition: TrackTools.h:150
RPCDetId::sector
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:81
L1TMuon::TriggerPrimitive::GEMData
Definition: MuonTriggerPrimitive.h:179
ME0DetId::chamber
int chamber() const
Chamber id: it identifies a chamber in a ring it goes from 1 to 36.
Definition: ME0DetId.h:41
PrimitiveConversion::pc_lut
const SectorProcessorLUT & pc_lut() const
Definition: PrimitiveConversion.h:31
l1t::EMTFHit::set_phi_fp
void set_phi_fp(int bits)
Definition: EMTFHit.h:181
l1t::EMTFHit::set_rho_sim
void set_rho_sim(float val)
Definition: EMTFHit.h:197
l1t::EMTFHit::set_track_num
void set_track_num(int bits)
Definition: EMTFHit.h:161
emtf::NUM_ZONES
constexpr int NUM_ZONES
Definition: Common.h:54
l1t::EMTFHit::Station
int Station() const
Definition: EMTFHit.h:204
emtf_assert
#define emtf_assert(expr)
Definition: DebugTools.h:18
PrimitiveConversion::get_zone_code
int get_zone_code(const EMTFHit &conv_hit, int th) const
Definition: PrimitiveConversion.cc:1151
l1t::EMTFHit::Pattern
int Pattern() const
Definition: EMTFHit.h:231
l1t::EMTFHit::SetME0DetId
void SetME0DetId(const ME0DetId &id)
Definition: EMTFHit.h:118
GEMDetId::station
constexpr int station() const
Definition: GEMDetId.h:179
SectorProcessorLUT::get_cppf_ph_lut
uint32_t get_cppf_ph_lut(int rpc_region, int rpc_sector, int rpc_station, int rpc_ring, int rpc_subsector, int rpc_roll, int halfstrip, bool is_neighbor) const
Definition: SectorProcessorLUT.cc:308
l1t::EMTFHit::CSC_nID
int CSC_nID() const
Definition: EMTFHit.h:213
DTChamberId
Definition: DTChamberId.h:14
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
l1t::EMTFHit::Is_CSC
bool Is_CSC() const
Definition: EMTFHit.h:286
l1t::EMTFHit::set_theta_sim
void set_theta_sim(float val)
Definition: EMTFHit.h:195
PrimitiveConversion::useRun3CCLUT_
bool useRun3CCLUT_
Definition: PrimitiveConversion.h:108
L1TMuon::TriggerPrimitive::CSCData
Definition: MuonTriggerPrimitive.h:93
ME0DetId::region
int region() const
Region id: 0 for Barrel Not in use, +/-1 For +/- Endcap.
Definition: ME0DetId.h:38
PrimitiveConversion::bxShiftCSC_
int bxShiftCSC_
Definition: PrimitiveConversion.h:101
l1t::EMTFHit::set_pc_station
void set_pc_station(int bits)
Definition: EMTFHit.h:150
l1t::EMTFHit::set_strip_low
void set_strip_low(int bits)
Definition: EMTFHit.h:156
l1t::EMTFHit::SetRPCDetId
void SetRPCDetId(const RPCDetId &id)
Definition: EMTFHit.h:116
l1t::EMTFHit::set_bend
void set_bend(int bits)
Definition: EMTFHit.h:165
l1t::EMTFHit::set_alct_quality
void set_alct_quality(int bits)
Definition: EMTFHit.h:199
l1t::EMTFHit::set_bt_segment
void set_bt_segment(int bits)
Definition: EMTFHit.h:188
RPCGeometry.h
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
SectorProcessorLUT::get_ph_patt_corr_sign
uint32_t get_ph_patt_corr_sign(int pattern) const
Definition: SectorProcessorLUT.cc:260
l1t::EMTFHit::set_roll
void set_roll(int bits)
Definition: EMTFHit.h:146
PrimitiveConversion::zoneBoundaries_
std::vector< int > zoneBoundaries_
Definition: PrimitiveConversion.h:103
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
L1TMuon::TriggerPrimitive::getME0Data
ME0Data getME0Data() const
Definition: MuonTriggerPrimitive.h:269
PrimitiveConversion::bxShiftRPC_
int bxShiftRPC_
Definition: PrimitiveConversion.h:101
l1t::EMTFHit::Phi_fp
int Phi_fp() const
Definition: EMTFHit.h:264
l1t::EMTFHit::set_subsector_RPC
void set_subsector_RPC(int bits)
Definition: EMTFHit.h:142
PrimitiveConversion::convert_csc
void convert_csc(int pc_sector, int pc_station, int pc_chamber, int pc_segment, const TriggerPrimitive &muon_primitive, EMTFHit &conv_hit) const
Definition: PrimitiveConversion.cc:93
l1t::EMTFHit::set_ring
void set_ring(int bits)
Definition: EMTFHit.h:137
l1t::EMTFHit::Strip
int Strip() const
Definition: EMTFHit.h:222