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