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