17 const std::vector<int>& zoneBoundaries,
55 std::map<int, TriggerPrimitiveCollection>::const_iterator map_tp_it = selected_prim_map.begin();
56 std::map<int, TriggerPrimitiveCollection>::const_iterator map_tp_end = selected_prim_map.end();
58 for (; map_tp_it != map_tp_end; ++map_tp_it) {
60 int selected = map_tp_it->first;
63 int pc_station = selected / 9;
64 int pc_chamber = selected % 9;
67 TriggerPrimitiveCollection::const_iterator tp_it = map_tp_it->second.begin();
68 TriggerPrimitiveCollection::const_iterator tp_end = map_tp_it->second.end();
70 for (; tp_it != tp_end; ++tp_it) {
73 convert_csc(pc_sector, pc_station, pc_chamber, pc_segment, *tp_it, conv_hit);
75 convert_rpc(pc_sector, pc_station, pc_chamber, pc_segment, *tp_it, conv_hit);
77 convert_gem(pc_sector, 0, selected, pc_segment, *tp_it, conv_hit);
79 convert_me0(pc_sector, 0, selected, pc_segment, *tp_it, conv_hit);
81 convert_dt(pc_sector, 0, selected, pc_segment, *tp_it, conv_hit);
85 conv_hits.push_back(conv_hit);
102 int tp_endcap = tp_detId.
endcap();
104 int tp_station = tp_detId.
station();
105 int tp_ring = tp_detId.
ring();
106 int tp_chamber = tp_detId.
chamber();
108 int tp_bx = tp_data.bx;
109 int tp_csc_ID = tp_data.cscID;
113 int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber % 6 > 2) ? 1 : 2);
115 const bool is_neighbor = (pc_station == 5);
117 int csc_nID = tp_csc_ID;
122 csc_nID = (pc_chamber < 3) ? (pc_chamber + 12) : (((pc_chamber - 1) % 2) + 9);
125 if (tp_station == 1) {
135 conv_hit.
set_endcap((tp_endcap == 2) ? -1 : tp_endcap);
183 double glob_eta =
gp.eta();
184 double glob_rho =
gp.perp();
185 double glob_z =
gp.z();
196 const bool is_neighbor = conv_hit.
Neighbor();
203 const int fw_endcap = (
endcap_ - 1);
204 const int fw_sector = (
sector_ - 1);
205 const int fw_station =
207 const int fw_cscid = (conv_hit.
CSC_nID() - 1);
208 const int fw_strip = conv_hit.
Strip();
209 const int fw_wire = conv_hit.
Wire();
218 const bool is_me11a = (conv_hit.
Station() == 1 && conv_hit.
Ring() == 4);
219 const bool is_me11b = (conv_hit.
Station() == 1 && conv_hit.
Ring() == 1);
220 const bool is_me13 = (conv_hit.
Station() == 1 && conv_hit.
Ring() == 3);
224 bool ph_reverse =
false;
225 if ((fw_endcap == 0 && fw_station >= 3) || (fw_endcap == 1 && fw_station < 3))
231 if (fw_station <= 1 && ((fw_cscid >= 6 && fw_cscid <= 8) || fw_cscid == 14))
233 else if (fw_station >= 2 && (fw_cscid <= 2 || fw_cscid == 9))
240 bool is_10degree =
false;
241 if ((fw_station <= 1) ||
242 (fw_station >= 2 && ((fw_cscid >= 3 && fw_cscid <= 8) || fw_cscid == 10))
250 int pc_lut_id = pc_chamber;
251 if (pc_station == 0) {
252 pc_lut_id = is_me11a ? pc_lut_id + 9 : pc_lut_id;
253 }
else if (pc_station == 1) {
255 pc_lut_id = is_me11a ? pc_lut_id + 9 : pc_lut_id;
256 }
else if (pc_station == 2) {
258 }
else if (pc_station == 3) {
260 }
else if (pc_station == 4) {
262 }
else if (pc_station == 5 && pc_chamber < 3) {
263 pc_lut_id = is_me11a ? pc_lut_id + 15 : pc_lut_id + 12;
264 }
else if (pc_station == 5 && pc_chamber < 5) {
265 pc_lut_id += 28 + 9 - 3;
266 }
else if (pc_station == 5 && pc_chamber < 7) {
267 pc_lut_id += 39 + 9 - 5;
268 }
else if (pc_station == 5 && pc_chamber < 9) {
269 pc_lut_id += 50 + 9 - 7;
274 std::cout <<
"pc_station: " << pc_station <<
" pc_chamber: " << pc_chamber <<
" fw_station: " << fw_station
275 <<
" fw_cscid: " << fw_cscid <<
" lut_id: " << pc_lut_id
287 int eighth_strip = 0;
294 bool bugStrip0BeforeFW48200 =
false;
295 if (bugStrip0BeforeFW48200 ==
false && fw_strip == 0 && clct_pat_corr_sign == -1)
299 eighth_strip = fw_strip << 2;
303 eighth_strip += clct_pat_corr_sign * (clct_pat_corr >> 1);
306 eighth_strip = fw_strip << 3;
310 eighth_strip += clct_pat_corr_sign * (clct_pat_corr >> 0);
313 emtf_assert(bugStrip0BeforeFW48200 ==
true || eighth_strip >= 0);
338 int ph_tmp = (eighth_strip *
factor) >> 10;
339 int ph_tmp_sign = (ph_reverse == 0) ? 1 : -1;
342 fph = fph + ph_tmp_sign * ph_tmp;
345 ph_hit = (ph_hit >> 1) + ph_tmp_sign * (ph_tmp >> 5) + ph_coverage;
350 ph_hit_fixed = ph_hit_fixed + ((fph + (1 << 4)) >> 5);
353 ph_hit = ph_hit_fixed;
360 zone_hit_fixed += ph_hit_fixed;
365 zone_hit = zone_hit_fixed;
374 int pc_wire_id = (fw_wire & 0x7f);
375 int th_tmp =
pc_lut().
get_th_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_id);
379 int pc_wire_strip_id =
380 (((fw_wire >> 4) & 0x3) << 5) | ((eighth_strip >> 4) & 0x1f);
385 bool bugME11DupesBeforeFW47114 =
false;
386 if (bugME11DupesBeforeFW47114) {
387 if (pc_segment == 1) {
388 pc_wire_strip_id = (((fw_wire >> 4) & 0x3) << 5) | (0);
394 int th_corr_sign = (ph_reverse == 0) ? 1 : -1;
396 th_tmp = th_tmp + th_corr_sign * th_corr;
399 const int th_negative = 50;
400 const int th_coverage = 45;
401 if (th_tmp > th_negative || th_tmp < 0 || fw_wire == 0)
403 if (th_tmp > th_coverage)
404 th_tmp = th_coverage;
407 int pc_wire_strip_id =
408 (((fw_wire >> 4) & 0x3) << 5) | ((eighth_strip >> 4) & 0x1f);
410 pc_wire_strip_id = (((fw_wire >> 4) & 0x3) << 5) | ((((eighth_strip * 341) >> 8) >> 4) &
414 th_tmp = th_tmp + th_corr;
417 const int th_coverage = 46;
420 if (th_tmp > th_coverage)
421 th_tmp = th_coverage;
430 th = (th == 0) ? 1 : th;
440 int fs_segment =
get_fs_segment(conv_hit, fw_station, fw_cscid, pc_segment);
442 int bt_station =
get_bt_station(conv_hit, fw_station, fw_cscid, pc_segment);
443 int bt_segment =
get_bt_segment(conv_hit, fw_station, fw_cscid, pc_segment);
478 int tp_region = tp_detId.
region();
479 int tp_endcap = (tp_region == -1) ? 2 : tp_region;
480 int tp_sector = tp_detId.
sector();
482 int tp_station = tp_detId.
station();
483 int tp_ring = tp_detId.
ring();
484 int tp_roll = tp_detId.
roll();
487 int tp_bx = tp_data.bx;
488 int tp_strip = ((tp_data.strip_low + tp_data.strip_hi) / 2);
490 const bool is_neighbor = (pc_station == 5);
493 int csc_tp_chamber = (tp_sector - 1) * 6 + tp_subsector;
494 int csc_tp_sector = (tp_subsector > 2) ? tp_sector : ((tp_sector + 4) % 6) + 1;
495 int csc_tp_subsector = (tp_station != 1) ? 0 : ((csc_tp_chamber % 6 > 2) ? 1 : 2);
497 const bool is_irpc = (tp_station == 3 || tp_station == 4) && (tp_ring == 1);
499 csc_tp_chamber = (tp_sector - 1) * 3 + tp_subsector;
500 csc_tp_sector = (tp_subsector > 1) ? tp_sector : ((tp_sector + 4) % 6) + 1;
501 csc_tp_subsector = (tp_station != 1) ? 0 : ((csc_tp_chamber % 6 > 2) ? 1 : 2);
505 int csc_nID = tp_csc_ID;
510 csc_nID = (pc_chamber < 3) ? (pc_chamber + 12) : (((pc_chamber - 1) % 2) + 9);
515 int tp_quality = (tp_data.strip_hi - tp_data.strip_low + 1);
526 conv_hit.
set_endcap((tp_endcap == 2) ? -1 : tp_endcap);
561 bool use_fullsim_coords =
true;
563 if (tp_data.isCPPF) {
566 }
else if (use_fullsim_coords) {
570 double glob_eta =
gp.eta();
571 double glob_rho =
gp.perp();
572 double glob_z =
gp.z();
590 th = (th == 0) ? 1 : th;
598 glob_eta = new_gp.
eta();
599 glob_rho = new_gp.
perp();
607 th = (th == 0) ? 1 : th;
627 const bool is_neighbor = conv_hit.
Neighbor();
635 const int fw_station = (conv_hit.
Station() == 1) ? (is_neighbor ? 0 : pc_station) : conv_hit.
Station();
636 const int fw_cscid = (conv_hit.
CSC_nID() - 1);
638 int fph = conv_hit.
Phi_fp();
642 bool use_cppf_lut = !isCPPF;
673 th = (th == 0) ? 1 : th;
677 std::cout <<
"RPC hit pc_station: " << pc_station <<
" pc_chamber: " << pc_chamber <<
" fw_station: " << fw_station
678 <<
" fw_cscid: " << fw_cscid <<
" tp_station: " << conv_hit.
Station() <<
" tp_ring: " << conv_hit.
Ring()
680 <<
" fph: " << fph <<
" th: " << th << std::endl;
686 int zone_hit = ((fph + (1 << 4)) >> 5);
691 int fs_segment =
get_fs_segment(conv_hit, fw_station, fw_cscid, pc_segment);
693 int bt_station =
get_bt_station(conv_hit, fw_station, fw_cscid, pc_segment);
694 int bt_segment =
get_bt_segment(conv_hit, fw_station, fw_cscid, pc_segment);
729 int tp_region = tp_detId.
region();
730 int tp_endcap = (tp_region == -1) ? 2 : tp_region;
731 int tp_station = tp_detId.
station();
732 int tp_ring = tp_detId.
ring();
733 int tp_roll = tp_detId.
roll();
735 int tp_chamber = tp_detId.
chamber();
737 int tp_bx = tp_data.bx;
738 int tp_pad = ((tp_data.pad_low + tp_data.pad_hi) / 2);
745 int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber % 6 > 2) ? 1 : 2);
747 const bool is_neighbor = (pc_chamber == 12 || pc_chamber == 13);
749 int csc_nID = tp_csc_ID;
754 if (tp_station == 1) {
762 int tp_quality = (tp_data.pad_hi - tp_data.pad_low + 1);
769 conv_hit.
set_endcap((tp_endcap == 2) ? -1 : tp_endcap);
804 bool use_fullsim_coords =
true;
805 if (use_fullsim_coords) {
809 double glob_eta =
gp.eta();
810 double glob_rho =
gp.perp();
811 double glob_z =
gp.z();
819 th = (th == 0) ? 1 : th;
838 const bool is_neighbor = conv_hit.
Neighbor();
846 const int fw_station =
848 const int fw_cscid = (conv_hit.
CSC_nID() - 1);
850 int fph = conv_hit.
Phi_fp();
854 std::cout <<
"GEM hit pc_station: " << pc_station <<
" pc_chamber: " << pc_chamber <<
" fw_station: " << fw_station
855 <<
" fw_cscid: " << fw_cscid <<
" tp_station: " << conv_hit.
Station() <<
" tp_ring: " << conv_hit.
Ring()
856 <<
" tp_sector: " << conv_hit.
Sector() <<
" tp_subsector: " << conv_hit.
Subsector() <<
" fph: " << fph
857 <<
" th: " << th << std::endl;
863 int zone_hit = ((fph + (1 << 4)) >> 5);
868 int fs_segment =
get_fs_segment(conv_hit, fw_station, fw_cscid, pc_segment);
870 int bt_station =
get_bt_station(conv_hit, fw_station, fw_cscid, pc_segment);
871 int bt_segment =
get_bt_segment(conv_hit, fw_station, fw_cscid, pc_segment);
906 int tp_region = tp_detId.
region();
907 int tp_endcap = (tp_region == -1) ? 2 : tp_region;
908 int tp_station = tp_detId.
station();
912 int tp_chamber = tp_detId.
chamber();
914 int tp_bx = tp_data.bx;
915 int tp_pad = tp_data.phiposition;
916 int tp_partition = tp_data.partition;
922 int tp_subsector = 0;
924 const bool is_neighbor = (pc_chamber == 14);
926 int csc_nID = tp_csc_ID;
939 conv_hit.
set_endcap((tp_endcap == 2) ? -1 : tp_endcap);
965 conv_hit.
set_bend(tp_data.deltaphi * (tp_data.bend == 0 ? 1 : -1));
974 bool use_fullsim_coords =
true;
975 if (use_fullsim_coords) {
979 double glob_eta =
gp.eta();
980 double glob_rho =
gp.perp();
981 double glob_z =
gp.z();
987 bool fix_me0_theta_edge =
true;
988 if (fix_me0_theta_edge) {
997 th = (th == 0) ? 1 : th;
1026 int tp_wheel = tp_detId.
wheel();
1027 int tp_station = tp_detId.
station();
1028 int tp_sector = tp_detId.
sector();
1033 if (tp_station == 4) {
1034 if (tp_sector == 13)
1036 else if (tp_sector == 14)
1040 int tp_bx = tp_data.bx;
1041 int tp_phi = tp_data.radialAngle;
1042 int tp_phiB = tp_data.bendingAngle;
1048 int tp_endcap = (tp_wheel > 0) ? +1 : ((tp_wheel < 0) ? 2 : 0);
1051 int tp_subsector = 0;
1053 const bool is_neighbor = (pc_chamber >= 8);
1055 int csc_nID = tp_csc_ID;
1068 conv_hit.
set_endcap((tp_endcap == 2) ? -1 : tp_endcap);
1091 conv_hit.
set_wire(tp_data.theta_bti_group);
1103 bool use_fullsim_coords =
true;
1104 if (use_fullsim_coords) {
1108 double glob_eta =
gp.eta();
1109 double glob_rho =
gp.perp();
1110 double glob_z =
gp.z();
1116 bool fix_dt_phi_edge =
true;
1117 if (fix_dt_phi_edge) {
1123 if ((loc + 22.) < 0. && (loc + 32.) > 0.)
1125 else if ((loc + 360. + 22.) < 0. && (loc + 360. + 32.) > 0.)
1131 th = (th == 0) ? 1 : th;
1157 bool is_me13 = (is_csc && conv_hit.
Station() == 1 && conv_hit.
Ring() == 3);
1164 if (zone_code_tmp & (1 << izone)) {
1166 ((izone == 0) || ((zone_code_tmp & (1 << (izone - 1))) == 0) || is_me13);
1167 bool no_use_bnd2 = (((zone_code_tmp & (1 << (izone + 1))) == 0) || is_me13);
1173 zone_code |= (1 << izone);
1186 if (conv_hit.
Ring() == 1 || conv_hit.
Ring() == 4) {
1187 phzvl = (zone_code >> 0);
1188 }
else if (conv_hit.
Ring() == 2) {
1190 phzvl = (zone_code >> 1);
1192 phzvl = (zone_code >> 2);
1194 }
else if (conv_hit.
Ring() == 3) {
1195 phzvl = (zone_code >> 3);
1201 static const unsigned int zone_code_table[4][3] = {
1203 {0b0011, 0b0100, 0b1000},
1204 {0b0011, 0b1100, 0b1100},
1205 {0b0001, 0b1110, 0b1110},
1206 {0b0001, 0b0110, 0b0110}
1209 static const unsigned int zone_code_table_new[4][3] = {
1211 {0b0011, 0b0110, 0b1000},
1212 {0b0011, 0b1110, 0b1110},
1213 {0b0011, 0b1110, 0b1110},
1214 {0b0001, 0b0110, 0b0110}
1217 unsigned int istation = (conv_hit.
Station() - 1);
1218 unsigned int iring = (conv_hit.
Ring() == 4) ? 0 : (conv_hit.
Ring() - 1);
1220 unsigned int zone_code =
useNewZones_ ? zone_code_table_new[istation][iring] : zone_code_table[istation][iring];
1228 int fs_chamber = -1;
1229 int fs_segment = pc_segment % 2;
1238 const bool is_neighbor = conv_hit.
Neighbor();
1239 if (fw_station <= 1) {
1240 int n = fw_cscid % 3;
1241 fs_chamber = is_neighbor ? 0 : ((fw_station == 0) ? 1 +
n : 4 +
n);
1243 int n = (conv_hit.
Ring() == 1) ? fw_cscid : (fw_cscid - 3);
1244 fs_chamber = is_neighbor ? 0 : 1 +
n;
1247 emtf_assert(fs_history == 0 && (0 <= fs_chamber && fs_chamber < 7) && (0 <= fs_segment && fs_segment < 2));
1251 fs_segment = ((fs_history & 0x3) << 4) | ((fs_chamber & 0x7) << 1) | (fs_segment & 0x1);
1256 int bt_station = fw_station;
1264 int bt_chamber = -1;
1265 int bt_segment = pc_segment % 2;
1275 bt_chamber = fw_cscid + 1;
1276 if (fw_station == 0 && bt_chamber >= 13)
1279 emtf_assert(bt_history == 0 && (0 <= bt_chamber && bt_chamber < 13) && (0 <= bt_segment && bt_segment < 2));
1283 bt_segment = ((bt_history & 0x3) << 5) | ((bt_chamber & 0xf) << 1) | (bt_segment & 0x1);
1288 bool is_csc = conv_hit.
Is_CSC();
1289 bool is_rpc = conv_hit.
Is_RPC();
1290 bool is_irpc = conv_hit.
Is_RPC() && ((conv_hit.
Station() == 3 || conv_hit.
Station() == 4) && (conv_hit.
Ring() == 1));
1292 (conv_hit.
Ring() == 3));
1293 return (is_csc || (is_rpc && !is_irpc && !is_omtf));